@builder.io/sdk-react-native 0.0.1-3 → 0.0.1-33

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 (80) hide show
  1. package/package.json +4 -2
  2. package/src/blocks/button.js +66 -24
  3. package/src/blocks/button.lite.tsx +10 -14
  4. package/src/blocks/columns.js +247 -40
  5. package/src/blocks/columns.lite.tsx +8 -13
  6. package/src/blocks/custom-code.js +73 -47
  7. package/src/blocks/custom-code.lite.tsx +12 -16
  8. package/src/blocks/embed.js +66 -47
  9. package/src/blocks/embed.lite.tsx +11 -13
  10. package/src/blocks/form.js +436 -198
  11. package/src/blocks/form.lite.tsx +67 -78
  12. package/src/blocks/fragment.js +21 -0
  13. package/src/blocks/fragment.lite.tsx +11 -0
  14. package/src/blocks/image.js +88 -77
  15. package/src/blocks/image.lite.tsx +45 -14
  16. package/src/blocks/img.js +45 -28
  17. package/src/blocks/img.lite.tsx +7 -7
  18. package/src/blocks/input.js +93 -28
  19. package/src/blocks/input.lite.tsx +5 -9
  20. package/src/blocks/raw-text.js +16 -12
  21. package/src/blocks/raw-text.lite.tsx +3 -3
  22. package/src/blocks/section.js +66 -23
  23. package/src/blocks/section.lite.tsx +5 -5
  24. package/src/blocks/select.js +67 -27
  25. package/src/blocks/select.lite.tsx +9 -11
  26. package/src/blocks/submit-button.js +41 -21
  27. package/src/blocks/submit-button.lite.tsx +4 -4
  28. package/src/blocks/symbol.js +18 -16
  29. package/src/blocks/symbol.lite.tsx +5 -5
  30. package/src/blocks/text.js +72 -16
  31. package/src/blocks/text.lite.tsx +4 -9
  32. package/src/blocks/textarea.js +53 -24
  33. package/src/blocks/textarea.lite.tsx +3 -3
  34. package/src/blocks/video.js +90 -46
  35. package/src/blocks/video.lite.tsx +6 -6
  36. package/src/components/block-styles.js +5 -0
  37. package/src/components/block-styles.lite.tsx +7 -0
  38. package/src/components/error-boundary.js +27 -0
  39. package/src/components/error-boundary.lite.tsx +7 -0
  40. package/src/components/render-block.js +103 -37
  41. package/src/components/render-block.lite.tsx +58 -33
  42. package/src/components/render-blocks.js +59 -35
  43. package/src/components/render-blocks.lite.tsx +20 -16
  44. package/src/components/render-content.js +160 -35
  45. package/src/components/render-content.lite.tsx +140 -37
  46. package/src/constants/device-sizes.js +8 -11
  47. package/src/context/builder.context.js +2 -4
  48. package/src/functions/evaluate.js +17 -9
  49. package/src/functions/get-block-actions.js +9 -10
  50. package/src/functions/get-block-component-options.js +21 -4
  51. package/src/functions/get-block-properties.js +20 -18
  52. package/src/functions/get-block-styles.js +43 -10
  53. package/src/functions/get-block-tag.js +2 -4
  54. package/src/functions/get-content.js +62 -28
  55. package/src/functions/get-content.test.js +56 -0
  56. package/src/functions/get-fetch.js +11 -0
  57. package/src/functions/get-global-this.js +17 -0
  58. package/src/functions/get-processed-block.js +11 -13
  59. package/src/functions/get-processed-block.test.js +14 -14
  60. package/src/functions/get-target.js +3 -5
  61. package/src/functions/if-target.js +1 -3
  62. package/src/functions/is-browser.js +3 -5
  63. package/src/functions/is-editing.js +3 -5
  64. package/src/functions/is-iframe.js +2 -4
  65. package/src/functions/is-previewing.js +13 -0
  66. package/src/functions/is-react-native.js +2 -4
  67. package/src/functions/macro-eval.js +2 -5
  68. package/src/functions/on-change.js +4 -7
  69. package/src/functions/on-change.test.js +10 -10
  70. package/src/functions/previewing-model-name.js +10 -0
  71. package/src/functions/register-component.js +34 -28
  72. package/src/functions/register.js +28 -0
  73. package/src/functions/set-editor-settings.js +14 -0
  74. package/src/functions/set.js +10 -4
  75. package/src/functions/set.test.js +14 -14
  76. package/src/functions/track.js +6 -8
  77. package/src/index.js +17 -14
  78. package/src/scripts/init-editing.js +67 -29
  79. package/src/types/deep-partial.js +1 -0
  80. package/index.js +0 -11
