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

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 +73 -22
  3. package/src/blocks/button.lite.tsx +5 -4
  4. package/src/blocks/columns.js +258 -36
  5. package/src/blocks/columns.lite.tsx +6 -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 +3 -3
  14. package/src/blocks/image.js +88 -80
  15. package/src/blocks/image.lite.tsx +16 -14
  16. package/src/blocks/img.js +51 -28
  17. package/src/blocks/img.lite.tsx +7 -7
  18. package/src/blocks/input.js +100 -28
  19. package/src/blocks/input.lite.tsx +5 -5
  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 +71 -23
  23. package/src/blocks/section.lite.tsx +4 -4
  24. package/src/blocks/select.js +78 -28
  25. package/src/blocks/select.lite.tsx +5 -5
  26. package/src/blocks/submit-button.js +47 -21
  27. package/src/blocks/submit-button.lite.tsx +3 -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 +4 -4
  32. package/src/blocks/textarea.js +60 -24
  33. package/src/blocks/textarea.lite.tsx +3 -3
  34. package/src/blocks/video.js +72 -60
  35. package/src/blocks/video.lite.tsx +6 -6
  36. package/src/components/block-styles.js +2 -4
  37. package/src/components/block-styles.lite.tsx +3 -3
  38. package/src/components/error-boundary.js +11 -9
  39. package/src/components/error-boundary.lite.tsx +3 -3
  40. package/src/components/render-block.js +104 -43
  41. package/src/components/render-block.lite.tsx +13 -13
  42. package/src/components/render-blocks.js +58 -32
  43. package/src/components/render-blocks.lite.tsx +11 -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/get-block-actions.js +9 -10
  50. package/src/functions/get-block-component-options.js +16 -9
  51. package/src/functions/get-block-properties.js +19 -15
  52. package/src/functions/get-block-styles.js +34 -17
  53. package/src/functions/get-block-tag.js +2 -4
  54. package/src/functions/get-content.js +48 -26
  55. package/src/functions/get-content.test.js +37 -26
  56. package/src/functions/get-fetch.js +5 -7
  57. package/src/functions/get-global-this.js +5 -7
  58. package/src/functions/get-processed-block.js +16 -12
  59. package/src/functions/get-processed-block.test.js +18 -14
  60. package/src/functions/get-target.js +2 -4
  61. package/src/functions/if-target.js +1 -3
  62. package/src/functions/is-browser.js +7 -5
  63. package/src/functions/is-editing.js +5 -5
  64. package/src/functions/is-iframe.js +2 -4
  65. package/src/functions/is-previewing.js +4 -6
  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 +3 -5
  71. package/src/functions/register-component.js +38 -27
  72. package/src/functions/register.js +8 -10
  73. package/src/functions/set-editor-settings.js +5 -7
  74. package/src/functions/set.js +14 -5
  75. package/src/functions/set.test.js +14 -14
  76. package/src/functions/track.js +6 -8
  77. package/src/index.js +15 -14
  78. package/src/scripts/init-editing.js +64 -40
@@ -1,26 +1,26 @@
1
- import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useState, useContext, useRef } from "react";
4
- import RenderBlock from "../components/render-block.lite";
1
+ import * as React from 'react';
2
+ import { View, StyleSheet, Image, Text } from 'react-native';
3
+ import { useState, useContext, useRef } from 'react';
4
+ import RenderBlock from '../components/render-block.lite';
5
5
 
