@builder.io/sdk-react-native 0.0.1-5 → 0.0.1-50

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 (83) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +15 -0
  3. package/package.json +6 -4
  4. package/src/blocks/button.js +5 -6
  5. package/src/blocks/button.lite.tsx +7 -11
  6. package/src/blocks/columns.js +32 -16
  7. package/src/blocks/columns.lite.tsx +39 -16
  8. package/src/blocks/custom-code.js +1 -2
  9. package/src/blocks/custom-code.lite.tsx +2 -10
  10. package/src/blocks/embed.js +1 -2
  11. package/src/blocks/embed.lite.tsx +2 -6
  12. package/src/blocks/form.js +11 -15
  13. package/src/blocks/form.lite.tsx +18 -22
  14. package/src/blocks/fragment.js +13 -0
  15. package/src/blocks/fragment.lite.tsx +10 -0
  16. package/src/blocks/image.js +27 -7
  17. package/src/blocks/image.lite.tsx +42 -10
  18. package/src/blocks/img.js +3 -3
  19. package/src/blocks/img.lite.tsx +2 -3
  20. package/src/blocks/input.js +3 -3
  21. package/src/blocks/input.lite.tsx +2 -5
  22. package/src/blocks/raw-text.js +1 -3
  23. package/src/blocks/raw-text.lite.tsx +1 -7
  24. package/src/blocks/section.js +3 -3
  25. package/src/blocks/section.lite.tsx +1 -2
  26. package/src/blocks/select.js +7 -6
  27. package/src/blocks/select.lite.tsx +6 -7
  28. package/src/blocks/submit-button.js +3 -3
  29. package/src/blocks/submit-button.lite.tsx +1 -2
  30. package/src/blocks/symbol.js +65 -12
  31. package/src/blocks/symbol.lite.tsx +44 -4
  32. package/src/blocks/text.js +57 -1
  33. package/src/blocks/text.lite.tsx +1 -7
  34. package/src/blocks/textarea.js +1 -1
  35. package/src/blocks/textarea.lite.tsx +0 -1
  36. package/src/blocks/video.js +90 -44
  37. package/src/blocks/video.lite.tsx +0 -1
  38. package/src/components/block-styles.js +7 -0
  39. package/src/components/block-styles.lite.tsx +6 -0
  40. package/src/components/error-boundary.js +25 -0
  41. package/src/components/error-boundary.lite.tsx +6 -0
  42. package/src/components/render-block.js +43 -19
  43. package/src/components/render-block.lite.tsx +69 -34
  44. package/src/components/render-blocks.js +12 -5
  45. package/src/components/render-blocks.lite.tsx +16 -7
  46. package/src/components/render-content.js +224 -24
  47. package/src/components/render-content.lite.tsx +247 -34
  48. package/src/context/builder.context.js +6 -1
  49. package/src/functions/evaluate.js +15 -6
  50. package/src/functions/event-handler-name.js +8 -0
  51. package/src/functions/get-block-actions.js +13 -12
  52. package/src/functions/get-block-component-options.js +17 -1
  53. package/src/functions/get-block-properties.js +7 -4
  54. package/src/functions/get-block-styles.js +31 -1
  55. package/src/functions/get-builder-search-params/fn.test.js +14 -0
  56. package/src/functions/get-builder-search-params/index.js +23 -0
  57. package/src/functions/get-content/fn.test.js +32 -0
  58. package/src/functions/get-content/index.js +138 -0
  59. package/src/functions/get-fetch.js +13 -0
  60. package/src/functions/get-global-this.js +19 -0
  61. package/src/functions/get-processed-block.js +3 -1
  62. package/src/functions/get-processed-block.test.js +12 -7
  63. package/src/functions/get-target.js +1 -1
  64. package/src/functions/is-browser.js +1 -2
  65. package/src/functions/is-previewing.js +15 -0
  66. package/src/functions/is-react-native.js +1 -1
  67. package/src/functions/on-change.test.js +0 -1
  68. package/src/functions/previewing-model-name.js +12 -0
  69. package/src/functions/register-component.js +1 -0
  70. package/src/functions/register.js +30 -0
  71. package/src/functions/set-editor-settings.js +16 -0
  72. package/src/functions/set.test.js +0 -1
  73. package/src/functions/track.js +5 -1
  74. package/src/functions/transform-block.js +38 -0
  75. package/src/index-helpers/blocks-exports.js +19 -0
  76. package/src/index-helpers/top-of-file.js +2 -0
  77. package/src/index.js +8 -18
  78. package/src/scripts/init-editing.js +18 -2
  79. package/src/types/deep-partial.js +1 -0
  80. package/src/types/typescript.js +1 -0
  81. package/index.js +0 -11
  82. package/src/functions/get-content.js +0 -103
  83. package/src/package.json +0 -18
