@contentstack/studio-react-editor 0.0.1

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 (75) hide show
  1. package/README.md +11 -0
  2. package/dist/components/EditableRenderer.js +92 -0
  3. package/dist/components/EditableRenderer.js.map +1 -0
  4. package/dist/components/Element.js +235 -0
  5. package/dist/components/Element.js.map +1 -0
  6. package/dist/components/ErrorComponent.js +13 -0
  7. package/dist/components/ErrorComponent.js.map +1 -0
  8. package/dist/components/PreviewRenderer.js +23 -0
  9. package/dist/components/PreviewRenderer.js.map +1 -0
  10. package/dist/components/RenderErrorHOC.js +21 -0
  11. package/dist/components/RenderErrorHOC.js.map +1 -0
  12. package/dist/components/RendererErrorBoundary.js +18 -0
  13. package/dist/components/RendererErrorBoundary.js.map +1 -0
  14. package/dist/components/Slot.js +18 -0
  15. package/dist/components/Slot.js.map +1 -0
  16. package/dist/components/TextPlaceholder.js +29 -0
  17. package/dist/components/TextPlaceholder.js.map +1 -0
  18. package/dist/components/elements/ConditionBlock.js +62 -0
  19. package/dist/components/elements/ConditionBlock.js.map +1 -0
  20. package/dist/components/elements/Repeater.js +70 -0
  21. package/dist/components/elements/Repeater.js.map +1 -0
  22. package/dist/components/elements/Symbol.js +58 -0
  23. package/dist/components/elements/Symbol.js.map +1 -0
  24. package/dist/components/styles.js +77 -0
  25. package/dist/components/styles.js.map +1 -0
  26. package/dist/contexts/providers/active-node.provider.js +9 -0
  27. package/dist/contexts/providers/active-node.provider.js.map +1 -0
  28. package/dist/contexts/providers/preview-mode.provider.js +6 -0
  29. package/dist/contexts/providers/preview-mode.provider.js.map +1 -0
  30. package/dist/contexts/providers/renderer.provider.js +22 -0
  31. package/dist/contexts/providers/renderer.provider.js.map +1 -0
  32. package/dist/contexts/providers/selected-node.provider.js +11 -0
  33. package/dist/contexts/providers/selected-node.provider.js.map +1 -0
  34. package/dist/contexts/providers/symbol-ui.provider.js +73 -0
  35. package/dist/contexts/providers/symbol-ui.provider.js.map +1 -0
  36. package/dist/contexts/providers/use-condition-block.provider.js +8 -0
  37. package/dist/contexts/providers/use-condition-block.provider.js.map +1 -0
  38. package/dist/contexts/providers/use-design-preview.provider.js +6 -0
  39. package/dist/contexts/providers/use-design-preview.provider.js.map +1 -0
  40. package/dist/contexts/providers/use-repeater.provider.js +6 -0
  41. package/dist/contexts/providers/use-repeater.provider.js.map +1 -0
  42. package/dist/hooks/use-active-node-path.hook.js +46 -0
  43. package/dist/hooks/use-active-node-path.hook.js.map +1 -0
  44. package/dist/hooks/use-canvas-events.hook.js +39 -0
  45. package/dist/hooks/use-canvas-events.hook.js.map +1 -0
  46. package/dist/hooks/use-condition-block-context.js +20 -0
  47. package/dist/hooks/use-condition-block-context.js.map +1 -0
  48. package/dist/hooks/use-design-preview.hook.js +20 -0
  49. package/dist/hooks/use-design-preview.hook.js.map +1 -0
  50. package/dist/hooks/use-is-node-selected.js +26 -0
  51. package/dist/hooks/use-is-node-selected.js.map +1 -0
  52. package/dist/hooks/use-preview-mode.hook.js +22 -0
  53. package/dist/hooks/use-preview-mode.hook.js.map +1 -0
  54. package/dist/hooks/use-register-symbol.hook.js +54 -0
  55. package/dist/hooks/use-register-symbol.hook.js.map +1 -0
  56. package/dist/hooks/use-renderer.hook.js +23 -0
  57. package/dist/hooks/use-renderer.hook.js.map +1 -0
  58. package/dist/hooks/use-repeater.hook.js +20 -0
  59. package/dist/hooks/use-repeater.hook.js.map +1 -0
  60. package/dist/hooks/use-should-show-design.hook.js +31 -0
  61. package/dist/hooks/use-should-show-design.hook.js.map +1 -0
  62. package/dist/hooks/use-spec-data-listener.hook.js +65 -0
  63. package/dist/hooks/use-spec-data-listener.hook.js.map +1 -0
  64. package/dist/hooks/use-static-values-listener.hook.js +33 -0
  65. package/dist/hooks/use-static-values-listener.hook.js.map +1 -0
  66. package/dist/hooks/use-symbol-events.hook.js +32 -0
  67. package/dist/hooks/use-symbol-events.hook.js.map +1 -0
  68. package/dist/hooks/use-symbol-ui-listener.hook.js +17 -0
  69. package/dist/hooks/use-symbol-ui-listener.hook.js.map +1 -0
  70. package/dist/index.d.ts +20 -0
  71. package/dist/index.js +6 -0
  72. package/dist/index.js.map +1 -0
  73. package/dist/utils/renderer.util.js +12 -0
  74. package/dist/utils/renderer.util.js.map +1 -0
  75. package/package.json +75 -0
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `studio-react-editor`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const composableStudioReactEditor = require('studio-react-editor');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,92 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { isCompositionBeingEdited, NODE_TO_PARENT, NODE_TO_PATH_NODE } from '@contentstack/studio-client';
3
+ import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
4
+ import { DataCtxProvider } from '@contentstack/studio-react-components/contexts';
5
+ import { useDataWithSpec } from '@contentstack/studio-react-components/hooks';
6
+ import { INTERNAL_COMPONENTS_NAMES } from '@contentstack/studio-registry';
7
+ import { useState, useEffect, useMemo, useCallback } from 'react';
8
+ import { RendererProvider } from '../contexts/providers/renderer.provider.js';
9
+ import { ActiveComponentPathContext } from '../contexts/providers/active-node.provider.js';
10
+ import { SymbolUIProvider } from '../contexts/providers/symbol-ui.provider.js';
11
+ import '../contexts/providers/use-design-preview.provider.js';
12
+ import '../contexts/providers/use-repeater.provider.js';
13
+ import '../contexts/providers/use-condition-block.provider.js';
14
+ import '../contexts/providers/preview-mode.provider.js';
15
+ import { useCanvasEvents } from '../hooks/use-canvas-events.hook.js';
16
+ import { Symbol } from './elements/Symbol.js';
17
+ import { useGetActiveComponentPathContext } from '../hooks/use-active-node-path.hook.js';
18
+ import { useSpecDataListener } from '../hooks/use-spec-data-listener.hook.js';
19
+ import { useStaticValuesListener } from '../hooks/use-static-values-listener.hook.js';
20
+ import { useSymbolsEvents } from '../hooks/use-symbol-events.hook.js';
21
+ import MemoizedElement from './Element.js';
22
+ import { RenderErrorHOC } from './RenderErrorHOC.js';
23
+ import { Repeater } from './elements/Repeater.js';
24
+ import { ConditionBlock } from './elements/ConditionBlock.js';
25
+
26
+ function EditableRendererHOC(props) {
27
+ const { spec, componentRegistry } = props;
28
+ return (jsx(RendererProvider, { spec: spec, componentRegistry: componentRegistry, children: jsx(SymbolUIProvider, { symbols: spec.symbols || [], children: jsx(EditableRenderer, { ...props }) }) }));
29
+ }
30
+ function EditableRenderer({ spec: initialSpec, data: stateData, componentRegistry, renderError, }) {
31
+ const [spec, setSpec] = useState(initialSpec);
32
+ const composableUid = spec?.compositionEntry?.composable_uid ?? "";
33
+ const isCompositionEdited = isCompositionBeingEdited(composableUid);
34
+ useCanvasEvents(composableUid);
35
+ useSpecDataListener(setSpec, spec, composableUid);
36
+ useStaticValuesListener(setSpec, spec, composableUid);
37
+ useSymbolsEvents(setSpec, spec, composableUid);
38
+ useEffect(() => {
39
+ // We update default preview versions of component with editable versions.
40
+ componentRegistry.updateComponents([
41
+ {
42
+ type: INTERNAL_COMPONENTS_NAMES.REPEATER,
43
+ component: Repeater,
44
+ },
45
+ {
46
+ type: INTERNAL_COMPONENTS_NAMES.CONDITION_BLOCK,
47
+ component: ConditionBlock,
48
+ },
49
+ {
50
+ type: INTERNAL_COMPONENTS_NAMES.SYMBOL,
51
+ component: Symbol,
52
+ },
53
+ ]);
54
+ }, []);
55
+ const data = useDataWithSpec(spec, stateData);
56
+ const activeComponentPathContext = useGetActiveComponentPathContext(spec);
57
+ useEffect(() => {
58
+ if (!isCompositionEdited)
59
+ return;
60
+ composableStudioEventManager
61
+ ?.send(POST_MESSAGE_EVENTS.GET_COMPONENT_PROPS, data)
62
+ .catch((error) => {
63
+ console.error("Error while setting component props.", error);
64
+ });
65
+ }, [data, isCompositionEdited]);
66
+ // * When we render the components, we set the parent and path for the nodes,
67
+ // * However, the root node and the page node are not set during the render.
68
+ // * Hence, we set the parent and path for the root and page node here.
69
+ useMemo(() => {
70
+ if (!spec || !isCompositionEdited)
71
+ return;
72
+ const rootNode = spec.ui;
73
+ if (!rootNode || !rootNode.slots)
74
+ return;
75
+ const rootSlotUid = Object.keys(rootNode.slots)[0];
76
+ if (!rootSlotUid || !rootNode.slots[rootSlotUid])
77
+ return;
78
+ const pageNode = rootNode.slots[rootSlotUid][0];
79
+ if (!pageNode)
80
+ return;
81
+ NODE_TO_PARENT.set(rootNode, undefined);
82
+ NODE_TO_PARENT.set(pageNode, rootNode);
83
+ NODE_TO_PATH_NODE.set(pageNode, [rootSlotUid, 0]);
84
+ }, [spec, isCompositionEdited]);
85
+ const renderErrorComponent = useCallback(({ error }) => {
86
+ return jsx(RenderErrorHOC, { error: error, renderError: renderError });
87
+ }, []);
88
+ return (jsx(ActiveComponentPathContext.Provider, { value: activeComponentPathContext, children: jsx(DataCtxProvider, { value: data, children: jsx(MemoizedElement, { node: spec.ui, renderError: renderErrorComponent }) }) }));
89
+ }
90
+
91
+ export { EditableRendererHOC as default };
92
+ //# sourceMappingURL=EditableRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditableRenderer.js","sources":["../../src/components/EditableRenderer.tsx"],"sourcesContent":["import {\n StudioSpec,\n isCompositionBeingEdited,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport {\n composableStudioEventManager,\n POST_MESSAGE_EVENTS,\n} from \"@contentstack/studio-messenger\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useDataWithSpec } from \"@contentstack/studio-react-components/hooks\";\nimport {\n ComposableStudioData,\n INTERNAL_COMPONENTS_NAMES,\n} from \"@contentstack/studio-registry\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport {\n ActiveComponentPathContext,\n RendererProvider,\n} from \"../contexts/providers\";\nimport { SymbolUIProvider } from \"../contexts/providers/symbol-ui.provider\";\nimport { useCanvasEvents } from \"../hooks\";\nimport { useGetActiveComponentPathContext } from \"../hooks/use-active-node-path.hook\";\nimport { useSpecDataListener } from \"../hooks/use-spec-data-listener.hook\";\nimport { useStaticValuesListener } from \"../hooks/use-static-values-listener.hook\";\nimport { useSymbolsEvents } from \"../hooks/use-symbol-events.hook\";\nimport { ComponentRegistryType } from \"../types\";\nimport Element from \"./Element\";\nimport { RenderErrorHOC } from \"./RenderErrorHOC\";\nimport { ConditionBlock, Repeater, Symbol } from \"./elements\";\n\ninterface EditableRendererHOCProps {\n spec: StudioSpec;\n data: ComposableStudioData;\n componentRegistry: ComponentRegistryType;\n renderError: (props: { error: Error }) => JSX.Element;\n}\n\nexport default function EditableRendererHOC(\n props: EditableRendererHOCProps & { children: React.ReactNode },\n) {\n const { spec, componentRegistry } = props;\n return (\n <RendererProvider spec={spec} componentRegistry={componentRegistry}>\n <SymbolUIProvider symbols={spec.symbols || []}>\n <EditableRenderer {...props} />\n </SymbolUIProvider>\n </RendererProvider>\n );\n}\n\ninterface EditableRendererProps {\n spec: StudioSpec;\n data: ComposableStudioData;\n componentRegistry: ComponentRegistryType;\n renderError: (props: { error: Error }) => JSX.Element;\n}\n\nfunction EditableRenderer({\n spec: initialSpec,\n data: stateData,\n componentRegistry,\n renderError,\n}: EditableRendererProps): JSX.Element {\n const [spec, setSpec] = useState<StudioSpec>(initialSpec);\n const composableUid = spec?.compositionEntry?.composable_uid ?? \"\";\n const isCompositionEdited = isCompositionBeingEdited(composableUid);\n useCanvasEvents(composableUid);\n useSpecDataListener(setSpec, spec, composableUid);\n useStaticValuesListener(setSpec, spec, composableUid);\n useSymbolsEvents(setSpec, spec, composableUid);\n useEffect(() => {\n // We update default preview versions of component with editable versions.\n componentRegistry.updateComponents([\n {\n type: INTERNAL_COMPONENTS_NAMES.REPEATER,\n component: Repeater,\n },\n {\n type: INTERNAL_COMPONENTS_NAMES.CONDITION_BLOCK,\n component: ConditionBlock,\n },\n {\n type: INTERNAL_COMPONENTS_NAMES.SYMBOL,\n component: Symbol,\n },\n ]);\n }, []);\n\n const data: ComposableStudioData = useDataWithSpec(spec, stateData);\n const activeComponentPathContext = useGetActiveComponentPathContext(spec);\n\n useEffect(() => {\n if (!isCompositionEdited) return;\n composableStudioEventManager\n ?.send(POST_MESSAGE_EVENTS.GET_COMPONENT_PROPS, data)\n .catch((error: any) => {\n console.error(\"Error while setting component props.\", error);\n });\n }, [data, isCompositionEdited]);\n\n // * When we render the components, we set the parent and path for the nodes,\n // * However, the root node and the page node are not set during the render.\n // * Hence, we set the parent and path for the root and page node here.\n useMemo(() => {\n if (!spec || !isCompositionEdited) return;\n const rootNode = spec.ui;\n if (!rootNode || !rootNode.slots) return;\n\n const rootSlotUid = Object.keys(rootNode.slots)[0];\n if (!rootSlotUid || !rootNode.slots[rootSlotUid]) return;\n\n const pageNode = rootNode.slots[rootSlotUid][0];\n if (!pageNode) return;\n\n NODE_TO_PARENT.set(rootNode, undefined);\n NODE_TO_PARENT.set(pageNode, rootNode);\n NODE_TO_PATH_NODE.set(pageNode, [rootSlotUid, 0]);\n }, [spec, isCompositionEdited]);\n const renderErrorComponent = useCallback(({ error }: { error: Error }) => {\n return <RenderErrorHOC error={error} renderError={renderError} />;\n }, []);\n\n return (\n <ActiveComponentPathContext.Provider value={activeComponentPathContext}>\n <DataCtxProvider value={data}>\n <Element node={spec.ui} renderError={renderErrorComponent} />\n </DataCtxProvider>\n </ActiveComponentPathContext.Provider>\n );\n}\n"],"names":["_jsx","Element"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuCc,SAAU,mBAAmB,CACzC,KAA+D,EAAA;AAE/D,IAAA,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,KAAK;AACzC,IAAA,QACEA,GAAA,CAAC,gBAAgB,EAAA,EAAC,IAAI,EAAE,IAAI,EAAE,iBAAiB,EAAE,iBAAiB,EAAA,QAAA,EAChEA,IAAC,gBAAgB,EAAA,EAAC,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EAAA,QAAA,EAC3CA,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AAA,EAAC,KAAK,EAAE,0BAA0B,EAAA,QAAA,EACpEA,GAAA,CAAC,eAAe,EAAA,EAAC,KAAK,EAAE,IAAI,EAAA,QAAA,EAC1BA,GAAA,CAACC,eAAO,EAAA,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAA,CAAI,EAAA,CAC7C,EAAA,CACkB;AAE1C;;;;"}
@@ -0,0 +1,235 @@
1
+ import { jsx, Fragment } from 'react/jsx-runtime';
2
+ import { composableStudioEventEmitter, COMPOSABLE_STUDIO_EMITTED_EVENTS, ELEMENT_TO_NODE, NODE_TO_ELEMENT, COMPOSABLE_DATA_ATTRIBUTES, getJSONRTE, loadGoogleFont, NODE_TO_PATH_NODE, NODE_TO_PARENT } from '@contentstack/studio-client';
3
+ import { lightSdk, sdk, handleNodeStyles } from '@contentstack/studio-core';
4
+ import { CurrentNodeContext } from '@contentstack/studio-react-components/contexts';
5
+ import { useData, useCurrentNode } from '@contentstack/studio-react-components/hooks';
6
+ import { resolveMetadataBindings, getRepeaterBinding, getBindingString, getCslpTag, retrievePropValue } from '@contentstack/studio-registry';
7
+ import classNames from 'classnames';
8
+ import { memo, useRef, useEffect, useCallback } from 'react';
9
+ import { RendererErrorComponent } from './ErrorComponent.js';
10
+ import { TextPlaceholder } from './TextPlaceholder.js';
11
+ import { RendererErrorBoundary } from './RendererErrorBoundary.js';
12
+ import { shouldRenderSlot } from '../utils/renderer.util.js';
13
+ import Slot from './Slot.js';
14
+ import { useRenderer } from '../hooks/use-renderer.hook.js';
15
+ import '../contexts/providers/renderer.provider.js';
16
+ import '../contexts/providers/active-node.provider.js';
17
+ import '@contentstack/studio-messenger';
18
+ import 'immer';
19
+ import '../contexts/providers/use-design-preview.provider.js';
20
+ import '../contexts/providers/use-repeater.provider.js';
21
+ import '../contexts/providers/use-condition-block.provider.js';
22
+ import '../contexts/providers/preview-mode.provider.js';
23
+ import { usePreviewMode } from '../hooks/use-preview-mode.hook.js';
24
+ import { SelectedNodeProvider } from '../contexts/providers/selected-node.provider.js';
25
+
26
+ const Element = ({ node, renderError, dataCslp, }) => {
27
+ const isPreviewMode = usePreviewMode();
28
+ const data = useData();
29
+ const { attrs, styles, uid } = node;
30
+ const { isCompositionBeingEdited, componentRegistry } = useRenderer();
31
+ resolveMetadataBindings(node, data);
32
+ const reference = useRef(null);
33
+ // handles the hidden element notification event
34
+ useEffect(() => {
35
+ const hiddenElementNotificationEventListener = (data) => {
36
+ if (!isCompositionBeingEdited)
37
+ return;
38
+ if (data.uid !== node.uid && data.uid !== "__all__")
39
+ return;
40
+ if (reference.current) {
41
+ if (data.action === "open") {
42
+ if ("open" in reference.current &&
43
+ typeof reference.current.open === "function") {
44
+ reference.current.open();
45
+ }
46
+ else {
47
+ // TODO: link to the documentation
48
+ console.error("Open method is not available on the reference. Please check the documentation for more details.");
49
+ }
50
+ }
51
+ else {
52
+ if ("close" in reference.current &&
53
+ typeof reference.current.close === "function") {
54
+ reference.current.close();
55
+ }
56
+ else {
57
+ // TODO: link to the documentation
58
+ console.error("Close method is not available on the reference. Please check the documentation for more details.");
59
+ }
60
+ }
61
+ }
62
+ };
63
+ composableStudioEventEmitter.on(COMPOSABLE_STUDIO_EMITTED_EVENTS.HIDDEN_ELEMENT_NOTIFICATION, hiddenElementNotificationEventListener);
64
+ return () => {
65
+ composableStudioEventEmitter.off(COMPOSABLE_STUDIO_EMITTED_EVENTS.HIDDEN_ELEMENT_NOTIFICATION, hiddenElementNotificationEventListener);
66
+ };
67
+ }, []);
68
+ if (!componentRegistry) {
69
+ return jsx(RendererErrorComponent, { reason: "SDK is not initialized" });
70
+ }
71
+ let internalAttributes = {};
72
+ if (isCompositionBeingEdited && !isPreviewMode) {
73
+ const ref = useCallback((ref) => {
74
+ reference.current = ref;
75
+ let refElement = null;
76
+ if (ref instanceof HTMLElement) {
77
+ refElement = ref;
78
+ }
79
+ else if (ref) {
80
+ if ("element" in ref) {
81
+ refElement = ref.element ?? null;
82
+ }
83
+ else {
84
+ // TODO: Link to documentation explaining how to use the element property
85
+ console.error("Reference is not a valid object. It should have a element property.");
86
+ }
87
+ }
88
+ if (refElement && node) {
89
+ ELEMENT_TO_NODE.set(refElement, node);
90
+ NODE_TO_ELEMENT.set(node, refElement);
91
+ }
92
+ else if (!refElement) {
93
+ const element = NODE_TO_ELEMENT.get(node);
94
+ if (element) {
95
+ ELEMENT_TO_NODE.delete(element);
96
+ }
97
+ if (NODE_TO_ELEMENT.has(node)) {
98
+ NODE_TO_ELEMENT.delete(node);
99
+ }
100
+ }
101
+ }, [node]);
102
+ internalAttributes = {
103
+ [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,
104
+ [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,
105
+ [COMPOSABLE_DATA_ATTRIBUTES.ID]: uid,
106
+ ref,
107
+ };
108
+ }
109
+ try {
110
+ const componentOptions = componentRegistry.getComponentByNode(node, false);
111
+ if (!componentOptions)
112
+ return null;
113
+ const Component = componentOptions.component;
114
+ if (dataCslp) {
115
+ internalAttributes["data-cslp"] = dataCslp;
116
+ }
117
+ const config = lightSdk?.internal?.getConfig() ?? sdk?.internal?.getConfig();
118
+ if (node.metadata?.repeaterWrapper && config?.cslp.appendTags) {
119
+ const binding = getRepeaterBinding(node);
120
+ if (binding) {
121
+ const bindingPath = getBindingString(binding);
122
+ const cslpValue = getCslpTag({ bindedField: bindingPath, data });
123
+ if (cslpValue["data-cslp"]) {
124
+ internalAttributes["data-cslp"] = cslpValue["data-cslp"];
125
+ }
126
+ }
127
+ }
128
+ const resolvedProps = retrievePropValue({
129
+ data,
130
+ defaultSlot: "I am a default slot", // TODO: this should be an component
131
+ componentOptions: componentOptions,
132
+ node: node,
133
+ placeholders: {
134
+ string: (placeholder) => (jsx(TextPlaceholder, { placeholder: placeholder })),
135
+ },
136
+ cslp: {
137
+ appendTags: config?.cslp.appendTags ?? false,
138
+ },
139
+ nodeUid: uid,
140
+ jsonRTE: getJSONRTE(),
141
+ getSlots({ slots, parent, slotUid }) {
142
+ return (jsx(VisualComponent, { parent: parent, nodes: slots, slotUid: slotUid, renderError: renderError }));
143
+ },
144
+ isCompositionBeingEdited,
145
+ });
146
+ const [defaultResponsiveClass, namedResponsiveClasses, fontFamilies] = handleNodeStyles(styles, uid);
147
+ // TODO: @RavenColEvol, can we memoize this?
148
+ useEffect(() => {
149
+ fontFamilies.forEach((fontFamily) => {
150
+ loadGoogleFont(fontFamily);
151
+ });
152
+ }, [fontFamilies]);
153
+ const componentClass = classNames(resolvedProps.className, defaultResponsiveClass, attrs.className);
154
+ const attrsWithResponsiveClass = {
155
+ ...attrs,
156
+ ...namedResponsiveClasses,
157
+ className: componentClass,
158
+ };
159
+ const WrapTag = typeof componentOptions.wrap === "string"
160
+ ? componentOptions.wrap || "div"
161
+ : "div";
162
+ if (componentOptions.wrap) {
163
+ return (jsx(RendererErrorBoundary, { renderError: renderError, children: jsx(WrapTag, { ...internalAttributes, children: jsx(Component, { ...attrsWithResponsiveClass, ...resolvedProps }) }) }));
164
+ }
165
+ return (jsx(RendererErrorBoundary, { renderError: renderError, children: jsx(Component, { studioAttributes: internalAttributes, ...attrsWithResponsiveClass, ...resolvedProps }) }));
166
+ }
167
+ catch (error) {
168
+ if (error instanceof Error) {
169
+ console.error("Error while rendering component", error);
170
+ return (jsx(RendererErrorComponent, { builderAttributes: internalAttributes, reason: error.message }));
171
+ }
172
+ throw error;
173
+ }
174
+ };
175
+ const MemoizedElement = memo(Element, (prev, next) => {
176
+ const isSame = prev.node === next.node &&
177
+ prev.dataCslp === next.dataCslp &&
178
+ prev.renderError === next.renderError;
179
+ return isSame;
180
+ });
181
+ const VisualComponent = ({ parent, nodes, slotUid, renderError, dataCslp = "", }) => {
182
+ const { uid } = parent;
183
+ const isPreviewMode = usePreviewMode();
184
+ const { isCompositionBeingEdited, componentRegistry } = useRenderer();
185
+ const { currentNodePath: parentNodePath = [] } = useCurrentNode();
186
+ const ref = useCallback((ref) => {
187
+ if (isPreviewMode)
188
+ return;
189
+ if (ref && parent) {
190
+ ELEMENT_TO_NODE.set(ref, parent);
191
+ NODE_TO_ELEMENT.set(parent, ref);
192
+ }
193
+ else if (!ref) {
194
+ // When component unmounts, remove references safely
195
+ const element = NODE_TO_ELEMENT.get(parent);
196
+ if (element) {
197
+ ELEMENT_TO_NODE.delete(element);
198
+ }
199
+ if (NODE_TO_ELEMENT.has(parent)) {
200
+ NODE_TO_ELEMENT.delete(parent);
201
+ }
202
+ }
203
+ }, [parent]);
204
+ if (!shouldRenderSlot(componentRegistry, parent, nodes, isCompositionBeingEdited)) {
205
+ const children = nodes?.map((node, idx) => {
206
+ const key = node.uid;
207
+ const currentNodePath = [...parentNodePath, [slotUid, idx]];
208
+ if (isCompositionBeingEdited) {
209
+ NODE_TO_PATH_NODE.set(node, [slotUid, idx]);
210
+ NODE_TO_PARENT.set(node, parent);
211
+ }
212
+ if (node.metadata?.visible === false) {
213
+ return;
214
+ }
215
+ return (jsx(CurrentNodeContext.Provider, { value: {
216
+ currentNodeUid: key,
217
+ currentNodePath: currentNodePath,
218
+ }, children: jsx(SelectedNodeProvider, { children: jsx(Element, { node: node, renderError: renderError, dataCslp: dataCslp }, key) }) }, key));
219
+ });
220
+ return jsx(Fragment, { children: children });
221
+ }
222
+ if (!isCompositionBeingEdited || isPreviewMode) {
223
+ return jsx(Slot, { studioAttributes: {}, slotUid: slotUid });
224
+ }
225
+ const internalAttributes = {
226
+ [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,
227
+ [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,
228
+ [COMPOSABLE_DATA_ATTRIBUTES.ID]: uid,
229
+ ref,
230
+ };
231
+ return jsx(Slot, { studioAttributes: internalAttributes, slotUid: slotUid });
232
+ };
233
+
234
+ export { MemoizedElement as default };
235
+ //# sourceMappingURL=Element.js.map
@@ -0,0 +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 { CurrentNodeContext } from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n} from \"@contentstack/studio-react-components/hooks\";\nimport {\n getBindingString,\n getCslpTag,\n getRepeaterBinding,\n GetSlotsParams,\n resolveMetadataBindings,\n retrievePropValue,\n} from \"@contentstack/studio-registry\";\nimport classNames from \"classnames\";\nimport { memo, RefCallback, useCallback, useEffect, useRef } 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 // TODO: link to the documentation\n console.error(\n \"Open method is not available on the reference. Please check the documentation for more details.\",\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 // TODO: link to the documentation\n console.error(\n \"Close method is not available on the reference. Please check the documentation for more details.\",\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 if (!componentRegistry) {\n return <RendererErrorComponent reason=\"SDK is not initialized\" />;\n }\n let internalAttributes: BuilderNodeInternalAttributes = {};\n\n if (isCompositionBeingEdited && !isPreviewMode) {\n const ref: RefCallback<StudioComponentRef> = useCallback(\n (ref) => {\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 [node],\n );\n\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 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 [defaultResponsiveClass, namedResponsiveClasses, fontFamilies] =\n handleNodeStyles(styles, uid);\n\n // TODO: @RavenColEvol, can we memoize this?\n useEffect(() => {\n fontFamilies.forEach((fontFamily) => {\n loadGoogleFont(fontFamily);\n });\n }, [fontFamilies]);\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 const WrapTag =\n typeof componentOptions.wrap === \"string\"\n ? componentOptions.wrap || \"div\"\n : \"div\";\n if (componentOptions.wrap) {\n return (\n <RendererErrorBoundary renderError={renderError}>\n <WrapTag {...internalAttributes}>\n <Component {...attrsWithResponsiveClass} {...resolvedProps} />\n </WrapTag>\n </RendererErrorBoundary>\n );\n }\n return (\n <RendererErrorBoundary renderError={renderError}>\n <Component\n studioAttributes={internalAttributes}\n {...attrsWithResponsiveClass}\n {...resolvedProps}\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 } = 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 if (!isCompositionBeingEdited || isPreviewMode) {\n return <Slot studioAttributes={{}} slotUid={slotUid} />;\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 <Slot studioAttributes={internalAttributes} slotUid={slotUid} />;\n};\n\nexport default MemoizedElement;\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,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;IACtB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI;IACnC,MAAM,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE;AACrE,IAAA,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAAC;AACnC,IAAA,MAAM,SAAS,GAAG,MAAM,CAAqB,IAAI,CAAC;;IAGlD,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,sCAAsC,GAAG,CAC7C,IAAwC,KACtC;AACF,YAAA,IAAI,CAAC,wBAAwB;gBAAE;AAE/B,YAAA,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;gBAAE;AAErD,YAAA,IAAI,SAAS,CAAC,O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AAA,EAAC,gBAAgB,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAA,CAAI;IACzD;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,OAAOA,GAAA,CAAC,IAAI,EAAA,EAAC,gBAAgB,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAA,CAAI;AACzE,CAAC;;;;"}
@@ -0,0 +1,13 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { styleFactory } from './styles.js';
3
+ import { css } from 'goober';
4
+
5
+ function RendererErrorComponent({ reason, builderAttributes, }) {
6
+ return (jsxs("section", { className: styleFactory(css).rendererErrorComponent, ...(builderAttributes || {}), children: [jsxs("div", { className: "header", children: [jsx(ErrorIcon, {}), jsx("h3", { children: "Component Loading Error" })] }), jsx("div", { children: jsx("p", { children: reason }) })] }));
7
+ }
8
+ function ErrorIcon() {
9
+ return (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: 26, height: 26, fill: "none", children: [jsx("path", { fill: "#A31B00", d: "M13 25c6.627 0 12-5.373 12-12S19.627 1 13 1 1 6.373 1 13s5.373 12 12 12Z" }), jsx("path", { fill: "#475161", fillRule: "evenodd", d: "M13 1.75C6.787 1.75 1.75 6.787 1.75 13S6.787 24.25 13 24.25 24.25 19.213 24.25 13 19.213 1.75 13 1.75ZM.25 13C.25 5.958 5.958.25 13 .25S25.75 5.958 25.75 13 20.042 25.75 13 25.75.25 20.042.25 13Z", clipRule: "evenodd" }), jsx("path", { fill: "#fff", d: "M17.707 9.707a1 1 0 0 0-1.414-1.414L13 11.586 9.707 8.293a1 1 0 0 0-1.414 1.414L11.586 13l-3.293 3.293a1 1 0 1 0 1.414 1.414L13 14.414l3.293 3.293a1 1 0 0 0 1.414-1.414L14.414 13l3.293-3.293Z" })] }));
10
+ }
11
+
12
+ export { RendererErrorComponent };
13
+ //# sourceMappingURL=ErrorComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorComponent.js","sources":["../../src/components/ErrorComponent.tsx"],"sourcesContent":["import { styleFactory } from \"./styles\";\nimport { css } from \"goober\";\n\nexport function RendererErrorComponent({\n reason,\n builderAttributes,\n}: {\n reason: string;\n builderAttributes?: any;\n}) {\n return (\n <section\n className={styleFactory(css).rendererErrorComponent}\n {...(builderAttributes || {})}\n >\n <div className=\"header\">\n <ErrorIcon />\n {/* TODO: Get the text from docs team */}\n <h3>Component Loading Error</h3>\n </div>\n <div>\n <p>{reason}</p>\n </div>\n </section>\n );\n}\n\nfunction ErrorIcon() {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width={26} height={26} fill=\"none\">\n <path\n fill=\"#A31B00\"\n d=\"M13 25c6.627 0 12-5.373 12-12S19.627 1 13 1 1 6.373 1 13s5.373 12 12 12Z\"\n />\n <path\n fill=\"#475161\"\n fillRule=\"evenodd\"\n d=\"M13 1.75C6.787 1.75 1.75 6.787 1.75 13S6.787 24.25 13 24.25 24.25 19.213 24.25 13 19.213 1.75 13 1.75ZM.25 13C.25 5.958 5.958.25 13 .25S25.75 5.958 25.75 13 20.042 25.75 13 25.75.25 20.042.25 13Z\"\n clipRule=\"evenodd\"\n />\n <path\n fill=\"#fff\"\n d=\"M17.707 9.707a1 1 0 0 0-1.414-1.414L13 11.586 9.707 8.293a1 1 0 0 0-1.414 1.414L11.586 13l-3.293 3.293a1 1 0 1 0 1.414 1.414L13 14.414l3.293 3.293a1 1 0 0 0 1.414-1.414L14.414 13l3.293-3.293Z\"\n />\n </svg>\n );\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;;SAGgB,sBAAsB,CAAC,EACrC,MAAM,EACN,iBAAiB,GAIlB,EAAA;AACC,IAAA,QACEA,IAAA,CAAA,SAAA,EAAA,EACE,SAAS,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,sBAAsB,MAC9C,iBAAiB,IAAI,EAAE,CAAC,EAAA,QAAA,EAAA,CAE7BA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,QAAQ,EAAA,QAAA,EAAA,CACrBC,GAAA,CAAC,SAAS,EAAA,EAAA,CAAG,EAEbA,GAAA,CAAA,IAAA,EAAA,EAAA,QAAA,EAAA,yBAAA,EAAA,CAAgC,CAAA,EAAA,CAC5B,EACNA,GAAA,CAAA,KAAA,EAAA,EAAA,QAAA,EACEA,qBAAI,MAAM,EAAA,CAAK,EAAA,CACX,CAAA,EAAA,CACE;AAEd;AAEA,SAAS,SAAS,GAAA;IAChB,QACED,IAAA,CAAA,KAAA,EAAA,EAAK,KAAK,EAAC,4BAA4B,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAC,MAAM,EAAA,QAAA,EAAA,CACxEC,GAAA,CAAA,MAAA,EAAA,EACE,IAAI,EAAC,SAAS,EACd,CAAC,EAAC,0EAA0E,EAAA,CAC5E,EACFA,cACE,IAAI,EAAC,SAAS,EACd,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,qMAAqM,EACvM,QAAQ,EAAC,SAAS,EAAA,CAClB,EACFA,GAAA,CAAA,MAAA,EAAA,EACE,IAAI,EAAC,MAAM,EACX,CAAC,EAAC,iMAAiM,EAAA,CACnM,CAAA,EAAA,CACE;AAEV;;;;"}
@@ -0,0 +1,23 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import MemoizedElement from './Element.js';
3
+ import '../contexts/providers/renderer.provider.js';
4
+ import '../contexts/providers/active-node.provider.js';
5
+ import '@contentstack/studio-client';
6
+ import '@contentstack/studio-messenger';
7
+ import '@contentstack/studio-react-components/contexts';
8
+ import 'immer';
9
+ import 'react';
10
+ import '@contentstack/studio-react-components/hooks';
11
+ import '@contentstack/studio-registry';
12
+ import '../contexts/providers/use-design-preview.provider.js';
13
+ import '../contexts/providers/use-repeater.provider.js';
14
+ import '../contexts/providers/use-condition-block.provider.js';
15
+ import { PreviewModeContext } from '../contexts/providers/preview-mode.provider.js';
16
+
17
+ function PreviewRenderer(props) {
18
+ const { spec } = props;
19
+ return (jsx(PreviewModeContext.Provider, { value: true, children: jsx(MemoizedElement, { node: spec.ui }) }));
20
+ }
21
+
22
+ export { PreviewRenderer };
23
+ //# sourceMappingURL=PreviewRenderer.js.map
@@ -0,0 +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 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;IACtB,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;;;;"}
@@ -0,0 +1,21 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { ComposableStudioError } from '@contentstack/studio-client';
3
+ import { RendererErrorComponent } from './ErrorComponent.js';
4
+
5
+ const RenderErrorHOC = ({ error, renderError, }) => {
6
+ const DefaultComponent = jsx(RendererErrorComponent, { reason: error.message });
7
+ if (error instanceof ComposableStudioError && renderError) {
8
+ const ErrorComponent = renderError;
9
+ return (jsx(ErrorComponent
10
+ // safe to cast, most likely fallback errors
11
+ // will not be thrown from the rendering logic
12
+ , {
13
+ // safe to cast, most likely fallback errors
14
+ // will not be thrown from the rendering logic
15
+ error: error, defaultComponent: DefaultComponent }));
16
+ }
17
+ return DefaultComponent;
18
+ };
19
+
20
+ export { RenderErrorHOC };
21
+ //# sourceMappingURL=RenderErrorHOC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenderErrorHOC.js","sources":["../../src/components/RenderErrorHOC.tsx"],"sourcesContent":["import {\n ComposableStudioError,\n ComposableStudioClientError,\n} from \"@contentstack/studio-client\";\nimport { RendererErrorComponent } from \"./ErrorComponent\";\n\nexport const RenderErrorHOC = ({\n error,\n renderError,\n}: {\n error: Error;\n renderError: any;\n}) => {\n const DefaultComponent = <RendererErrorComponent reason={error.message} />;\n if (error instanceof ComposableStudioError && renderError) {\n const ErrorComponent = renderError;\n return (\n <ErrorComponent\n // safe to cast, most likely fallback errors\n // will not be thrown from the rendering logic\n error={error as ComposableStudioClientError}\n defaultComponent={DefaultComponent}\n />\n );\n }\n return DefaultComponent;\n};\n"],"names":["_jsx"],"mappings":";;;;AAMO,MAAM,cAAc,GAAG,CAAC,EAC7B,KAAK,EACL,WAAW,GAIZ,KAAI;IACH,MAAM,gBAAgB,GAAGA,GAAA,CAAC,sBAAsB,EAAA,EAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAA,CAAI;AAC1E,IAAA,IAAI,KAAK,YAAY,qBAAqB,IAAI,WAAW,EAAE;QACzD,MAAM,cAAc,GAAG,WAAW;QAClC,QACEA,IAAC;;;;;;YAGC,KAAK,EAAE,KAAoC,EAC3C,gBAAgB,EAAE,gBAAgB,EAAA,CAClC;IAEN;AACA,IAAA,OAAO,gBAAgB;AACzB;;;;"}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import React from 'react';
4
+ import { ErrorBoundary } from 'react-error-boundary';
5
+ import { RendererErrorComponent } from './ErrorComponent.js';
6
+
7
+ const RendererErrorBoundary = React.memo(({ children, renderError }) => {
8
+ return (jsx(ErrorBoundary, { FallbackComponent: ({ error }) => {
9
+ if (renderError) {
10
+ const CustomErrorComponent = renderError;
11
+ return jsx(CustomErrorComponent, { error: error });
12
+ }
13
+ return jsx(RendererErrorComponent, { reason: error.message });
14
+ }, children: children }));
15
+ });
16
+
17
+ export { RendererErrorBoundary };
18
+ //# sourceMappingURL=RendererErrorBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RendererErrorBoundary.js","sources":["../../src/components/RendererErrorBoundary.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\nimport { RendererErrorComponent } from \"./ErrorComponent\";\n\ninterface RendererErrorBoundaryProps {\n children: React.ReactNode;\n renderError?: React.ComponentType<{ error: Error }>;\n}\n\nexport const RendererErrorBoundary = React.memo(\n ({ children, renderError }: RendererErrorBoundaryProps) => {\n return (\n <ErrorBoundary\n FallbackComponent={({ error }) => {\n if (renderError) {\n const CustomErrorComponent = renderError;\n return <CustomErrorComponent error={error} />;\n }\n return <RendererErrorComponent reason={error.message} />;\n }}\n >\n {children}\n </ErrorBoundary>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;AAWO;;;;AAOK;;;AAGJ;AAKN;;"}
@@ -0,0 +1,18 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { COMPOSABLE_DATA_ATTRIBUTES } from '@contentstack/studio-client';
3
+ import { css } from 'goober';
4
+ import { styleFactory } from './styles.js';
5
+
6
+ function Slot({ studioAttributes, slotUid }) {
7
+ const attributes = {
8
+ [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,
9
+ [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,
10
+ };
11
+ return (jsxs("div", { ...attributes, className: styleFactory(css).slotStyle, ...studioAttributes, children: [jsx(AddIcon, {}), " Drop Here", jsx("p", { className: styleFactory(css).slotContentStyle })] }));
12
+ }
13
+ const AddIcon = () => {
14
+ 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" })] }));
15
+ };
16
+
17
+ export { Slot as default };
18
+ //# sourceMappingURL=Slot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Slot.js","sources":["../../src/components/Slot.tsx"],"sourcesContent":["import { COMPOSABLE_DATA_ATTRIBUTES } from \"@contentstack/studio-client\";\nimport { css } from \"goober\";\nimport { styleFactory } from \"./styles\";\nimport { StudioAttributes } from \"../types/renderer.type\";\n\ninterface SlotProps extends StudioAttributes {\n slotUid: string;\n}\n\nexport default function Slot({ studioAttributes, slotUid }: SlotProps) {\n const attributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n };\n return (\n <div\n {...attributes}\n className={styleFactory(css).slotStyle}\n {...studioAttributes}\n >\n <AddIcon /> Drop Here\n <p className={styleFactory(css).slotContentStyle}></p>\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":["_jsxs","_jsx"],"mappings":";;;;;AASc,SAAU,IAAI,CAAC,EAAE,gBAAgB,EAAE,OAAO,EAAa,EAAA;AACnE,IAAA,MAAM,UAAU,GAAG;AACjB,QAAA,CAAC,0BAA0B,CAAC,IAAI,GAAG,IAAI;AACvC,QAAA,CAAC,0BAA0B,CAAC,QAAQ,GAAG,OAAO;KAC/C;AACD,IAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EAAA,GACM,UAAU,EACd,SAAS,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,SAAS,KAClC,gBAAgB,EAAA,QAAA,EAAA,CAEpBC,GAAA,CAAC,OAAO,EAAA,EAAA,CAAG,EAAA,YAAA,EACXA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAA,CAAM,CAAA,EAAA,CAClD;AAEV;AAEA,MAAM,OAAO,GAAa,MAAK;AAC7B,IAAA,QACED,IAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,EAAA,QAAA,EAAA,CAElCC,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;;;;"}
@@ -0,0 +1,29 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { COMPOSABLE_DATA_ATTRIBUTES } from '@contentstack/studio-client';
3
+
4
+ const DEFAULT_PLACEHOLDER = "Your text here";
5
+ const TextPlaceholder = ({ placeholder = DEFAULT_PLACEHOLDER, }) => {
6
+ const attributes = {
7
+ [COMPOSABLE_DATA_ATTRIBUTES.PLACEHOLDER]: true,
8
+ };
9
+ const placeholderStyles = {
10
+ position: "absolute",
11
+ pointerEvents: "none",
12
+ width: "100%",
13
+ maxWidth: "100%",
14
+ display: "block",
15
+ opacity: 0.333,
16
+ color: "#000",
17
+ userSelect: "none",
18
+ textDecoration: "none",
19
+ };
20
+ const containerStyles = {
21
+ display: "inline-block",
22
+ width: "100%",
23
+ position: "relative",
24
+ };
25
+ return (jsxs("span", { ...attributes, style: containerStyles, children: [jsx("span", { style: placeholderStyles, children: placeholder }), "", jsx("br", {})] }));
26
+ };
27
+
28
+ export { TextPlaceholder };
29
+ //# sourceMappingURL=TextPlaceholder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextPlaceholder.js","sources":["../../src/components/TextPlaceholder.tsx"],"sourcesContent":["import { COMPOSABLE_DATA_ATTRIBUTES } from \"@contentstack/studio-client\";\n\nconst DEFAULT_PLACEHOLDER = \"Your text here\";\n\nexport const TextPlaceholder = ({\n placeholder = DEFAULT_PLACEHOLDER,\n}: {\n placeholder?: string;\n}) => {\n const attributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.PLACEHOLDER]: true,\n };\n const placeholderStyles = {\n position: \"absolute\",\n pointerEvents: \"none\",\n width: \"100%\",\n maxWidth: \"100%\",\n display: \"block\",\n opacity: 0.333,\n color: \"#000\",\n userSelect: \"none\",\n textDecoration: \"none\",\n } as React.CSSProperties;\n\n const containerStyles = {\n display: \"inline-block\",\n width: \"100%\",\n position: \"relative\" as const,\n };\n return (\n <span {...attributes} style={containerStyles}>\n <span style={placeholderStyles}>{placeholder}</span>\n {\"\"}\n <br />\n </span>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAEA,MAAM,mBAAmB,GAAG,gBAAgB;AAErC,MAAM,eAAe,GAAG,CAAC,EAC9B,WAAW,GAAG,mBAAmB,GAGlC,KAAI;AACH,IAAA,MAAM,UAAU,GAAG;AACjB,QAAA,CAAC,0BAA0B,CAAC,WAAW,GAAG,IAAI;KAC/C;AACD,IAAA,MAAM,iBAAiB,GAAG;AACxB,QAAA,QAAQ,EAAE,UAAU;AACpB,QAAA,aAAa,EAAE,MAAM;AACrB,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,OAAO,EAAE,OAAO;AAChB,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,UAAU,EAAE,MAAM;AAClB,QAAA,cAAc,EAAE,MAAM;KACA;AAExB,IAAA,MAAM,eAAe,GAAG;AACtB,QAAA,OAAO,EAAE,cAAc;AACvB,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,QAAQ,EAAE,UAAmB;KAC9B;IACD,QACEA,kBAAU,UAAU,EAAE,KAAK,EAAE,eAAe,aAC1CC,GAAA,CAAA,MAAA,EAAA,EAAM,KAAK,EAAE,iBAAiB,EAAA,QAAA,EAAG,WAAW,EAAA,CAAQ,EACnD,EAAE,EACHA,GAAA,CAAA,IAAA,EAAA,EAAA,CAAM,CAAA,EAAA,CACD;AAEX;;;;"}