@builder.io/sdk-react-native 0.0.1-31 → 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 (78) hide show
  1. package/package.json +1 -1
  2. package/src/blocks/button.js +22 -66
  3. package/src/blocks/button.lite.tsx +4 -4
  4. package/src/blocks/columns.js +36 -247
  5. package/src/blocks/columns.lite.tsx +7 -7
  6. package/src/blocks/custom-code.js +47 -73
  7. package/src/blocks/custom-code.lite.tsx +16 -12
  8. package/src/blocks/embed.js +47 -66
  9. package/src/blocks/embed.lite.tsx +13 -11
  10. package/src/blocks/form.js +195 -436
  11. package/src/blocks/form.lite.tsx +72 -65
  12. package/src/blocks/fragment.js +8 -16
  13. package/src/blocks/fragment.lite.tsx +3 -3
  14. package/src/blocks/image.js +80 -88
  15. package/src/blocks/image.lite.tsx +16 -17
  16. package/src/blocks/img.js +28 -45
  17. package/src/blocks/img.lite.tsx +7 -7
  18. package/src/blocks/input.js +28 -93
  19. package/src/blocks/input.lite.tsx +7 -5
  20. package/src/blocks/raw-text.js +12 -16
  21. package/src/blocks/raw-text.lite.tsx +3 -3
  22. package/src/blocks/section.js +23 -66
  23. package/src/blocks/section.lite.tsx +4 -4
  24. package/src/blocks/select.js +28 -67
  25. package/src/blocks/select.lite.tsx +8 -6
  26. package/src/blocks/submit-button.js +21 -41
  27. package/src/blocks/submit-button.lite.tsx +3 -3
  28. package/src/blocks/symbol.js +16 -18
  29. package/src/blocks/symbol.lite.tsx +5 -5
  30. package/src/blocks/text.js +27 -29
  31. package/src/blocks/text.lite.tsx +9 -4
  32. package/src/blocks/textarea.js +24 -53
  33. package/src/blocks/textarea.lite.tsx +3 -3
  34. package/src/blocks/video.js +60 -81
  35. package/src/blocks/video.lite.tsx +6 -6
  36. package/src/components/block-styles.js +4 -2
  37. package/src/components/block-styles.lite.tsx +3 -3
  38. package/src/components/error-boundary.js +9 -11
  39. package/src/components/error-boundary.lite.tsx +3 -3
  40. package/src/components/render-block.js +40 -85
  41. package/src/components/render-block.lite.tsx +25 -17
  42. package/src/components/render-blocks.js +32 -56
  43. package/src/components/render-blocks.lite.tsx +14 -14
  44. package/src/components/render-content.js +52 -100
  45. package/src/components/render-content.lite.tsx +41 -32
  46. package/src/constants/device-sizes.js +11 -8
  47. package/src/context/builder.context.js +4 -2
  48. package/src/functions/evaluate.js +9 -17
  49. package/src/functions/get-block-actions.js +10 -9
  50. package/src/functions/get-block-component-options.js +10 -11
  51. package/src/functions/get-block-properties.js +17 -15
  52. package/src/functions/get-block-styles.js +17 -20
  53. package/src/functions/get-block-tag.js +4 -2
  54. package/src/functions/get-content.js +30 -39
  55. package/src/functions/get-content.test.js +28 -37
  56. package/src/functions/get-fetch.js +7 -5
  57. package/src/functions/get-global-this.js +7 -5
  58. package/src/functions/get-processed-block.js +13 -11
  59. package/src/functions/get-processed-block.test.js +14 -14
  60. package/src/functions/get-target.js +4 -2
  61. package/src/functions/if-target.js +3 -1
  62. package/src/functions/is-browser.js +5 -3
  63. package/src/functions/is-editing.js +5 -3
  64. package/src/functions/is-iframe.js +4 -2
  65. package/src/functions/is-previewing.js +6 -4
  66. package/src/functions/is-react-native.js +4 -2
  67. package/src/functions/macro-eval.js +5 -2
  68. package/src/functions/on-change.js +7 -4
  69. package/src/functions/on-change.test.js +10 -10
  70. package/src/functions/previewing-model-name.js +5 -3
  71. package/src/functions/register-component.js +28 -33
  72. package/src/functions/register.js +10 -8
  73. package/src/functions/set-editor-settings.js +7 -5
  74. package/src/functions/set.js +4 -10
  75. package/src/functions/set.test.js +14 -14
  76. package/src/functions/track.js +8 -6
  77. package/src/index.js +18 -20
  78. package/src/scripts/init-editing.js +40 -64