@@ -1,49 +1,95 @@
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";
1
+ import * as React from 'react';
23
2
  import { View } from "react-native";
3
+ import ReactVideo from "react-native-video";
4
+ import { registerComponent } from "../functions/register-component";
24
5
  function Video(props) {
25
- var _a;
26
- return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
27
- preload: "none",
28
- style: __spreadProps(__spreadValues({
29
- width: "100%",
30
- height: "100%"
31
- }, (_a = props.attributes) == null ? void 0 : _a.style), {
32
- objectFit: props.fit,
33
- objectPosition: props.position,
34
- borderRadius: 1
35
- }),
36
- key: props.video || "no-src",
37
- poster: props.posterImage,
38
- autoPlay: props.autoPlay,
39
- muted: props.muted,
40
- controls: props.controls,
41
- loop: props.loop
42
- }));
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: {
17
+ position: "absolute",
18
+ top: 0,
19
+ bottom: 0,
20
+ left: 0,
21
+ right: 0,
22
+ zIndex: 1
23
+ },
24
+ source: { uri: props.video }
25
+ }), /* @__PURE__ */ React.createElement(View, {
26
+ style: {
27
+ width: "100%",
28
+ paddingTop: `${props.aspectRatio * 100}%`
29
+ }
30
+ }));
43
31
  }
32
+ registerComponent(Video, {
33
+ name: "Video",
34
+ static: true,
35
+ builtIn: true,
36
+ 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",
37
+ defaultStyles: {
38
+ position: "relative",
39
+ minHeight: "20px",
40
+ minWidth: "20px",
41
+ overflow: "hidden"
42
+ },
43
+ canHaveChildren: true,
44
+ inputs: [
45
+ {
46
+ name: "video",
47
+ type: "file",
48
+ allowedFileTypes: ["mp4"],
49
+ bubble: true,
50
+ defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
51
+ required: true
52
+ },
53
+ {
54
+ name: "posterImage",
55
+ type: "file",
56
+ allowedFileTypes: ["jpeg", "png"],
57
+ helperText: "Image to show before the video plays"
58
+ },
59
+ {
60
+ name: "autoPlay",
61
+ type: "boolean",
62
+ defaultValue: true
63
+ },
64
+ {
65
+ name: "controls",
66
+ type: "boolean",
67
+ defaultValue: false
68
+ },
69
+ {
70
+ name: "muted",
71
+ type: "boolean",
72
+ defaultValue: true
73
+ },
74
+ {
75
+ name: "loop",
76
+ type: "boolean",
77
+ defaultValue: true
78
+ },
79
+ {
80
+ name: "fit",
81
+ type: "text",
82
+ defaultValue: "cover",
83
+ enum: ["contain", "cover", "stretch"]
84
+ },
85
+ {
86
+ name: "aspectRatio",
87
+ type: "number",
88
+ advanced: true,
89
+ defaultValue: 0.7004048582995948
90
+ }
91
+ ]
92
+ });
44
93
  export {
45
- Video as default
94
+ Video as default
46
95
  };
