@builder.io/sdk-react-native 0.1.9 → 0.1.10

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 (36) hide show
  1. package/dist/blocks/button/button.js +1 -1
  2. package/dist/blocks/columns/columns.js +17 -17
  3. package/dist/blocks/form/form.js +2 -2
  4. package/dist/blocks/image/component-info.js +1 -1
  5. package/dist/components/render-blocks.js +8 -4
  6. package/dist/components/render-content/components/render-styles.js +13 -0
  7. package/dist/components/render-content/render-content.js +5 -9
  8. package/dist/functions/is-editing.js +2 -1
  9. package/dist/index.js +0 -1
  10. package/package.json +1 -1
  11. package/src/blocks/button/button.jsx +11 -2
  12. package/src/blocks/columns/columns.jsx +28 -19
  13. package/src/blocks/custom-code/custom-code.jsx +11 -2
  14. package/src/blocks/embed/embed.jsx +11 -2
  15. package/src/blocks/form/form.jsx +11 -3
  16. package/src/blocks/fragment/fragment.jsx +11 -2
  17. package/src/blocks/image/component-info.js +1 -1
  18. package/src/blocks/img/img.jsx +11 -2
  19. package/src/blocks/input/input.jsx +11 -2
  20. package/src/blocks/raw-text/raw-text.jsx +11 -2
  21. package/src/blocks/section/section.jsx +11 -2
  22. package/src/blocks/select/select.jsx +11 -2
  23. package/src/blocks/submit-button/submit-button.jsx +11 -2
  24. package/src/blocks/symbol/symbol.jsx +11 -2
  25. package/src/blocks/textarea/textarea.jsx +11 -2
  26. package/src/components/render-block/block-styles.jsx +11 -2
  27. package/src/components/render-block/render-block.jsx +11 -2
  28. package/src/components/render-block/render-component.jsx +11 -2
  29. package/src/components/render-block/render-repeated-block.jsx +11 -2
  30. package/src/components/render-blocks.jsx +19 -6
  31. package/src/components/render-content/builder-editing.jsx +11 -2
  32. package/src/components/render-content/components/render-styles.jsx +24 -2
  33. package/src/components/render-content/render-content.jsx +23 -19
  34. package/src/components/render-inlined-styles.jsx +11 -2
  35. package/src/functions/is-editing.js +2 -1
  36. package/src/index.js +0 -1
@@ -35,5 +35,5 @@ function Button(props) {
35
35
  React.createElement(BaseText_1.default, null, props.text)))) : (React.createElement(react_native_1.View, { ...props.attributes, style: styles.view1 },
36
36
  React.createElement(BaseText_1.default, null, props.text)))));
37
37
  }
38
- exports.default = Button;
39
38
  const styles = react_native_1.StyleSheet.create({ view1: { all: "unset" } });
39
+ exports.default = Button;
@@ -110,26 +110,26 @@ function Columns(props) {
110
110
  }