@@ -4,31 +4,31 @@ 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) =>
8
- key in obj
9
- ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value })
10
- : (obj[key] = value);
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
8
  var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
13
12
  if (__getOwnPropSymbols)
14
13
  for (var prop of __getOwnPropSymbols(b)) {
15
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
16
  }
17
17
  return a;
18
18
  };
19
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';
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
32
  function RenderBlock(props) {
33
33
  var _a, _b, _c;
34
34
  function component() {
@@ -63,14 +63,14 @@ function RenderBlock(props) {
63
63
  return getProcessedBlock({
64
64
  block: props.block,
65
65
  state: builderContext.state,
66
- context: builderContext.context,
66
+ context: builderContext.context
67
67
  });
68
68
  }
69
69
  function actions() {
70
70
  return getBlockActions({
71
71
  block: useBlock(),
72
72
  state: builderContext.state,
73
- context: builderContext.context,
73
+ context: builderContext.context
74
74
  });
75
75
  }
76
76
  function css() {
@@ -82,69 +82,24 @@ function RenderBlock(props) {
82
82
  const builderContext = useContext(BuilderContext);
83
83
  const ComponentRefRef = componentRef();
84
84
  const TagNameRef = tagName();
85
- return /* @__PURE__ */ React.createElement(
86
- React.Fragment,
87
- null,
88
- !((_a = componentInfo == null ? void 0 : componentInfo()) == null ? void 0 : _a.noWrap)
89
- ? /* @__PURE__ */ React.createElement(
90
- React.Fragment,
91
- null,
92
- /* @__PURE__ */ React.createElement(
93
- TagNameRef,
94
- __spreadProps(__spreadValues({}, properties()), {
95
- style: css(),
96
- }),
97
- /* @__PURE__ */ React.createElement(BlockStyles, {
98
- block: useBlock(),
99
- }),
100
- componentRef()
101
- ? /* @__PURE__ */ React.createElement(
102
- ComponentRefRef,
103
- __spreadProps(__spreadValues({}, componentOptions()), {
104
- builderBlock: useBlock(),
105
- }),
106
- useBlock().children
107
- ? /* @__PURE__ */ React.createElement(
108
- React.Fragment,
109
- null,
110
- /* @__PURE__ */ React.createElement(RenderBlocks, {
111
- path: 'children',
112
- blocks: useBlock().children,
113
- })
114
- )
115
- : null
116
- )
117
- : null,
118
- !componentRef() && useBlock().children && useBlock().children.length
119
- ? /* @__PURE__ */ React.createElement(
120
- React.Fragment,
121
- null,
122
- (_b = useBlock().children) == null
123
- ? void 0
124
- : _b.map(child =>
125
- /* @__PURE__ */ React.createElement(RenderBlock, {
126
- block: child,
127
- })
128
- )
129
- )
130
- : null
131
- )
132
- )
133
- : /* @__PURE__ */ React.createElement(
134
- ComponentRefRef,
135
- __spreadProps(
136
- __spreadValues(
137
- {},
138
- (_c = componentInfo == null ? void 0 : componentInfo()) == null ? void 0 : _c.options
139
- ),
140
- {
141
- attributes: properties(),
142
- builderBlock: useBlock(),
143
- style: css(),
144
- children: useBlock().children,
145
- }
146
- )
147
- )
148
- );
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
+ })));
149
102
  }
