@builder.io/sdk-react-native 0.4.5 → 0.5.1

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 (251) hide show
  1. package/dist/blocks/button/button.js +6 -2
  2. package/dist/blocks/button/component-info.js +4 -8
  3. package/dist/blocks/columns/columns.js +17 -21
  4. package/dist/blocks/columns/component-info.js +27 -48
  5. package/dist/blocks/custom-code/component-info.js +4 -8
  6. package/dist/blocks/custom-code/custom-code.js +1 -1
  7. package/dist/blocks/embed/component-info.js +7 -11
  8. package/dist/blocks/embed/embed.js +1 -1
  9. package/dist/blocks/embed/helpers.js +2 -6
  10. package/dist/blocks/form/component-info.js +33 -69
  11. package/dist/blocks/form/form.js +2 -203
  12. package/dist/blocks/fragment/fragment.js +1 -1
  13. package/dist/blocks/helpers.js +33 -0
  14. package/dist/blocks/image/component-info.js +21 -47
  15. package/dist/blocks/image/image.helpers.js +2 -2
  16. package/dist/blocks/img/component-info.js +2 -4
  17. package/dist/blocks/img/img.js +2 -1
  18. package/dist/blocks/input/component-info.js +8 -34
  19. package/dist/blocks/input/input.js +2 -1
  20. package/dist/blocks/raw-text/component-info.js +2 -4
  21. package/dist/blocks/raw-text/raw-text.js +3 -2
  22. package/dist/blocks/section/component-info.js +5 -10
  23. package/dist/blocks/section/section.js +2 -1
  24. package/dist/blocks/select/component-info.js +12 -24
  25. package/dist/blocks/select/select.js +2 -1
  26. package/dist/blocks/submit-button/component-info.js +2 -4
  27. package/dist/blocks/submit-button/submit-button.js +2 -1
  28. package/dist/blocks/symbol/component-info.js +7 -12
  29. package/dist/blocks/symbol/symbol.helpers.js +66 -0
  30. package/dist/blocks/symbol/symbol.js +23 -52
  31. package/dist/blocks/text/component-info.js +3 -4
  32. package/dist/blocks/textarea/component-info.js +6 -12
  33. package/dist/blocks/textarea/textarea.js +2 -1
  34. package/dist/blocks/video/component-info.js +21 -41
  35. package/dist/components/block/block.helpers.js +12 -23
  36. package/dist/components/block/block.js +40 -70
  37. package/dist/components/block/components/block-styles.js +1 -1
  38. package/dist/components/block/components/block-wrapper/block-wrapper.js +41 -0
  39. package/dist/components/block/components/block-wrapper.js +56 -0
  40. package/dist/components/block/components/component-ref/component-ref.helpers.js +40 -0
  41. package/dist/components/block/components/component-ref/component-ref.js +63 -0
  42. package/dist/components/block/components/component-ref.js +81 -0
  43. package/dist/components/block/components/interactive-element/interactive-element.helpers.js +35 -0
  44. package/dist/components/block/components/interactive-element/interactive-element.js +36 -0
  45. package/dist/components/block/components/interactive-element.js +46 -0
  46. package/dist/components/block/components/repeated-block.js +4 -4
  47. package/dist/components/blocks/blocks-wrapper.js +5 -2
  48. package/dist/components/blocks/blocks.js +9 -3
  49. package/dist/components/content/builder-editing.js +32 -0
  50. package/dist/components/content/components/enable-editor.js +30 -33
  51. package/dist/components/content/components/styles.helpers.js +55 -0
  52. package/dist/components/content/components/styles.js +61 -0
  53. package/dist/components/content/content.helpers.js +10 -3
  54. package/dist/components/content/content.js +27 -40
  55. package/dist/components/content/wrap-component-ref.js +1 -1
  56. package/dist/components/content-variants/content-variants.js +38 -34
  57. package/dist/components/content-variants/content-variants.types.js +1 -0
  58. package/dist/components/content-variants/helpers.js +61 -25
  59. package/dist/components/inlined-script.js +1 -1
  60. package/dist/components/inlined-styles.js +1 -1
  61. package/dist/constants/device-sizes.js +2 -2
  62. package/dist/constants/sdk-version.js +1 -1
  63. package/dist/context/builder.context.js +1 -1
  64. package/dist/context/components.context.js +6 -0
  65. package/dist/functions/apply-patch-with-mutation.js +75 -0
  66. package/dist/functions/apply-patch-with-mutation.test.js +55 -0
  67. package/dist/functions/camel-to-kebab-case.js +1 -1
  68. package/dist/functions/evaluate/acorn.js +1691 -0
  69. package/dist/functions/evaluate/evaluate.js +72 -0
  70. package/dist/functions/evaluate/index.js +5 -0
  71. package/dist/functions/evaluate/interpreter.js +2903 -0
  72. package/dist/functions/evaluate/non-node-runtime.js +97 -0
  73. package/dist/functions/evaluate/types.js +1 -0
  74. package/dist/functions/evaluate.test.js +12 -6
  75. package/dist/functions/event-handler-name.js +1 -1
  76. package/dist/functions/extract-text-styles.js +3 -9
  77. package/dist/functions/fast-clone.js +1 -1
  78. package/dist/functions/get-block-actions-handler.js +2 -2
  79. package/dist/functions/get-block-actions.js +14 -1
  80. package/dist/functions/get-block-component-options.js +6 -1
  81. package/dist/functions/get-block-properties.js +21 -8
  82. package/dist/functions/get-builder-search-params/fn.test.js +3 -3
  83. package/dist/functions/get-builder-search-params/index.js +4 -4
  84. package/dist/functions/get-content/generate-content-url.js +12 -5
  85. package/dist/functions/get-content/generate-content-url.test.js +31 -17
  86. package/dist/functions/get-content/index.js +36 -12
  87. package/dist/functions/get-content/processCookies.js +7 -0
  88. package/dist/functions/get-processed-block.js +8 -3
  89. package/dist/functions/get-processed-block.test.js +3 -1
  90. package/dist/functions/get-react-native-block-styles.js +6 -1
  91. package/dist/functions/is-non-node-server.js +12 -0
  92. package/dist/functions/on-change.test.js +13 -3
  93. package/dist/functions/register-component.js +24 -19
  94. package/dist/functions/sanitize-react-native-block-styles.js +17 -6
  95. package/dist/functions/set.test.js +9 -3
  96. package/dist/functions/track/helpers.js +5 -5
  97. package/dist/functions/track/index.js +29 -18
  98. package/dist/functions/track/interaction.js +10 -4
  99. package/dist/functions/transform-block-properties.js +2 -0
  100. package/dist/helpers/ab-tests.js +35 -14
  101. package/dist/helpers/canTrack.js +2 -2
  102. package/dist/helpers/css.js +2 -2
  103. package/dist/helpers/flatten.js +10 -7
  104. package/dist/helpers/nullable.js +1 -1
  105. package/dist/helpers/preview-lru-cache/get.js +11 -0
  106. package/dist/helpers/preview-lru-cache/helpers.js +13 -0
  107. package/dist/helpers/preview-lru-cache/init.js +13 -0
  108. package/dist/helpers/preview-lru-cache/set.js +37 -0
  109. package/dist/helpers/preview-lru-cache/types.js +1 -0
  110. package/dist/helpers/sessionId.js +13 -6
  111. package/dist/helpers/url.js +1 -1
  112. package/dist/helpers/visitorId.js +4 -1
  113. package/dist/index-helpers/blocks-exports.js +2 -2
  114. package/dist/scripts/init-editing.js +61 -46
  115. package/package.json +2 -2
  116. package/src/blocks/button/button.jsx +11 -2
  117. package/src/blocks/button/component-info.js +16 -22
  118. package/src/blocks/columns/columns.jsx +27 -26
  119. package/src/blocks/columns/component-info.js +203 -226
  120. package/src/blocks/custom-code/component-info.js +19 -25
  121. package/src/blocks/custom-code/custom-code.jsx +1 -1
  122. package/src/blocks/embed/component-info.js +31 -37
  123. package/src/blocks/embed/embed.jsx +1 -1
  124. package/src/blocks/embed/helpers.js +3 -9
  125. package/src/blocks/form/component-info.js +174 -212
  126. package/src/blocks/form/form.jsx +3 -247
  127. package/src/blocks/fragment/component-info.js +1 -3
  128. package/src/blocks/fragment/fragment.jsx +1 -1
  129. package/src/blocks/helpers.js +27 -0
  130. package/src/blocks/image/component-info.js +105 -133
  131. package/src/blocks/image/image.helpers.js +3 -5
  132. package/src/blocks/img/component-info.js +8 -12
  133. package/src/blocks/img/img.jsx +3 -1
  134. package/src/blocks/input/component-info.js +29 -57
  135. package/src/blocks/input/input.jsx +3 -1
  136. package/src/blocks/raw-text/component-info.js +7 -11
  137. package/src/blocks/raw-text/raw-text.jsx +4 -2
  138. package/src/blocks/section/component-info.js +24 -31
  139. package/src/blocks/section/section.jsx +3 -1
  140. package/src/blocks/select/component-info.js +34 -48
  141. package/src/blocks/select/select.jsx +3 -1
  142. package/src/blocks/submit-button/component-info.js +6 -10
  143. package/src/blocks/submit-button/submit-button.jsx +3 -2
  144. package/src/blocks/symbol/component-info.js +30 -37
  145. package/src/blocks/symbol/symbol.helpers.js +60 -0
  146. package/src/blocks/symbol/symbol.jsx +33 -61
  147. package/src/blocks/text/component-info.js +10 -13
  148. package/src/blocks/textarea/component-info.js +22 -30
  149. package/src/blocks/textarea/textarea.jsx +3 -1
  150. package/src/blocks/video/component-info.js +74 -96
  151. package/src/components/{render-block/render-block.helpers.js → block/block.helpers.js} +26 -44
  152. package/src/components/{render-block/render-block.jsx → block/block.jsx} +68 -81
  153. package/src/components/{render-block → block/components}/block-styles.jsx +18 -17
  154. package/src/components/block/components/block-wrapper.jsx +58 -0
  155. package/src/components/block/components/component-ref/component-ref.helpers.js +41 -0
  156. package/src/components/block/components/component-ref/component-ref.jsx +72 -0
  157. package/src/components/block/components/interactive-element.jsx +37 -0
  158. package/src/components/{render-block/render-repeated-block.jsx → block/components/repeated-block.jsx} +10 -6
  159. package/src/components/blocks/blocks-wrapper.jsx +74 -0
  160. package/src/components/blocks/blocks.jsx +61 -0
  161. package/src/components/{render-content/render-content.jsx → content/components/enable-editor.jsx} +77 -163
  162. package/src/components/{render-content/components/render-styles.helpers.js → content/components/styles.helpers.js} +6 -7
  163. package/src/components/{render-content/components/render-styles.jsx → content/components/styles.jsx} +5 -5
  164. package/src/components/{render-content/render-content.helpers.js → content/content.helpers.js} +15 -15
  165. package/src/components/content/content.jsx +148 -0
  166. package/src/components/content/index.js +2 -0
  167. package/src/components/content/wrap-component-ref.js +2 -0
  168. package/src/components/{render-content-variants/render-content-variants.jsx → content-variants/content-variants.jsx} +20 -23
  169. package/src/components/{render-content-variants → content-variants}/helpers.js +28 -40
  170. package/src/components/inlined-script.jsx +1 -1
  171. package/src/components/inlined-styles.jsx +1 -1
  172. package/src/constants/device-sizes.js +6 -6
  173. package/src/constants/sdk-version.js +1 -1
  174. package/src/context/builder.context.js +1 -1
  175. package/src/context/components.context.js +5 -0
  176. package/src/functions/apply-patch-with-mutation.js +66 -0
  177. package/src/functions/camel-to-kebab-case.js +2 -4
  178. package/src/functions/evaluate/acorn.js +1595 -0
  179. package/src/functions/{evaluate.js → evaluate/evaluate.js} +36 -10
  180. package/src/functions/evaluate/index.js +2 -0
  181. package/src/functions/evaluate/interpreter.js +2801 -0
  182. package/src/functions/evaluate/non-node-runtime.js +92 -0
  183. package/src/functions/evaluate/types.js +0 -0
  184. package/src/functions/event-handler-name.js +2 -4
  185. package/src/functions/extract-text-styles.js +4 -12
  186. package/src/functions/fast-clone.js +2 -4
  187. package/src/functions/get-block-actions-handler.js +3 -5
  188. package/src/functions/get-block-actions.js +15 -4
  189. package/src/functions/get-block-component-options.js +11 -12
  190. package/src/functions/get-block-properties.js +29 -19
  191. package/src/functions/get-builder-search-params/index.js +5 -10
  192. package/src/functions/get-content/generate-content-url.js +17 -19
  193. package/src/functions/get-content/index.js +43 -29
  194. package/src/functions/get-fetch.js +1 -3
  195. package/src/functions/get-global-this.js +1 -3
  196. package/src/functions/get-processed-block.js +12 -13
  197. package/src/functions/get-react-native-block-styles.js +11 -12
  198. package/src/functions/if-target.js +1 -3
  199. package/src/functions/is-browser.js +1 -3
  200. package/src/functions/is-editing.js +1 -3
  201. package/src/functions/is-iframe.js +1 -3
  202. package/src/functions/is-non-node-server.js +9 -0
  203. package/src/functions/is-previewing.js +1 -3
  204. package/src/functions/on-change.js +1 -4
  205. package/src/functions/register-component.js +34 -42
  206. package/src/functions/register.js +1 -3
  207. package/src/functions/sanitize-react-native-block-styles.js +22 -17
  208. package/src/functions/set-editor-settings.js +1 -3
  209. package/src/functions/set.js +1 -3
  210. package/src/functions/track/helpers.js +3 -5
  211. package/src/functions/track/index.js +45 -43
  212. package/src/functions/track/interaction.js +11 -7
  213. package/src/functions/transform-block-properties.js +2 -0
  214. package/src/helpers/ab-tests.js +45 -28
  215. package/src/helpers/canTrack.js +3 -5
  216. package/src/helpers/css.js +3 -7
  217. package/src/helpers/flatten.js +15 -18
  218. package/src/helpers/localStorage.js +1 -4
  219. package/src/helpers/logger.js +1 -3
  220. package/src/helpers/nullable.js +2 -4
  221. package/src/helpers/preview-lru-cache/get.js +8 -0
  222. package/src/helpers/preview-lru-cache/helpers.js +10 -0
  223. package/src/helpers/preview-lru-cache/init.js +10 -0
  224. package/src/helpers/preview-lru-cache/set.js +35 -0
  225. package/src/helpers/preview-lru-cache/types.js +0 -0
  226. package/src/helpers/sessionId.js +14 -11
  227. package/src/helpers/time.js +1 -3
  228. package/src/helpers/url.js +2 -4
  229. package/src/helpers/uuid.js +4 -6
  230. package/src/helpers/visitorId.js +8 -7
  231. package/src/index-helpers/blocks-exports.js +1 -1
  232. package/src/index.js +2 -17
  233. package/src/scripts/init-editing.js +62 -48
  234. package/src/types/api-version.js +1 -3
  235. package/src/types/builder-props.js +0 -0
  236. package/src/blocks/util.js +0 -8
  237. package/src/components/render-block/render-component.jsx +0 -55
  238. package/src/components/render-blocks.jsx +0 -101
  239. package/src/components/render-content/builder-editing.jsx +0 -16
  240. package/src/components/render-content/index.js +0 -4
  241. package/src/components/render-content/wrap-component-ref.js +0 -4
  242. package/src/functions/evaluate.test.js +0 -17
  243. package/src/functions/get-builder-search-params/fn.test.js +0 -13
  244. package/src/functions/get-content/generate-content-url.test.js +0 -97
  245. package/src/functions/get-processed-block.test.js +0 -34
  246. package/src/functions/on-change.test.js +0 -19
  247. package/src/functions/set.test.js +0 -16
  248. package/src/helpers/url.test.js +0 -21
  249. /package/src/components/{render-block → block}/types.js +0 -0
  250. /package/src/components/{render-content/render-content.types.js → content/content.types.js} +0 -0
  251. /package/src/components/{render-content-variants/render-content-variants.types.js → content-variants/content-variants.types.js} +0 -0
