@contentstack/studio-react-editor 1.1.3 → 1.2.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.
@@ -151,9 +151,9 @@ const Element = ({ node, renderError, dataCslp, }) => {
151
151
  // TODO: @RavenColEvol, can we memoize this?
152
152
  useEffect(() => {
153
153
  fontFamilies.forEach((fontFamily) => {
154
- loadGoogleFont(fontFamily, fontVariants.get(fontFamily));
154
+ loadGoogleFont(fontFamily, fontVariants.get(fontFamily), styles, uid);
155
155
  });
156
- }, [fontFamilies]);
156
+ }, [fontFamilies, styles, uid]);
157
157
  const componentClass = classNames(resolvedProps.className, defaultResponsiveClass, attrs.className);
158
158
  const attrsWithResponsiveClass = {
159
159
  ...attrs,
@@ -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 { 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 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 // 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 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 [\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)!);\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":["_js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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 INTERNAL_COMPONENTS_NAMES,\n ComponentRegistry,\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 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 // 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 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 [\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 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 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":";;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,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;;IAG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C,EAAA,QAAA,EAEDA,GAAA,CAAC,oBAAoB,EAAA,EAAA,QAAA,EACnBA,GAAA,CAAC,OAAO,IAEN,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAAA,EAHb,GAAG,CAIR,EAAA,CACmB,EAAA,EAblB,GAAG,CAcoB;AAElC,QAAA,CAAC,CAAC;QAEF,OAAOA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI;IACxB;AAEA,IAAA,IAAI,CAAC,wBAAwB,IAAI,aAAa,EAAE;QAC9C,OAAOD,GAAA,CAAC,IAAI,EAAA,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;;;;"}
@@ -6,13 +6,7 @@ const RenderErrorHOC = ({ error, renderError, }) => {
6
6
  const DefaultComponent = jsx(RendererErrorComponent, { reason: error.message });
7
7
  if (error instanceof ComposableStudioError && renderError) {
8
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 }));
9
+ return jsx(ErrorComponent, { error: error, defaultComponent: DefaultComponent });
16
10
  }
17
11
  return DefaultComponent;
18
12
  };
@@ -1 +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;;;;"}
1
+ {"version":3,"file":"RenderErrorHOC.js","sources":["../../src/components/RenderErrorHOC.tsx"],"sourcesContent":["import { ComposableStudioError } 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 <ErrorComponent error={error} defaultComponent={DefaultComponent} />;\n }\n return DefaultComponent;\n};\n"],"names":["_jsx"],"mappings":";;;;AAGO,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,OAAOA,GAAA,CAAC,cAAc,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAA,CAAI;IAC7E;AACA,IAAA,OAAO,gBAAgB;AACzB;;;;"}
@@ -1 +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;;"}
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 const errorObj = error as Error;\n if (renderError) {\n const CustomErrorComponent = renderError;\n return <CustomErrorComponent error={error as Error} />;\n }\n return <RendererErrorComponent reason={(error as Error).message} />;\n }}\n >\n {children}\n </ErrorBoundary>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;AAWO;;;;AAQK;;;AAGJ;AAKN;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/studio-react-editor",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "description": "Contains all logic of editing for react based environment",
5
5
  "author": "RavenColEvol <ravilamkoti@gmail.com>",
6
6
  "homepage": "https://github.com/contentstack/composable-studio-sdk#readme",
@@ -60,17 +60,17 @@
60
60
  "typescript": "^5.2.2"
61
61
  },
62
62
  "dependencies": {
63
- "@contentstack/studio-client": "^1.2.0",
64
- "@contentstack/studio-core": "^1.1.3",
65
- "@contentstack/studio-internal": "^1.1.3",
66
- "@contentstack/studio-messenger": "^1.1.3",
67
- "@contentstack/studio-react-components": "^1.3.0",
68
- "@contentstack/studio-registry": "^1.2.0",
63
+ "@contentstack/studio-client": "^1.4.0",
64
+ "@contentstack/studio-core": "^1.1.5",
65
+ "@contentstack/studio-internal": "^1.1.5",
66
+ "@contentstack/studio-messenger": "^1.2.0",
67
+ "@contentstack/studio-react-components": "^1.4.1",
68
+ "@contentstack/studio-registry": "^1.3.0",
69
69
  "classnames": "^2.5.1",
70
70
  "goober": "^2.1.16",
71
71
  "immer": "^10.1.1",
72
- "lodash-es": "^4.17.21",
72
+ "lodash-es": "^4.17.23",
73
73
  "react-error-boundary": "^6.0.0"
74
74
  },
75
- "gitHead": "72726052f099c6a4cd39b1fcbc1bfe97f64ab130"
75
+ "gitHead": "6739518a282ff9788218b0acd2e46e0be2a6fb68"
76
76
  }