47
-
48
-
49
- registerComponent(Video, {name:'Video',canHaveChildren:true,defaultStyles:{minHeight:'20px',minWidth:'20px'},image:'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb',inputs:[{name:'video',type:'file',allowedFileTypes:['mp4'],bubble:true,defaultValue:'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f',required:true,onChange:" const 0.7004048582995948 = 0.7004048582995948; function loadImage(url: string, timeout = 60000): Promise<HTMLImageElement> { return new Promise((resolve, reject) => { const img = document.createElement('img'); let loaded = false; img.onload = () => { loaded = true; resolve(img); }; img.addEventListener('error', event => { console.warn('Image load failed', event.error); reject(event.error); }); img.src = url; setTimeout(() => { if (!loaded) { reject(new Error('Image load timed out')); } }, timeout); }); } function round(num: number) { return Math.round(num * 1000) / 1000; } // TODO const value = options.get('image'); const aspectRatio = options.get('aspectRatio'); if (value && (!aspectRatio || aspectRatio === 0.7004048582995948)) { return loadImage(value).then(img => { const possiblyUpdatedAspectRatio = options.get('aspectRatio'); if ( options.get('image') === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === 0.7004048582995948) ) { if (img.width && img.height) { options.set('aspectRatio', round(img.height / img.width)); } } }); } "},{name:'posterImage',type:'file',allowedFileTypes:['jpeg','png'],helperText:'Image to show before the video plays'},{name:'autoPlay',type:'boolean',defaultValue:true},{name:'controls',type:'boolean',defaultValue:false},{name:'muted',type:'boolean',defaultValue:true},{name:'loop',type:'boolean',defaultValue:true},{name:'playsInline',type:'boolean',defaultValue:true},{name:'fit',type:'text',defaultValue:'cover',enum:['contain','cover','fill','auto']},{name:'fitContent',type:'boolean',helperText:'When child blocks are provided, fit to them instead of using the aspect ratio',defaultValue:true,advanced:true},{name:'position',type:'text',defaultValue:'center',enum:['center','top','left','right','bottom','top left','top right','bottom left','bottom right']},{name:'height',type:'number',advanced:true},{name:'width',type:'number',advanced:true},{name:'aspectRatio',type:'number',advanced:true,defaultValue:0.7004048582995948},{name:'lazyLoad',type:'boolean',helperText:'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',defaultValue:true,advanced:true}]});
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
2
  import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useContext } from "react";
4
3
 
5
4
  export default function Video(props) {
6
5
  return (
@@ -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,6 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Image, Text } from "react-native";
3
+
4
+ export default function BlockStyles(props) {
5
+ return <></>;
6
+ }
@@ -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,6 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Image, Text } from "react-native";
3
+
4
+ export default function ErrorBoundary(props) {
5
+ return <></>;
6
+ }
@@ -27,11 +27,22 @@ import { components } from "../functions/register-component";
27
27
  import BuilderContext from "../context/builder.context";
28
28
  import { getBlockActions } from "../functions/get-block-actions";
29
29
  import { getProcessedBlock } from "../functions/get-processed-block";
