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

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