150
- export { RenderBlock as default };
103
+ export {
104
+ RenderBlock as default
105
+ };
@@ -1,16 +1,16 @@
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';
12
- import BlockStyles from './block-styles.lite';
13
- import RenderBlocks from './render-blocks.lite';
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";
12
+ import BlockStyles from "./block-styles.lite";
13
+ import RenderBlocks from "./render-blocks.lite";
14
14
 
15
15
  export default function RenderBlock(props) {
16
16
  function component() {
@@ -85,18 +85,26 @@ export default function RenderBlock(props) {
85
85
  <BlockStyles block={useBlock()} />
86
86
 
87
87
  {componentRef() ? (
88
- <ComponentRefRef {...componentOptions()} builderBlock={useBlock()}>
88
+ <ComponentRefRef
89
+ {...componentOptions()}
90
+ builderBlock={useBlock()}
91
+ >
89
92
  {useBlock().children ? (
90
93
  <>
91
- <RenderBlocks path="children" blocks={useBlock().children} />
94
+ <RenderBlocks
95
+ path="children"
96
+ blocks={useBlock().children}
97
+ />
92
98
  </>
93
99
  ) : null}
94
100
  </ComponentRefRef>
95
101
  ) : null}
96
102
 
97
- {!componentRef() && useBlock().children && useBlock().children.length ? (
103
+ {!componentRef() &&
104
+ useBlock().children &&
105
+ useBlock().children.length ? (
98
106
  <>
99
- {useBlock().children?.map(child => (
107
+ {useBlock().children?.map((child) => (
100
108
  <RenderBlock block={child} />
101
109
  ))}
102
110
  </>
@@ -1,71 +1,47 @@
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, _b;
7
7
  function onClick() {
8
8
  var _a2, _b2;
9
9
  if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
10
- (_b2 = window.parent) == null
11
- ? void 0
12
- : _b2.postMessage(
13
- {
14
- type: 'builder.clickEmptyBlocks',
15
- data: {
16
- parentElementId: props.parent,
17
- dataPath: props.path,
18
- },
19
- },
20
- '*'
21
- );
10
+ (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
11
+ type: "builder.clickEmptyBlocks",
12
+ data: {
13
+ parentElementId: props.parent,
14
+ dataPath: props.path
15
+ }
16
+ }, "*");
22
17
  }
23
18
  }
24
19
  function onMouseEnter() {
25
20
  var _a2, _b2;
26
21
  if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
27
- (_b2 = window.parent) == null
28
- ? void 0
29
- : _b2.postMessage(
30
- {
31
- type: 'builder.hoverEmptyBlocks',
32
- data: {
33
- parentElementId: props.parent,
34
- dataPath: props.path,
35
- },
36
- },
37
- '*'
38
- );
22
+ (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
23
+ type: "builder.hoverEmptyBlocks",
24
+ data: {
25
+ parentElementId: props.parent,
26
+ dataPath: props.path
27
+ }
28
+ }, "*");
39
29
  }
40
30
  }
41
- return /* @__PURE__ */ React.createElement(
42
- View,
43
- {
44
- 'builder-path': props.path,
45
- 'builder-parent-id': props.parent,
46
- onClick: event => onClick,
47
- onMouseEnter: event => onMouseEnter,
48
- className:
49
- 'builder-blocks' +
50
- (!((_a = props.blocks) == null ? void 0 : _a.length) ? ' no-blocks' : ''),
51
- style: styles.view1,
52
- },
53
- props.blocks
54
- ? /* @__PURE__ */ React.createElement(
55
- React.Fragment,
56
- null,
57
- (_b = props.blocks) == null
58
- ? void 0
59
- : _b.map(block =>
60
- /* @__PURE__ */ React.createElement(RenderBlock, {
61
- block,
62
- })
63
- )
64
- )
65
- : null
66
- );
31
+ return /* @__PURE__ */ React.createElement(View, {
32
+ "builder-path": props.path,
33
+ "builder-parent-id": props.parent,
34
+ onClick: (event) => onClick,
35
+ onMouseEnter: (event) => onMouseEnter,
36
+ className: "builder-blocks" + (!((_a = props.blocks) == null ? void 0 : _a.length) ? " no-blocks" : ""),
37
+ style: styles.view1
38
+ }, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = props.blocks) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
39
+ block
40
+ }))) : null);
67
41
  }