@@ -1,12 +1,17 @@
1
- import * as React from "react";
2
- import { View } 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";
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';
8
13
  function RenderContent(props) {
9
- var _a, _b, _c, _d, _e;
14
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
10
15
  function useContent() {
11
16
  return overrideContent || props.content;
12
17
  }
@@ -14,11 +19,55 @@ function RenderContent(props) {
14
19
  const [state, setState] = useState(() => ({}));
15
20
  const [context, setContext] = useState(() => ({}));
16
21
  const [overrideContent, setOverrideContent] = useState(() => null);
22
+ function getCssFromFont(font, data) {
23
+ const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
24
+ const name = family.split(',')[0];
25
+ const url = font.fileUrl ? font.fileUrl : font.files && font.files.regular;
26
+ let str = '';
27
+ if (url && family && name) {
28
+ str += `
29
+ @font-face {
30
+ font-family: "${family}";
31
+ src: local("${name}"), url('${url}') format('woff2');
32
+ font-display: fallback;
33
+ font-weight: 400;
34
+ }
35
+ `.trim();
36
+ }
37
+ if (font.files) {
38
+ for (const weight in font.files) {
39
+ const isNumber = String(Number(weight)) === weight;
40
+ if (!isNumber) {
41
+ continue;
42
+ }
43
+ const weightUrl = font.files[weight];
44
+ if (weightUrl && weightUrl !== url) {
45
+ str += `
46
+ @font-face {
47
+ font-family: "${family}";
48
+ src: url('${weightUrl}') format('woff2');
49
+ font-display: fallback;
50
+ font-weight: ${weight};
51
+ }
52
+ `.trim();
53
+ }
54
+ }
55
+ }
56
+ return str;
57
+ }
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
+ );
65
+ }
17
66
  function processMessage(event) {
18
67
  const { data } = event;
19
68
  if (data) {
20
69
  switch (data.type) {
21
- case "builder.contentUpdate": {
70
+ case 'builder.contentUpdate': {
22
71
  const key = data.data.key || data.data.alias || data.data.entry || data.data.modelName;
23
72
  const contentData = data.data.data;
24
73
  if (key === props.model) {
@@ -26,7 +75,7 @@ function RenderContent(props) {
26
75
  }
27
76
  break;
28
77
  }
29
- case "builder.patchUpdates": {
78
+ case 'builder.patchUpdates': {
30
79
  break;
31
80
  }
32
81
  }
@@ -34,33 +83,109 @@ function RenderContent(props) {
34
83
  }
35
84
  useEffect(() => {
36
85
  if (isBrowser()) {
37
- window.addEventListener("message", processMessage);
86
+ if (isEditing()) {
87
+ window.addEventListener('message', processMessage);
88
+ }
89
+ if (useContent() && !isEditing()) {
90
+ track('impression', {
91
+ contentId: useContent().id,
92
+ });
93
+ }
94
+ if (isPreviewing()) {
95
+ if (props.model && previewingModelName() === props.model) {
96
+ const options = {};
97
+ const currentUrl = new URL(location.href);
98
+ const apiKey = currentUrl.searchParams.get('apiKey');
99
+ if (apiKey) {
100
+ const builderPrefix = 'builder.';
101
+ currentUrl.searchParams.forEach((value, key) => {
102
+ if (key.startsWith(builderPrefix)) {
103
+ options[key.replace(builderPrefix, '')] = value;
104
+ }
105
+ });
106
+ getContent({
107
+ model: props.model,
108
+ apiKey,
109
+ options,
110
+ }).then(content => {
111
+ if (content) {
112
+ setOverrideContent(content);
113
+ }
114
+ });
115
+ }
116
+ }
117
+ }
38
118
  }
39
119
  }, []);
40
- return /* @__PURE__ */ React.createElement(BuilderContext.Provider, {
41
- value: {
42
- get content() {
43
- return props.content;
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
+ },
44
133
  },
45
- get state() {
46
- return state;
47
- },
48
- get context() {
49
- return context;
50
- }
51
- }
52
- }, /* @__PURE__ */ React.createElement(View, {
53
- onClick: (event) => {
54
- track("click", {
55
- contentId: props.content.id
56
- });
57
134
  },
58
- "data-builder-content-id": (_a = props.content) == null ? void 0 : _a.id
59
- }, ((_c = (_b = useContent == null ? void 0 : useContent()) == null ? void 0 : _b.data) == null ? void 0 : _c.cssCode) && /* @__PURE__ */ React.createElement(View, null, useContent().data.cssCode), (_e = (_d = useContent == null ? void 0 : useContent()) == null ? void 0 : _d.data) == null ? void 0 : _e.blocks.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
60
- key: block.id,
61
- block
62
- }))));
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
+ );
63
190
  }
