@builder.io/sdk-react-native 0.0.1-34 → 0.0.1-35

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 (82) hide show
  1. package/package.json +1 -1
  2. package/src/blocks/button.js +35 -0
  3. package/src/blocks/button.lite.tsx +25 -0
  4. package/src/blocks/columns.js +43 -0
  5. package/src/blocks/columns.lite.tsx +41 -0
  6. package/src/blocks/custom-code.js +56 -0
  7. package/src/blocks/custom-code.lite.tsx +67 -0
  8. package/src/blocks/embed.js +56 -0
  9. package/src/blocks/embed.lite.tsx +65 -0
  10. package/src/blocks/form.js +226 -0
  11. package/src/blocks/form.lite.tsx +253 -0
  12. package/src/blocks/fragment.js +13 -0
  13. package/src/blocks/fragment.lite.tsx +11 -0
  14. package/src/blocks/image.js +121 -0
  15. package/src/blocks/image.lite.tsx +67 -0
  16. package/src/blocks/img.js +41 -0
  17. package/src/blocks/img.lite.tsx +19 -0
  18. package/src/blocks/input.js +41 -0
  19. package/src/blocks/input.lite.tsx +21 -0
  20. package/src/blocks/raw-text.js +17 -0
  21. package/src/blocks/raw-text.lite.tsx +12 -0
  22. package/src/blocks/section.js +36 -0
  23. package/src/blocks/section.lite.tsx +20 -0
  24. package/src/blocks/select.js +41 -0
  25. package/src/blocks/select.lite.tsx +24 -0
  26. package/src/blocks/submit-button.js +34 -0
  27. package/src/blocks/submit-button.lite.tsx +11 -0
  28. package/src/blocks/symbol.js +20 -0
  29. package/src/blocks/symbol.lite.tsx +20 -0
  30. package/src/blocks/text.js +85 -0
  31. package/src/blocks/text.lite.tsx +12 -0
  32. package/src/blocks/textarea.js +37 -0
  33. package/src/blocks/textarea.lite.tsx +15 -0
  34. package/src/blocks/video.js +88 -0
  35. package/src/blocks/video.lite.tsx +28 -0
  36. package/src/components/block-styles.js +7 -0
  37. package/src/components/block-styles.lite.tsx +7 -0
  38. package/src/components/error-boundary.js +25 -0
  39. package/src/components/error-boundary.lite.tsx +7 -0
  40. package/src/components/render-block.js +105 -0
  41. package/src/components/render-block.lite.tsx +125 -0
  42. package/src/components/render-blocks.js +47 -0
  43. package/src/components/render-blocks.lite.tsx +60 -0
  44. package/src/components/render-content.js +143 -0
  45. package/src/components/render-content.lite.tsx +207 -0
  46. package/src/constants/device-sizes.js +40 -0
  47. package/src/context/builder.context.js +5 -0
  48. package/src/functions/evaluate.js +20 -0
  49. package/src/functions/get-block-actions.js +23 -0
  50. package/src/functions/get-block-component-options.js +24 -0
  51. package/src/functions/get-block-properties.js +43 -0
  52. package/src/functions/get-block-styles.js +61 -0
  53. package/src/functions/get-block-tag.js +8 -0
  54. package/src/functions/get-content.js +128 -0
  55. package/src/functions/get-content.test.js +47 -0
  56. package/src/functions/get-fetch.js +13 -0
  57. package/src/functions/get-global-this.js +19 -0
  58. package/src/functions/get-processed-block.js +45 -0
  59. package/src/functions/get-processed-block.test.js +27 -0
  60. package/src/functions/get-target.js +7 -0
  61. package/src/functions/if-target.js +7 -0
  62. package/src/functions/is-browser.js +8 -0
  63. package/src/functions/is-editing.js +8 -0
  64. package/src/functions/is-iframe.js +8 -0
  65. package/src/functions/is-previewing.js +15 -0
  66. package/src/functions/is-react-native.js +7 -0
  67. package/src/functions/macro-eval.js +6 -0
  68. package/src/functions/on-change.js +28 -0
  69. package/src/functions/on-change.test.js +21 -0
  70. package/src/functions/previewing-model-name.js +12 -0
  71. package/src/functions/register-component.js +54 -0
  72. package/src/functions/register.js +30 -0
  73. package/src/functions/set-editor-settings.js +16 -0
  74. package/src/functions/set.js +12 -0
  75. package/src/functions/set.test.js +18 -0
  76. package/src/functions/track.js +19 -0
  77. package/src/index.js +25 -0
  78. package/src/package.json +18 -0
  79. package/src/scripts/init-editing.js +71 -0
  80. package/src/types/builder-block.js +1 -0
  81. package/src/types/builder-content.js +1 -0
  82. package/src/types/deep-partial.js +1 -0
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Image, Text } from "react-native";
3
+ import { useContext } from "react";
4
+
5
+ export default function SectionComponent(props) {
6
+ return (
7
+ <View
8
+ {...props.attributes}
9
+ style={
10
+ props.maxWidth && typeof props.maxWidth === "number"
11
+ ? {
12
+ maxWidth: props.maxWidth,
13
+ }
14
+ : undefined
15
+ }
16
+ >
17
+ <Text>{props.children}</Text>
18
+ </View>
19
+ );
20
+ }
@@ -0,0 +1,41 @@
1
+ import { registerComponent } from '../functions/register-component';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ import * as React from "react";
23
+ import { View, Text } from "react-native";
24
+ import { isEditing } from "../functions/is-editing";
25
+ function SelectComponent(props) {
26
+ var _a;
27
+ return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
28
+ value: props.value,
29
+ key: isEditing() && props.defaultValue ? props.defaultValue : "default-key",
30
+ defaultValue: props.defaultValue,
31
+ name: props.name
32
+ }), (_a = props.options) == null ? void 0 : _a.map((option) => /* @__PURE__ */ React.createElement(View, {
33
+ value: option.value
34
+ }, /* @__PURE__ */ React.createElement(Text, null, option.name || option.value))));
35
+ }
36
+ export {
37
+ SelectComponent as default
38
+ };
39
+
40
+
41
+ registerComponent(SelectComponent, {name:'Form:Select',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F83acca093fb24aaf94dee136e9a4b045',defaultStyles:{alignSelf:'flex-start'},inputs:[{name:'options',type:'list',required:true,subFields:[{name:'value',type:'text',required:true},{name:'name',type:'text'}],defaultValue:[{value:'option 1'},{value:'option 2'}]},{name:'name',type:'string',required:true,helperText:'Every select in a form needs a unique name describing what it gets, e.g. "email"'},{name:'defaultValue',type:'string'},{name:'value',type:'string',advanced:true},{name:'required',type:'boolean',defaultValue:false}],static:true,noWrap:true});
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Image, Text } from "react-native";
3
+ import { useContext } from "react";
4
+ import { isEditing } from "../functions/is-editing";
5
+
6
+ export default function SelectComponent(props) {
7
+ return (
8
+ <View
9
+ {...props.attributes}
10
+ value={props.value}
11
+ key={
12
+ isEditing() && props.defaultValue ? props.defaultValue : "default-key"
13
+ }
14
+ defaultValue={props.defaultValue}
15
+ name={props.name}
16
+ >
17
+ {props.options?.map((option) => (
18
+ <View value={option.value}>
19
+ <Text>{option.name || option.value}</Text>
20
+ </View>
21
+ ))}
22
+ </View>
23
+ );
24
+ }
@@ -0,0 +1,34 @@
1
+ import { registerComponent } from '../functions/register-component';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ import * as React from "react";
23
+ import { View, Text } from "react-native";
24
+ function SubmitButton(props) {
25
+ return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
26
+ type: "submit"
27
+ }), /* @__PURE__ */ React.createElement(Text, null, props.text));
28
+ }
29
+ export {
30
+ SubmitButton as default
31
+ };
32
+
33
+
34
+ registerComponent(SubmitButton, {name:'Form:SubmitButton',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fdf2820ffed1f4349a94c40b3221f5b98',defaultStyles:{appearance:'none',paddingTop:'15px',paddingBottom:'15px',paddingLeft:'25px',paddingRight:'25px',backgroundColor:'#3898EC',color:'white',borderRadius:'4px',cursor:'pointer'},inputs:[{name:'text',type:'text',defaultValue:'Click me'}],static:true,noWrap:true});
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Image, Text } from "react-native";
3
+ import { useContext } from "react";
4
+
5
+ export default function SubmitButton(props) {
6
+ return (
7
+ <View {...props.attributes} type="submit">
8
+ <Text>{props.text}</Text>
9
+ </View>
10
+ );
11
+ }
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ import { View } from "react-native";
3
+ import { useContext } from "react";
4
+ import RenderContent from "../components/render-content";
5
+ import BuilderContext from "../context/builder.context";
6
+ function Symbol(props) {
7
+ var _a, _b, _c;
8
+ const builderContext = useContext(BuilderContext);
9
+ return /* @__PURE__ */ React.createElement(View, {
10
+ className: "builder-symbol"
11
+ }, /* @__PURE__ */ React.createElement(RenderContent, {
12
+ context: builderContext.context,
13
+ data: (_a = props.symbol) == null ? void 0 : _a.data,
14
+ model: (_b = props.symbol) == null ? void 0 : _b.model,
15
+ content: (_c = props.symbol) == null ? void 0 : _c.content
16
+ }));
17
+ }
18
+ export {
19
+ Symbol as default
20
+ };
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Image, Text } from "react-native";
3
+ import { useContext } from "react";
4
+ import RenderContent from "../components/render-content.lite";
5
+ import BuilderContext from "../context/builder.context.lite";
6
+
7
+ export default function Symbol(props) {
8
+ const builderContext = useContext(BuilderContext);
9
+
10
+ return (
11
+ <View className="builder-symbol">
12
+ <RenderContent
13
+ context={builderContext.context}
14
+ data={props.symbol?.data}
15
+ model={props.symbol?.model}
16
+ content={props.symbol?.content}
17
+ />
18
+ </View>
19
+ );
20
+ }
@@ -0,0 +1,85 @@
1
+ import * as React from 'react';
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __spreadValues = (a, b) => {
8
+ for (var prop in b || (b = {}))
9
+ if (__hasOwnProp.call(b, prop))
10
+ __defNormalProp(a, prop, b[prop]);
11
+ if (__getOwnPropSymbols)
12
+ for (var prop of __getOwnPropSymbols(b)) {
13
+ if (__propIsEnum.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ }
16
+ return a;
17
+ };
18
+ import HTML from "react-native-render-html";
19
+ import { registerComponent } from "../functions/register-component";
20
+ function camelToKebabCase(string) {
21
+ return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
22
+ }
23
+ function pick(object, keys) {
24
+ return keys.reduce((obj, key) => {
25
+ if (object && object.hasOwnProperty(key)) {
26
+ obj[key] = object[key];
27
+ }
28
+ return obj;
29
+ }, {});
30
+ }
31
+ const PICK_STYLES = ["textAlign"];
32
+ function getBlockStyles(block) {
33
+ var _a, _b, _c;
34
+ const styles = __spreadValues(__spreadValues({}, (_a = block.responsiveStyles) == null ? void 0 : _a.large), block.styles);
35
+ if ((_b = block.responsiveStyles) == null ? void 0 : _b.medium) {
36
+ Object.assign(styles, block.responsiveStyles.medium);
37
+ }
38
+ if ((_c = block.responsiveStyles) == null ? void 0 : _c.small) {
39
+ Object.assign(styles, block.responsiveStyles.small);
40
+ }
41
+ return styles;
42
+ }
43
+ function getCss(block) {
44
+ const styleObject = pick(getBlockStyles(block), PICK_STYLES);
45
+ if (!styleObject) {
46
+ return "";
47
+ }
48
+ let str = ``;
49
+ for (const key in styleObject) {
50
+ const value = styleObject[key];
51
+ if (typeof value === "string") {
52
+ str += `${camelToKebabCase(key)}: ${value};`;
53
+ }
54
+ }
55
+ return str;
56
+ }
57
+ function Text(props) {
58
+ return /* @__PURE__ */ React.createElement(HTML, {
59
+ source: { html: `<div style="${getCss(props.builderBlock)}">${props.text || ""}</div>` }
60
+ });
61
+ }
62
+ registerComponent(Text, {
63
+ name: "Text",
64
+ static: true,
65
+ builtIn: true,
66
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
67
+ inputs: [
68
+ {
69
+ name: "text",
70
+ type: "html",
71
+ required: true,
72
+ autoFocus: true,
73
+ bubble: true,
74
+ defaultValue: "Enter some text..."
75
+ }
76
+ ],
77
+ defaultStyles: {
78
+ lineHeight: "normal",
79
+ height: "auto",
80
+ textAlign: "center"
81
+ }
82
+ });
83
+ export {
84
+ Text as default
85
+ };
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Image, Text } from "react-native";
3
+ import { useContext } from "react";
4
+
5
+ export default function Text(props) {
6
+ return (
7
+ <View
8
+ className="builder-text"
9
+ dangerouslySetInnerHTML={{ __html: "props.text" }}
10
+ />
11
+ );
12
+ }
@@ -0,0 +1,37 @@
1
+ import { registerComponent } from '../functions/register-component';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ import * as React from "react";
23
+ import { View } from "react-native";
24
+ function Textarea(props) {
25
+ return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
26
+ placeholder: props.placeholder,
27
+ name: props.name,
28
+ value: props.value,
29
+ defaultValue: props.defaultValue
30
+ }));
31
+ }
32
+ export {
33
+ Textarea as default
34
+ };
35
+
36
+
37
+ registerComponent(Textarea, {name:'Form:TextArea',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3',inputs:[{advanced:true,name:'value',type:'string'},{name:'name',type:'string',required:true,helperText:'Every input in a form needs a unique name describing what it gets, e.g. "email"'},{name:'defaultValue',type:'string'},{name:'placeholder',type:'string',defaultValue:'Hello there'},{name:'required',type:'boolean',defaultValue:false}],defaultStyles:{paddingTop:'10px',paddingBottom:'10px',paddingLeft:'10px',paddingRight:'10px',borderRadius:'3px',borderWidth:'1px',borderStyle:'solid',borderColor:'#ccc'},static:true,noWrap:true});
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Image, Text } from "react-native";
3
+ import { useContext } from "react";
4
+
5
+ export default function Textarea(props) {
6
+ return (
7
+ <View
8
+ {...props.attributes}
9
+ placeholder={props.placeholder}
10
+ name={props.name}
11
+ value={props.value}
12
+ defaultValue={props.defaultValue}
13
+ />
14
+ );
15
+ }
@@ -0,0 +1,88 @@
1
+ import * as React from 'react';
2
+ import { View } from "react-native";
3
+ import ReactVideo from "react-native-video";
4
+ import { registerComponent } from "../functions/register-component";
5
+ function Video(props) {
6
+ return /* @__PURE__ */ React.createElement(View, {
7
+ style: { position: "relative" }
8
+ }, /* @__PURE__ */ React.createElement(ReactVideo, {
9
+ paused: !props.autoPlay,
10
+ controls: props.controls,
11
+ muted: props.muted,
12
+ repeat: props.loop,
13
+ poster: props.posterImage,
14
+ posterResizeMode: props.fit || "contain",
15
+ resizeMode: props.fit || "contain",
16
+ style: { position: "absolute", top: 0, bottom: 0, left: 0, right: 0, zIndex: 1 },
17
+ source: { uri: props.video }
18
+ }), /* @__PURE__ */ React.createElement(View, {
19
+ style: {
20
+ width: "100%",
21
+ paddingTop: `${props.aspectRatio * 100}%`
22
+ }
23
+ }));
24
+ }
25
+ registerComponent(Video, {
26
+ name: "Video",
27
+ static: true,
28
+ builtIn: true,
29
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
30
+ defaultStyles: {
31
+ position: "relative",
32
+ minHeight: "20px",
33
+ minWidth: "20px",
34
+ overflow: "hidden"
35
+ },
36
+ canHaveChildren: true,
37
+ inputs: [
38
+ {
39
+ name: "video",
40
+ type: "file",
41
+ allowedFileTypes: ["mp4"],
42
+ bubble: true,
43
+ defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
44
+ required: true
45
+ },
46
+ {
47
+ name: "posterImage",
48
+ type: "file",
49
+ allowedFileTypes: ["jpeg", "png"],
50
+ helperText: "Image to show before the video plays"
51
+ },
52
+ {
53
+ name: "autoPlay",
54
+ type: "boolean",
55
+ defaultValue: true
56
+ },
57
+ {
58
+ name: "controls",
59
+ type: "boolean",
60
+ defaultValue: false
61
+ },
62
+ {
63
+ name: "muted",
64
+ type: "boolean",
65
+ defaultValue: true
66
+ },
67
+ {
68
+ name: "loop",
69
+ type: "boolean",
70
+ defaultValue: true
71
+ },
72
+ {
73
+ name: "fit",
74
+ type: "text",
75
+ defaultValue: "cover",
76
+ enum: ["contain", "cover", "stretch"]
77
+ },
78
+ {
79
+ name: "aspectRatio",
80
+ type: "number",
81
+ advanced: true,
82
+ defaultValue: 0.7004048582995948
83
+ }
84
+ ]
85
+ });
86
+ export {
87
+ Video as default
88
+ };
@@ -0,0 +1,28 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Image, Text } from "react-native";
3
+ import { useContext } from "react";
4
+
5
+ export default function Video(props) {
6
+ return (
7
+ <View
8
+ {...props.attributes}
9
+ preload="none"
10
+ style={{
11
+ width: "100%",
12
+ height: "100%",
13
+ ...props.attributes?.style,
14
+ objectFit: props.fit,
15
+ objectPosition: props.position,
16
+ // Hack to get object fit to work as expected and
17
+ // not have the video overflow
18
+ borderRadius: 1,
19
+ }}
20
+ key={props.video || "no-src"}
21
+ poster={props.posterImage}
22
+ autoPlay={props.autoPlay}
23
+ muted={props.muted}
24
+ controls={props.controls}
25
+ loop={props.loop}
26
+ />
27
+ );
28
+ }
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ function BlockStyles(props) {
3
+ return /* @__PURE__ */ React.createElement(React.Fragment, null);
4
+ }
5
+ export {
6
+ BlockStyles as default
7
+ };
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Image, Text } from "react-native";
3
+ import { useContext } from "react";
4
+
5
+ export default function BlockStyles(props) {
6
+ return <></>;
7
+ }
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import { Text } from "react-native";
3
+ class ErrorBoundary extends React.Component {
4
+ constructor(props) {
5
+ super(props);
6
+ this.state = { hasError: false };
7
+ }
8
+ static getDerivedStateFromError(error) {
9
+ return { hasError: true };
10
+ }
11
+ componentDidCatch(error, errorInfo) {
12
+ console.error("Error rendering Builder.io block", error, errorInfo);
13
+ }
14
+ render() {
15
+ if (this.state.hasError) {
16
+ return /* @__PURE__ */ React.createElement(Text, {
17
+ style: { color: "gray" }
18
+ }, "Error rendering Builder.io block");
19
+ }
20
+ return this.props.children;
21
+ }
22
+ }
23
+ export {
24
+ ErrorBoundary as default
25
+ };
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Image, Text } from "react-native";
3
+ import { useContext } from "react";
4
+
5
+ export default function ErrorBoundary(props) {
6
+ return <></>;
7
+ }
@@ -0,0 +1,105 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import * as React from "react";
21
+ import { useContext } from "react";
22
+ import { getBlockComponentOptions } from "../functions/get-block-component-options";
23
+ import { getBlockProperties } from "../functions/get-block-properties";
24
+ import { getBlockStyles } from "../functions/get-block-styles";
25
+ import { getBlockTag } from "../functions/get-block-tag";
26
+ import { components } from "../functions/register-component";
27
+ import BuilderContext from "../context/builder.context";
28
+ import { getBlockActions } from "../functions/get-block-actions";
29
+ import { getProcessedBlock } from "../functions/get-processed-block";
30
+ import BlockStyles from "./block-styles";
31
+ import RenderBlocks from "./render-blocks";
32
+ function RenderBlock(props) {
33
+ var _a, _b, _c;
34
+ function component() {
35
+ var _a2, _b2;
36
+ const componentName = (_a2 = useBlock().component) == null ? void 0 : _a2.name;
37
+ if (!componentName) {
38
+ return null;
39
+ }
40
+ const ref = components[(_b2 = useBlock().component) == null ? void 0 : _b2.name];
41
+ if (componentName && !ref) {
42
+ console.warn(`
43
+ Could not find a registered component named "${componentName}".
44
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
45
+ }
46
+ return ref;
47
+ }
48
+ function componentInfo() {
49
+ var _a2;
50
+ return (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.info;
51
+ }
52
+ function componentRef() {
53
+ var _a2;
54
+ return (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component;
55
+ }
56
+ function tagName() {
57
+ return getBlockTag(useBlock());
58
+ }
59
+ function properties() {
60
+ return getBlockProperties(useBlock());
61
+ }
62
+ function useBlock() {
63
+ return getProcessedBlock({
64
+ block: props.block,
65
+ state: builderContext.state,
66
+ context: builderContext.context
67
+ });
68
+ }
69
+ function actions() {
70
+ return getBlockActions({
71
+ block: useBlock(),
72
+ state: builderContext.state,
73
+ context: builderContext.context
74
+ });
75
+ }
76
+ function css() {
77
+ return getBlockStyles(useBlock());
78
+ }
79
+ function componentOptions() {
80
+ return getBlockComponentOptions(useBlock());
81
+ }
82
+ const builderContext = useContext(BuilderContext);
83
+ const ComponentRefRef = componentRef();
84
+ const TagNameRef = tagName();
85
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, !((_a = componentInfo == null ? void 0 : componentInfo()) == null ? void 0 : _a.noWrap) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadProps(__spreadValues({}, properties()), {
86
+ style: css()
87
+ }), /* @__PURE__ */ React.createElement(BlockStyles, {
88
+ block: useBlock()
89
+ }), componentRef() ? /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadProps(__spreadValues({}, componentOptions()), {
90
+ builderBlock: useBlock()
91
+ }), useBlock().children ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderBlocks, {
92
+ path: "children",
93
+ blocks: useBlock().children
94
+ })) : null) : null, !componentRef() && useBlock().children && useBlock().children.length ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = useBlock().children) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
95
+ block: child
96
+ }))) : null)) : /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadProps(__spreadValues({}, (_c = componentInfo == null ? void 0 : componentInfo()) == null ? void 0 : _c.options), {
97
+ attributes: properties(),
98
+ builderBlock: useBlock(),
99
+ style: css(),
100
+ children: useBlock().children
101
+ })));
102
+ }
103
+ export {
104
+ RenderBlock as default
105
+ };