68
42
  const styles = StyleSheet.create({
69
- view1: { display: 'flex', flexDirection: 'column', alignItems: 'stretch' },
43
+ view1: { display: "flex", flexDirection: "column", alignItems: "stretch" }
70
44
  });
71
- export { RenderBlocks as default };
45
+ export {
46
+ RenderBlocks as default
47
+ };
@@ -1,21 +1,21 @@
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 { useState, useContext } from "react";
4
+ import { isEditing } from "../functions/is-editing";
5
+ import RenderBlock from "./render-block.lite";
6
6
 
7
7
  export default function RenderBlocks(props) {
8
8
  function onClick() {
9
9
  if (isEditing() && !props.blocks?.length) {
10
10
  window.parent?.postMessage(
11
11
  {
12
- type: 'builder.clickEmptyBlocks',
12
+ type: "builder.clickEmptyBlocks",
13
13
  data: {
14
14
  parentElementId: props.parent,
15
15
  dataPath: props.path,
16
16
  },
17
17
  },
18
- '*'
18
+ "*"
19
19
  );
20
20
  }
21
21
  }
@@ -24,13 +24,13 @@ export default function RenderBlocks(props) {
24
24
  if (isEditing() && !props.blocks?.length) {
25
25
  window.parent?.postMessage(
26
26
  {
27
- type: 'builder.hoverEmptyBlocks',
27
+ type: "builder.hoverEmptyBlocks",
28
28
  data: {
29
29
  parentElementId: props.parent,
30
30
  dataPath: props.path,
31
31
  },
32
32
  },
33
- '*'
33
+ "*"
34
34
  );
35
35
  }
36
36
  }
@@ -39,14 +39,14 @@ export default function RenderBlocks(props) {
39
39
  <View
40
40
  builder-path={props.path}
41
41
  builder-parent-id={props.parent}
42
- onClick={event => onClick}
43
- onMouseEnter={event => onMouseEnter}
44
- className={'builder-blocks' + (!props.blocks?.length ? ' no-blocks' : '')}
42
+ onClick={(event) => onClick}
43
+ onMouseEnter={(event) => onMouseEnter}
44
+ className={"builder-blocks" + (!props.blocks?.length ? " no-blocks" : "")}
45
45
  style={styles.view1}
46
46
  >
47
47
  {props.blocks ? (
48
48
  <>
49
- {props.blocks?.map(block => (
49
+ {props.blocks?.map((block) => (
50
50
  <RenderBlock block={block} />
51
51
  ))}
52
52
  </>
@@ -56,5 +56,5 @@ export default function RenderBlocks(props) {
56
56
  }
57
57
 
58
58
  const styles = StyleSheet.create({
59
- view1: { display: 'flex', flexDirection: 'column', alignItems: 'stretch' },
59
+ view1: { display: "flex", flexDirection: "column", alignItems: "stretch" },
60
60
  });
@@ -1,15 +1,15 @@
1
- import * as React from 'react';
2
- import { View, Text } from 'react-native';
3
- import { useState, useEffect } from 'react';
4
- import { isBrowser } from '../functions/is-browser';
5
- import RenderBlock from './render-block';
6
- import BuilderContext from '../context/builder.context';
7
- import { track } from '../functions/track';
8
- import { isReactNative } from '../functions/is-react-native';
9
- import { isEditing } from '../functions/is-editing';
10
- import { isPreviewing } from '../functions/is-previewing';
11
- import { previewingModelName } from '../functions/previewing-model-name';
12
- import { getContent } from '../functions/get-content';
1
+ import * as React from "react";
2
+ import { View, Text } from "react-native";
3
+ import { useState, useEffect } from "react";
4
+ import { isBrowser } from "../functions/is-browser";
5
+ import RenderBlock from "./render-block";
6
+ import BuilderContext from "../context/builder.context";
7
+ import { track } from "../functions/track";
8
+ import { isReactNative } from "../functions/is-react-native";
9
+ import { isEditing } from "../functions/is-editing";
10
+ import { isPreviewing } from "../functions/is-previewing";
11
+ import { previewingModelName } from "../functions/previewing-model-name";
12
+ import { getContent } from "../functions/get-content";
13
13
  function RenderContent(props) {
14
14
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
15
15
  function useContent() {
@@ -20,10 +20,10 @@ function RenderContent(props) {
20
20
  const [context, setContext] = useState(() => ({}));
21
21
  const [overrideContent, setOverrideContent] = useState(() => null);
22
22
  function getCssFromFont(font, data) {
23
- const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
24
- const name = family.split(',')[0];
23
+ const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
24
+ const name = family.split(",")[0];
25
25
  const url = font.fileUrl ? font.fileUrl : font.files && font.files.regular;
26
- let str = '';
26
+ let str = "";
27
27
  if (url && family && name) {
28
28
  str += `
29
29
  @font-face {
@@ -56,18 +56,13 @@ function RenderContent(props) {
56
56
  return str;
57
57
  }
58
58
  function getFontCss(data) {
59
- return (
60
- ((data == null ? void 0 : data.customFonts) &&
61
- data.customFonts.length &&
62
- data.customFonts.map(font => this.getCssFromFont(font, data)).join(' ')) ||
63
- ''
64
- );
59
+ return (data == null ? void 0 : data.customFonts) && data.customFonts.length && data.customFonts.map((font) => this.getCssFromFont(font, data)).join(" ") || "";
65
60
  }
66
61
  function processMessage(event) {
67
62
  const { data } = event;
68
63
  if (data) {
69
64
  switch (data.type) {
70
- case 'builder.contentUpdate': {
65
+ case "builder.contentUpdate": {
71
66
  const key = data.data.key || data.data.alias || data.data.entry || data.data.modelName;
72
67
  const contentData = data.data.data;
73
68
  if (key === props.model) {
@@ -75,7 +70,7 @@ function RenderContent(props) {
75
70
  }
76
71
  break;
77
72
  }
78
- case 'builder.patchUpdates': {
73
+ case "builder.patchUpdates": {
79
74
  break;
80
75
  }
81
76
  }
@@ -84,30 +79,30 @@ function RenderContent(props) {
84
79
  useEffect(() => {
85
80
  if (isBrowser()) {
86
81
  if (isEditing()) {
87
- window.addEventListener('message', processMessage);
82
+ window.addEventListener("message", processMessage);
88
83
  }
89
84
  if (useContent() && !isEditing()) {
90
- track('impression', {
91
- contentId: useContent().id,
85
+ track("impression", {
86
+ contentId: useContent().id
92
87
  });
93
88
  }
94
89
  if (isPreviewing()) {
95
90
  if (props.model && previewingModelName() === props.model) {
96
91
  const options = {};
97
92
  const currentUrl = new URL(location.href);
98
- const apiKey = currentUrl.searchParams.get('apiKey');
93
+ const apiKey = currentUrl.searchParams.get("apiKey");
99
94
  if (apiKey) {
100
- const builderPrefix = 'builder.';
95
+ const builderPrefix = "builder.";
101
96
  currentUrl.searchParams.forEach((value, key) => {
102
97
  if (key.startsWith(builderPrefix)) {
103
- options[key.replace(builderPrefix, '')] = value;
98
+ options[key.replace(builderPrefix, "")] = value;
104
99
  }
105
100
  });
106
101
  getContent({
107
102
  model: props.model,
108
103
  apiKey,
109
- options,
110
- }).then(content => {
104
+ options
105
+ }).then((content) => {
111
106
  if (content) {
112
107
  setOverrideContent(content);
113
108
  }
@@ -117,75 +112,32 @@ function RenderContent(props) {
117
112
  }
118
113
  }
119
114
  }, []);
120
- return /* @__PURE__ */ React.createElement(
121
- BuilderContext.Provider,
122
- {
123
- value: {
124
- get content() {
125
- return useContent();
126
- },
127
- get state() {
128
- return state;
129
- },
130
- get context() {
131
- return context;
132
- },
115
+ return /* @__PURE__ */ React.createElement(BuilderContext.Provider, {
116
+ value: {
117
+ get content() {
118
+ return useContent();
133
119
  },
120
+ get state() {
121
+ return state;
122
+ },
123
+ get context() {
124
+ return context;
125
+ }
126
+ }
127
+ }, useContent() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, {
128
+ onClick: (event) => {
129
+ if (!isEditing()) {
130
+ track("click", {
131
+ contentId: useContent().id
132
+ });
133
+ }
134
134
  },
135
- useContent()
136
- ? /* @__PURE__ */ React.createElement(
137
- React.Fragment,
138
- null,
139
- /* @__PURE__ */ React.createElement(
140
- View,
141
- {
142
- onClick: event => {
143
- if (!isEditing()) {
144
- track('click', {
145
- contentId: useContent().id,
146
- });
147
- }
148
- },
149
- 'data-builder-content-id':
150
- (_a = useContent == null ? void 0 : useContent()) == null ? void 0 : _a.id,
151
- },
152
- (((_c = (_b = useContent == null ? void 0 : useContent()) == null ? void 0 : _b.data) ==
153
- null
154
- ? void 0
155
- : _c.cssCode) ||
156
- (((_e =
157
- (_d = useContent == null ? void 0 : useContent()) == null ? void 0 : _d.data) ==
158
- null
159
- ? void 0
160
- : _e.customFonts) &&
161
- ((_g =
162
- (_f = useContent == null ? void 0 : useContent()) == null ? void 0 : _f.data) ==
163
- null
164
- ? void 0
165
- : _g.customFonts.length))) &&
166
- !isReactNative()
167
- ? /* @__PURE__ */ React.createElement(
168
- View,
169
- null,
170
- /* @__PURE__ */ React.createElement(Text, null, useContent().data.cssCode),
171
- /* @__PURE__ */ React.createElement(Text, null, getFontCss(useContent().data))
172
- )
173
- : null,
174
- (_j =
175
- (_i = (_h = useContent == null ? void 0 : useContent()) == null ? void 0 : _h.data) ==
176
- null
177
- ? void 0
178
- : _i.blocks) == null
179
- ? void 0
180
- : _j.map(block =>
181
- /* @__PURE__ */ React.createElement(RenderBlock, {
182
- key: block.id,
183
- block,
184
- })
185
- )
186
- )
187
- )
188
- : null
189
- );
135
+ "data-builder-content-id": (_a = useContent == null ? void 0 : useContent()) == null ? void 0 : _a.id
136
+ }, (((_c = (_b = useContent == null ? void 0 : useContent()) == null ? void 0 : _b.data) == null ? void 0 : _c.cssCode) || ((_e = (_d = useContent == null ? void 0 : useContent()) == null ? void 0 : _d.data) == null ? void 0 : _e.customFonts) && ((_g = (_f = useContent == null ? void 0 : useContent()) == null ? void 0 : _f.data) == null ? void 0 : _g.customFonts.length)) && !isReactNative() ? /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(Text, null, useContent().data.cssCode), /* @__PURE__ */ React.createElement(Text, null, getFontCss(useContent().data))) : null, (_j = (_i = (_h = useContent == null ? void 0 : useContent()) == null ? void 0 : _h.data) == null ? void 0 : _i.blocks) == null ? void 0 : _j.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
137
+ key: block.id,
138
+ block
139
+ })))) : null);
190
140
  }
191
- export { RenderContent as default };
141
+ export {
142
+ RenderContent as default
143
+ };