@@ -6,100 +6,78 @@ const componentInfo = {
6
6
  minWidth: "20px"
7
7
  },
8
8
  image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb",
9
- inputs: [
10
- {
11
- name: "video",
12
- type: "file",
13
- allowedFileTypes: ["mp4"],
14
- bubble: true,
15
- defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
16
- required: true
17
- },
18
- {
19
- name: "posterImage",
20
- type: "file",
21
- allowedFileTypes: ["jpeg", "png"],
22
- helperText: "Image to show before the video plays"
23
- },
24
- {
25
- name: "autoPlay",
26
- type: "boolean",
27
- defaultValue: true
28
- },
29
- {
30
- name: "controls",
31
- type: "boolean",
32
- defaultValue: false
33
- },
34
- {
35
- name: "muted",
36
- type: "boolean",
37
- defaultValue: true
38
- },
39
- {
40
- name: "loop",
41
- type: "boolean",
42
- defaultValue: true
43
- },
44
- {
45
- name: "playsInline",
46
- type: "boolean",
47
- defaultValue: true
48
- },
49
- {
50
- name: "fit",
51
- type: "text",
52
- defaultValue: "cover",
53
- enum: ["contain", "cover", "fill", "auto"]
54
- },
55
- {
56
- name: "fitContent",
57
- type: "boolean",
58
- helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
59
- defaultValue: true,
60
- advanced: true
61
- },
62
- {
63
- name: "position",
64
- type: "text",
65
- defaultValue: "center",
66
- enum: [
67
- "center",
68
- "top",
69
- "left",
70
- "right",
71
- "bottom",
72
- "top left",
73
- "top right",
74
- "bottom left",
75
- "bottom right"
76
- ]
77
- },
78
- {
79
- name: "height",
80
- type: "number",
81
- advanced: true
82
- },
83
- {
84
- name: "width",
85
- type: "number",
86
- advanced: true
87
- },
88
- {
89
- name: "aspectRatio",
90
- type: "number",
91
- advanced: true,
92
- defaultValue: 0.7004048582995948
93
- },
94
- {
95
- name: "lazyLoad",
96
- type: "boolean",
97
- helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
98
- defaultValue: true,
99
- advanced: true
100
- }
101
- ]
102
- };
103
- export {
104
- componentInfo
9
+ inputs: [{
10
+ name: "video",
11
+ type: "file",
12
+ allowedFileTypes: ["mp4"],
13
+ bubble: true,
14
+ defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
15
+ required: true
16
+ }, {
17
+ name: "posterImage",
18
+ type: "file",
19
+ allowedFileTypes: ["jpeg", "png"],
20
+ helperText: "Image to show before the video plays"
21
+ }, {
22
+ name: "autoPlay",
23
+ type: "boolean",
24
+ defaultValue: true
25
+ }, {
26
+ name: "controls",
27
+ type: "boolean",
28
+ defaultValue: false
29
+ }, {
30
+ name: "muted",
31
+ type: "boolean",
32
+ defaultValue: true
33
+ }, {
34
+ name: "loop",
35
+ type: "boolean",
36
+ defaultValue: true
37
+ }, {
38
+ name: "playsInline",
39
+ type: "boolean",
40
+ defaultValue: true
41
+ }, {
42
+ name: "fit",
43
+ type: "text",
44
+ defaultValue: "cover",
45
+ enum: ["contain", "cover", "fill", "auto"]
46
+ }, {
47
+ name: "preload",
48
+ type: "text",
49
+ defaultValue: "metadata",
50
+ enum: ["auto", "metadata", "none"]
51
+ }, {
52
+ name: "fitContent",
53
+ type: "boolean",
54
+ helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
55
+ defaultValue: true,
56
+ advanced: true
57
+ }, {
58
+ name: "position",
59
+ type: "text",
60
+ defaultValue: "center",
61
+ enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
62
+ }, {
63
+ name: "height",
64
+ type: "number",
65
+ advanced: true
66
+ }, {
67
+ name: "width",
68
+ type: "number",
69
+ advanced: true
70
+ }, {
71
+ name: "aspectRatio",
72
+ type: "number",
73
+ advanced: true,
74
+ defaultValue: 0.7004048582995948
75
+ }, {
76
+ name: "lazyLoad",
77
+ type: "boolean",
78
+ helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
79
+ defaultValue: true,
80
+ advanced: true
81
+ }]
105
82
  };