111
111
  function columnsStyles() {
112
112
  return `
113
- @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
114
- .${props.builderBlock.id}-breakpoints {
115
- ${(0, css_1.convertStyleMapToCSS)(columnStyleObjects().columns.medium)}
116
- }
113
+ @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
114
+ .${props.builderBlock.id}-breakpoints {
115
+ ${(0, css_1.convertStyleMapToCSS)(columnStyleObjects().columns.medium)}
116
+ }
117
117
 
118
- .${props.builderBlock.id}-breakpoints > .builder-column {
119
- ${(0, css_1.convertStyleMapToCSS)(columnStyleObjects().column.medium)}
120
- }
118
+ .${props.builderBlock.id}-breakpoints > .builder-column {
119
+ ${(0, css_1.convertStyleMapToCSS)(columnStyleObjects().column.medium)}
121
120
  }
121
+ }
122
122
 
123
- @media (max-width: ${getWidthForBreakpointSize("small")}px) {
124
- .${props.builderBlock.id}-breakpoints {
125
- ${(0, css_1.convertStyleMapToCSS)(columnStyleObjects().columns.small)}
126
- }
123
+ @media (max-width: ${getWidthForBreakpointSize("small")}px) {
124
+ .${props.builderBlock.id}-breakpoints {
125
+ ${(0, css_1.convertStyleMapToCSS)(columnStyleObjects().columns.small)}
126
+ }
127
127
 
128
- .${props.builderBlock.id}-breakpoints > .builder-column {
129
- ${(0, css_1.convertStyleMapToCSS)(columnStyleObjects().column.small)}
130
- }
131
- },
132
- `;
128
+ .${props.builderBlock.id}-breakpoints > .builder-column {
129
+ ${(0, css_1.convertStyleMapToCSS)(columnStyleObjects().column.small)}
130
+ }
131
+ },
132
+ `;
133
133
  }
134
134
  function reactNativeColumnsStyles() {
135
135
  return columnStyleObjects.columns.small;
@@ -146,8 +146,8 @@ function Columns(props) {
146
146
  flexGrow: "1",
147
147
  } }))))));
148
148
  }
149
- exports.default = Columns;
150
149
  const styles = react_native_1.StyleSheet.create({
151
150
  view1: { display: "flex" },
152
151
  view2: { display: "flex", flexDirection: "column", alignItems: "stretch" },
153
152
  });
153
+ exports.default = Columns;
@@ -154,7 +154,7 @@ function FormComponent(props) {
154
154
  /* TODO: allow supplying an error formatter function */ let message = get(body, props.errorMessagePath);
155
155
  if (message) {
156
156
  if (typeof message !== "string") {
157
- /* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message =
157
+ /* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message =
158
158
  JSON.stringify(message);
159
159
  }
160
160
  setFormErrorMessage(message);
@@ -226,7 +226,7 @@ function FormComponent(props) {
226
226
  React.createElement(render_blocks_1.default, { dataPath: "successMessage", blocks: props.successMessage }))) : null,
227
227
  " "));
228
228
  }
229
- exports.default = FormComponent;
230
229
  const styles = react_native_1.StyleSheet.create({
231
230
  view1: { padding: 10, color: "red", textAlign: "center" },
232
231
  });
232
+ exports.default = FormComponent;
@@ -20,7 +20,7 @@ const componentInfo = {
20
20
  bubble: true,
21
21
  allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
22
22
  required: true,
23
- defaultValue: "https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
23
+ defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
24
24
  onChange: (0, util_js_1.serializeFn)((options) => {
25
25
  const DEFAULT_ASPECT_RATIO = 0.7041;
26
26
  options.delete("srcset");
@@ -64,13 +64,17 @@ function RenderBlocks(props) {
64
64
  }
65
65
  }
66
66
  const builderContext = (0, react_1.useContext)(builder_context_js_1.default);
67
- return (React.createElement(react_native_1.View, { "builder-path": props.path, "builder-parent-id": props.parent, dataSet: {
67
+ return (React.createElement(react_native_1.ScrollView, { "builder-path": props.path, "builder-parent-id": props.parent, dataSet: {
68
68
  class: className(),
69
- }, style: styles.view1, onClick: (event) => onClick(), onMouseEnter: (event) => onMouseEnter() },
69
+ }, contentContainerStyle: styles.scrollView1, onClick: (event) => onClick(), onMouseEnter: (event) => onMouseEnter() },
70
70
  props.blocks ? (React.createElement(React.Fragment, null, (_a = props.blocks) === null || _a === void 0 ? void 0 : _a.map((block) => (React.createElement(render_block_1.default, { key: "render-block-" + block.id, block: block, context: builderContext }))))) : null,
71
71
  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: builderContext }))))) : null));
72
72
  }
73
- exports.default = RenderBlocks;
74
73
  const styles = react_native_1.StyleSheet.create({
75
- view1: { display: "flex", flexDirection: "column", alignItems: "stretch" },
74
+ scrollView1: {
75
+ display: "flex",
76
+ flexDirection: "column",
77
+ alignItems: "stretch",
78
+ },
76
79
  });
80
+ exports.default = RenderBlocks;
@@ -41,6 +41,19 @@ ${(0, render_styles_helpers_1.getCss)({
41
41
  ${(0, render_styles_helpers_2.getFontCss)({
42
42
  customFonts: props.customFonts,
43
43
  })}
44
+
45
+ .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
46
+ margin: 0;
47
+ }
48
+ .builder-text > p, .builder-text > .builder-paragraph {
49
+ color: inherit;
50
+ line-height: inherit;
51
+ letter-spacing: inherit;
52
+ font-weight: inherit;
53
+ font-size: inherit;
54
+ text-align: inherit;
55
+ font-family: inherit;
56
+ }
44
57
  `);
45
58
  return React.createElement(render_inlined_styles_1.default, { styles: injectedStyles });
46
59
  }
@@ -30,7 +30,6 @@ const React = __importStar(require("react"));
30
30
  const react_native_1 = require("react-native");
31
31
  const react_1 = require("react");
