@builder.io/sdk-react-native 0.0.1-4 → 0.0.1-49

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 (90) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +15 -0
  3. package/package.json +6 -4
  4. package/src/blocks/button.js +73 -24
  5. package/src/blocks/button.lite.tsx +10 -14
  6. package/src/blocks/columns.js +286 -40
  7. package/src/blocks/columns.lite.tsx +43 -20
  8. package/src/blocks/custom-code.js +74 -47
  9. package/src/blocks/custom-code.lite.tsx +11 -19
  10. package/src/blocks/embed.js +68 -47
  11. package/src/blocks/embed.lite.tsx +11 -15
  12. package/src/blocks/form.js +490 -198
  13. package/src/blocks/form.lite.tsx +54 -58
  14. package/src/blocks/fragment.js +21 -0
  15. package/src/blocks/fragment.lite.tsx +10 -0
  16. package/src/blocks/image.js +125 -83
  17. package/src/blocks/image.lite.tsx +46 -14
  18. package/src/blocks/img.js +51 -28
  19. package/src/blocks/img.lite.tsx +6 -7
  20. package/src/blocks/input.js +100 -28
  21. package/src/blocks/input.lite.tsx +4 -7
  22. package/src/blocks/raw-text.js +12 -12
  23. package/src/blocks/raw-text.lite.tsx +3 -9
  24. package/src/blocks/section.js +71 -23
  25. package/src/blocks/section.lite.tsx +4 -5
  26. package/src/blocks/select.js +78 -27
  27. package/src/blocks/select.lite.tsx +8 -9
  28. package/src/blocks/submit-button.js +47 -21
  29. package/src/blocks/submit-button.lite.tsx +3 -4
  30. package/src/blocks/symbol.js +16 -16
  31. package/src/blocks/symbol.lite.tsx +6 -6
  32. package/src/blocks/text.js +85 -16
  33. package/src/blocks/text.lite.tsx +3 -9
  34. package/src/blocks/textarea.js +60 -24
  35. package/src/blocks/textarea.lite.tsx +2 -3
  36. package/src/blocks/video.js +97 -46
  37. package/src/blocks/video.lite.tsx +5 -6
  38. package/src/components/block-styles.js +5 -0
  39. package/src/components/block-styles.lite.tsx +6 -0
  40. package/src/components/error-boundary.js +27 -0
  41. package/src/components/error-boundary.lite.tsx +6 -0
  42. package/src/components/render-block.js +119 -39
  43. package/src/components/render-block.lite.tsx +76 -36
  44. package/src/components/render-blocks.js +65 -32
  45. package/src/components/render-blocks.lite.tsx +25 -16
  46. package/src/components/render-content.js +190 -36
  47. package/src/components/render-content.lite.tsx +143 -32
  48. package/src/constants/device-sizes.js +8 -11
  49. package/src/context/builder.context.js +2 -4
  50. package/src/functions/evaluate.js +18 -9
  51. package/src/functions/event-handler-name.js +6 -0
  52. package/src/functions/get-block-actions.js +13 -13
  53. package/src/functions/get-block-component-options.js +27 -4
  54. package/src/functions/get-block-properties.js +23 -16
  55. package/src/functions/get-block-styles.js +56 -9
  56. package/src/functions/get-block-tag.js +2 -4
  57. package/src/functions/get-builder-search-params/fn.test.js +18 -0
  58. package/src/functions/get-builder-search-params/index.js +20 -0
  59. package/src/functions/get-content/fn.test.js +34 -0
  60. package/src/functions/get-content/index.js +156 -0
  61. package/src/functions/get-fetch.js +11 -0
  62. package/src/functions/get-global-this.js +17 -0
  63. package/src/functions/get-processed-block.js +19 -13
  64. package/src/functions/get-processed-block.test.js +32 -16
  65. package/src/functions/get-target.js +3 -5
  66. package/src/functions/if-target.js +1 -3
  67. package/src/functions/is-browser.js +2 -5
  68. package/src/functions/is-editing.js +5 -5
  69. package/src/functions/is-iframe.js +2 -4
  70. package/src/functions/is-previewing.js +13 -0
  71. package/src/functions/is-react-native.js +2 -4
  72. package/src/functions/macro-eval.js +2 -5
  73. package/src/functions/on-change.js +4 -7
  74. package/src/functions/on-change.test.js +10 -10
  75. package/src/functions/previewing-model-name.js +10 -0
  76. package/src/functions/register-component.js +39 -27
  77. package/src/functions/register.js +28 -0
  78. package/src/functions/set-editor-settings.js +14 -0
  79. package/src/functions/set.js +14 -5
  80. package/src/functions/set.test.js +14 -14
  81. package/src/functions/track.js +7 -9
  82. package/src/functions/transform-block.js +42 -0
  83. package/src/index-helpers/blocks-exports.js +19 -0
  84. package/src/index-helpers/top-of-file.js +2 -0
  85. package/src/index.js +10 -21
  86. package/src/scripts/init-editing.js +67 -29
  87. package/src/types/deep-partial.js +1 -0
  88. package/index.js +0 -11
  89. package/src/functions/get-content.js +0 -103
  90. package/src/package.json +0 -18