83
+ export { componentInfo }
@@ -4,56 +4,38 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value
12
+ }) : obj[key] = value;
8
13
  var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
14
+ for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
17
+ }
17
18
  return a;
18
19
  };
19
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
21
  var __objRest = (source, exclude) => {
21
22
  var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
23
+ for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop];
24
+ if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) {
25
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop];
26
+ }
30
27
  return target;
31
28
  };
32
29
  import { evaluate } from "../../functions/evaluate";
33
- import { getProcessedBlock } from "../../functions/get-processed-block";
34
- const EMPTY_HTML_ELEMENTS = [
35
- "area",
36
- "base",
37
- "br",
38
- "col",
39
- "embed",
40
- "hr",
41
- "img",
42
- "input",
43
- "keygen",
44
- "link",
45
- "meta",
46
- "param",
47
- "source",
48
- "track",
49
- "wbr"
50
- ];
51
- const isEmptyHtmlElement = (tagName) => {
30
+ import { getProcessedBlock } from "../../functions/get-processed-block.js";
31
+ const EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
32
+ const isEmptyHtmlElement = tagName => {
52
33
  return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
53
34
  };
54
35
  const getComponent = ({
55
36
  block,
56
- context
37
+ context,
38
+ registeredComponents
57
39
  }) => {
58
40
  var _a;
59
41
  const componentName = (_a = getProcessedBlock({
@@ -67,7 +49,7 @@ const getComponent = ({
67
49
  if (!componentName) {
68
50
  return null;
69
51
  }
70
- const ref = context.registeredComponents[componentName];
52
+ const ref = registeredComponents[componentName];
71
53
  if (!ref) {
72
54
  console.warn(`
73
55
  Could not find a registered component named "${componentName}".
@@ -81,7 +63,11 @@ const getRepeatItemData = ({
81
63
  block,
82
64
  context
83
65
  }) => {
84
- const _a = block, { repeat } = _a, blockWithoutRepeat = __objRest(_a, ["repeat"]);
66
+ const _a = block,
67
+ {
68
+ repeat
69
+ } = _a,
70
+ blockWithoutRepeat = __objRest(_a, ["repeat"]);
85
71
  if (!(repeat == null ? void 0 : repeat.collection)) {
86
72
  return void 0;
87
73
  }
@@ -110,8 +96,4 @@ const getRepeatItemData = ({
110
96
  }));
111
97
  return repeatArray;
112
98
  };
113
- export {
114
- getComponent,
115
- getRepeatItemData,
116
- isEmptyHtmlElement
117
- };
99
+ export { getComponent, getRepeatItemData, isEmptyHtmlElement }
@@ -1,4 +1,4 @@
1
- 'use client';
1
+ "use client";
2
2
  import * as React from "react";
3
3
  import {
4
4
  FlatList,
@@ -9,29 +9,28 @@ import {
9
9
  Text,
10
10
  } from "react-native";
11
11
  import { useState } from "react";
12
- import { getBlockActions } from "../../functions/get-block-actions.js";
13
12
  import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
14
13
  import { getBlockProperties } from "../../functions/get-block-properties.js";
15
14
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
16
- import BlockStyles from "./block-styles";
15
+ import BlockStyles from "./components/block-styles";
17
16
  import {
18
17
  getComponent,
19
18
  getRepeatItemData,
20
19
  isEmptyHtmlElement,
21
- } from "./render-block.helpers.js";
22
- import RenderRepeatedBlock from "./render-repeated-block";
23
- import { TARGET } from "../../constants/target.js";
20
+ } from "./block.helpers.js";
21
+ import RepeatedBlock from "./components/repeated-block";
24
22
  import { extractTextStyles } from "../../functions/extract-text-styles.js";
25
- import RenderComponent from "./render-component";
26
- import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
23
+ import ComponentRef from "./components/component-ref/component-ref";
24
+ import BlockWrapper from "./components/block-wrapper";
27
25
 
28
- function RenderBlock(props) {
29
- const [component, setComponent] = useState(() =>
30
- getComponent({
26
+ function Block(props) {
27
+ function blockComponent() {
28
+ return getComponent({
31
29
  block: props.block,
32
30
  context: props.context,
33
- })
34
- );
31
+ registeredComponents: props.registeredComponents,
32
+ });
33
+ }
35
34
 
36
35
  function repeatItem() {
37
36
  return getRepeatItemData({
@@ -40,7 +39,7 @@ function RenderBlock(props) {
40
39
  });
41
40
  }
42
41
 
43
- function useBlock() {
42
+ function processedBlock() {
44
43
  return repeatItem()
45
44
  ? props.block
46
45
  : getProcessedBlock({
@@ -53,44 +52,20 @@ function RenderBlock(props) {
53
52
  });
54
53
  }
55
54
 
56
- const [Tag, setTag] = useState(() => props.block.tagName || "div");
55
+ function Tag() {
56
+ return props.block.tagName || "div";
57
+ }
57
58
 
58
59
  function canShowBlock() {
59
- if ("hide" in useBlock()) {
60
- return !useBlock().hide;
60
+ if ("hide" in processedBlock()) {
61
+ return !processedBlock().hide;
61
62
  }
62
- if ("show" in useBlock()) {
63
- return useBlock().show;
63
+ if ("show" in processedBlock()) {
64
+ return processedBlock().show;
64
65
  }
65
66
  return true;
66
67
  }
67
68
 
68
- function actions() {
69
- return getBlockActions({
70
- block: useBlock(),
71
- rootState: props.context.rootState,
72
- rootSetState: props.context.rootSetState,
73
- localState: props.context.localState,
74
- context: props.context.context,
75
- });
76
- }
77
-
78
- function attributes() {
79
- const blockProperties = getBlockProperties(useBlock());
80
- return {
81
- ...blockProperties,
82
- ...(TARGET === "reactNative"
83
- ? {
84
- style: getReactNativeBlockStyles({
85
- block: useBlock(),
86
- context: props.context,
87
- blockStyles: blockProperties.style,
88
- }),
89
- }
90
- : {}),
91
- };
92
- }
93
-
94
69
  function childrenWithoutParentComponent() {
95
70
  /**
96
71
  * When there is no `componentRef`, there might still be children that need to be rendered. In this case,
@@ -99,30 +74,31 @@ function RenderBlock(props) {
99
74
  * blocks, and the children will be repeated within those blocks.
100
75
  */
101
76
  const shouldRenderChildrenOutsideRef =
102
- !component?.component && !repeatItem();
103
- return shouldRenderChildrenOutsideRef ? useBlock().children ?? [] : [];
77
+ !blockComponent?.()?.component && !repeatItem();
78
+ return shouldRenderChildrenOutsideRef
79
+ ? processedBlock().children ?? []
80
+ : [];
104
81
  }
105
82
 
106
- function renderComponentProps() {
83
+ function componentRefProps() {
107
84
  return {
108
- blockChildren: useBlock().children ?? [],
109
- componentRef: component?.component,
85
+ blockChildren: processedBlock().children ?? [],
86
+ componentRef: blockComponent?.()?.component,
110
87
  componentOptions: {
111
- ...getBlockComponentOptions(useBlock()),
112
- /**
113
- * These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
114
- * they are provided to the component itself directly.
115
- */
116
- ...(!component?.noWrap
117
- ? {}
118
- : {
119
- attributes: {
120
- ...attributes(),
121
- ...actions(),
122
- },
123
- }),
88
+ ...getBlockComponentOptions(processedBlock()),
89
+ builderContext: props.context,
90
+ ...(blockComponent?.()?.name === "Symbol" ||
91
+ blockComponent?.()?.name === "Columns"
92
+ ? {
93
+ builderComponents: props.registeredComponents,
94
+ }
95
+ : {}),
124
96
  },
125
97
  context: childrenContext,
98
+ registeredComponents: props.registeredComponents,
99
+ builderBlock: processedBlock(),
100
+ includeBlockProps: blockComponent?.()?.noWrap === true,
101
+ isInteractive: !blockComponent?.()?.isRSC,
126
102
  };
127
103
  }
128
104
 
@@ -134,13 +110,12 @@ function RenderBlock(props) {
134
110
  rootSetState: props.context.rootSetState,
135
111
  content: props.context.content,
136
112
  context: props.context.context,
137
- registeredComponents: props.context.registeredComponents,
113
+ componentInfos: props.context.componentInfos,
138
114
  inheritedStyles: extractTextStyles(
139
- getReactNativeBlockStyles({
140
- block: useBlock(),
115
+ getBlockProperties({
116
+ block: processedBlock(),
141
117
  context: props.context,
142
- blockStyles: attributes().style,
143
- })
118
+ }).style || {}
144
119
  ),
145
120
  }));
146
121
 
@@ -148,34 +123,46 @@ function RenderBlock(props) {
148
123
  <>
149
124
  {canShowBlock() ? (
150
125
  <>
151
- {!component?.noWrap ? (
126
+ {!blockComponent?.()?.noWrap ? (
152
127
  <>
153
- {isEmptyHtmlElement(Tag) ? (
128
+ {isEmptyHtmlElement(Tag()) ? (
154
129
  <>
155
- <Tag {...attributes()} {...actions()} />
130
+ <BlockWrapper
131
+ Wrapper={Tag()}
132
+ block={processedBlock()}
133
+ context={props.context}
134
+ hasChildren={false}
135
+ />
156
136
  </>
157
137
  ) : null}
158
- {!isEmptyHtmlElement(Tag) && repeatItem() ? (
138
+ {!isEmptyHtmlElement(Tag()) && repeatItem() ? (
159
139
  <>
160
140
  {repeatItem()?.map((data, index) => (
161
- <RenderRepeatedBlock
141
+ <RepeatedBlock
162
142
  key={index}
163
143
  repeatContext={data.context}
164
144
  block={data.block}
145
+ registeredComponents={props.registeredComponents}
165
146
  />
166
147
  ))}
167
148
  </>
168
149
  ) : null}
169
- {!isEmptyHtmlElement(Tag) && !repeatItem() ? (
150
+ {!isEmptyHtmlElement(Tag()) && !repeatItem() ? (
170
151
  <>
171
- <Tag {...attributes()} {...actions()}>
172
- <RenderComponent {...renderComponentProps()} />
152
+ <BlockWrapper
153
+ Wrapper={Tag()}
154
+ block={processedBlock()}
155
+ context={props.context}
156
+ hasChildren={true}
157
+ >
158
+ <ComponentRef {...componentRefProps()} />
173
159
 
174
160
  {childrenWithoutParentComponent()?.map((child) => (
175
- <RenderBlock
176
- key={"render-block-" + child.id}
161
+ <Block
162
+ key={"block-" + child.id}
177
163
  block={child}
178
164
  context={childrenContext}
165
+ registeredComponents={props.registeredComponents}
179
166
  />
180
167
  ))}
181
168
 
@@ -186,13 +173,13 @@ function RenderBlock(props) {
186
173
  context={childrenContext}
187
174
  />
188
175
  ))}
189
- </Tag>
176
+ </BlockWrapper>
190
177
  </>
191
178
  ) : null}
192
179
  </>
193
180
  ) : (
194
181
  <>
195
- <RenderComponent {...renderComponentProps()} />
182
+ <ComponentRef {...componentRefProps()} />
196
183
  </>
197
184
  )}
198
185
  </>
@@ -201,4 +188,4 @@ function RenderBlock(props) {
201
188
  );
202
189
  }
203
190
 
204
- export default RenderBlock;
191
+ export default Block;
@@ -1,4 +1,4 @@
1
- 'use client';
1
+ "use client";
2
2
  import * as React from "react";
3
3
  import {
4
4
  FlatList,
@@ -8,41 +8,42 @@ import {
8
8
  Image,
9
9
  Text,
10
10
  } from "react-native";
11
+ import { useState } from "react";
11
12
  import {
12
13
  getMaxWidthQueryForSize,
13
14
  getSizesForBreakpoints,
14
- } from "../../constants/device-sizes.js";
15
- import { TARGET } from "../../constants/target.js";
16
- import { getProcessedBlock } from "../../functions/get-processed-block.js";
17
- import { createCssClass } from "../../helpers/css.js";
18
- import { checkIsDefined } from "../../helpers/nullable.js";
19
- import InlinedStyles from "../inlined-styles";
15
+ } from "../../../constants/device-sizes.js";
16
+ import { TARGET } from "../../../constants/target.js";
17
+ import { getProcessedBlock } from "../../../functions/get-processed-block.js";
18
+ import { createCssClass } from "../../../helpers/css.js";
19
+ import { checkIsDefined } from "../../../helpers/nullable.js";
20
+ import InlinedStyles from "../../inlined-styles";
20
21
 
21
22
  function BlockStyles(props) {
22
- function useBlock() {
23
- return getProcessedBlock({
23
+ const [processedBlock, setProcessedBlock] = useState(() =>
24
+ getProcessedBlock({
24
25
  block: props.block,
25
26
  localState: props.context.localState,
26
27
  rootState: props.context.rootState,
27
28
  rootSetState: props.context.rootSetState,
28
29
  context: props.context.context,
29
30
  shouldEvaluateBindings: true,
30
- });
31
- }
31
+ })
32
+ );
32
33
 
33
34
  function canShowBlock() {
34
35
  // only render styles for blocks that are visible
35
- if (checkIsDefined(useBlock().hide)) {
36
- return !useBlock().hide;
36
+ if (checkIsDefined(processedBlock.hide)) {
37
+ return !processedBlock.hide;
37
38
  }
38
- if (checkIsDefined(useBlock().show)) {
39
- return useBlock().show;
39
+ if (checkIsDefined(processedBlock.show)) {
40
+ return processedBlock.show;
40
41
  }
41
42
  return true;
42
43
  }
43
44
 
44
45
  function css() {
45
- const styles = useBlock().responsiveStyles;
46
+ const styles = processedBlock.responsiveStyles;
46
47
  const content = props.context.content;
47
48
  const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(
48
49
  content?.meta?.breakpoints || {}
@@ -50,7 +51,7 @@ function BlockStyles(props) {
50
51
  const largeStyles = styles?.large;
51
52
  const mediumStyles = styles?.medium;
52
53
  const smallStyles = styles?.small;
53
- const className = useBlock().id;
54
+ const className = processedBlock.id;
54
55
  if (!className) {
55
56
  return "";
56
57
  }
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ import * as React from "react";
3
+ import {
4
+ FlatList,
5
+ ScrollView,
6
+ View,
7
+ StyleSheet,
8
+ Image,
9
+ Text,
10
+ } from "react-native";
11
+ import { getBlockActions } from "../../../functions/get-block-actions.js";
12
+ import { getBlockProperties } from "../../../functions/get-block-properties.js";
13
+
14
+ function BlockWrapper(props) {
15
+ return (
16
+ <>
17
+ {props.hasChildren ? (
18
+ <>
19
+ <props.Wrapper
20
+ {...getBlockProperties({
21
+ block: props.block,
22
+ context: props.context,
23
+ })}
24
+ {...getBlockActions({
25
+ block: props.block,
26
+ rootState: props.context.rootState,
27
+ rootSetState: props.context.rootSetState,
28
+ localState: props.context.localState,
29
+ context: props.context.context,
30
+ stripPrefix: true,
31
+ })}
32
+ >
33
+ {props.children}
34
+ </props.Wrapper>
35
+ </>
36
+ ) : (
37
+ <>
38
+ <props.Wrapper
39
+ {...getBlockProperties({
40
+ block: props.block,
41
+ context: props.context,
42
+ })}
43
+ {...getBlockActions({
44
+ block: props.block,
45
+ rootState: props.context.rootState,
46
+ rootSetState: props.context.rootSetState,
47
+ localState: props.context.localState,
48
+ context: props.context.context,
49
+ stripPrefix: true,
50
+ })}
51
+ />
52
+ </>
53
+ )}
54
+ </>
55
+ );
56
+ }
57
+
58
+ export default BlockWrapper;