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

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 (54) hide show
  1. package/package.json +1 -1
  2. package/src/blocks/button.js +10 -3
  3. package/src/blocks/button.lite.tsx +1 -1
  4. package/src/blocks/columns.js +17 -6
  5. package/src/blocks/columns.lite.tsx +1 -2
  6. package/src/blocks/custom-code.js +7 -4
  7. package/src/blocks/custom-code.lite.tsx +9 -5
  8. package/src/blocks/embed.js +7 -4
  9. package/src/blocks/embed.lite.tsx +6 -4
  10. package/src/blocks/form.js +88 -33
  11. package/src/blocks/form.lite.tsx +25 -18
  12. package/src/blocks/fragment.lite.tsx +0 -1
  13. package/src/blocks/image.lite.tsx +5 -3
  14. package/src/blocks/img.js +8 -2
  15. package/src/blocks/img.lite.tsx +0 -1
  16. package/src/blocks/input.js +10 -3
  17. package/src/blocks/input.lite.tsx +3 -2
  18. package/src/blocks/raw-text.lite.tsx +0 -1
  19. package/src/blocks/section.js +9 -4
  20. package/src/blocks/section.lite.tsx +0 -1
  21. package/src/blocks/select.js +16 -5
  22. package/src/blocks/select.lite.tsx +4 -3
  23. package/src/blocks/submit-button.js +8 -2
  24. package/src/blocks/submit-button.lite.tsx +0 -1
  25. package/src/blocks/text.js +17 -4
  26. package/src/blocks/text.lite.tsx +6 -2
  27. package/src/blocks/textarea.js +10 -3
  28. package/src/blocks/textarea.lite.tsx +0 -1
  29. package/src/blocks/video.js +8 -1
  30. package/src/blocks/video.lite.tsx +0 -1
  31. package/src/components/block-styles.lite.tsx +0 -1
  32. package/src/components/error-boundary.lite.tsx +0 -1
  33. package/src/components/render-block.js +30 -11
  34. package/src/components/render-block.lite.tsx +19 -7
  35. package/src/components/render-blocks.js +6 -4
  36. package/src/components/render-blocks.lite.tsx +3 -4
  37. package/src/components/render-content.js +41 -17
  38. package/src/components/render-content.lite.tsx +16 -7
  39. package/src/functions/evaluate.js +9 -8
  40. package/src/functions/get-block-actions.js +4 -1
  41. package/src/functions/get-block-component-options.js +8 -2
  42. package/src/functions/get-block-properties.js +9 -3
  43. package/src/functions/get-block-styles.js +20 -6
  44. package/src/functions/get-content.js +24 -11
  45. package/src/functions/get-content.test.js +6 -4
  46. package/src/functions/get-processed-block.js +8 -2
  47. package/src/functions/get-processed-block.test.js +5 -1
  48. package/src/functions/is-browser.js +5 -1
  49. package/src/functions/is-editing.js +3 -1
  50. package/src/functions/register-component.js +9 -3
  51. package/src/functions/set.js +5 -2
  52. package/src/index.js +9 -10
  53. package/src/scripts/init-editing.js +1 -1
  54. package/src/package.json +0 -18
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react-native",
3
3
  "description": "Builder.io SDK for React Native",
4
- "version": "0.0.1-33",
4
+ "version": "0.0.1-37",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
7
  "release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
@@ -8,10 +8,16 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
9
  var __defNormalProp = (obj, key, value) =>
10
10
  key in obj
11
- ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value })
11
+ ? __defProp(obj, key, {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value,
16
+ })
12
17
  : (obj[key] = value);
13
18
  var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
19
+ for (var prop in b || (b = {}))
20
+ if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
15
21
  if (__getOwnPropSymbols)