32
32
  const builder_registered_components_js_1 = require("../../constants/builder-registered-components.js");
33
- const target_js_1 = require("../../constants/target.js");
34
33
  const evaluate_js_1 = require("../../functions/evaluate.js");
35
34
  const index_js_1 = require("../../functions/get-content/index.js");
36
35
  const get_fetch_js_1 = require("../../functions/get-fetch.js");
@@ -46,6 +45,7 @@ const init_editing_js_1 = require("../../scripts/init-editing.js");
46
45
  const nullable_js_1 = require("../../helpers/nullable.js");
47
46
  const interaction_js_1 = require("../../functions/track/interaction.js");
48
47
  const render_content_helpers_js_1 = require("./render-content.helpers.js");
48
+ const target_js_1 = require("../../constants/target.js");
49
49
  function RenderContent(props) {
50
50
  var _a, _b, _c, _d, _e;
51
51
  const elementRef = (0, react_1.useRef)(null);
@@ -217,11 +217,6 @@ function RenderContent(props) {
217
217
  }));
218
218
  }
219
219
  }
220
- function shouldRenderContentStyles() {
221
- var _a, _b, _c;
222
- return Boolean((((_a = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _a === void 0 ? void 0 : _a.cssCode) || ((_c = (_b = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _b === void 0 ? void 0 : _b.customFonts) === null || _c === void 0 ? void 0 : _c.length)) &&
223
- target_js_1.TARGET !== "reactNative");
224
- }
225
220
  (0, react_1.useEffect)(() => {
226
221
  if (!props.apiKey) {
227
222
  console.error("[Builder.io]: No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
@@ -268,7 +263,7 @@ function RenderContent(props) {
268
263
  const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
269
264
  /**
270
265
  * Make sure that:
271
- * - the preview model name is the same as the one we're rendering, since there can be multiple models rendered * at the same time, e.g. header/page/footer. * - the API key is the same, since we don't want to preview content from other organizations.
266
+ * - the preview model name is the same as the one we're rendering, since there can be multiple models rendered * at the same time, e.g. header/page/footer. * - the API key is the same, since we don't want to preview content from other organizations.
272
267
  *
273
268
  * TO-DO: should we check that the preview item ID is the same as the initial one being rendered? Or would
274
269
  * this break scenarios where the item is not published yet?
@@ -317,8 +312,9 @@ function RenderContent(props) {
317
312
  apiKey: props.apiKey,
318
313
  registeredComponents: allRegisteredComponents,
319
314
  } }, useContent ? (React.createElement(React.Fragment, null,
320
- React.createElement(react_native_1.View, { ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": useContent === null || useContent === void 0 ? void 0 : useContent.id, "builder-model": props.model },
321
- shouldRenderContentStyles() ? (React.createElement(render_styles_1.default, { contentId: useContent === null || useContent === void 0 ? void 0 : useContent.id, cssCode: (_c = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _c === void 0 ? void 0 : _c.cssCode, customFonts: (_d = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _d === void 0 ? void 0 : _d.customFonts })) : null,
315
+ React.createElement(react_native_1.ScrollView, { ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": useContent === null || useContent === void 0 ? void 0 : useContent.id, "builder-model": props.model },
316
+ target_js_1.TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
317
+ React.createElement(render_styles_1.default, { contentId: useContent === null || useContent === void 0 ? void 0 : useContent.id, cssCode: (_c = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _c === void 0 ? void 0 : _c.cssCode, customFonts: (_d = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _d === void 0 ? void 0 : _d.customFonts }))) : null,
322
318
  React.createElement(render_blocks_1.default, { blocks: (_e = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _e === void 0 ? void 0 : _e.blocks, key: forceReRenderCount })))) : null));
323
319
  }
324
320
  exports.default = RenderContent;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isEditing = void 0;
4
+ const target_js_1 = require("../constants/target.js");
4
5
  const is_iframe_js_1 = require("./is-iframe.js");
5
6
  function isEditing() {
6
- return (0, is_iframe_js_1.isIframe)() && window.location.search.indexOf("builder.frameEditing=") !== -1;
7
+ return (0, is_iframe_js_1.isIframe)() && (target_js_1.TARGET === "reactNative" || window.location.search.indexOf("builder.frameEditing=") !== -1);
7
8
  }
8
9
  exports.isEditing = isEditing;
package/dist/index.js CHANGED
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.track = void 0;
18
18
  __exportStar(require("./index-helpers/top-of-file.js"), exports);
19
- require("./scripts/init-editing.js");
20
19
  __exportStar(require("./index-helpers/blocks-exports.js"), exports);
21
20
  __exportStar(require("./functions/is-editing.js"), exports);
22
21
  __exportStar(require("./functions/is-previewing.js"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react-native",
3
3
  "description": "Builder.io SDK for React Native",
4
- "version": "0.1.9",
4
+ "version": "0.1.10",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -1,8 +1,15 @@
1
1
  import BaseText from "../BaseText";
2
2
  import * as React from "react";
3
- import { View, StyleSheet, Image, Text } from "react-native";
3
+ import {
4
+ FlatList,
5
+ ScrollView,
6
+ View,
7
+ StyleSheet,
8
+ Image,
9
+ Text,
10
+ } from "react-native";
4
11
 
5
- export default function Button(props) {
12
+ function Button(props) {
6
13
  return (
7
14
  <>
8
15
  {props.link ? (
@@ -26,3 +33,5 @@ export default function Button(props) {
26
33
  }
27
34
 
28
35
  const styles = StyleSheet.create({ view1: { all: "unset" } });
36
+
37
+ export default Button;
@@ -1,5 +1,12 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { useContext } from "react";
4
11
  import RenderBlocks from "../../components/render-blocks";
5
12
  import { getSizesForBreakpoints } from "../../constants/device-sizes";
@@ -8,7 +15,7 @@ import { TARGET } from "../../constants/target.js";
8
15
  import { convertStyleMapToCSS } from "../../helpers/css";
9
16
  import BuilderContext from "../../context/builder.context.js";
10
17
 
11
- export default function Columns(props) {
18
+ function Columns(props) {
12
19
  function getGutterSize() {
13
20
  return typeof props.space === "number" ? props.space || 0 : 20;
14
21
  }
@@ -92,26 +99,26 @@ export default function Columns(props) {
92
99
 
93
100
  function columnsStyles() {
94
101
  return `
95
- @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
96
- .${props.builderBlock.id}-breakpoints {
97
- ${convertStyleMapToCSS(columnStyleObjects().columns.medium)}
98
- }
99
-
100
- .${props.builderBlock.id}-breakpoints > .builder-column {
101
- ${convertStyleMapToCSS(columnStyleObjects().column.medium)}
102
- }
102
+ @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
103
+ .${props.builderBlock.id}-breakpoints {
104
+ ${convertStyleMapToCSS(columnStyleObjects().columns.medium)}
103
105
  }
104
106
 
105
- @media (max-width: ${getWidthForBreakpointSize("small")}px) {
106
- .${props.builderBlock.id}-breakpoints {
107
- ${convertStyleMapToCSS(columnStyleObjects().columns.small)}
108
- }
107
+ .${props.builderBlock.id}-breakpoints > .builder-column {
108
+ ${convertStyleMapToCSS(columnStyleObjects().column.medium)}
109
+ }
110
+ }
109
111
 
110
- .${props.builderBlock.id}-breakpoints > .builder-column {
111
- ${convertStyleMapToCSS(columnStyleObjects().column.small)}
112
- }
113
- },
114
- `;
112
+ @media (max-width: ${getWidthForBreakpointSize("small")}px) {
113
+ .${props.builderBlock.id}-breakpoints {
114
+ ${convertStyleMapToCSS(columnStyleObjects().columns.small)}
115
+ }
116
+
117
+ .${props.builderBlock.id}-breakpoints > .builder-column {
118
+ ${convertStyleMapToCSS(columnStyleObjects().column.small)}
119
+ }
120
+ },
121
+ `;
115
122
  }
116
123
 
117
124
  function reactNativeColumnsStyles() {
@@ -152,3 +159,5 @@ const styles = StyleSheet.create({
152
159
  view1: { display: "flex" },
153
160
  view2: { display: "flex", flexDirection: "column", alignItems: "stretch" },
154
161
  });
162
+
163
+ export default Columns;
@@ -1,8 +1,15 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { useState, useRef, useEffect } from "react";
4
11
 
5
- export default function CustomCode(props) {
12
+ function CustomCode(props) {
6
13
  const elem = useRef(null);
7
14
  const [scriptsInserted, setScriptsInserted] = useState(() => []);
8
15
 
@@ -55,3 +62,5 @@ export default function CustomCode(props) {
55
62
 
56
63
  return <View ref={elem} dangerouslySetInnerHTML={{ __html: props.code }} />;
57
64
  }
65
+
66
+ export default CustomCode;
@@ -1,9 +1,16 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { useState, useRef, useEffect } from "react";
4
11
  import { isJsScript } from "./helpers.js";
5
12
 
6
- export default function Embed(props) {
13
+ function Embed(props) {
7
14
  const elem = useRef(null);
8
15
  const [scriptsInserted, setScriptsInserted] = useState(() => []);
9
16
 
@@ -44,3 +51,5 @@ export default function Embed(props) {
44
51
  <View ref={elem} dangerouslySetInnerHTML={{ __html: props.content }} />
45
52
  );
46
53
  }
54
+
55
+ export default Embed;
@@ -1,12 +1,19 @@
1
1
  import BaseText from "../BaseText";
2
2
  import * as React from "react";
3
- import { View, StyleSheet, Image, Text } from "react-native";
3
+ import {
4
+ FlatList,
5
+ ScrollView,
6
+ View,
7
+ StyleSheet,
8
+ Image,
9
+ Text,
10
+ } from "react-native";
4
11
  import { useState, useContext, useRef } from "react";
5
12
  import RenderBlock from "../../components/render-block/render-block";
6
13
  import BuilderBlocks from "../../components/render-blocks";
7
14
  import { isEditing } from "../../functions/is-editing.js";
8
15
 
9
- export default function FormComponent(props) {
16
+ function FormComponent(props) {
10
17
  const formRef = useRef(null);
11
18
  const [formState, setFormState] = useState(() => "unsubmitted");
12
19
 
@@ -139,7 +146,7 @@ export default function FormComponent(props) {
139
146
  get(body, props.errorMessagePath);
140
147
  if (message) {
141
148
  if (typeof message !== "string") {
142
- /* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message =
149
+ /* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message =
143
150
  JSON.stringify(message);
144
151
  }
145
152
  setFormErrorMessage(message);
@@ -249,3 +256,4 @@ export default function FormComponent(props) {
249
256
  const styles = StyleSheet.create({
250
257
  view1: { padding: 10, color: "red", textAlign: "center" },
251
258
  });
259
+ export default FormComponent;
@@ -1,11 +1,20 @@
1
1
  import BaseText from "../BaseText";
2
2
  import * as React from "react";
3
- import { View, StyleSheet, Image, Text } from "react-native";
3
+ import {
4
+ FlatList,
5
+ ScrollView,
6
+ View,
7
+ StyleSheet,
8
+ Image,
9
+ Text,
10
+ } from "react-native";
4
11
 
5
- export default function FragmentComponent(props) {
12
+ function FragmentComponent(props) {
6
13
  return (
7
14
  <View>
8
15
  <BaseText>{props.children}</BaseText>
9
16
  </View>
10
17
  );
11
18
  }
19
+
20
+ export default FragmentComponent;
@@ -17,7 +17,7 @@ const componentInfo = {
17
17
  bubble: true,
18
18
  allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
19
19
  required: true,
20
- defaultValue: "https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
20
+ defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
21
21
  onChange: serializeFn((options) => {
22
22
  const DEFAULT_ASPECT_RATIO = 0.7041;
23
23
  options.delete("srcset");
@@ -1,8 +1,15 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { isEditing } from "../../functions/is-editing.js";
4
11
 
5
- export default function ImgComponent(props) {
12
+ function ImgComponent(props) {
6
13
  return (
7
14
  <View
8
15
  style={{
@@ -16,3 +23,5 @@ export default function ImgComponent(props) {
16
23
  />
17
24
  );
18
25
  }
26
+
27
+ export default ImgComponent;
@@ -1,8 +1,15 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { isEditing } from "../../functions/is-editing.js";
4
11
 
5
- export default function FormInputComponent(props) {
12
+ function FormInputComponent(props) {
6
13
  return (
7
14
  <View
8
15
  {...props.attributes}
@@ -18,3 +25,5 @@ export default function FormInputComponent(props) {
18
25
  />
19
26
  );
20
27
  }
28
+
29
+ export default FormInputComponent;
@@ -1,6 +1,15 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
 
4
- export default function RawText(props) {
11
+ function RawText(props) {
5
12
  return <View dangerouslySetInnerHTML={{ __html: props.text || "" }} />;
6
13
  }
14
+
15
+ export default RawText;
@@ -1,8 +1,15 @@
1
1
  import BaseText from "../BaseText";
2
2
  import * as React from "react";
3
- import { View, StyleSheet, Image, Text } from "react-native";
3
+ import {
4
+ FlatList,
5
+ ScrollView,
6
+ View,
7
+ StyleSheet,
8
+ Image,
9
+ Text,
10
+ } from "react-native";
4
11
 
5
- export default function SectionComponent(props) {
12
+ function SectionComponent(props) {
6
13
  return (
7
14
  <View
8
15
  {...props.attributes}
@@ -23,3 +30,5 @@ export default function SectionComponent(props) {
23
30
  </View>
24
31
  );
25
32
  }
33
+
34
+ export default SectionComponent;
@@ -1,9 +1,16 @@
1
1
  import BaseText from "../BaseText";
2
2
  import * as React from "react";
3
- import { View, StyleSheet, Image, Text } from "react-native";
3
+ import {
4
+ FlatList,
5
+ ScrollView,
6
+ View,
7
+ StyleSheet,
8
+ Image,
9
+ Text,
10
+ } from "react-native";
4
11
  import { isEditing } from "../../functions/is-editing.js";
5
12
 
6
- export default function SelectComponent(props) {
13
+ function SelectComponent(props) {
7
14
  return (
8
15
  <View
9
16
  {...props.attributes}
@@ -22,3 +29,5 @@ export default function SelectComponent(props) {
22
29
  </View>
23
30
  );
24
31
  }
32
+
33
+ export default SelectComponent;
@@ -1,11 +1,20 @@
1
1
  import BaseText from "../BaseText";
2
2
  import * as React from "react";
3
- import { View, StyleSheet, Image, Text } from "react-native";
3
+ import {
4
+ FlatList,
5
+ ScrollView,
6
+ View,
7
+ StyleSheet,
8
+ Image,
9
+ Text,
10
+ } from "react-native";
4
11
 
5
- export default function SubmitButton(props) {
12
+ function SubmitButton(props) {
6
13
  return (
7
14
  <View type="submit" {...props.attributes}>
8
15
  <BaseText>{props.text}</BaseText>
9
16
  </View>
10
17
  );
11
18
  }
19
+
20
+ export default SubmitButton;
@@ -1,12 +1,19 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { useState, useContext, useEffect } from "react";
4
11
  import RenderContent from "../../components/render-content/render-content";
5
12
  import BuilderContext from "../../context/builder.context.js";
6
13
  import { getContent } from "../../functions/get-content/index.js";
7
14
  import { TARGET } from "../../constants/target";
8
15
 
9
- export default function Symbol(props) {
16
+ function Symbol(props) {
10
17
  function className() {
11
18
  return [
12
19
  ...(TARGET === "vue2" || TARGET === "vue3"
@@ -84,3 +91,5 @@ export default function Symbol(props) {
84
91
  </View>
85
92
  );
86
93
  }
94
+
95
+ export default Symbol;
@@ -1,7 +1,14 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
 
4
- export default function Textarea(props) {
11
+ function Textarea(props) {
5
12
  return (
6
13
  <View
7
14
  {...props.attributes}
@@ -12,3 +19,5 @@ export default function Textarea(props) {
12
19
  />
13
20
  );
14
21
  }
22
+
23
+ export default Textarea;
@@ -1,5 +1,12 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import {
4
11
  getMaxWidthQueryForSize,
5
12
  getSizesForBreakpoints,
@@ -10,7 +17,7 @@ import { createCssClass } from "../../helpers/css.js";
10
17
  import { checkIsDefined } from "../../helpers/nullable.js";
11
18
  import RenderInlinedStyles from "../render-inlined-styles";
12
19
 
13
- export default function BlockStyles(props) {
20
+ function BlockStyles(props) {
14
21
  function useBlock() {
15
22
  return getProcessedBlock({
16
23
  block: props.block,
@@ -80,3 +87,5 @@ export default function BlockStyles(props) {
80
87
  </>
81
88
  );
82
89
  }
90
+
91
+ export default BlockStyles;
@@ -1,5 +1,12 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { useState } from "react";
4
11
  import { getBlockActions } from "../../functions/get-block-actions.js";
5
12
  import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
@@ -19,7 +26,7 @@ import RenderComponent from "./render-component";
19
26
  import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
20
27
  import { checkIsDefined } from "../../helpers/nullable.js";
21
28
 
22
- export default function RenderBlock(props) {
29
+ function RenderBlock(props) {
23
30
  const [component, setComponent] = useState(() =>
24
31
  getComponent({
25
32
  block: props.block,
@@ -216,3 +223,5 @@ export default function RenderBlock(props) {
216
223
  </>
217
224
  );
218
225
  }
226
+
227
+ export default RenderBlock;
@@ -1,11 +1,18 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { useContext } from "react";
4
11
  import BlockStyles from "./block-styles";
5
12
  import RenderBlock from "./render-block";
6
13
  import BuilderContext from "../../context/builder.context.js";
7
14
 
8
- export default function RenderComponent(props) {
15
+ function RenderComponent(props) {
9
16
  const ComponentRefRef = props.componentRef;
10
17
 
11
18
  return (
@@ -43,3 +50,5 @@ export default function RenderComponent(props) {
43
50
  </BuilderContext.Provider>
44
51
  );
45
52
  }
53
+
54
+ export default RenderComponent;
@@ -1,10 +1,17 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { useContext } from "react";
4
11
  import BuilderContext from "../../context/builder.context.js";
5
12
  import RenderBlock from "./render-block";
6
13
 
7
- export default function RenderRepeatedBlock(props) {
14
+ function RenderRepeatedBlock(props) {
8
15
  return (
9
16
  <BuilderContext.Provider
10
17
  value={{
@@ -21,3 +28,5 @@ export default function RenderRepeatedBlock(props) {
21
28
  </BuilderContext.Provider>
22
29
  );
23
30
  }
31
+
32
+ export default RenderRepeatedBlock;
@@ -1,12 +1,19 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { useContext } from "react";
4
11
  import BuilderContext from "../context/builder.context.js";
5
12
  import { isEditing } from "../functions/is-editing.js";
6
13
  import BlockStyles from "./render-block/block-styles";
7
14
  import RenderBlock from "./render-block/render-block";
8
15
 
9
- export default function RenderBlocks(props) {
16
+ function RenderBlocks(props) {
10
17
  function className() {
11
18
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
12
19
  }
@@ -44,13 +51,13 @@ export default function RenderBlocks(props) {
44
51
  const builderContext = useContext(BuilderContext);
45
52
 
46
53
  return (
47
- <View
54
+ <ScrollView
48
55
  builder-path={props.path}
49
56
  builder-parent-id={props.parent}
50
57
  dataSet={{
51
58
  class: className(),
52
59
  }}
53
- style={styles.view1}
60
+ contentContainerStyle={styles.scrollView1}
54
61
  onClick={(event) => onClick()}
55
62
  onMouseEnter={(event) => onMouseEnter()}
56
63
  >
@@ -77,10 +84,16 @@ export default function RenderBlocks(props) {
77
84
  ))}
78
85
  </>
79
86
  ) : null}
80
- </View>
87
+ </ScrollView>
81
88
  );
82
89
  }
83
90
 
84
91
  const styles = StyleSheet.create({
85
- view1: { display: "flex", flexDirection: "column", alignItems: "stretch" },
92
+ scrollView1: {
93
+ display: "flex",
94
+ flexDirection: "column",
95
+ alignItems: "stretch",
96
+ },
86
97
  });
98
+
99
+ export default RenderBlocks;
@@ -1,6 +1,15 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
 
4
- export default function BuilderEditing(props) {
11
+ function BuilderEditing(props) {
5
12
  return <View />;
6
13
  }
14
+
15
+ export default BuilderEditing;
@@ -1,11 +1,18 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { useState } from "react";
4
11
  import RenderInlinedStyles from "../../render-inlined-styles";
5
12
  import { getCss } from "./render-styles.helpers";
6
13
  import { getFontCss } from "./render-styles.helpers";
7
14
 
8
- export default function RenderContentStyles(props) {
15
+ function RenderContentStyles(props) {
9
16
  const [injectedStyles, setInjectedStyles] = useState(
10
17
  () => `
11
18
  ${getCss({
@@ -15,8 +22,23 @@ ${getCss({
15
22
  ${getFontCss({
16
23
  customFonts: props.customFonts,
17
24
  })}
25
+
26
+ .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
27
+ margin: 0;
28
+ }
29
+ .builder-text > p, .builder-text > .builder-paragraph {
30
+ color: inherit;
31
+ line-height: inherit;
32
+ letter-spacing: inherit;
33
+ font-weight: inherit;
34
+ font-size: inherit;
35
+ text-align: inherit;
36
+ font-family: inherit;
37
+ }
18
38
  `
19
39
  );
20
40
 
21
41
  return <RenderInlinedStyles styles={injectedStyles} />;
22
42
  }
43
+
44
+ export default RenderContentStyles;
@@ -1,8 +1,14 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { useState, useContext, useRef, useEffect } from "react";
4
11
  import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
5
- import { TARGET } from "../../constants/target.js";
6
12
  import { evaluate } from "../../functions/evaluate.js";
7
13
  import { getContent } from "../../functions/get-content/index.js";
8
14
  import { fetch } from "../../functions/get-fetch.js";
@@ -27,8 +33,9 @@ import {
27
33
  getContentInitialValue,
28
34
  getContextStateInitialValue,
29
35
  } from "./render-content.helpers.js";
36
+ import { TARGET } from "../../constants/target.js";
30
37
 
31
- export default function RenderContent(props) {
38
+ function RenderContent(props) {
32
39
  const elementRef = useRef(null);
33
40
  const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
34
41
 
@@ -232,13 +239,6 @@ export default function RenderContent(props) {
232
239
  }
233
240
  }
234
241
 
235
- function shouldRenderContentStyles() {
236
- return Boolean(
237
- (useContent?.data?.cssCode || useContent?.data?.customFonts?.length) &&
238
- TARGET !== "reactNative"
239
- );
240
- }
241
-
242
242
  useEffect(() => {
243
243
  if (!props.apiKey) {
244
244
  console.error(
@@ -294,7 +294,7 @@ export default function RenderContent(props) {
294
294
 
295
295
  /**
296
296
  * Make sure that:
297
- * - the preview model name is the same as the one we're rendering, since there can be multiple models rendered * at the same time, e.g. header/page/footer. * - the API key is the same, since we don't want to preview content from other organizations.
297
+ * - the preview model name is the same as the one we're rendering, since there can be multiple models rendered * at the same time, e.g. header/page/footer. * - the API key is the same, since we don't want to preview content from other organizations.
298
298
  *
299
299
  * TO-DO: should we check that the preview item ID is the same as the initial one being rendered? Or would
300
300
  * this break scenarios where the item is not published yet?
@@ -356,27 +356,31 @@ export default function RenderContent(props) {
356
356
  >
357
357
  {useContent ? (
358
358
  <>
359
- <View
359
+ <ScrollView
360
360
  ref={elementRef}
361
361
  onClick={(event) => onClick(event)}
362
362
  builder-content-id={useContent?.id}
363
363
  builder-model={props.model}
364
364
  >
365
- {shouldRenderContentStyles() ? (
366
- <RenderContentStyles
367
- contentId={useContent?.id}
368
- cssCode={useContent?.data?.cssCode}
369
- customFonts={useContent?.data?.customFonts}
370
- />
365
+ {TARGET !== "reactNative" ? (
366
+ <>
367
+ <RenderContentStyles
368
+ contentId={useContent?.id}
369
+ cssCode={useContent?.data?.cssCode}
370
+ customFonts={useContent?.data?.customFonts}
371
+ />
372
+ </>
371
373
  ) : null}
372
374
 
373
375
  <RenderBlocks
374
376
  blocks={useContent?.data?.blocks}
375
377
  key={forceReRenderCount}
376
378
  />
377
- </View>
379
+ </ScrollView>
378
380
  </>
379
381
  ) : null}
380
382
  </builderContext.Provider>
381
383
  );
382
384
  }
385
+
386
+ export default RenderContent;
@@ -1,8 +1,15 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ } from "react-native";
3
10
  import { TARGET } from "../constants/target.js";
4
11
 
5
- export default function RenderInlinedStyles(props) {
12
+ function RenderInlinedStyles(props) {
6
13
  function injectedStyleScript() {
7
14
  return `<${tag()}>${props.styles}</${tag()}>`;
8
15
  }
@@ -27,3 +34,5 @@ export default function RenderInlinedStyles(props) {
27
34
  </>
28
35
  );
29
36
  }
37
+
38
+ export default RenderInlinedStyles;
@@ -1,6 +1,7 @@
1
+ import { TARGET } from "../constants/target.js";
1
2
  import { isIframe } from "./is-iframe.js";
2
3
  function isEditing() {
3
- return isIframe() && window.location.search.indexOf("builder.frameEditing=") !== -1;
4
+ return isIframe() && (TARGET === "reactNative" || window.location.search.indexOf("builder.frameEditing=") !== -1);
4
5
  }
5
6
  export {
6
7
  isEditing
package/src/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from "./index-helpers/top-of-file.js";
2
- import "./scripts/init-editing.js";
3
2
  export * from "./index-helpers/blocks-exports.js";
4
3
  export * from "./functions/is-editing.js";
5
4
  export * from "./functions/is-previewing.js";