@builder.io/sdk-react-native 0.1.14 → 0.1.16
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/blocks/columns/columns.js +6 -6
- package/dist/components/render-block/render-block.js +1 -0
- package/dist/components/render-block/render-component.js +1 -0
- package/dist/components/render-content/render-content.js +1 -1
- package/dist/functions/get-content/index.js +17 -4
- package/package.json +1 -1
- package/src/blocks/columns/columns.jsx +6 -6
- package/src/components/render-block/render-block.jsx +1 -0
- package/src/components/render-block/render-component.jsx +1 -0
- package/src/components/render-content/render-content.jsx +1 -1
- package/src/functions/get-content/index.js +16 -4
|
@@ -73,26 +73,26 @@ function Columns(props) {
|
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
function columnCssVars(index) {
|
|
76
|
-
const
|
|
77
|
-
const gutter = `${index === 0 ? 0 : gutterSize}px`;
|
|
76
|
+
const gutter = index === 0 ? 0 : gutterSize;
|
|
78
77
|
if (target_js_1.TARGET === "reactNative") {
|
|
79
78
|
return {
|
|
80
|
-
width,
|
|
81
79
|
marginLeft: props.stackColumnsAt === "never" ? gutter : 0,
|
|
82
80
|
};
|
|
83
81
|
}
|
|
82
|
+
const width = getColumnCssWidth(index);
|
|
83
|
+
const gutterPixels = `${gutterSize}px`;
|
|
84
84
|
const mobileWidth = "100%";
|
|
85
85
|
const mobileMarginLeft = 0;
|
|
86
86
|
return {
|
|
87
87
|
width,
|
|
88
|
-
"margin-left":
|
|
88
|
+
"margin-left": gutterPixels,
|
|
89
89
|
"--column-width-mobile": getMobileStyle({
|
|
90
90
|
stackedStyle: mobileWidth,
|
|
91
91
|
desktopStyle: width,
|
|
92
92
|
}),
|
|
93
93
|
"--column-margin-left-mobile": getMobileStyle({
|
|
94
94
|
stackedStyle: mobileMarginLeft,
|
|
95
|
-
desktopStyle:
|
|
95
|
+
desktopStyle: gutterPixels,
|
|
96
96
|
}),
|
|
97
97
|
"--column-width-tablet": getTabletStyle({
|
|
98
98
|
stackedStyle: mobileWidth,
|
|
@@ -100,7 +100,7 @@ function Columns(props) {
|
|
|
100
100
|
}),
|
|
101
101
|
"--column-margin-left-tablet": getTabletStyle({
|
|
102
102
|
stackedStyle: mobileMarginLeft,
|
|
103
|
-
desktopStyle:
|
|
103
|
+
desktopStyle: gutterPixels,
|
|
104
104
|
}),
|
|
105
105
|
};
|
|
106
106
|
}
|
|
@@ -42,6 +42,7 @@ function RenderComponent(props) {
|
|
|
42
42
|
apiKey: props.context.apiKey,
|
|
43
43
|
registeredComponents: props.context.registeredComponents,
|
|
44
44
|
inheritedStyles: props.context.inheritedStyles,
|
|
45
|
+
apiVersion: props.context.apiVersion,
|
|
45
46
|
} }, props.componentRef ? (React.createElement(React.Fragment, null,
|
|
46
47
|
React.createElement(ComponentRefRef, { ...props.componentOptions }, (_a = props.blockChildren) === null || _a === void 0 ? void 0 :
|
|
47
48
|
_a.map((child) => (React.createElement(render_block_1.default, { key: "render-block-" + child.id, block: child, context: props.context }))), (_b = props.blockChildren) === null || _b === void 0 ? void 0 :
|
|
@@ -189,7 +189,7 @@ function RenderContent(props) {
|
|
|
189
189
|
setContextState(newState);
|
|
190
190
|
})
|
|
191
191
|
.catch((err) => {
|
|
192
|
-
console.
|
|
192
|
+
console.error("error fetching dynamic data", url, err);
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
195
|
function runHttpRequests() {
|
|
@@ -47,7 +47,11 @@ const ab_testing_js_1 = require("./ab-testing.js");
|
|
|
47
47
|
const generate_content_url_js_1 = require("./generate-content-url.js");
|
|
48
48
|
function getContent(options) {
|
|
49
49
|
return __async(this, null, function* () {
|
|
50
|
-
|
|
50
|
+
const allContent = yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }));
|
|
51
|
+
if ("results" in allContent) {
|
|
52
|
+
return (allContent == null ? void 0 : allContent.results[0]) || null;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
51
55
|
});
|
|
52
56
|
}
|
|
53
57
|
exports.getContent = getContent;
|
|
@@ -56,12 +60,21 @@ function getAllContent(options) {
|
|
|
56
60
|
const url = (0, generate_content_url_js_1.generateContentUrl)(options);
|
|
57
61
|
const res = yield (0, get_fetch_js_1.fetch)(url.href);
|
|
58
62
|
const content = yield res.json();
|
|
63
|
+
if ("status" in content && !("results" in content)) {
|
|
64
|
+
console.error("[Builder.io]: Error fetching data. ", content, options);
|
|
65
|
+
return content;
|
|
66
|
+
}
|
|
59
67
|
const canTrack = options.canTrack !== false;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
try {
|
|
69
|
+
if (canTrack && Array.isArray(content.results)) {
|
|
70
|
+
for (const item of content.results) {
|
|
71
|
+
yield (0, ab_testing_js_1.handleABTesting)({ item, canTrack });
|
|
72
|
+
}
|
|
63
73
|
}
|
|
64
74
|
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
console.error("[Builder.io]: Could not setup A/B testing. ", e);
|
|
77
|
+
}
|
|
65
78
|
return content;
|
|
66
79
|
});
|
|
67
80
|
}
|
package/package.json
CHANGED
|
@@ -66,26 +66,26 @@ function Columns(props) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
function columnCssVars(index) {
|
|
69
|
-
const
|
|
70
|
-
const gutter = `${index === 0 ? 0 : gutterSize}px`;
|
|
69
|
+
const gutter = index === 0 ? 0 : gutterSize;
|
|
71
70
|
if (TARGET === "reactNative") {
|
|
72
71
|
return {
|
|
73
|
-
width,
|
|
74
72
|
marginLeft: props.stackColumnsAt === "never" ? gutter : 0,
|
|
75
73
|
};
|
|
76
74
|
}
|
|
75
|
+
const width = getColumnCssWidth(index);
|
|
76
|
+
const gutterPixels = `${gutterSize}px`;
|
|
77
77
|
const mobileWidth = "100%";
|
|
78
78
|
const mobileMarginLeft = 0;
|
|
79
79
|
return {
|
|
80
80
|
width,
|
|
81
|
-
"margin-left":
|
|
81
|
+
"margin-left": gutterPixels,
|
|
82
82
|
"--column-width-mobile": getMobileStyle({
|
|
83
83
|
stackedStyle: mobileWidth,
|
|
84
84
|
desktopStyle: width,
|
|
85
85
|
}),
|
|
86
86
|
"--column-margin-left-mobile": getMobileStyle({
|
|
87
87
|
stackedStyle: mobileMarginLeft,
|
|
88
|
-
desktopStyle:
|
|
88
|
+
desktopStyle: gutterPixels,
|
|
89
89
|
}),
|
|
90
90
|
"--column-width-tablet": getTabletStyle({
|
|
91
91
|
stackedStyle: mobileWidth,
|
|
@@ -93,7 +93,7 @@ function Columns(props) {
|
|
|
93
93
|
}),
|
|
94
94
|
"--column-margin-left-tablet": getTabletStyle({
|
|
95
95
|
stackedStyle: mobileMarginLeft,
|
|
96
|
-
desktopStyle:
|
|
96
|
+
desktopStyle: gutterPixels,
|
|
97
97
|
}),
|
|
98
98
|
};
|
|
99
99
|
}
|
|
@@ -42,7 +42,11 @@ import { handleABTesting } from "./ab-testing.js";
|
|
|
42
42
|
import { generateContentUrl } from "./generate-content-url.js";
|
|
43
43
|
function getContent(options) {
|
|
44
44
|
return __async(this, null, function* () {
|
|
45
|
-
|
|
45
|
+
const allContent = yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }));
|
|
46
|
+
if ("results" in allContent) {
|
|
47
|
+
return (allContent == null ? void 0 : allContent.results[0]) || null;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
46
50
|
});
|
|
47
51
|
}
|
|
48
52
|
function getAllContent(options) {
|
|
@@ -50,11 +54,19 @@ function getAllContent(options) {
|
|
|
50
54
|
const url = generateContentUrl(options);
|
|
51
55
|
const res = yield fetch(url.href);
|
|
52
56
|
const content = yield res.json();
|
|
57
|
+
if ("status" in content && !("results" in content)) {
|
|
58
|
+
console.error("[Builder.io]: Error fetching data. ", content, options);
|
|
59
|
+
return content;
|
|
60
|
+
}
|
|
53
61
|
const canTrack = options.canTrack !== false;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
try {
|
|
63
|
+
if (canTrack && Array.isArray(content.results)) {
|
|
64
|
+
for (const item of content.results) {
|
|
65
|
+
yield handleABTesting({ item, canTrack });
|
|
66
|
+
}
|
|
57
67
|
}
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.error("[Builder.io]: Could not setup A/B testing. ", e);
|
|
58
70
|
}
|
|
59
71
|
return content;
|
|
60
72
|
});
|