6
6
  export default function FormComponent(props) {
7
- const [state, setState] = useState(() => "unsubmitted");
7
+ const [state, setState] = useState(() => 'unsubmitted');
8
8
 
9
9
  const [responseData, setResponseData] = useState(() => null);
10
10
 
11
- const [formErrorMessage, setFormErrorMessage] = useState(() => "");
11
+ const [formErrorMessage, setFormErrorMessage] = useState(() => '');
12
12
 
13
13
  function submissionState() {
14
14
  return (Builder.isEditing && props.previewState) || state;
15
15
  }
16
16
 
17
17
  function onSubmit(event) {
18
- const sendWithJs = props.sendWithJs || props.sendSubmissionsTo === "email";
18
+ const sendWithJs = props.sendWithJs || props.sendSubmissionsTo === 'email';
19
19
 
20
- if (props.sendSubmissionsTo === "zapier") {
20
+ if (props.sendSubmissionsTo === 'zapier') {
21
21
  event.preventDefault();
22
22
  } else if (sendWithJs) {
23
- if (!(props.action || props.sendSubmissionsTo === "email")) {
23
+ if (!(props.action || props.sendSubmissionsTo === 'email')) {
24
24
  event.preventDefault();
25
25
  return;
26
26
  }
@@ -32,7 +32,7 @@ export default function FormComponent(props) {
32
32
  const formData = new FormData(el); // TODO: maybe support null
33
33
 
34
34
  const formPairs = Array.from(
35
- event.currentTarget.querySelectorAll("input,select,textarea")
35
+ event.currentTarget.querySelectorAll('input,select,textarea')
36
36
  )
37
37
  .filter((el) => !!el.name)
38
38
  .map((el) => {
@@ -40,7 +40,7 @@ export default function FormComponent(props) {
40
40
  const key = el.name;
41
41
 
42
42
  if (el instanceof HTMLInputElement) {
43
- if (el.type === "radio") {
43
+ if (el.type === 'radio') {
44
44
  if (el.checked) {
45
45
  value = el.name;
46
46
  return {
@@ -48,15 +48,15 @@ export default function FormComponent(props) {
48
48
  value,
49
49
  };
50
50
  }
51
- } else if (el.type === "checkbox") {
51
+ } else if (el.type === 'checkbox') {
52
52
  value = el.checked;
53
- } else if (el.type === "number" || el.type === "range") {
53
+ } else if (el.type === 'number' || el.type === 'range') {
54
54
  const num = el.valueAsNumber;
55
55
 
56
56
  if (!isNaN(num)) {
57
57
  value = num;
58
58
  }
59
- } else if (el.type === "file") {
59
+ } else if (el.type === 'file') {
60
60
  // TODO: one vs multiple files
61
61
  value = el.files;
62
62
  } else {
@@ -73,8 +73,8 @@ export default function FormComponent(props) {
73
73
  });
74
74
  let contentType = props.contentType;
75
75
 
76
- if (props.sendSubmissionsTo === "email") {
77
- contentType = "multipart/form-data";
76
+ if (props.sendSubmissionsTo === 'email') {
77
+ contentType = 'multipart/form-data';
78
78
  }
79
79
 
80
80
  Array.from(formPairs).forEach(({ value }) => {
@@ -83,13 +83,13 @@ export default function FormComponent(props) {
83
83
  (Array.isArray(value) && value[0] instanceof File) ||
84
84
  value instanceof FileList
85
85
  ) {
86
- contentType = "multipart/form-data";
86
+ contentType = 'multipart/form-data';
87
87
  }
88
88
  }); // TODO: send as urlEncoded or multipart by default
89
89
  // because of ease of use and reliability in browser API
90
90
  // for encoding the form?
91
91
 
92
- if (contentType !== "application/json") {
92
+ if (contentType !== 'application/json') {
93
93
  body = formData;
94
94
  } else {
95
95
  // Json
@@ -100,38 +100,38 @@ export default function FormComponent(props) {
100
100
  body = JSON.stringify(json);
101
101
  }
102
102
 
103
- if (contentType && contentType !== "multipart/form-data") {
103
+ if (contentType && contentType !== 'multipart/form-data') {
104
104
  if (
105
105
  /* Zapier doesn't allow content-type header to be sent from browsers */ !(
106
- sendWithJs && props.action?.includes("zapier.com")
106
+ sendWithJs && props.action?.includes('zapier.com')
107
107
  )
108
108
  ) {
109
- headers["content-type"] = contentType;
109
+ headers['content-type'] = contentType;
110
110
  }
111
111
  }
112
- const presubmitEvent = new CustomEvent("presubmit", { detail: { body } });
112
+ const presubmitEvent = new CustomEvent('presubmit', { detail: { body } });
113
113
  if (formRef.current) {
114
114
  formRef.current.dispatchEvent(presubmitEvent);
115
115
  if (presubmitEvent.defaultPrevented) {
116
116
  return;
117
117
  }
118
118
  }
119
- setState("sending");
119
+ setState('sending');
120
120
  const formUrl = `${
121
- builder.env === "dev" ? "http://localhost:5000" : "https://builder.io"
121
+ builder.env === 'dev' ? 'http://localhost:5000' : 'https://builder.io'
122
122
  }/api/v1/form-submit?apiKey=${builder.apiKey}&to=${btoa(
123
- props.sendSubmissionsToEmail || ""
124
- )}&name=${encodeURIComponent(props.name || "")}`;
123
+ props.sendSubmissionsToEmail || ''
124
+ )}&name=${encodeURIComponent(props.name || '')}`;
125
125
  fetch(
126
- props.sendSubmissionsTo === "email"
126
+ props.sendSubmissionsTo === 'email'
127
127
  ? formUrl
128
128
  : props.action /* TODO: throw error if no action URL */,
129
- { body, headers, method: props.method || "post" }
129
+ { body, headers, method: props.method || 'post' }
130
130
  ).then(
131
131
  async (res) => {
132
132
  let body;
133
- const contentType = res.headers.get("content-type");
134
- if (contentType && contentType.indexOf("application/json") !== -1) {
133
+ const contentType = res.headers.get('content-type');
134
+ if (contentType && contentType.indexOf('application/json') !== -1) {
135
135
  body = await res.json();
136
136
  } else {
137
137
  body = await res.text();
@@ -140,7 +140,7 @@ export default function FormComponent(props) {
140
140
  /* TODO: allow supplying an error formatter function */ let message =
141
141
  get(body, props.errorMessagePath);
142
142
  if (message) {
143
- if (typeof message !== "string") {
143
+ if (typeof message !== 'string') {
144
144
  /* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message =
145
145
  JSON.stringify(message);
146
146
  }
@@ -148,9 +148,9 @@ export default function FormComponent(props) {
148
148
  }
149
149
  }
150
150
  setResponseData(body);
151
- setState(res.ok ? "success" : "error");
151
+ setState(res.ok ? 'success' : 'error');
152
152
  if (res.ok) {
153
- const submitSuccessEvent = new CustomEvent("submit:success", {
153
+ const submitSuccessEvent = new CustomEvent('submit:success', {
154
154
  detail: { res, body },
155
155
  });
156
156
  if (formRef.current) {
@@ -168,7 +168,7 @@ export default function FormComponent(props) {
168
168
  props.successUrl
169
169
  ) {
170
170
  if (formRef.current) {
171
- const event = new CustomEvent("route", {
171
+ const event = new CustomEvent('route', {
172
172
  detail: { url: props.successUrl },
173
173
  });
174
174
  formRef.current.dispatchEvent(event);
@@ -182,7 +182,7 @@ export default function FormComponent(props) {
182
182
  }
183
183
  },
184
184
  (err) => {
185
- const submitErrorEvent = new CustomEvent("submit:error", {
185
+ const submitErrorEvent = new CustomEvent('submit:error', {
186
186
  detail: { error: err },
187
187
  });
188
188
  if (formRef.current) {
@@ -192,7 +192,7 @@ export default function FormComponent(props) {
192
192
  }
193
193
  }
194
194
  setResponseData(err);
195
- setState("error");
195
+ setState('error');
196
196
  }
197
197
  );
198
198
  }
@@ -208,46 +208,46 @@ export default function FormComponent(props) {
208
208
  name={props.name}
209
209
  onSubmit={(event) => onSubmit(event)}
210
210
  >
211
- {" "}
211
+ {' '}
212
212
  {props.builderBlock && props.builderBlock.children ? (
213
213
  <>
214
214
  {props.builderBlock?.children?.map((block) => (
215
215
  <RenderBlock block={block} />
216
216
  ))}
217
217
  </>
218
- ) : null}{" "}
219
- {submissionState() === "error" ? (
218
+ ) : null}{' '}
219
+ {submissionState() === 'error' ? (
220
220
  <>
221
221
  <BuilderBlocks dataPath="errorMessage" blocks={props.errorMessage} />
222
222
  </>
223
- ) : null}{" "}
224
- {submissionState() === "sending" ? (
223
+ ) : null}{' '}
224
+ {submissionState() === 'sending' ? (
225
225
  <>
226
226
  <BuilderBlocks
227
227
  dataPath="sendingMessage"
228
228
  blocks={props.sendingMessage}
229
229
  />
230
230
  </>
231
- ) : null}{" "}
232
- {submissionState() === "error" && responseData ? (
231
+ ) : null}{' '}
232
+ {submissionState() === 'error' && responseData ? (
233
233
  <>
234
234
  <View className="builder-form-error-text" style={styles.view1}>
235
- {" "}
236
- <Text>{JSON.stringify(responseData, null, 2)}</Text>{" "}
235
+ {' '}
236
+ <Text>{JSON.stringify(responseData, null, 2)}</Text>{' '}
237
237
  </View>
238
238
  </>
239
- ) : null}{" "}
240
- {submissionState() === "success" ? (
239
+ ) : null}{' '}
240
+ {submissionState() === 'success' ? (
241
241
  <>
242
242
  <BuilderBlocks
243
243
  dataPath="successMessage"
244
244
  blocks={props.successMessage}
245
245
  />
246
246
  </>
247
- ) : null}{" "}
247
+ ) : null}{' '}
248
248
  </View>
249
249
  );
250
250
  }
251
251
  const styles = StyleSheet.create({
252
- view1: { padding: 10, color: "red", textAlign: "center" },
252
+ view1: { padding: 10, color: 'red', textAlign: 'center' },
253
253
  });
@@ -1,13 +1,21 @@
1
1
  import { registerComponent } from '../functions/register-component';
2
2
 
3
- import * as React from "react";
4
- import { View, Text } from "react-native";
3
+ import * as React from 'react';
4
+ import { View, Text } from 'react-native';
5
5
  function FragmentComponent(props) {
6
- return /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(Text, null, props.children));
6
+ return /* @__PURE__ */ React.createElement(
7
+ View,
8
+ null,
9
+ /* @__PURE__ */ React.createElement(Text, null, props.children)
10
+ );
7
11
  }
8
- export {
9
- FragmentComponent as default
10
- };
12
+ export { FragmentComponent as default };
11
13
 
12
-
13
- registerComponent(FragmentComponent, {name:'Fragment',static:true,hidden:true,builtIn:true,canHaveChildren:true,noWrap:true});
14
+ registerComponent(FragmentComponent, {
15
+ name: 'Fragment',
16
+ static: true,
17
+ hidden: true,
18
+ builtIn: true,
19
+ canHaveChildren: true,
20
+ noWrap: true,
21
+ });
@@ -1,6 +1,6 @@
1
- import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useContext } from "react";
1
+ import * as React from 'react';
2
+ import { View, StyleSheet, Image, Text } from 'react-native';
3
+ import { useContext } from 'react';
4
4
 
5
5
  export default function FragmentComponent(props) {
6
6
  return (
@@ -1,121 +1,129 @@
1
1
  import * as React from 'react';
2
- import { Image as ReactImage, View } from "react-native";
3
- import { registerComponent } from "../functions/register-component";
2
+ import { Image as ReactImage, View } from 'react-native';
3
+ import { registerComponent } from '../functions/register-component';
4
4
  function Image(props) {
5
- return /* @__PURE__ */ React.createElement(View, {
6
- style: { position: "relative" }
7
- }, /* @__PURE__ */ React.createElement(ReactImage, {
8
- resizeMode: props.backgroundSize || "contain",
9
- style: { position: "absolute", top: 0, bottom: 0, left: 0, right: 0 },
10
- source: { uri: props.image }
11
- }), /* @__PURE__ */ React.createElement(View, {
12
- style: {
13
- width: "100%",
14
- paddingTop: props.aspectRatio * 100 + "%"
15
- }
16
- }));
5
+ return /* @__PURE__ */ React.createElement(
6
+ View,
7
+ {
8
+ style: { position: 'relative' },
9
+ },
10
+ /* @__PURE__ */ React.createElement(ReactImage, {
11
+ resizeMode: props.backgroundSize || 'contain',
12
+ style: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0 },
13
+ source: { uri: props.image },
14
+ }),
15
+ /* @__PURE__ */ React.createElement(View, {
16
+ style: {
17
+ width: '100%',
18
+ paddingTop: props.aspectRatio * 100 + '%',
19
+ },
20
+ })
21
+ );
17
22
  }
18
23
  registerComponent(Image, {
19
- name: "Image",
24
+ name: 'Image',
20
25
  static: true,
21
26
  builtIn: true,
22
- image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
27
+ image:
28
+ 'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4',
23
29
  defaultStyles: {
24
- position: "relative",
25
- minHeight: "20px",
26
- minWidth: "20px",
27
- overflow: "hidden"
30
+ position: 'relative',
31
+ minHeight: '20px',
32
+ minWidth: '20px',
33
+ overflow: 'hidden',
28
34
  },
29
35
  canHaveChildren: true,
30
36
  inputs: [
31
37
  {
32
- name: "image",
33
- type: "file",
38
+ name: 'image',
39
+ type: 'file',
34
40
  bubble: true,
35
- allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
41
+ allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg'],
36
42
  required: true,
37
- defaultValue: "https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
38
- onChange: " const DEFAULT_ASPECT_RATIO = 0.7041; options.delete('srcset'); options.delete('noWebp'); function loadImage(url, timeout) { return new Promise((resolve, reject) => { const img = document.createElement('img'); let loaded = false; img.onload = () => { loaded = true; resolve(img); }; img.addEventListener('error', event => { console.warn('Image load failed', event.error); reject(event.error); }); img.src = url; setTimeout(() => { if (!loaded) { reject(new Error('Image load timed out')); } }, timeout); }); } function round(num) { return Math.round(num * 1000) / 1000; } const value = options.get('image'); const aspectRatio = options.get('aspectRatio'); // For SVG images - don't render as webp, keep them as SVG fetch(value) .then(res => res.blob()) .then(blob => { if (blob.type.includes('svg')) { options.set('noWebp', true); } }); if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) { return loadImage(value).then(img => { const possiblyUpdatedAspectRatio = options.get('aspectRatio'); if ( options.get('image') === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO) ) { if (img.width && img.height) { options.set('aspectRatio', round(img.height / img.width)); options.set('height', img.height); options.set('width', img.width); } } }); }"
43
+ defaultValue:
44
+ 'https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
45
+ onChange:
46
+ " const DEFAULT_ASPECT_RATIO = 0.7041; options.delete('srcset'); options.delete('noWebp'); function loadImage(url, timeout) { return new Promise((resolve, reject) => { const img = document.createElement('img'); let loaded = false; img.onload = () => { loaded = true; resolve(img); }; img.addEventListener('error', event => { console.warn('Image load failed', event.error); reject(event.error); }); img.src = url; setTimeout(() => { if (!loaded) { reject(new Error('Image load timed out')); } }, timeout); }); } function round(num) { return Math.round(num * 1000) / 1000; } const value = options.get('image'); const aspectRatio = options.get('aspectRatio'); // For SVG images - don't render as webp, keep them as SVG fetch(value) .then(res => res.blob()) .then(blob => { if (blob.type.includes('svg')) { options.set('noWebp', true); } }); if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) { return loadImage(value).then(img => { const possiblyUpdatedAspectRatio = options.get('aspectRatio'); if ( options.get('image') === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO) ) { if (img.width && img.height) { options.set('aspectRatio', round(img.height / img.width)); options.set('height', img.height); options.set('width', img.width); } } }); }",
39
47
  },
40
48
  {
41
- name: "backgroundSize",
42
- type: "text",
43
- defaultValue: "cover",
49
+ name: 'backgroundSize',
50
+ type: 'text',
51
+ defaultValue: 'cover',
44
52
  enum: [
45
53
  {
46
- label: "contain",
47
- value: "contain",
48
- helperText: "The image should never get cropped"
54
+ label: 'contain',
55
+ value: 'contain',
56
+ helperText: 'The image should never get cropped',
49
57
  },
50
58
  {
51
- label: "cover",
52
- value: "cover",
53
- helperText: `The image should fill it's box, cropping when needed`
54
- }
55
- ]
59
+ label: 'cover',
60
+ value: 'cover',
61
+ helperText: `The image should fill it's box, cropping when needed`,
62
+ },
63
+ ],
56
64
  },
57
65
  {
58
- name: "backgroundPosition",
59
- type: "text",
60
- defaultValue: "center",
66
+ name: 'backgroundPosition',
67
+ type: 'text',
68
+ defaultValue: 'center',
61
69
  enum: [
62
- "center",
63
- "top",
64
- "left",
65
- "right",
66
- "bottom",
67
- "top left",
68
- "top right",
69
- "bottom left",
70
- "bottom right"
71
- ]
70
+ 'center',
71
+ 'top',
72
+ 'left',
73
+ 'right',
74
+ 'bottom',
75
+ 'top left',
76
+ 'top right',
77
+ 'bottom left',
78
+ 'bottom right',
79
+ ],
72
80
  },
73
81
  {
74
- name: "altText",
75
- type: "string",
76
- helperText: "Text to display when the user has images off"
82
+ name: 'altText',
83
+ type: 'string',
84
+ helperText: 'Text to display when the user has images off',
77
85
  },
78
86
  {
79
- name: "height",
80
- type: "number",
81
- hideFromUI: true
87
+ name: 'height',
88
+ type: 'number',
89
+ hideFromUI: true,
82
90
  },
83
91
  {
84
- name: "width",
85
- type: "number",
86
- hideFromUI: true
92
+ name: 'width',
93
+ type: 'number',
94
+ hideFromUI: true,
87
95
  },
88
96
  {
89
- name: "sizes",
90
- type: "string",
91
- hideFromUI: true
97
+ name: 'sizes',
98
+ type: 'string',
99
+ hideFromUI: true,
92
100
  },
93
101
  {
94
- name: "srcset",
95
- type: "string",
96
- hideFromUI: true
102
+ name: 'srcset',
103
+ type: 'string',
104
+ hideFromUI: true,
97
105
  },
98
106
  {
99
- name: "lazy",
100
- type: "boolean",
107
+ name: 'lazy',
108
+ type: 'boolean',
101
109
  defaultValue: true,
102
- hideFromUI: true
110
+ hideFromUI: true,
103
111
  },
104
112
  {
105
- name: "fitContent",
106
- type: "boolean",
107
- helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
108
- defaultValue: true
113
+ name: 'fitContent',
114
+ type: 'boolean',
115
+ helperText:
116
+ "When child blocks are provided, fit to them instead of using the image's aspect ratio",
117
+ defaultValue: true,
109
118
  },
110
119
  {
111
- name: "aspectRatio",
112
- type: "number",
113
- helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
120
+ name: 'aspectRatio',
121
+ type: 'number',
122
+ helperText:
123
+ "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
114
124
  advanced: true,
115
- defaultValue: 0.7041
116
- }
117
- ]
125
+ defaultValue: 0.7041,
126
+ },
127
+ ],
118
128
  });
119
- export {
120
- Image as default
121
- };
129
+ export { Image as default };
@@ -1,6 +1,6 @@
1
- import * as React from "react";
2
- import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useContext } from "react";
1
+ import * as React from 'react';
2
+ import { View, StyleSheet, Image, Text } from 'react-native';
3
+ import { useContext } from 'react';
4
4
 
5
5
  export default function Image(props) {
6
6
  return (
@@ -9,9 +9,9 @@ export default function Image(props) {
9
9
  <View
10
10
  loading="lazy"
11
11
  alt={props.altText}
12
- aria-role={props.altText ? "presentation" : undefined}
12
+ aria-role={props.altText ? 'presentation' : undefined}
13
13
  style={styles.view2}
14
- className={"builder-image" + (props.class ? " " + props.class : "")}
14
+ className={'builder-image' + (props.class ? ' ' + props.class : '')}
15
15
  src={props.image}
16
16
  srcset={props.srcset}
17
17
  sizes={props.sizes}
@@ -28,7 +28,9 @@ export default function Image(props) {
28
28
  ) : null}
29
29
 
30
30
  {props.builderBlock?.children?.length && props.fitContent ? (
31
- <Text>{props.children}</Text>
31
+ <>
32
+ <Text>{props.children}</Text>
33
+ </>
32
34
  ) : null}
33
35
 
34
36
  {!props.fitContent ? (
@@ -43,22 +45,22 @@ export default function Image(props) {
43
45
  }
44
46
 
45
47
  const styles = StyleSheet.create({
46
- view1: { position: "relative" },
48
+ view1: { position: 'relative' },
47
49
  view2: {
48
50
  opacity: 1,
49
- transition: "opacity 0.2s ease-in-out",
50
- position: "absolute",
51
+ transition: 'opacity 0.2s ease-in-out',
52
+ position: 'absolute',
51
53
  height: 100,
52
54
  width: 100,
53
55
  top: 0,
54
56
  left: 0,
55
57
  },
56
- view3: { width: 100, pointerEvents: "none", fontSize: 0 },
58
+ view3: { width: 100, pointerEvents: 'none', fontSize: 0 },
57
59
  view4: {
58
- display: "flex",
59
- flexDirection: "column",
60
- alignItems: "stretch",
61
- position: "absolute",
60
+ display: 'flex',
61
+ flexDirection: 'column',
62
+ alignItems: 'stretch',
63
+ position: 'absolute',
62
64
  top: 0,
63
65
  left: 0,
64
66
  width: 100,