64
- export {
65
- RenderContent as default
66
- };
191
+ export { RenderContent as default };
@@ -1,12 +1,17 @@
1
- import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useState, useContext, useEffect } from "react";
4
- import { isBrowser } from "../functions/is-browser";
5
- import RenderBlock from "./render-block.lite";
6
- import BuilderContext from "../context/builder.context.lite";
7
- import { track } from "../functions/track";
8
- import { ifTarget } from "../functions/if-target";
9
- import { onChange } from "../functions/on-change";
1
+ import * as React from 'react';
2
+ import { View, StyleSheet, Image, Text } from 'react-native';
3
+ import { useState, useContext, useEffect } from 'react';
4
+ import { isBrowser } from '../functions/is-browser';
5
+ import RenderBlock from './render-block.lite';
6
+ import BuilderContext from '../context/builder.context.lite';
7
+ import { track } from '../functions/track';
8
+ import { ifTarget } from '../functions/if-target';
9
+ import { onChange } from '../functions/on-change';
10
+ import { isReactNative } from '../functions/is-react-native';
11
+ import { isEditing } from '../functions/is-editing';
12
+ import { isPreviewing } from '../functions/is-previewing';
13
+ import { previewingModelName } from '../functions/previewing-model-name';
14
+ import { getContent } from '../functions/get-content';
10
15
 
