@builder.io/sdk-react-native 0.0.1-32 → 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 (44) hide show
  1. package/package.json +1 -1
  2. package/src/blocks/button.js +10 -3
  3. package/src/blocks/button.lite.tsx +1 -0
  4. package/src/blocks/columns.js +17 -6
  5. package/src/blocks/columns.lite.tsx +1 -1
  6. package/src/blocks/custom-code.js +7 -4
  7. package/src/blocks/custom-code.lite.tsx +8 -4
  8. package/src/blocks/embed.js +7 -4
  9. package/src/blocks/embed.lite.tsx +5 -3
  10. package/src/blocks/form.js +88 -33
  11. package/src/blocks/form.lite.tsx +24 -17
  12. package/src/blocks/image.lite.tsx +5 -2
  13. package/src/blocks/img.js +8 -2
  14. package/src/blocks/input.js +10 -3
  15. package/src/blocks/input.lite.tsx +3 -1
  16. package/src/blocks/section.js +9 -4
  17. package/src/blocks/select.js +16 -5
  18. package/src/blocks/select.lite.tsx +4 -2
  19. package/src/blocks/submit-button.js +8 -2
  20. package/src/blocks/text.js +17 -4
  21. package/src/blocks/text.lite.tsx +6 -1
  22. package/src/blocks/textarea.js +10 -3
  23. package/src/blocks/video.js +8 -1
  24. package/src/components/render-block.js +25 -9
  25. package/src/components/render-block.lite.tsx +12 -4
  26. package/src/components/render-blocks.js +6 -4
  27. package/src/components/render-blocks.lite.tsx +3 -3
  28. package/src/components/render-content.js +41 -17
  29. package/src/components/render-content.lite.tsx +16 -7
  30. package/src/functions/evaluate.js +8 -7
  31. package/src/functions/get-block-actions.js +1 -1
  32. package/src/functions/get-block-component-options.js +8 -2
  33. package/src/functions/get-block-properties.js +9 -3
  34. package/src/functions/get-block-styles.js +20 -6
  35. package/src/functions/get-content.js +24 -11
  36. package/src/functions/get-content.test.js +6 -4
  37. package/src/functions/get-processed-block.js +8 -2
  38. package/src/functions/get-processed-block.test.js +5 -1
  39. package/src/functions/is-browser.js +5 -1
  40. package/src/functions/is-editing.js +3 -1
  41. package/src/functions/register-component.js +9 -3
  42. package/src/functions/set.js +5 -2
  43. package/src/index.js +9 -10
  44. package/src/scripts/init-editing.js +1 -1
@@ -5,10 +5,16 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
6
  var __defNormalProp = (obj, key, value) =>
7
7
  key in obj
8
- ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value })
8
+ ? __defProp(obj, key, {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value,
13
+ })
9
14
  : (obj[key] = value);
10
15
  var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
12
18
  if (__getOwnPropSymbols)
13
19
  for (var prop of __getOwnPropSymbols(b)) {
14
20
  if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
@@ -29,7 +35,7 @@ function validateReactNativeStyles(styles) {
29
35
  }
30
36
  delete styles[key];
31
37
  }