30
+ import BlockStyles from "./block-styles";
30
31
  function RenderBlock(props) {
31
- var _a, _b, _c;
32
+ var _a, _b, _c, _d;
32
33
  function component() {
33
- var _a2;
34
- return components[(_a2 = block().component) == null ? void 0 : _a2.name];
34
+ var _a2, _b2;
35
+ const componentName = (_a2 = useBlock().component) == null ? void 0 : _a2.name;
36
+ if (!componentName) {
37
+ return null;
38
+ }
39
+ const ref = components[(_b2 = useBlock().component) == null ? void 0 : _b2.name];
40
+ if (componentName && !ref) {
41
+ console.warn(`
42
+ Could not find a registered component named "${componentName}".
43
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
44
+ }
45
+ return ref;
35
46
  }
36
47
  function componentInfo() {
37
48
  var _a2;
@@ -42,42 +53,55 @@ function RenderBlock(props) {
42
53
  return (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component;
43
54
  }
44
55
  function tagName() {
45
- return getBlockTag(block());
56
+ return getBlockTag(useBlock());
46
57
  }
47
- function properties() {
48
- return getBlockProperties(block());
49
- }
50
- function block() {
58
+ function useBlock() {
51
59
  return getProcessedBlock({
52
60
  block: props.block,
53
61
  state: builderContext.state,
54
62
  context: builderContext.context
55
63
  });
56
64
  }
57
- function actions() {
58
- return getBlockActions({
59
- block: block(),
65
+ function propertiesAndActions() {
66
+ return __spreadValues(__spreadValues({}, getBlockProperties(useBlock())), getBlockActions({
67
+ block: useBlock(),
60
68
  state: builderContext.state,
61
69
  context: builderContext.context
62
- });
70
+ }));
63
71
  }
64
72
  function css() {
65
- return getBlockStyles(block());
73
+ return getBlockStyles(useBlock());
66
74
  }
67
75
  function componentOptions() {
68
- return getBlockComponentOptions(block());
76
+ return getBlockComponentOptions(useBlock());
77
+ }
78
+ function children() {
79
+ var _a2;
80
+ return (_a2 = useBlock().children) != null ? _a2 : [];
81
+ }
82
+ function noCompRefChildren() {
83
+ return componentRef() ? [] : children();
69
84
  }
70
85
  const builderContext = useContext(BuilderContext);
71
86
  const ComponentRefRef = componentRef();
72
87
  const TagNameRef = tagName();
73
- 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(ComponentRefRef, __spreadProps(__spreadValues({}, (_b = componentInfo == null ? void 0 : componentInfo()) == null ? void 0 : _b.options), {
74
- attributes: properties(),
88
+ 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({}, propertiesAndActions()), {
75
89
  style: css()
76
- }))), !((_c = componentInfo == null ? void 0 : componentInfo()) == null ? void 0 : _c.noWrap) && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadProps(__spreadValues({}, properties()), {
90
+ }), /* @__PURE__ */ React.createElement(BlockStyles, {
91
+ block: useBlock()
92
+ }), componentRef() ? /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadProps(__spreadValues({}, componentOptions()), {
93
+ builderBlock: useBlock()
94
+ }), (_b = children()) == null ? void 0 : _b.map((child, index) => /* @__PURE__ */ React.createElement(RenderBlock, {
95
+ block: child
96
+ }))) : null, (_c = noCompRefChildren()) == null ? void 0 : _c.map((child, index) => /* @__PURE__ */ React.createElement(RenderBlock, {
97
+ block: child
98
+ })))) : /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadProps(__spreadValues({}, componentOptions()), {
99
+ attributes: propertiesAndActions(),
100
+ builderBlock: useBlock(),
77
101
  style: css()
78
- }), componentRef() && /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadValues({}, componentOptions())), !componentRef() && block().children && block().children.length && /* @__PURE__ */ React.createElement(React.Fragment, null, block().children.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
102
+ }), (_d = children()) == null ? void 0 : _d.map((child, index) => /* @__PURE__ */ React.createElement(RenderBlock, {
79
103
  block: child
80
- }))))));
104
+ }))));
81
105
  }
82
106
  export {
83
107
  RenderBlock as default
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useState, useContext } from "react";
3
+ import { useContext } from "react";
4
4
  import { getBlockComponentOptions } from "../functions/get-block-component-options";
5
5
  import { getBlockProperties } from "../functions/get-block-properties";
6
6
  import { getBlockStyles } from "../functions/get-block-styles";
@@ -9,10 +9,26 @@ import { components } from "../functions/register-component";
9
9
  import BuilderContext from "../context/builder.context.lite";
10
10
  import { getBlockActions } from "../functions/get-block-actions";
11
11
  import { getProcessedBlock } from "../functions/get-processed-block";
12
+ import BlockStyles from "./block-styles.lite";
12
13
 
13
14
  export default function RenderBlock(props) {
14
15
  function component() {
15
- return components[block().component?.name];
16
+ const componentName = useBlock().component?.name;
17
+
18
+ if (!componentName) {
19
+ return null;
20
+ }
21
+
22
+ const ref = components[useBlock().component?.name];
23
+
24
+ if (componentName && !ref) {
25
+ // TODO: Public doc page with more info about this message
26
+ console.warn(`
27
+ Could not find a registered component named "${componentName}".
28
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
29
+ }
30
+
31
+ return ref;
16
32
  }
17
33
 
18
34
  function componentInfo() {
@@ -24,14 +40,10 @@ export default function RenderBlock(props) {
24
40
  }
25
41
 
26
42
  function tagName() {
27
- return getBlockTag(block());
43
+ return getBlockTag(useBlock());
28
44
  }
29
45
 
30
- function properties() {
31
- return getBlockProperties(block());
32
- }
33
-
34
- function block() {
46
+ function useBlock() {
35
47
  return getProcessedBlock({
36
48
  block: props.block,
37
49
  state: builderContext.state,
@@ -39,20 +51,35 @@ export default function RenderBlock(props) {
39
51
  });
40
52
  }
41
53
 
42
- function actions() {
43
- return getBlockActions({
44
- block: block(),
45
- state: builderContext.state,
46
- context: builderContext.context,
47
- });
54
+ function propertiesAndActions() {
55
+ return {
56
+ ...getBlockProperties(useBlock()),
57
+ ...getBlockActions({
58
+ block: useBlock(),
59
+ state: builderContext.state,
60
+ context: builderContext.context,
61
+ }),
62
+ };
48
63
  }
49
64
 
50
65
  function css() {
51
- return getBlockStyles(block());
66
+ return getBlockStyles(useBlock());
52
67
  }
53
68
 
54
69
  function componentOptions() {
55
- return getBlockComponentOptions(block());
70
+ return getBlockComponentOptions(useBlock());
71
+ }
72
+
73
+ function children() {
74
+ // TO-DO: When should `canHaveChildren` dictate rendering?
75
+ // This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
76
+ // but still receive and need to render children.
77
+ // return componentInfo?.()?.canHaveChildren ? useBlock().children : [];
78
+ return useBlock().children ?? [];
79
+ }
80
+
81
+ function noCompRefChildren() {
82
+ return componentRef() ? [] : children();
56
83
  }
57
84
 
58
85
  const builderContext = useContext(BuilderContext);
@@ -62,30 +89,38 @@ export default function RenderBlock(props) {
62
89
 
63
90
  return (
64
91
  <>
65
- {componentInfo?.()?.noWrap && (
92
+ {!componentInfo?.()?.noWrap ? (
66
93
  <>
67
- <ComponentRefRef
68
- {...componentInfo?.()?.options}
69
- attributes={properties()}
70
- style={css()}
71
- />
72
- </>
73
- )}
74
-
75
- {!componentInfo?.()?.noWrap && (
76
- <>
77
- <TagNameRef {...properties()} style={css()}>
78
- {componentRef() && <ComponentRefRef {...componentOptions()} />}
94
+ <TagNameRef {...propertiesAndActions()} style={css()}>
95
+ <BlockStyles block={useBlock()} />
79
96
 
80
- {!componentRef() && block().children && block().children.length && (
81
- <>
82
- {block().children.map((child) => (
97
+ {componentRef() ? (
98
+ <ComponentRefRef
99
+ {...componentOptions()}
100
+ builderBlock={useBlock()}
101
+ >
102
+ {children()?.map((child, index) => (
83
103
  <RenderBlock block={child} />
84
104
  ))}
85
- </>
86
- )}
105
+ </ComponentRefRef>
106
+ ) : null}
107
+
108
+ {noCompRefChildren()?.map((child, index) => (
109
+ <RenderBlock block={child} />
110
+ ))}
87
111
  </TagNameRef>
88
112
  </>
113
+ ) : (
114
+ <ComponentRefRef
115
+ {...componentOptions()}
116
+ attributes={propertiesAndActions()}
117
+ builderBlock={useBlock()}
118
+ style={css()}
119
+ >
120
+ {children()?.map((child, index) => (
121
+ <RenderBlock block={child} />
122
+ ))}
123
+ </ComponentRefRef>
89
124
  )}
90
125
  </>
91
126
  );
@@ -4,6 +4,10 @@ import { isEditing } from "../functions/is-editing";
4
4
  import RenderBlock from "./render-block";
5
5
  function RenderBlocks(props) {
6
6
  var _a;
7
+ function className() {
8
+ var _a2;
9
+ return "builder-blocks" + (!((_a2 = props.blocks) == null ? void 0 : _a2.length) ? " no-blocks" : "");
10
+ }
7
11
  function onClick() {
8
12
  var _a2, _b;
9
13
  if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
@@ -29,15 +33,18 @@ function RenderBlocks(props) {
29
33
  }
30
34
  }
31
35
  return /* @__PURE__ */ React.createElement(View, {
32
- className: "builder-blocks" + (!((_a = props.blocks) == null ? void 0 : _a.length) ? " no-blocks" : ""),
33
36
  "builder-path": props.path,
34
37
  "builder-parent-id": props.parent,
35
- onClick: (event) => onClick,
36
- onMouseEnter: (event) => onMouseEnter,
38
+ dataSet: {
39
+ class: className()
40
+ },
41
+ onClick: (event) => onClick(),
42
+ onMouseEnter: (event) => onMouseEnter(),
37
43
  style: styles.view1
38
- }, props.blocks.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
44
+ }, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block, index) => /* @__PURE__ */ React.createElement(RenderBlock, {
45
+ key: block.id,
39
46
  block
40
- })));
47
+ }))) : null);
41
48
  }
42
49
  const styles = StyleSheet.create({
43
50
  view1: { display: "flex", flexDirection: "column", alignItems: "stretch" }
@@ -1,10 +1,13 @@
1
1
  import * as React from "react";
2
2
  import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useState, useContext } from "react";
4
3
  import { isEditing } from "../functions/is-editing";
5
4
  import RenderBlock from "./render-block.lite";
6
5
 
7
6
  export default function RenderBlocks(props) {
7
+ function className() {
8
+ return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
9
+ }
10
+
8
11
  function onClick() {
9
12
  if (isEditing() && !props.blocks?.length) {
10
13
  window.parent?.postMessage(
@@ -37,16 +40,22 @@ export default function RenderBlocks(props) {
37
40
 
38
41
  return (
39
42
  <View
40
- className={"builder-blocks" + (!props.blocks?.length ? " no-blocks" : "")}
41
43
  builder-path={props.path}
42
44
  builder-parent-id={props.parent}
43
- onClick={(event) => onClick}
44
- onMouseEnter={(event) => onMouseEnter}
45
+ dataSet={{
46
+ class: className(),
47
+ }}
48
+ onClick={(event) => onClick()}
49
+ onMouseEnter={(event) => onMouseEnter()}
45
50
  style={styles.view1}
46
51
  >
47
- {props.blocks.map((block) => (
48
- <RenderBlock block={block} />
49
- ))}
52
+ {props.blocks ? (
53
+ <>
54
+ {props.blocks?.map((block, index) => (
55
+ <RenderBlock key={block.id} block={block} />
56
+ ))}
57
+ </>
58
+ ) : null}
50
59
  </View>
51
60
  );
52
61
  }