11
16
  export default function RenderContent(props) {
12
17
  function useContent() {
@@ -21,17 +26,71 @@ export default function RenderContent(props) {
21
26
 
22
27
  const [overrideContent, setOverrideContent] = useState(() => null);
23
28
 
29
+ function getCssFromFont(font, data) {
30
+ // TODO: compute what font sizes are used and only load those.......
31
+ const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
32
+ const name = family.split(',')[0];
33
+ const url = font.fileUrl ? font.fileUrl : font.files && font.files.regular;
34
+ let str = '';
35
+
36
+ if (url && family && name) {
37
+ str += `
38
+ @font-face {
39
+ font-family: "${family}";
40
+ src: local("${name}"), url('${url}') format('woff2');
41
+ font-display: fallback;
42
+ font-weight: 400;
43
+ }
44
+ `.trim();
45
+ }
46
+
47
+ if (font.files) {
48
+ for (const weight in font.files) {
49
+ const isNumber = String(Number(weight)) === weight;
50
+
51
+ if (!isNumber) {
52
+ continue;
53
+ } // TODO: maybe limit number loaded
54
+
55
+ const weightUrl = font.files[weight];
56
+
57
+ if (weightUrl && weightUrl !== url) {
58
+ str += `
59
+ @font-face {
60
+ font-family: "${family}";
61
+ src: url('${weightUrl}') format('woff2');
62
+ font-display: fallback;
63
+ font-weight: ${weight};
64
+ }
65
+ `.trim();
66
+ }
67
+ }
68
+ }
69
+
70
+ return str;
71
+ }
72
+
73
+ function getFontCss(data) {
74
+ // TODO: flag for this
75
+ // if (!this.builder.allowCustomFonts) {
76
+ // return '';
77
+ // }
78
+ // TODO: separate internal data from external
79
+ return (
80
+ (data?.customFonts &&
81
+ data.customFonts.length &&
82
+ data.customFonts.map(font => this.getCssFromFont(font, data)).join(' ')) ||
83
+ ''
84
+ );
85
+ }
86
+
24
87
  function processMessage(event) {
25
88
  const { data } = event;
26
89
 
27
90
  if (data) {
28
91
  switch (data.type) {
29
- case "builder.contentUpdate": {
30
- const key =
31
- data.data.key ||
32
- data.data.alias ||
33
- data.data.entry ||
34
- data.data.modelName;
92
+ case 'builder.contentUpdate': {
93
+ const key = data.data.key || data.data.alias || data.data.entry || data.data.modelName;
35
94
  const contentData = data.data.data; // oof
36
95
 
37
96
  if (key === props.model) {
@@ -41,7 +100,7 @@ export default function RenderContent(props) {
41
100
  break;
42
101
  }
43
102
 
44
- case "builder.patchUpdates": {
103
+ case 'builder.patchUpdates': {
45
104
  // TODO
46
105
  break;
47
106
  }
@@ -51,10 +110,42 @@ export default function RenderContent(props) {
51
110
 
52
111
  useEffect(() => {
53
112
  if (isBrowser()) {
54
- window.addEventListener("message", processMessage); // TODO: run this when content is defined
55
- // track('impression', {
56
- // contentId: props.content!.id,
57
- // });
113
+ if (isEditing()) {
114
+ window.addEventListener('message', processMessage);
115
+ }
116
+
117
+ if (useContent() && !isEditing()) {
118
+ track('impression', {
119
+ contentId: useContent().id,
120
+ });
121
+ }
122
+
123
+ if (isPreviewing()) {
124
+ if (props.model && previewingModelName() === props.model) {
125
+ const options = {};
126
+ const currentUrl = new URL(location.href);
127
+ const apiKey = currentUrl.searchParams.get('apiKey');
128
+
129
+ if (apiKey) {
130
+ const builderPrefix = 'builder.';
131
+ currentUrl.searchParams.forEach((value, key) => {
132
+ if (key.startsWith(builderPrefix)) {
133
+ options[key.replace(builderPrefix, '')] = value;
134
+ }
135
+ }); // TODO: need access to API key
136
+
137
+ getContent({
138
+ model: props.model,
139
+ apiKey,
140
+ options,
141
+ }).then(content => {
142
+ if (content) {
143
+ setOverrideContent(content);
144
+ }
145
+ });
146
+ } // TODO: fetch content and override. Forward all builder.* params
147
+ }
148
+ }
58
149
  }
59
150
  }, []);
60
151
 
@@ -62,7 +153,7 @@ export default function RenderContent(props) {
62
153
  <BuilderContext.Provider
63
154
  value={{
64
155
  get content() {
65
- return props.content;
156
+ return useContent();
66
157
  },
67
158
 
68
159
  get state() {
@@ -74,22 +165,34 @@ export default function RenderContent(props) {
74
165
  },
75
166
  }}
76
167
  >
77
- <View
78
- onClick={(event) => {
79
- track("click", {
80
- contentId: props.content.id,
81
- });
82
- }}
83
- data-builder-content-id={props.content?.id}
84
- >
85
- {useContent?.()?.data?.cssCode && (
86
- <View>{useContent().data.cssCode}</View>
87
- )}
88
-
89
- {useContent?.()?.data?.blocks.map((block) => (
90
- <RenderBlock key={block.id} block={block} />
91
- ))}
92
- </View>
168
+ {useContent() ? (
169
+ <>
170
+ <View
171
+ onClick={event => {
172
+ if (!isEditing()) {
173
+ track('click', {
174
+ contentId: useContent().id,
175
+ });
176
+ }
177
+ }}
178
+ data-builder-content-id={useContent?.()?.id}
179
+ >
180
+ {(useContent?.()?.data?.cssCode ||
181
+ (useContent?.()?.data?.customFonts && useContent?.()?.data?.customFonts.length)) &&
182
+ !isReactNative() ? (
183
+ <View>
184
+ <Text>{useContent().data.cssCode}</Text>
185
+
186
+ <Text>{getFontCss(useContent().data)}</Text>
187
+ </View>
188
+ ) : null}
189
+
190
+ {useContent?.()?.data?.blocks?.map(block => (
191
+ <RenderBlock key={block.id} block={block} />
192
+ ))}
193
+ </View>
194
+ </>
195
+ ) : null}
93
196
  </BuilderContext.Provider>
94
197
  );
95
198
  }
@@ -1,25 +1,25 @@
1
1
  import * as React from 'react';
2
- const sizeNames = ["xsmall", "small", "medium", "large"];
2
+ const sizeNames = ['xsmall', 'small', 'medium', 'large'];
3
3
  const sizes = {
4
4
  xsmall: {
5
5
  min: 0,
6
6
  default: 0,
7
- max: 0
7
+ max: 0,
8
8
  },
9
9
  small: {
10
10
  min: 320,
11
11
  default: 321,
12
- max: 640
12
+ max: 640,
13
13
  },
14
14
  medium: {
15
15
  min: 641,
16
16
  default: 642,
17
- max: 991
17
+ max: 991,
18
18
  },
19
19
  large: {
20
20
  min: 990,
21
21
  default: 991,
22
- max: 1200
22
+ max: 1200,
23
23
  },
24
24
  getWidthForSize(size) {
25
25
  return this[size].default;
@@ -31,10 +31,7 @@ const sizes = {
31
31
  return size;
32
32
  }
33
33
  }
34
- return "large";
35
- }
36
- };
37
- export {
38
- sizeNames,
39
- sizes
34
+ return 'large';
35
+ },
40
36
  };
37
+ export { sizeNames, sizes };
@@ -1,5 +1,3 @@
1
- import { createContext } from "react";
1
+ import { createContext } from 'react';
2
2
  var stdin_default = createContext({ content: null, context: {}, state: {} });
3
- export {
4
- stdin_default as default
5
- };
3
+ export { stdin_default as default };
@@ -1,20 +1,28 @@
1
1
  import * as React from 'react';
2
- import { isBrowser } from "./is-browser";
3
- import { isEditing } from "./is-editing";
2
+ import { isBrowser } from './is-browser';
3
+ import { isEditing } from './is-editing';
4
4
  function evaluate(options) {
5
5
  const { code } = options;
6
6
  const builder = {
7
7
  isEditing: isEditing(),
8
- isBrowser: isBrowser()
8
+ isBrowser: isBrowser(),
9
9
  };
10
- const useReturn = !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
10
+ const useReturn = !(
11
+ code.includes(';') ||
12
+ code.includes(' return ') ||
13
+ code.trim().startsWith('return ')
14
+ );
11
15
  const useCode = `${useReturn ? `return (${code});` : code}`;
12
16
  try {
13
- return new Function("builder", "Builder", "state", "context", "event", useCode)(builder, builder, options.state, options.context, options.event);
17
+ return new Function('builder', 'Builder', 'state', 'context', 'event', useCode)(
18
+ builder,
19
+ builder,
20
+ options.state,
21
+ options.context,
22
+ options.event
23
+ );
14
24
  } catch (e) {
15
- console.warn("Builder custom code error", e);
25
+ console.warn('Builder custom code error', e);
16
26
  }
17
27
  }
18
- export {
19
- evaluate
20
- };
28
+ export { evaluate };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { evaluate } from "./evaluate";
2
+ import { evaluate } from './evaluate';
3
3
  function capitalizeFirstLetter(string) {
4
4
  return string.charAt(0).toUpperCase() + string.slice(1);
5
5
  }
@@ -8,16 +8,15 @@ function getBlockActions(options) {
8
8
  if (options.block.actions) {
9
9
  for (const key in options.block.actions) {
10
10
  const value = options.block.actions[key];
11
- obj["on" + capitalizeFirstLetter(key)] = (event) => evaluate({
12
- code: value,
13
- context: options.context,
14
- state: options.state,
15
- event
16
- });
11
+ obj['on' + capitalizeFirstLetter(key)] = event =>
12
+ evaluate({
13
+ code: value,
14
+ context: options.context,
15
+ state: options.state,
16
+ event,
17
+ });
17
18
  }
18
19
  }
19
20
  return obj;
20
21
  }
21
- export {
22
- getBlockActions
23
- };
22
+ export { getBlockActions };
@@ -1,8 +1,25 @@
1
1
  import * as React from 'react';
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
+ var __defNormalProp = (obj, key, value) =>
7
+ key in obj
8
+ ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value })
9
+ : (obj[key] = value);
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
15
+ }
16
+ return a;
17
+ };
2
18
  function getBlockComponentOptions(block) {
3
19
  var _a;
4
- return (_a = block.component) == null ? void 0 : _a.options;
20
+ return __spreadValues(
21
+ __spreadValues({}, (_a = block.component) == null ? void 0 : _a.options),
22
+ block.options
23
+ );
5
24
  }
6
- export {
7
- getBlockComponentOptions
8
- };
25
+ export { getBlockComponentOptions };
@@ -5,35 +5,37 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
5
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __defNormalProp = (obj, key, value) =>
9
+ key in obj
10
+ ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value })
11
+ : (obj[key] = value);
9
12
  var __spreadValues = (a, b) => {
10
- for (var prop in b || (b = {}))
11
- if (__hasOwnProp.call(b, prop))
12
- __defNormalProp(a, prop, b[prop]);
13
+ for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
13
14
  if (__getOwnPropSymbols)
14
15
  for (var prop of __getOwnPropSymbols(b)) {
15
- if (__propIsEnum.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
16
+ if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
17
17
  }
18
18
  return a;
19
19
  };
20
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- import { findDOMNode } from "react-dom";
21
+ import { findDOMNode } from 'react-dom';
22
+ import { isBrowser } from './is-browser';
23
+ import { isReactNative } from './is-react-native';
22
24
  function getBlockProperties(block) {
23
25
  return __spreadProps(__spreadValues({}, block.properties), {
24
- ref: (ref) => {
25
- const el = findDOMNode(ref);
26
- if (el) {
27
- el.setAttribute("builder-id", block.id);
28
- el.classList.add(block.id);
26
+ ref: ref => {
27
+ if (isBrowser() && !isReactNative()) {
28
+ const el = findDOMNode(ref);
29
+ if (el) {
30
+ el.setAttribute('builder-id', block.id);
31
+ el.classList.add(block.id);
32
+ }
29
33
  }
30
34
  },
31
35
  dataSet: {
32
- "builder-id": block.id,
33
- class: [block.id, "builder-block", block.class].filter(Boolean).join(" ")
34
- }
36
+ 'builder-id': block.id,
37
+ class: [block.id, 'builder-block', block.class].filter(Boolean).join(' '),
38
+ },
35
39
  });
36
40
  }
37
- export {
38
- getBlockProperties
39
- };
41
+ export { getBlockProperties };