32
- if (typeof propertyValue === 'string' && propertyValue.match(/^\d/)) {
38
+ if (typeof propertyValue === 'string' && propertyValue.match(/^\-?\d/)) {
33
39
  const newValue = parseFloat(propertyValue);
34
40
  if (!isNaN(newValue)) {
35
41
  styles[key] = newValue;
@@ -38,9 +44,14 @@ function validateReactNativeStyles(styles) {
38
44
  styles[key] = 0;
39
45
  }
40
46
  }
41
- if (propertiesThatMustBeNumber.has(key) && typeof styles[key] !== 'number') {
47
+ if (
48
+ propertiesThatMustBeNumber.has(key) &&
49
+ typeof styles[key] !== 'number'
50
+ ) {
42
51
  if (SHOW_WARNINGS) {
43
- console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
52
+ console.warn(
53
+ `Style key ${key} must be a number, but had value \`${styles[key]}\``
54
+ );
44
55
  }
45
56
  delete styles[key];
46
57
  }
@@ -49,7 +60,10 @@ function validateReactNativeStyles(styles) {
49
60
  function getBlockStyles(block) {
50
61
  var _a, _b, _c;
51
62
  const styles = __spreadValues(
52
- __spreadValues({}, (_a = block.responsiveStyles) == null ? void 0 : _a.large),
63
+ __spreadValues(
64
+ {},
65
+ (_a = block.responsiveStyles) == null ? void 0 : _a.large
66
+ ),
53
67
  block.styles
54
68
  );
55
69
  if ((_b = block.responsiveStyles) == null ? void 0 : _b.medium) {
@@ -7,10 +7,16 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
8
  var __defNormalProp = (obj, key, value) =>
9
9
  key in obj
10
- ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value })
10
+ ? __defProp(obj, key, {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value,
15
+ })
11
16
  : (obj[key] = value);
12
17
  var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
18
+ for (var prop in b || (b = {}))
19
+ if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
14
20
  if (__getOwnPropSymbols)
15
21
  for (var prop of __getOwnPropSymbols(b)) {
16
22
  if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
@@ -20,22 +26,24 @@ var __spreadValues = (a, b) => {
20
26
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
27
  var __async = (__this, __arguments, generator) => {
22
28
  return new Promise((resolve, reject) => {
23
- var fulfilled = value => {
29
+ var fulfilled = (value) => {
24
30
  try {
25
31
  step(generator.next(value));
26
32
  } catch (e) {
27
33
  reject(e);
28
34
  }
29
35
  };
30
- var rejected = value => {
36
+ var rejected = (value) => {
31
37
  try {
32
38
  step(generator.throw(value));
33
39
  } catch (e) {
34
40
  reject(e);
35
41
  }
36
42
  };
37
- var step = x =>
38
- x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
43
+ var step = (x) =>
44
+ x.done
45
+ ? resolve(x.value)
46
+ : Promise.resolve(x.value).then(fulfilled, rejected);
39
47
  step((generator = generator.apply(__this, __arguments)).next());
40
48
  });
41
49
  };
@@ -51,15 +59,19 @@ function flatten(object, path = null, separator = '.') {
51
59
  !(Array.isArray(value) && value.length === 0),
52
60
  ].every(Boolean);
53
61
  return isObject
54
- ? __spreadValues(__spreadValues({}, acc), flatten(value, newPath, separator))
62
+ ? __spreadValues(
63
+ __spreadValues({}, acc),
64
+ flatten(value, newPath, separator)
65
+ )
55
66
  : __spreadProps(__spreadValues({}, acc), { [newPath]: value });
56
67
  }, {});
57
68
  }
58
69
  function getContent(options) {
59
70
  return __async(this, null, function* () {
60
71
  return (
61
- (yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }))).results[0] ||
62
- null
72
+ (yield getAllContent(
73
+ __spreadProps(__spreadValues({}, options), { limit: 1 })
74
+ )).results[0] || null
63
75
  );
64
76
  });
65
77
  }
@@ -92,7 +104,7 @@ function getAllContent(options) {
92
104
  url.searchParams.set(key, JSON.stringify(flattened[key]));
93
105
  }
94
106
  }
95
- const content = yield fetch(url.href).then(res => res.json());
107
+ const content = yield fetch(url.href).then((res) => res.json());
96
108
  if (testGroups) {
97
109
  for (const item of content.results) {
98
110
  if (item.variations && Object.keys(item.variations).length) {
@@ -112,7 +124,8 @@ function getAllContent(options) {
112
124
  n += testRatio;
113
125
  if (random < n) {
114
126
  const variationName =
115
- variation.name || (variation.id === item.id ? 'Default variation' : '');
127
+ variation.name ||
128
+ (variation.id === item.id ? 'Default variation' : '');
116
129
  set = true;
117
130
  Object.assign(item, {
118
131
  data: variation.data,
@@ -1,22 +1,24 @@
1
1
  import * as React from 'react';
2
2
  var __async = (__this, __arguments, generator) => {
3
3
  return new Promise((resolve, reject) => {
4
- var fulfilled = value => {
4
+ var fulfilled = (value) => {
5
5
  try {
6
6
  step(generator.next(value));
7
7
  } catch (e) {
8
8
  reject(e);
9
9
  }
10
10
  };
11
- var rejected = value => {
11
+ var rejected = (value) => {
12
12
  try {
13
13
  step(generator.throw(value));
14
14
  } catch (e) {
15
15
  reject(e);
16
16
  }
17
17
  };
18
- var step = x =>
19
- x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ var step = (x) =>
19
+ x.done
20
+ ? resolve(x.value)
21
+ : Promise.resolve(x.value).then(fulfilled, rejected);
20
22
  step((generator = generator.apply(__this, __arguments)).next());
21
23
  });
22
24
  };
@@ -7,10 +7,16 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
8
  var __defNormalProp = (obj, key, value) =>
9
9
  key in obj
10
- ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value })
10
+ ? __defProp(obj, key, {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value,
15
+ })
11
16
  : (obj[key] = value);
12
17
  var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
18
+ for (var prop in b || (b = {}))
19
+ if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
14
20
  if (__getOwnPropSymbols)
15
21
  for (var prop of __getOwnPropSymbols(b)) {
16
22
  if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
@@ -17,7 +17,11 @@ test('Can process bindings', () => {
17
17
  'properties.isEditing': 'builder.isEditing',
18
18
  },
19
19
  };
20
- const processed = getProcessedBlock({ block, context: {}, state: { test: 'hello' } });
20
+ const processed = getProcessedBlock({
21
+ block,
22
+ context: {},
23
+ state: { test: 'hello' },
24
+ });
21
25
  expect(processed).not.toEqual(block);
22
26
  expect(processed.properties.foo).toEqual('baz');
23
27
  expect(processed.properties.test).toEqual('hello');
@@ -1,6 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { isReactNative } from './is-react-native';
3
3
  function isBrowser() {
4
- return typeof window !== 'undefined' && typeof document !== 'undefined' && !isReactNative();
4
+ return (
5
+ typeof window !== 'undefined' &&
6
+ typeof document !== 'undefined' &&
7
+ !isReactNative()
8
+ );
5
9
  }
6
10
  export { isBrowser };
@@ -1,6 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { isIframe } from './is-iframe';
3
3
  function isEditing() {
4
- return isIframe() && window.location.search.indexOf('builder.frameEditing=') !== -1;
4
+ return (
5
+ isIframe() && window.location.search.indexOf('builder.frameEditing=') !== -1
6
+ );
5
7
  }
6
8
  export { isEditing };
@@ -7,10 +7,16 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
8
  var __defNormalProp = (obj, key, value) =>
9
9
  key in obj
10
- ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value })
10
+ ? __defProp(obj, key, {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value,
15
+ })
11
16
  : (obj[key] = value);
12
17
  var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
18
+ for (var prop in b || (b = {}))
19
+ if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
14
20
  if (__getOwnPropSymbols)
15
21
  for (var prop of __getOwnPropSymbols(b)) {
16
22
  if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
@@ -41,7 +47,7 @@ function prepareComponentInfoToSend(info) {
41
47
  return __spreadValues(
42
48
  __spreadValues({}, info),
43
49
  info.inputs && {
44
- inputs: info.inputs.map(input => {
50
+ inputs: info.inputs.map((input) => {
45
51
  const keysToConvertFnToString = ['onChange', 'showIf'];
46
52
  for (const key of keysToConvertFnToString) {
47
53
  if (input[key] && typeof input[key] === 'function') {
@@ -3,14 +3,17 @@ const set = (obj, _path, value) => {
3
3
  if (Object(obj) !== obj) {
4
4
  return obj;
5
5
  }
6
- const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
6
+ const path = Array.isArray(_path)
7
+ ? _path
8
+ : _path.toString().match(/[^.[\]]+/g);
7
9
  path
8
10
  .slice(0, -1)
9
11
  .reduce(
10
12
  (a, c, i) =>
11
13
  Object(a[c]) === a[c]
12
14
  ? a[c]
13
- : (a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}),
15
+ : (a[c] =
16
+ Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}),
14
17
  obj
15
18
  )[path[path.length - 1]] = value;
16
19
  return obj;
package/src/index.js CHANGED
@@ -6,22 +6,21 @@ if (isEditing()) {
6
6
  import { default as default2 } from './blocks/columns';
7
7
  import { default as default3 } from './blocks/image';
8
8
  import { default as default4 } from './blocks/text';
9
- import { default as default5 } from './blocks/video';
10
- import { default as default6 } from './blocks/symbol';
11
- import { default as default7 } from './blocks/section';
12
- import { default as default8 } from './blocks/fragment';
13
- import { default as default9 } from './components/render-content';
9
+ import { default as default5 } from './blocks/symbol';
10
+ import { default as default6 } from './blocks/section';
11
+ import { default as default7 } from './blocks/fragment';
12
+ import { default as default8 } from './components/render-content';
13
+ export * from './functions/is-editing';
14
14
  export * from './functions/register-component';
15
15
  export * from './functions/register';
16
16
  export * from './functions/set-editor-settings';
17
17
  export * from './functions/get-content';
18
18
  export {
19
19
  default2 as Columns,
20
- default8 as Fragment,
20
+ default7 as Fragment,
21
21
  default3 as Image,
22
- default9 as RenderContent,
23
- default7 as Section,
24
- default6 as Symbol,
22
+ default8 as RenderContent,
23
+ default6 as Section,
24
+ default5 as Symbol,
25
25
  default4 as Text,
26
- default5 as Video,
27
26
  };
@@ -62,7 +62,7 @@ if (isBrowser()) {
62
62
  } else {
63
63
  if (result && typeof result.then === 'function') {
64
64
  result
65
- .then(finalResult => {
65
+ .then((finalResult) => {
66
66
  var _a3;
67
67
  (_a3 = window.parent) == null
68
68
  ? void 0