@builder.io/sdk-react-native 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.js +8 -2
- package/dist/components/content/content.js +10 -6
- package/dist/constants/sdk-version.js +1 -1
- package/dist/context/components.context.js +6 -0
- package/package.json +1 -1
- package/src/components/blocks/blocks.jsx +13 -3
- package/src/components/content/content.jsx +42 -35
- package/src/constants/sdk-version.js +1 -1
- package/src/context/components.context.js +5 -0
|
@@ -29,13 +29,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
const React = __importStar(require("react"));
|
|
31
31
|
const react_native_1 = require("react-native");
|
|
32
|
+
const react_1 = require("react");
|
|
32
33
|
const block_styles_1 = __importDefault(require("../block/components/block-styles"));
|
|
33
34
|
const block_1 = __importDefault(require("../block/block"));
|
|
34
35
|
const blocks_wrapper_1 = __importDefault(require("./blocks-wrapper"));
|
|
36
|
+
const builder_context_1 = __importDefault(require("../../context/builder.context"));
|
|
37
|
+
const components_context_1 = __importDefault(require("../../context/components.context"));
|
|
35
38
|
function Blocks(props) {
|
|
36
39
|
var _a, _b;
|
|
40
|
+
const builderContext = (0, react_1.useContext)(builder_context_1.default);
|
|
41
|
+
const componentsContext = (0, react_1.useContext)(components_context_1.default);
|
|
37
42
|
return (React.createElement(blocks_wrapper_1.default, { blocks: props.blocks, parent: props.parent, path: props.path, styleProp: props.styleProp },
|
|
38
|
-
props.blocks ? (React.createElement(React.Fragment, null, (_a = props.blocks) === null || _a === void 0 ? void 0 : _a.map((block) => (React.createElement(block_1.default, { key: "render-block-" + block.id, block: block, context: props.context, registeredComponents: props.registeredComponents
|
|
39
|
-
|
|
43
|
+
props.blocks ? (React.createElement(React.Fragment, null, (_a = props.blocks) === null || _a === void 0 ? void 0 : _a.map((block) => (React.createElement(block_1.default, { key: "render-block-" + block.id, block: block, context: props.context || builderContext, registeredComponents: props.registeredComponents ||
|
|
44
|
+
componentsContext.registeredComponents }))))) : null,
|
|
45
|
+
props.blocks ? (React.createElement(React.Fragment, null, (_b = props.blocks) === null || _b === void 0 ? void 0 : _b.map((block) => (React.createElement(block_styles_1.default, { key: "block-style-" + block.id, block: block, context: props.context || builderContext }))))) : null));
|
|
40
46
|
}
|
|
41
47
|
exports.default = Blocks;
|
|
@@ -40,6 +40,7 @@ const helpers_js_1 = require("../content-variants/helpers.js");
|
|
|
40
40
|
const enable_editor_1 = __importDefault(require("./components/enable-editor"));
|
|
41
41
|
const inlined_script_1 = __importDefault(require("../inlined-script"));
|
|
42
42
|
const wrap_component_ref_js_1 = require("./wrap-component-ref.js");
|
|
43
|
+
const components_context_1 = __importDefault(require("../../context/components.context"));
|
|
43
44
|
function ContentComponent(props) {
|
|
44
45
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
45
46
|
const [scriptStr, setScriptStr] = (0, react_1.useState)(() => {
|
|
@@ -100,11 +101,14 @@ function ContentComponent(props) {
|
|
|
100
101
|
}), {}),
|
|
101
102
|
inheritedStyles: {},
|
|
102
103
|
}));
|
|
103
|
-
return (React.createElement(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
return (React.createElement(components_context_1.default.Provider, { value: {
|
|
105
|
+
registeredComponents: registeredComponents,
|
|
106
|
+
} },
|
|
107
|
+
React.createElement(enable_editor_1.default, { 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 },
|
|
108
|
+
props.isSsrAbTest ? (React.createElement(React.Fragment, null,
|
|
109
|
+
React.createElement(inlined_script_1.default, { scriptStr: scriptStr }))) : null,
|
|
110
|
+
target_js_1.TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
111
|
+
React.createElement(styles_1.default, { contentId: (_a = builderContextSignal.content) === null || _a === void 0 ? void 0 : _a.id, cssCode: (_c = (_b = builderContextSignal.content) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.cssCode, customFonts: (_e = (_d = builderContextSignal.content) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.customFonts }))) : null,
|
|
112
|
+
React.createElement(blocks_1.default, { blocks: (_g = (_f = builderContextSignal.content) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.blocks, context: builderContextSignal, registeredComponents: registeredComponents }))));
|
|
109
113
|
}
|
|
110
114
|
exports.default = ContentComponent;
|
package/package.json
CHANGED
|
@@ -8,11 +8,18 @@ import {
|
|
|
8
8
|
Image,
|
|
9
9
|
Text,
|
|
10
10
|
} from "react-native";
|
|
11
|
+
import { useContext } from "react";
|
|
11
12
|
import BlockStyles from "../block/components/block-styles";
|
|
12
13
|
import Block from "../block/block";
|
|
13
14
|
import BlocksWrapper from "./blocks-wrapper";
|
|
15
|
+
import BuilderContext from "../../context/builder.context";
|
|
16
|
+
import ComponentsContext from "../../context/components.context";
|
|
14
17
|
|
|
15
18
|
function Blocks(props) {
|
|
19
|
+
const builderContext = useContext(BuilderContext);
|
|
20
|
+
|
|
21
|
+
const componentsContext = useContext(ComponentsContext);
|
|
22
|
+
|
|
16
23
|
return (
|
|
17
24
|
<BlocksWrapper
|
|
18
25
|
blocks={props.blocks}
|
|
@@ -26,8 +33,11 @@ function Blocks(props) {
|
|
|
26
33
|
<Block
|
|
27
34
|
key={"render-block-" + block.id}
|
|
28
35
|
block={block}
|
|
29
|
-
context={props.context}
|
|
30
|
-
registeredComponents={
|
|
36
|
+
context={props.context || builderContext}
|
|
37
|
+
registeredComponents={
|
|
38
|
+
props.registeredComponents ||
|
|
39
|
+
componentsContext.registeredComponents
|
|
40
|
+
}
|
|
31
41
|
/>
|
|
32
42
|
))}
|
|
33
43
|
</>
|
|
@@ -39,7 +49,7 @@ function Blocks(props) {
|
|
|
39
49
|
<BlockStyles
|
|
40
50
|
key={"block-style-" + block.id}
|
|
41
51
|
block={block}
|
|
42
|
-
context={props.context}
|
|
52
|
+
context={props.context || builderContext}
|
|
43
53
|
/>
|
|
44
54
|
))}
|
|
45
55
|
</>
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
Image,
|
|
9
9
|
Text,
|
|
10
10
|
} from "react-native";
|
|
11
|
-
import { useState } from "react";
|
|
11
|
+
import { useState, useContext } from "react";
|
|
12
12
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
13
13
|
import {
|
|
14
14
|
components,
|
|
@@ -25,6 +25,7 @@ import { getRenderContentScriptString } from "../content-variants/helpers.js";
|
|
|
25
25
|
import EnableEditor from "./components/enable-editor";
|
|
26
26
|
import InlinedScript from "../inlined-script";
|
|
27
27
|
import { wrapComponentRef } from "./wrap-component-ref.js";
|
|
28
|
+
import ComponentsContext from "../../context/components.context";
|
|
28
29
|
|
|
29
30
|
function ContentComponent(props) {
|
|
30
31
|
const [scriptStr, setScriptStr] = useState(() =>
|
|
@@ -97,44 +98,50 @@ function ContentComponent(props) {
|
|
|
97
98
|
}));
|
|
98
99
|
|
|
99
100
|
return (
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
context={props.context}
|
|
104
|
-
apiKey={props.apiKey}
|
|
105
|
-
canTrack={props.canTrack}
|
|
106
|
-
locale={props.locale}
|
|
107
|
-
includeRefs={props.includeRefs}
|
|
108
|
-
enrich={props.enrich}
|
|
109
|
-
classNameProp={props.classNameProp}
|
|
110
|
-
showContent={props.showContent}
|
|
111
|
-
builderContextSignal={builderContextSignal}
|
|
112
|
-
{...{
|
|
113
|
-
setBuilderContextSignal: setBuilderContextSignal,
|
|
101
|
+
<ComponentsContext.Provider
|
|
102
|
+
value={{
|
|
103
|
+
registeredComponents: registeredComponents,
|
|
114
104
|
}}
|
|
115
105
|
>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
106
|
+
<EnableEditor
|
|
107
|
+
content={props.content}
|
|
108
|
+
model={props.model}
|
|
109
|
+
context={props.context}
|
|
110
|
+
apiKey={props.apiKey}
|
|
111
|
+
canTrack={props.canTrack}
|
|
112
|
+
locale={props.locale}
|
|
113
|
+
includeRefs={props.includeRefs}
|
|
114
|
+
enrich={props.enrich}
|
|
115
|
+
classNameProp={props.classNameProp}
|
|
116
|
+
showContent={props.showContent}
|
|
117
|
+
builderContextSignal={builderContextSignal}
|
|
118
|
+
{...{
|
|
119
|
+
setBuilderContextSignal: setBuilderContextSignal,
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
{props.isSsrAbTest ? (
|
|
123
|
+
<>
|
|
124
|
+
<InlinedScript scriptStr={scriptStr} />
|
|
125
|
+
</>
|
|
126
|
+
) : null}
|
|
121
127
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
{TARGET !== "reactNative" ? (
|
|
129
|
+
<>
|
|
130
|
+
<ContentStyles
|
|
131
|
+
contentId={builderContextSignal.content?.id}
|
|
132
|
+
cssCode={builderContextSignal.content?.data?.cssCode}
|
|
133
|
+
customFonts={builderContextSignal.content?.data?.customFonts}
|
|
134
|
+
/>
|
|
135
|
+
</>
|
|
136
|
+
) : null}
|
|
131
137
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
<Blocks
|
|
139
|
+
blocks={builderContextSignal.content?.data?.blocks}
|
|
140
|
+
context={builderContextSignal}
|
|
141
|
+
registeredComponents={registeredComponents}
|
|
142
|
+
/>
|
|
143
|
+
</EnableEditor>
|
|
144
|
+
</ComponentsContext.Provider>
|
|
138
145
|
);
|
|
139
146
|
}
|
|
140
147
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.5.
|
|
1
|
+
export const SDK_VERSION = "0.5.1"
|