@@ -4,81 +4,161 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
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;
7
+ var __defNormalProp = (obj, key, value) =>
8
+ key in obj
9
+ ? __defProp(obj, key, {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value,
14
+ })
15
+ : (obj[key] = value);
8
16
  var __spreadValues = (a, b) => {
9
17
  for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
18
+ if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
12
19
  if (__getOwnPropSymbols)
13
20
  for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
21
+ if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
16
22
  }
17
23
  return a;
18
24
  };
19
25
  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";
26
+ import * as React from 'react';
27
+ import { useContext } from 'react';
28
+ import { getBlockComponentOptions } from '../functions/get-block-component-options';
29
+ import { getBlockProperties } from '../functions/get-block-properties';
30
+ import { getBlockStyles } from '../functions/get-block-styles';
31
+ import { getBlockTag } from '../functions/get-block-tag';
32
+ import { components } from '../functions/register-component';
33
+ import BuilderContext from '../context/builder.context';
34
+ import { getBlockActions } from '../functions/get-block-actions';
35
+ import { getProcessedBlock } from '../functions/get-processed-block';
36
+ import BlockStyles from './block-styles';
30
37
  function RenderBlock(props) {
31
- var _a, _b, _c;
38
+ var _a, _b, _c, _d;
32
39
  function component() {
33
- var _a2;
34
- return components[(_a2 = block().component) == null ? void 0 : _a2.name];
40
+ var _a2, _b2;
41
+ const componentName =
42
+ (_a2 = useBlock().component) == null ? void 0 : _a2.name;
43
+ if (!componentName) {
44
+ return null;
45
+ }
46
+ const ref =
47
+ components[(_b2 = useBlock().component) == null ? void 0 : _b2.name];
48
+ if (componentName && !ref) {
49
+ console.warn(`
50
+ Could not find a registered component named "${componentName}".
51
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
52
+ }
53
+ return ref;
35
54
  }
36
55
  function componentInfo() {
37
56
  var _a2;
38
- return (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.info;
57
+ return (_a2 = component == null ? void 0 : component()) == null
58
+ ? void 0
59
+ : _a2.info;
39
60
  }
40
61
  function componentRef() {
41
62
  var _a2;
42
- return (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component;
63
+ return (_a2 = component == null ? void 0 : component()) == null
64
+ ? void 0
65
+ : _a2.component;
43
66
  }
44
67
  function tagName() {
45
- return getBlockTag(block());
68
+ return getBlockTag(useBlock());
46
69
  }
47
70
  function properties() {
48
- return getBlockProperties(block());
71
+ return getBlockProperties(useBlock());
49
72
  }
50
- function block() {
73
+ function useBlock() {
51
74
  return getProcessedBlock({
52
75
  block: props.block,
53
76
  state: builderContext.state,
54
- context: builderContext.context
77
+ context: builderContext.context,
55
78
  });
56
79
  }
80
+ function propertiesAndActions() {
81
+ return __spreadValues(__spreadValues({}, properties()), actions());
82
+ }
57
83
  function actions() {
58
84
  return getBlockActions({
59
- block: block(),
85
+ block: useBlock(),
60
86
  state: builderContext.state,
61
- context: builderContext.context
87
+ context: builderContext.context,
62
88
  });
63
89
  }
64
90
  function css() {
65
- return getBlockStyles(block());
91
+ return getBlockStyles(useBlock());
66
92
  }
67
93
  function componentOptions() {
68
- return getBlockComponentOptions(block());
94
+ return getBlockComponentOptions(useBlock());
95
+ }
96
+ function children() {
97
+ var _a2;
98
+ return (_a2 = useBlock().children) != null ? _a2 : [];
99
+ }
100
+ function noCompRefChildren() {
101
+ return componentRef() ? [] : children();
69
102
  }
70
103
  const builderContext = useContext(BuilderContext);
71
104
  const ComponentRefRef = componentRef();
72
105
  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(),
75
- 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()), {
77
- 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, {
79
- block: child
80
- }))))));
106
+ return /* @__PURE__ */ React.createElement(
107
+ React.Fragment,
108
+ null,
109
+ !((_a = componentInfo == null ? void 0 : componentInfo()) == null
110
+ ? void 0
111
+ : _a.noWrap)
112
+ ? /* @__PURE__ */ React.createElement(
113
+ React.Fragment,
114
+ null,
115
+ /* @__PURE__ */ React.createElement(
116
+ TagNameRef,
117
+ __spreadProps(__spreadValues({}, propertiesAndActions()), {
118
+ style: css(),
119
+ }),
120
+ /* @__PURE__ */ React.createElement(BlockStyles, {
121
+ block: useBlock(),
122
+ }),
123
+ componentRef()
124
+ ? /* @__PURE__ */ React.createElement(
125
+ ComponentRefRef,
126
+ __spreadProps(__spreadValues({}, componentOptions()), {
127
+ builderBlock: useBlock(),
128
+ }),
129
+ (_b = children()) == null
130
+ ? void 0
131
+ : _b.map((child) =>
132
+ /* @__PURE__ */ React.createElement(RenderBlock, {
133
+ block: child,
134
+ })
135
+ )
136
+ )
137
+ : null,
138
+ (_c = noCompRefChildren()) == null
139
+ ? void 0
140
+ : _c.map((child) =>
141
+ /* @__PURE__ */ React.createElement(RenderBlock, {
142
+ block: child,
143
+ })
144
+ )
145
+ )
146
+ )
147
+ : /* @__PURE__ */ React.createElement(
148
+ ComponentRefRef,
149
+ __spreadProps(__spreadValues({}, componentOptions()), {
150
+ attributes: propertiesAndActions(),
151
+ builderBlock: useBlock(),
152
+ style: css(),
153
+ }),
154
+ (_d = children()) == null
155
+ ? void 0
156
+ : _d.map((child) =>
157
+ /* @__PURE__ */ React.createElement(RenderBlock, {
158
+ block: child,
159
+ })
160
+ )
161
+ )
162
+ );
81
163
  }
82
- export {
83
- RenderBlock as default
84
- };
164
+ export { RenderBlock as default };
@@ -1,18 +1,34 @@
1
- import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useState, useContext } from "react";
4
- import { getBlockComponentOptions } from "../functions/get-block-component-options";
5
- import { getBlockProperties } from "../functions/get-block-properties";
6
- import { getBlockStyles } from "../functions/get-block-styles";
7
- import { getBlockTag } from "../functions/get-block-tag";
8
- import { components } from "../functions/register-component";
9
- import BuilderContext from "../context/builder.context.lite";
10
- import { getBlockActions } from "../functions/get-block-actions";
11
- import { getProcessedBlock } from "../functions/get-processed-block";
1
+ import * as React from 'react';
2
+ import { View, StyleSheet, Image, Text } from 'react-native';
3
+ import { useContext } from 'react';
4
+ import { getBlockComponentOptions } from '../functions/get-block-component-options';
5
+ import { getBlockProperties } from '../functions/get-block-properties';
6
+ import { getBlockStyles } from '../functions/get-block-styles';
7
+ import { getBlockTag } from '../functions/get-block-tag';
8
+ import { components } from '../functions/register-component';
9
+ import BuilderContext from '../context/builder.context.lite';
10
+ import { getBlockActions } from '../functions/get-block-actions';
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,14 @@ 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
46
  function properties() {
31
- return getBlockProperties(block());
47
+ return getBlockProperties(useBlock());
32
48
  }
33
49
 
34
- function block() {
50
+ function useBlock() {
35
51
  return getProcessedBlock({
36
52
  block: props.block,
37
53
  state: builderContext.state,
@@ -39,20 +55,36 @@ export default function RenderBlock(props) {
39
55
  });
40
56
  }
41
57
 
58
+ function propertiesAndActions() {
59
+ return { ...properties(), ...actions() };
60
+ }
61
+
42
62
  function actions() {
43
63
  return getBlockActions({
44
- block: block(),
64
+ block: useBlock(),
45
65
  state: builderContext.state,
46
66
  context: builderContext.context,
47
67
  });
48
68
  }
49
69
 
50
70
  function css() {
51
- return getBlockStyles(block());
71
+ return getBlockStyles(useBlock());
52
72
  }
53
73
 
54
74
  function componentOptions() {
55
- return getBlockComponentOptions(block());
75
+ return getBlockComponentOptions(useBlock());
76
+ }
77
+
78
+ function children() {
79
+ // TO-DO: When should `canHaveChildren` dictate rendering?
80
+ // This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
81
+ // but still receive and need to render children.
82
+ // return componentInfo?.()?.canHaveChildren ? useBlock().children : [];
83
+ return useBlock().children ?? [];
84
+ }
85
+
86
+ function noCompRefChildren() {
87
+ return componentRef() ? [] : children();
56
88
  }
57
89
 
58
90
  const builderContext = useContext(BuilderContext);
@@ -62,30 +94,38 @@ export default function RenderBlock(props) {
62
94
 
63
95
  return (
64
96
  <>
65
- {componentInfo?.()?.noWrap && (
97
+ {!componentInfo?.()?.noWrap ? (
66
98
  <>
67
- <ComponentRefRef
68
- {...componentInfo?.()?.options}
69
- attributes={properties()}
70
- style={css()}
71
- />
72
- </>
73
- )}
99
+ <TagNameRef {...propertiesAndActions()} style={css()}>
100
+ <BlockStyles block={useBlock()} />
74
101
 
75
- {!componentInfo?.()?.noWrap && (
76
- <>
77
- <TagNameRef {...properties()} style={css()}>
78
- {componentRef() && <ComponentRefRef {...componentOptions()} />}
79
-
80
- {!componentRef() && block().children && block().children.length && (
81
- <>
82
- {block().children.map((child) => (
102
+ {componentRef() ? (
103
+ <ComponentRefRef
104
+ {...componentOptions()}
105
+ builderBlock={useBlock()}
106
+ >
107
+ {children()?.map((child) => (
83
108
  <RenderBlock block={child} />
84
109
  ))}
85
- </>
86
- )}
110
+ </ComponentRefRef>
111
+ ) : null}
112
+
113
+ {noCompRefChildren()?.map((child) => (
114
+ <RenderBlock block={child} />
115
+ ))}
87
116
  </TagNameRef>
88
117
  </>
118
+ ) : (
119
+ <ComponentRefRef
120
+ {...componentOptions()}
121
+ attributes={propertiesAndActions()}
122
+ builderBlock={useBlock()}
123
+ style={css()}
124
+ >
125
+ {children()?.map((child) => (
126
+ <RenderBlock block={child} />
127
+ ))}
128
+ </ComponentRefRef>
89
129
  )}
90
130
  </>
91
131
  );
@@ -1,47 +1,80 @@
1
- import * as React from "react";
2
- import { View, StyleSheet } from "react-native";
3
- import { isEditing } from "../functions/is-editing";
4
- import RenderBlock from "./render-block";
1
+ import * as React from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import { isEditing } from '../functions/is-editing';
4
+ import RenderBlock from './render-block';
5
5
  function RenderBlocks(props) {
6
6
  var _a;
7
+ function className() {
8
+ var _a2;
9
+ return (
10
+ 'builder-blocks' +
11
+ (!((_a2 = props.blocks) == null ? void 0 : _a2.length)
12
+ ? ' no-blocks'
13
+ : '')
14
+ );
15
+ }
7
16
  function onClick() {
8
17
  var _a2, _b;
9
18
  if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
10
- (_b = window.parent) == null ? void 0 : _b.postMessage({
11
- type: "builder.clickEmptyBlocks",
12
- data: {
13
- parentElementId: props.parent,
14
- dataPath: props.path
15
- }
16
- }, "*");
19
+ (_b = window.parent) == null
20
+ ? void 0
21
+ : _b.postMessage(
22
+ {
23
+ type: 'builder.clickEmptyBlocks',
24
+ data: {
25
+ parentElementId: props.parent,
26
+ dataPath: props.path,
27
+ },
28
+ },
29
+ '*'
30
+ );
17
31
  }
18
32
  }
19
33
  function onMouseEnter() {
20
34
  var _a2, _b;
21
35
  if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
22
- (_b = window.parent) == null ? void 0 : _b.postMessage({
23
- type: "builder.hoverEmptyBlocks",
24
- data: {
25
- parentElementId: props.parent,
26
- dataPath: props.path
27
- }
28
- }, "*");
36
+ (_b = window.parent) == null
37
+ ? void 0
38
+ : _b.postMessage(
39
+ {
40
+ type: 'builder.hoverEmptyBlocks',
41
+ data: {
42
+ parentElementId: props.parent,
43
+ dataPath: props.path,
44
+ },
45
+ },
46
+ '*'
47
+ );
29
48
  }
30
49
  }
31
- return /* @__PURE__ */ React.createElement(View, {
32
- className: "builder-blocks" + (!((_a = props.blocks) == null ? void 0 : _a.length) ? " no-blocks" : ""),
33
- "builder-path": props.path,
34
- "builder-parent-id": props.parent,
35
- onClick: (event) => onClick,
36
- onMouseEnter: (event) => onMouseEnter,
37
- style: styles.view1
38
- }, props.blocks.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
39
- block
40
- })));
50
+ return /* @__PURE__ */ React.createElement(
51
+ View,
52
+ {
53
+ 'builder-path': props.path,
54
+ 'builder-parent-id': props.parent,
55
+ dataSet: {
56
+ class: className(),
57
+ },
58
+ onClick: (event) => onClick(),
59
+ onMouseEnter: (event) => onMouseEnter(),
60
+ style: styles.view1,
61
+ },
62
+ props.blocks
63
+ ? /* @__PURE__ */ React.createElement(
64
+ React.Fragment,
65
+ null,
66
+ (_a = props.blocks) == null
67
+ ? void 0
68
+ : _a.map((block) =>
69
+ /* @__PURE__ */ React.createElement(RenderBlock, {
70
+ block,
71
+ })
72
+ )
73
+ )
74
+ : null
75
+ );
41
76
  }
42
77
  const styles = StyleSheet.create({
43
- view1: { display: "flex", flexDirection: "column", alignItems: "stretch" }
78
+ view1: { display: 'flex', flexDirection: 'column', alignItems: 'stretch' },
44
79
  });
45
- export {
46
- RenderBlocks as default
47
- };
80
+ export { RenderBlocks as default };
@@ -1,21 +1,24 @@
1
- import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useState, useContext } from "react";
4
- import { isEditing } from "../functions/is-editing";
5
- import RenderBlock from "./render-block.lite";
1
+ import * as React from 'react';
2
+ import { View, StyleSheet, Image, Text } from 'react-native';
3
+ import { isEditing } from '../functions/is-editing';
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(
11
14
  {
12
- type: "builder.clickEmptyBlocks",
15
+ type: 'builder.clickEmptyBlocks',
13
16
  data: {
14
17
  parentElementId: props.parent,
15
18
  dataPath: props.path,
16
19
  },
17
20
  },
18
- "*"
21
+ '*'
19
22
  );
20
23
  }
21
24
  }
@@ -24,33 +27,39 @@ export default function RenderBlocks(props) {
24
27
  if (isEditing() && !props.blocks?.length) {
25
28
  window.parent?.postMessage(
26
29
  {
27
- type: "builder.hoverEmptyBlocks",
30
+ type: 'builder.hoverEmptyBlocks',
28
31
  data: {
29
32
  parentElementId: props.parent,
30
33
  dataPath: props.path,
31
34
  },
32
35
  },
33
- "*"
36
+ '*'
34
37
  );
35
38
  }
36
39
  }
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) => (
55
+ <RenderBlock block={block} />
56
+ ))}
57
+ </>
58
+ ) : null}
50
59
  </View>
51
60
  );
52
61
  }
53
62
 
54
63
  const styles = StyleSheet.create({
55
- view1: { display: "flex", flexDirection: "column", alignItems: "stretch" },
64
+ view1: { display: 'flex', flexDirection: 'column', alignItems: 'stretch' },
56
65
  });