16
22
  for (var prop of __getOwnPropSymbols(b)) {
17
23
  if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
@@ -32,6 +38,7 @@ function Button(props) {
32
38
  /* @__PURE__ */ React.createElement(
33
39
  View,
34
40
  __spreadProps(__spreadValues({}, props.attributes), {
41
+ role: 'button',
35
42
  href: props.link,
36
43
  target: props.openLinkInNewTab ? '_blank' : void 0,
37
44
  }),
@@ -58,7 +65,7 @@ registerComponent(Button, {
58
65
  paddingBottom: '15px',
59
66
  paddingLeft: '25px',
60
67
  paddingRight: '25px',
61
- backgroundColor: '#3898EC',
68
+ backgroundColor: '#000000',
62
69
  color: 'white',
63
70
  borderRadius: '4px',
64
71
  textAlign: 'center',
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { View, StyleSheet, Image, Text } from 'react-native';
3
- import { useContext } from 'react';
4
3
 
5
4
  export default function Button(props) {
6
5
  return (
@@ -9,6 +8,7 @@ export default function Button(props) {
9
8
  <>
10
9
  <View
11
10
  {...props.attributes}
11
+ role="button"
12
12
  href={props.link}
13
13
  target={props.openLinkInNewTab ? '_blank' : undefined}
14
14
  >
@@ -29,7 +29,7 @@ function Columns(props) {
29
29
  },
30
30
  (_a = props.columns) == null
31
31
  ? void 0
32
- : _a.map(column =>
32
+ : _a.map((column) =>
33
33
  /* @__PURE__ */ React.createElement(
34
34
  View,
35
35
  {
@@ -107,7 +107,10 @@ registerComponent(Columns, {
107
107
  height: 'auto',
108
108
  },
109
109
  },
110
- component: { name: 'Text', options: { text: '<p>Enter some text...</p>' } },
110
+ component: {
111
+ name: 'Text',
112
+ options: { text: '<p>Enter some text...</p>' },
113
+ },
111
114
  },
112
115
  ],
113
116
  },
@@ -120,7 +123,8 @@ registerComponent(Columns, {
120
123
  {
121
124
  name: 'link',
122
125
  type: 'url',
123
- helperText: 'Optionally set a url that clicking this column will link to',
126
+ helperText:
127
+ 'Optionally set a url that clicking this column will link to',
124
128
  },
125
129
  ],
126
130
  defaultValue: [
@@ -170,7 +174,10 @@ registerComponent(Columns, {
170
174
  height: 'auto',
171
175
  },
172
176
  },
173
- component: { name: 'Text', options: { text: '<p>Enter some text...</p>' } },
177
+ component: {
178
+ name: 'Text',
179
+ options: { text: '<p>Enter some text...</p>' },
180
+ },
174
181
  },
175
182
  ],
176
183
  },
@@ -220,7 +227,10 @@ registerComponent(Columns, {
220
227
  height: 'auto',
221
228
  },
222
229
  },
223
- component: { name: 'Text', options: { text: '<p>Enter some text...</p>' } },
230
+ component: {
231
+ name: 'Text',
232
+ options: { text: '<p>Enter some text...</p>' },
233
+ },
224
234
  },
225
235
  ],
226
236
  },
@@ -247,7 +257,8 @@ registerComponent(Columns, {
247
257
  name: 'reverseColumnsWhenStacked',
248
258
  type: 'boolean',
249
259
  defaultValue: false,
250
- helperText: 'When stacking columns for mobile devices, reverse the ordering',
260
+ helperText:
261
+ 'When stacking columns for mobile devices, reverse the ordering',
251
262
  advanced: true,
252
263
  },
253
264
  ],
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { View, StyleSheet, Image, Text } from 'react-native';
3
- import { useState, useContext } from 'react';
4
3
  import RenderBlocks from '../components/render-blocks.lite';
5
4
 
6
5
  export default function Columns(props) {
@@ -26,7 +25,7 @@ export default function Columns(props) {
26
25
 
27
26
  return (
28
27
  <View className="builder-columns" style={styles.view1}>
29
- {props.columns?.map(column => (
28
+ {props.columns?.map((column) => (
30
29
  <View className="builder-column" style={styles.view2}>
31
30
  <RenderBlocks blocks={column.blocks} />
32
31
  </View>
@@ -22,9 +22,11 @@ function CustomCode(props) {
22
22
  document.head.appendChild(newScript);
23
23
  } else if (
24
24
  !script.type ||
25
- ['text/javascript', 'application/javascript', 'application/ecmascript'].includes(
26
- script.type
27
- )
25
+ [
26
+ 'text/javascript',
27
+ 'application/javascript',
28
+ 'application/ecmascript',
29
+ ].includes(script.type)
28
30
  ) {
29
31
  if (scriptsRun.includes(script.innerText)) {
30
32
  continue;
@@ -45,7 +47,8 @@ function CustomCode(props) {
45
47
  }, []);
46
48
  return /* @__PURE__ */ React.createElement(View, {
47
49
  ref: elem,
48
- className: 'builder-custom-code' + (props.replaceNodes ? ' replace-nodes' : ''),
50
+ className:
51
+ 'builder-custom-code' + (props.replaceNodes ? ' replace-nodes' : ''),
49
52
  dangerouslySetInnerHTML: { __html: 'props.code' },
50
53
  });
51
54
  }
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { View, StyleSheet, Image, Text } from 'react-native';
3
- import { useState, useContext, useRef, useEffect } from 'react';
3
+ import { useState, useRef, useEffect } from 'react';
4
4
 
5
5
  export default function CustomCode(props) {
6
6
  const [scriptsInserted, setScriptsInserted] = useState(() => []);
@@ -28,9 +28,11 @@ export default function CustomCode(props) {
28
28
  document.head.appendChild(newScript);
29
29
  } else if (
30
30
  !script.type ||
31
- ['text/javascript', 'application/javascript', 'application/ecmascript'].includes(
32
- script.type
33
- )
31
+ [
32
+ 'text/javascript',
33
+ 'application/javascript',
34
+ 'application/ecmascript',
35
+ ].includes(script.type)
34
36
  ) {
35
37
  if (scriptsRun.includes(script.innerText)) {
36
38
  continue;
@@ -56,7 +58,9 @@ export default function CustomCode(props) {
56
58
  return (
57
59
  <View
58
60
  ref={elem}
59
- className={'builder-custom-code' + (props.replaceNodes ? ' replace-nodes' : '')}
61
+ className={
62
+ 'builder-custom-code' + (props.replaceNodes ? ' replace-nodes' : '')
63
+ }
60
64
  dangerouslySetInnerHTML={{ __html: 'props.code' }}
61
65
  />
62
66
  );
@@ -22,9 +22,11 @@ function Embed(props) {
22
22
  document.head.appendChild(newScript);
23
23
  } else if (
24
24
  !script.type ||
25
- ['text/javascript', 'application/javascript', 'application/ecmascript'].includes(
26
- script.type
27
- )
25
+ [
26
+ 'text/javascript',
27
+ 'application/javascript',
28
+ 'application/ecmascript',
29
+ ].includes(script.type)
28
30
  ) {
29
31
  if (scriptsRun.includes(script.innerText)) {
30
32
  continue;
@@ -68,7 +70,8 @@ registerComponent(Embed, {
68
70
  {
69
71
  name: 'content',
70
72
  type: 'html',
71
- defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
73
+ defaultValue:
74
+ '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
72
75
  hideFromUI: true,
73
76
  },
74
77
  ],
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { View, StyleSheet, Image, Text } from 'react-native';
3
- import { useState, useContext, useRef, useEffect } from 'react';
3
+ import { useState, useRef, useEffect } from 'react';
4
4
 
5
5
  export default function Embed(props) {
6
6
  const [scriptsInserted, setScriptsInserted] = useState(() => []);
@@ -28,9 +28,11 @@ export default function Embed(props) {
28
28
  document.head.appendChild(newScript);
29
29
  } else if (
30
30
  !script.type ||
31
- ['text/javascript', 'application/javascript', 'application/ecmascript'].includes(
32
- script.type
33
- )
31
+ [
32
+ 'text/javascript',
33
+ 'application/javascript',
34
+ 'application/ecmascript',
35
+ ].includes(script.type)
34
36
  ) {
35
37
  if (scriptsRun.includes(script.innerText)) {
36
38
  continue;
@@ -8,10 +8,16 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
9
  var __defNormalProp = (obj, key, value) =>
10
10
  key in obj
11
- ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value })
11
+ ? __defProp(obj, key, {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value,
16
+ })
12
17
  : (obj[key] = value);
13
18
  var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
19
+ for (var prop in b || (b = {}))
20
+ if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
15
21
  if (__getOwnPropSymbols)
16
22
  for (var prop of __getOwnPropSymbols(b)) {
17
23
  if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
@@ -21,22 +27,24 @@ var __spreadValues = (a, b) => {
21
27
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
28
  var __async = (__this, __arguments, generator) => {
23
29
  return new Promise((resolve, reject) => {
24
- var fulfilled = value => {
30
+ var fulfilled = (value) => {
25
31
  try {
26
32
  step(generator.next(value));
27
33
  } catch (e) {
28
34
  reject(e);
29
35
  }
30
36
  };
31
- var rejected = value => {
37
+ var rejected = (value) => {
32
38
  try {
33
39
  step(generator.throw(value));
34
40
  } catch (e) {
35
41
  reject(e);
36
42
  }
37
43
  };
38
- var step = x =>
39
- x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
44
+ var step = (x) =>
45
+ x.done
46
+ ? resolve(x.value)
47
+ : Promise.resolve(x.value).then(fulfilled, rejected);
40
48
  step((generator = generator.apply(__this, __arguments)).next());
41
49
  });
42
50
  };
@@ -67,9 +75,11 @@ function FormComponent(props) {
67
75
  const headers = props.customHeaders || {};
68
76
  let body;
69
77
  const formData = new FormData(el);
70
- const formPairs = Array.from(event.currentTarget.querySelectorAll('input,select,textarea'))
71
- .filter(el2 => !!el2.name)
72
- .map(el2 => {
78
+ const formPairs = Array.from(
79
+ event.currentTarget.querySelectorAll('input,select,textarea')
80
+ )
81
+ .filter((el2) => !!el2.name)
82
+ .map((el2) => {
73
83
  let value;
74
84
  const key = el2.name;
75
85
  if (el2 instanceof HTMLInputElement) {
@@ -124,7 +134,12 @@ function FormComponent(props) {
124
134
  body = JSON.stringify(json);
125
135
  }
126
136
  if (contentType && contentType !== 'multipart/form-data') {
127
- if (!(sendWithJs && ((_a2 = props.action) == null ? void 0 : _a2.includes('zapier.com')))) {
137
+ if (
138
+ !(
139
+ sendWithJs &&
140
+ ((_a2 = props.action) == null ? void 0 : _a2.includes('zapier.com'))
141
+ )
142
+ ) {
128
143
  headers['content-type'] = contentType;
129
144
  }
130
145
  }
@@ -146,11 +161,14 @@ function FormComponent(props) {
146
161
  headers,
147
162
  method: props.method || 'post',
148
163
  }).then(
149
- res =>
164
+ (res) =>
150
165
  __async(this, null, function* () {
151
166
  let body2;
152
167
  const contentType2 = res.headers.get('content-type');
153
- if (contentType2 && contentType2.indexOf('application/json') !== -1) {
168
+ if (
169
+ contentType2 &&
170
+ contentType2.indexOf('application/json') !== -1
171
+ ) {
154
172
  body2 = yield res.json();
155
173
  } else {
156
174
  body2 = yield res.text();
@@ -194,7 +212,7 @@ function FormComponent(props) {
194
212
  }
195
213
  }
196
214
  }),
197
- err => {
215
+ (err) => {
198
216
  const submitErrorEvent = new CustomEvent('submit:error', {
199
217
  detail: { error: err },
200
218
  });
@@ -219,16 +237,17 @@ function FormComponent(props) {
219
237
  action: !props.sendWithJs && props.action,
220
238
  method: props.method,
221
239
  name: props.name,
222
- onSubmit: event => onSubmit(event),
240
+ onSubmit: (event) => onSubmit(event),
223
241
  }),
224
242
  ' ',
225
243
  props.builderBlock && props.builderBlock.children
226
244
  ? /* @__PURE__ */ React.createElement(
227
245
  React.Fragment,
228
246
  null,
229
- (_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null
247
+ (_b = (_a = props.builderBlock) == null ? void 0 : _a.children) ==
248
+ null
230
249
  ? void 0
231
- : _b.map(block =>
250
+ : _b.map((block) =>
232
251
  /* @__PURE__ */ React.createElement(RenderBlock, {
233
252
  block,
234
253
  })
@@ -269,7 +288,11 @@ function FormComponent(props) {
269
288
  style: styles.view1,
270
289
  },
271
290
  ' ',
272
- /* @__PURE__ */ React.createElement(Text, null, JSON.stringify(responseData, null, 2)),
291
+ /* @__PURE__ */ React.createElement(
292
+ Text,
293
+ null,
294
+ JSON.stringify(responseData, null, 2)
295
+ ),
273
296
  ' '
274
297
  )
275
298
  )
@@ -296,7 +319,9 @@ export { FormComponent as default };
296
319
  registerComponent(FormComponent, {
297
320
  name: 'Form:Form',
298
321
  builtIn: true,
299
- defaults: { responsiveStyles: { large: { marginTop: '15px', paddingBottom: '15px' } } },
322
+ defaults: {
323
+ responsiveStyles: { large: { marginTop: '15px', paddingBottom: '15px' } },
324
+ },
300
325
  image:
301
326
  'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fef36d2a846134910b64b88e6d18c5ca5',
302
327
  inputs: [
@@ -307,7 +332,8 @@ registerComponent(FormComponent, {
307
332
  {
308
333
  label: 'Send to email',
309
334
  value: 'email',
310
- helperText: 'Send form submissions to the email address of your choosing',
335
+ helperText:
336
+ 'Send form submissions to the email address of your choosing',
311
337
  },
312
338
  {
313
339
  label: 'Custom',
@@ -344,8 +370,13 @@ registerComponent(FormComponent, {
344
370
  type: 'string',
345
371
  defaultValue: 'application/json',
346
372
  advanced: true,
347
- enum: ['application/json', 'multipart/form-data', 'application/x-www-form-urlencoded'],
348
- showIf: 'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true',
373
+ enum: [
374
+ 'application/json',
375
+ 'multipart/form-data',
376
+ 'application/x-www-form-urlencoded',
377
+ ],
378
+ showIf:
379
+ 'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true',
349
380
  },
350
381
  {
351
382
  name: 'method',
@@ -361,18 +392,22 @@ registerComponent(FormComponent, {
361
392
  defaultValue: 'unsubmitted',
362
393
  helperText:
363
394
  'Choose a state to edit, e.g. choose "success" to show what users see on success and edit the message',
364
- showIf: 'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true',
395
+ showIf:
396
+ 'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true',
365
397
  },
366
398
  {
367
399
  name: 'successUrl',
368
400
  type: 'url',
369
- helperText: 'Optional URL to redirect the user to on form submission success',
370
- showIf: 'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true',
401
+ helperText:
402
+ 'Optional URL to redirect the user to on form submission success',
403
+ showIf:
404
+ 'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true',
371
405
  },
372
406
  {
373
407
  name: 'resetFormOnSubmit',
374
408
  type: 'boolean',
375
- showIf: "options.get('sendSubmissionsTo') === 'custom' && options.get('sendWithJs') === true",
409
+ showIf:
410
+ "options.get('sendSubmissionsTo') === 'custom' && options.get('sendWithJs') === true",
376
411
  advanced: true,
377
412
  },
378
413
  {
@@ -383,7 +418,10 @@ registerComponent(FormComponent, {
383
418
  {
384
419
  '@type': '@builder.io/sdk:Element',
385
420
  responsiveStyles: { large: { marginTop: '10px' } },
386
- component: { name: 'Text', options: { text: '<span>Thanks!</span>' } },
421
+ component: {
422
+ name: 'Text',
423
+ options: { text: '<span>Thanks!</span>' },
424
+ },
387
425
  },
388
426
  ],
389
427
  },
@@ -404,7 +442,8 @@ registerComponent(FormComponent, {
404
442
  '@type': '@builder.io/sdk:Element',
405
443
  responsiveStyles: { large: { marginTop: '10px' } },
406
444
  bindings: {
407
- 'component.options.text': 'state.formErrorMessage || block.component.options.text',
445
+ 'component.options.text':
446
+ 'state.formErrorMessage || block.component.options.text',
408
447
  },
409
448
  component: {
410
449
  name: 'Text',
@@ -423,7 +462,10 @@ registerComponent(FormComponent, {
423
462
  {
424
463
  '@type': '@builder.io/sdk:Element',
425
464
  responsiveStyles: { large: { marginTop: '10px' } },
426
- component: { name: 'Text', options: { text: '<span>Sending...</span>' } },
465
+ component: {
466
+ name: 'Text',
467
+ options: { text: '<span>Sending...</span>' },
468
+ },
427
469
  },
428
470
  ],
429
471
  },
@@ -432,7 +474,8 @@ registerComponent(FormComponent, {
432
474
  type: 'map',
433
475
  valueType: { type: 'string' },
434
476
  advanced: true,
435
- showIf: 'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true',
477
+ showIf:
478
+ 'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true',
436
479
  },
437
480
  ],
438
481
  noWrap: true,
@@ -441,22 +484,34 @@ registerComponent(FormComponent, {
441
484
  {
442
485
  '@type': '@builder.io/sdk:Element',
443
486
  responsiveStyles: { large: { marginTop: '10px' } },
444
- component: { name: 'Text', options: { text: '<span>Enter your name</span>' } },
487
+ component: {
488
+ name: 'Text',
489
+ options: { text: '<span>Enter your name</span>' },
490
+ },
445
491
  },
446
492
  {
447
493
  '@type': '@builder.io/sdk:Element',
448
494
  responsiveStyles: { large: { marginTop: '10px' } },
449
- component: { name: 'Form:Input', options: { name: 'name', placeholder: 'Jane Doe' } },
495
+ component: {
496
+ name: 'Form:Input',
497
+ options: { name: 'name', placeholder: 'Jane Doe' },
498
+ },
450
499
  },
451
500
  {
452
501
  '@type': '@builder.io/sdk:Element',
453
502
  responsiveStyles: { large: { marginTop: '10px' } },
454
- component: { name: 'Text', options: { text: '<span>Enter your email</span>' } },
503
+ component: {
504
+ name: 'Text',
505
+ options: { text: '<span>Enter your email</span>' },
506
+ },
455
507
  },
456
508
  {
457
509
  '@type': '@builder.io/sdk:Element',
458
510
  responsiveStyles: { large: { marginTop: '10px' } },
459
- component: { name: 'Form:Input', options: { name: 'email', placeholder: 'jane@doe.com' } },
511
+ component: {
512
+ name: 'Form:Input',
513
+ options: { name: 'email', placeholder: 'jane@doe.com' },
514
+ },
460
515
  },
461
516
  {
462
517
  '@type': '@builder.io/sdk:Element',
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { View, StyleSheet, Image, Text } from 'react-native';
3
- import { useState, useContext, useRef } from 'react';
3
+ import { useState, useRef } from 'react';
4
4
  import RenderBlock from '../components/render-block.lite';
5
5
 
6
6
  export default function FormComponent(props) {
@@ -31,9 +31,11 @@ export default function FormComponent(props) {
31
31
  let body;
32
32
  const formData = new FormData(el); // TODO: maybe support null
33
33
 
34
- const formPairs = Array.from(event.currentTarget.querySelectorAll('input,select,textarea'))
35
- .filter(el => !!el.name)
36
- .map(el => {
34
+ const formPairs = Array.from(
35
+ event.currentTarget.querySelectorAll('input,select,textarea')
36
+ )
37
+ .filter((el) => !!el.name)
38
+ .map((el) => {
37
39
  let value;
38
40
  const key = el.name;
39
41
 
@@ -126,7 +128,7 @@ export default function FormComponent(props) {
126
128
  : props.action /* TODO: throw error if no action URL */,
127
129
  { body, headers, method: props.method || 'post' }
128
130
  ).then(
129
- async res => {
131
+ async (res) => {
130
132
  let body;
131
133
  const contentType = res.headers.get('content-type');
132
134
  if (contentType && contentType.indexOf('application/json') !== -1) {
@@ -135,15 +137,12 @@ export default function FormComponent(props) {
135
137
  body = await res.text();
136
138
  }
137
139
  if (!res.ok && props.errorMessagePath) {
138
- /* TODO: allow supplying an error formatter function */ let message = get(
139
- body,
140
- props.errorMessagePath
141
- );
140
+ /* TODO: allow supplying an error formatter function */ let message =
141
+ get(body, props.errorMessagePath);
142
142
  if (message) {
143
143
  if (typeof message !== 'string') {
144
- /* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message = JSON.stringify(
145
- message
146
- );
144
+ /* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message =
145
+ JSON.stringify(message);
147
146
  }
148
147
  setFormErrorMessage(message);
149
148
  }
@@ -159,7 +158,9 @@ export default function FormComponent(props) {
159
158
  if (submitSuccessEvent.defaultPrevented) {
160
159
  return;
161
160
  }
162
- /* TODO: option to turn this on/off? */ if (props.resetFormOnSubmit !== false) {
161
+ /* TODO: option to turn this on/off? */ if (
162
+ props.resetFormOnSubmit !== false
163
+ ) {
163
164
  formRef.current.reset();
164
165
  }
165
166
  }
@@ -180,7 +181,7 @@ export default function FormComponent(props) {
180
181
  }
181
182
  }
182
183
  },
183
- err => {
184
+ (err) => {
184
185
  const submitErrorEvent = new CustomEvent('submit:error', {
185
186
  detail: { error: err },
186
187
  });
@@ -205,12 +206,12 @@ export default function FormComponent(props) {
205
206
  action={!props.sendWithJs && props.action}
206
207
  method={props.method}
207
208
  name={props.name}
208
- onSubmit={event => onSubmit(event)}
209
+ onSubmit={(event) => onSubmit(event)}
209
210
  >
210
211
  {' '}
211
212
  {props.builderBlock && props.builderBlock.children ? (
212
213
  <>
213
- {props.builderBlock?.children?.map(block => (
214
+ {props.builderBlock?.children?.map((block) => (
214
215
  <RenderBlock block={block} />
215
216
  ))}
216
217
  </>
@@ -222,7 +223,10 @@ export default function FormComponent(props) {
222
223
  ) : null}{' '}
223
224
  {submissionState() === 'sending' ? (
224
225
  <>
225
- <BuilderBlocks dataPath="sendingMessage" blocks={props.sendingMessage} />
226
+ <BuilderBlocks
227
+ dataPath="sendingMessage"
228
+ blocks={props.sendingMessage}
229
+ />
226
230
  </>
227
231
  ) : null}{' '}
228
232
  {submissionState() === 'error' && responseData ? (
@@ -235,7 +239,10 @@ export default function FormComponent(props) {
235
239
  ) : null}{' '}
236
240
  {submissionState() === 'success' ? (
237
241
  <>
238
- <BuilderBlocks dataPath="successMessage" blocks={props.successMessage} />
242
+ <BuilderBlocks
243
+ dataPath="successMessage"
244
+ blocks={props.successMessage}
245
+ />
239
246
  </>
240
247
  ) : null}{' '}
241
248
  </View>
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { View, StyleSheet, Image, Text } from 'react-native';
3
- import { useContext } from 'react';
4
3
 
5
4
  export default function FragmentComponent(props) {
6
5
  return (
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { View, StyleSheet, Image, Text } from 'react-native';
3
- import { useContext } from 'react';
4
3
 
5
4
  export default function Image(props) {
6
5
  return (
@@ -20,14 +19,17 @@ export default function Image(props) {
20
19
  <View srcSet={props.srcset} />
21
20
  </View>
22
21
 
23
- {props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length) ? (
22
+ {props.aspectRatio &&
23
+ !(props.fitContent && props.builderBlock?.children?.length) ? (
24
24
  <View className="builder-image-sizer" style={styles.view3}>
25
25
  <Text> </Text>
26
26
  </View>
27
27
  ) : null}
28
28
 
29
29
  {props.builderBlock?.children?.length && props.fitContent ? (
30
- <Text>{props.children}</Text>
30
+ <>
31
+ <Text>{props.children}</Text>
32
+ </>
31
33
  ) : null}
32
34
 
33
35
  {!props.fitContent ? (