@builder.io/sdk-react 0.5.0 → 0.5.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.
- package/dist/components/blocks/blocks.d.ts +2 -2
- package/dist/components/blocks/blocks.js +8 -2
- package/dist/components/content/content.js +10 -6
- package/dist/constants/sdk-version.d.ts +1 -1
- package/dist/constants/sdk-version.js +1 -1
- package/dist/context/components.context.d.ts +3 -0
- package/dist/context/components.context.js +2 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type BlocksProps = Partial<BlocksWrapperProps> & {
|
|
2
|
-
context
|
|
3
|
-
registeredComponents
|
|
2
|
+
context?: BuilderContextInterface;
|
|
3
|
+
registeredComponents?: RegisteredComponents;
|
|
4
4
|
};
|
|
5
5
|
import type { BlocksWrapperProps } from "./blocks-wrapper";
|
|
6
6
|
import type { BuilderContextInterface, RegisteredComponents } from "../../context/types.js";
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import { useContext } from "react";
|
|
3
4
|
import BlockStyles from "../block/components/block-styles";
|
|
4
5
|
import Block from "../block/block";
|
|
5
6
|
import BlocksWrapper from "./blocks-wrapper";
|
|
7
|
+
import BuilderContext from "../../context/builder.context";
|
|
8
|
+
import ComponentsContext from "../../context/components.context";
|
|
6
9
|
function Blocks(props) {
|
|
10
|
+
const builderContext = useContext(BuilderContext);
|
|
11
|
+
const componentsContext = useContext(ComponentsContext);
|
|
7
12
|
return (React.createElement(BlocksWrapper, { blocks: props.blocks, parent: props.parent, path: props.path, styleProp: props.styleProp },
|
|
8
|
-
props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(Block, { key: "render-block-" + block.id, block: block, context: props.context, registeredComponents: props.registeredComponents
|
|
9
|
-
|
|
13
|
+
props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(Block, { key: "render-block-" + block.id, block: block, context: props.context || builderContext, registeredComponents: props.registeredComponents ||
|
|
14
|
+
componentsContext.registeredComponents }))))) : null,
|
|
15
|
+
props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(BlockStyles, { key: "block-style-" + block.id, block: block, context: props.context || builderContext }))))) : null));
|
|
10
16
|
}
|
|
11
17
|
export default Blocks;
|
|
@@ -10,6 +10,7 @@ import { TARGET } from "../../constants/target.js";
|
|
|
10
10
|
import { getRenderContentScriptString } from "../content-variants/helpers.js";
|
|
11
11
|
import EnableEditor from "./components/enable-editor";
|
|
12
12
|
import InlinedScript from "../inlined-script";
|
|
13
|
+
import ComponentsContext from "../../context/components.context";
|
|
13
14
|
function ContentComponent(props) {
|
|
14
15
|
const [scriptStr, setScriptStr] = useState(() => getRenderContentScriptString({
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
@@ -69,11 +70,14 @@ function ContentComponent(props) {
|
|
|
69
70
|
}), {}),
|
|
70
71
|
inheritedStyles: {},
|
|
71
72
|
}));
|
|
72
|
-
return (React.createElement(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
React.createElement(
|
|
77
|
-
|
|
73
|
+
return (React.createElement(ComponentsContext.Provider, { value: {
|
|
74
|
+
registeredComponents: registeredComponents,
|
|
75
|
+
} },
|
|
76
|
+
React.createElement(EnableEditor, { content: props.content, model: props.model, context: props.context, apiKey: props.apiKey, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, classNameProp: props.classNameProp, showContent: props.showContent, builderContextSignal: builderContextSignal, setBuilderContextSignal: setBuilderContextSignal },
|
|
77
|
+
props.isSsrAbTest ? (React.createElement(React.Fragment, null,
|
|
78
|
+
React.createElement(InlinedScript, { scriptStr: scriptStr }))) : null,
|
|
79
|
+
TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
80
|
+
React.createElement(ContentStyles, { contentId: builderContextSignal.content?.id, cssCode: builderContextSignal.content?.data?.cssCode, customFonts: builderContextSignal.content?.data?.customFonts }))) : null,
|
|
81
|
+
React.createElement(Blocks, { blocks: builderContextSignal.content?.data?.blocks, context: builderContextSignal, registeredComponents: registeredComponents }))));
|
|
78
82
|
}
|
|
79
83
|
export default ContentComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.5.
|
|
1
|
+
export declare const SDK_VERSION = "0.5.1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.5.
|
|
1
|
+
export const SDK_VERSION = "0.5.1";
|