@builder.io/sdk-react 0.1.1 → 0.1.3

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 (576) hide show
  1. package/dist/react/blocks/BaseText.js +7 -0
  2. package/dist/react/blocks/button/button.js +9 -0
  3. package/dist/react/blocks/button/component-info.js +39 -0
  4. package/dist/react/blocks/columns/columns.js +131 -0
  5. package/dist/react/blocks/columns/component-info.js +241 -0
  6. package/dist/react/blocks/custom-code/component-info.js +29 -0
  7. package/dist/react/blocks/custom-code/custom-code.js +49 -0
  8. package/dist/react/blocks/embed/component-info.js +44 -0
  9. package/dist/react/blocks/embed/embed.js +40 -0
  10. package/dist/react/blocks/embed/helpers.js +7 -0
  11. package/dist/react/blocks/form/component-info.js +260 -0
  12. package/dist/react/blocks/form/form.js +201 -0
  13. package/dist/react/blocks/fragment/component-info.js +9 -0
  14. package/dist/react/blocks/fragment/fragment.js +4 -0
  15. package/dist/react/blocks/image/component-info.js +149 -0
  16. package/dist/react/blocks/image/image.helpers.js +46 -0
  17. package/dist/react/blocks/image/image.js +82 -0
  18. package/dist/react/blocks/img/component-info.js +18 -0
  19. package/dist/react/blocks/img/img.js +8 -0
  20. package/dist/react/blocks/input/component-info.js +72 -0
  21. package/dist/react/blocks/input/input.js +5 -0
  22. package/dist/react/blocks/raw-text/component-info.js +14 -0
  23. package/dist/react/blocks/raw-text/raw-text.js +4 -0
  24. package/dist/react/blocks/section/component-info.js +47 -0
  25. package/dist/react/blocks/section/section.js +17 -0
  26. package/dist/react/blocks/select/component-info.js +57 -0
  27. package/dist/react/blocks/select/select.js +5 -0
  28. package/dist/react/blocks/submit-button/component-info.js +26 -0
  29. package/dist/react/blocks/submit-button/submit-button.js +4 -0
  30. package/dist/react/blocks/symbol/component-info.js +41 -0
  31. package/dist/react/blocks/symbol/symbol.js +63 -0
  32. package/dist/react/blocks/text/component-info.js +22 -0
  33. package/dist/react/blocks/text/text.js +4 -0
  34. package/dist/react/blocks/textarea/component-info.js +45 -0
  35. package/dist/react/blocks/textarea/textarea.js +4 -0
  36. package/dist/react/blocks/util.js +6 -0
  37. package/dist/react/blocks/video/component-info.js +104 -0
  38. package/dist/react/blocks/video/video.js +48 -0
  39. package/dist/react/components/render-block/block-styles.js +48 -0
  40. package/dist/react/components/render-block/render-block.helpers.js +104 -0
  41. package/dist/react/components/render-block/render-block.js +122 -0
  42. package/dist/react/components/render-block/render-component-with-context.js +27 -0
  43. package/dist/react/components/render-block/render-component.js +10 -0
  44. package/dist/react/components/render-block/render-repeated-block.js +15 -0
  45. package/dist/react/components/render-block/types.js +1 -0
  46. package/dist/react/components/render-blocks.js +45 -0
  47. package/dist/react/components/render-content/builder-editing.js +4 -0
  48. package/dist/react/components/render-content/components/render-styles.js +59 -0
  49. package/dist/react/components/render-content/index.js +2 -0
  50. package/dist/react/components/render-content/render-content.js +285 -0
  51. package/dist/react/components/render-inlined-styles.js +15 -0
  52. package/dist/react/constants/builder-registered-components.js +52 -0
  53. package/dist/react/constants/device-sizes.js +45 -0
  54. package/dist/react/constants/target.js +2 -0
  55. package/dist/react/context/builder.context.js +10 -0
  56. package/dist/react/context/types.js +1 -0
  57. package/dist/react/functions/camel-to-kebab-case.js +2 -0
  58. package/dist/react/functions/evaluate.js +22 -0
  59. package/dist/react/functions/event-handler-name.js +5 -0
  60. package/dist/react/functions/extract-text-styles.js +20 -0
  61. package/dist/react/functions/fast-clone.js +2 -0
  62. package/dist/react/functions/get-block-actions-handler.js +9 -0
  63. package/dist/react/functions/get-block-actions.js +16 -0
  64. package/dist/react/functions/get-block-component-options.js +26 -0
  65. package/dist/react/functions/get-block-properties.js +48 -0
  66. package/dist/react/functions/get-block-tag.js +4 -0
  67. package/dist/react/functions/get-builder-search-params/fn.test.js +13 -0
  68. package/dist/react/functions/get-builder-search-params/index.js +33 -0
  69. package/dist/react/functions/get-content/ab-testing.js +86 -0
  70. package/dist/react/functions/get-content/generate-content-url.js +41 -0
  71. package/dist/react/functions/get-content/generate-content-url.test.js +31 -0
  72. package/dist/react/functions/get-content/index.js +64 -0
  73. package/dist/react/functions/get-content/types.js +1 -0
  74. package/dist/react/functions/get-fetch.js +12 -0
  75. package/dist/react/functions/get-global-this.js +16 -0
  76. package/dist/react/functions/get-processed-block.js +49 -0
  77. package/dist/react/functions/get-processed-block.test.js +32 -0
  78. package/dist/react/functions/get-react-native-block-styles.js +27 -0
  79. package/dist/react/functions/if-target.js +10 -0
  80. package/dist/react/functions/is-browser.js +4 -0
  81. package/dist/react/functions/is-editing.js +5 -0
  82. package/dist/react/functions/is-iframe.js +5 -0
  83. package/dist/react/functions/is-previewing.js +12 -0
  84. package/dist/react/functions/on-change.js +24 -0
  85. package/dist/react/functions/on-change.test.js +19 -0
  86. package/dist/react/functions/register-component.js +60 -0
  87. package/dist/react/functions/register.js +28 -0
  88. package/dist/react/functions/sanitize-react-native-block-styles.js +68 -0
  89. package/dist/react/functions/set-editor-settings.js +13 -0
  90. package/dist/react/functions/set.js +9 -0
  91. package/dist/react/functions/set.test.js +16 -0
  92. package/dist/react/functions/track/helpers.js +50 -0
  93. package/dist/react/functions/track/index.js +120 -0
  94. package/dist/react/functions/track/interaction.js +48 -0
  95. package/dist/react/functions/track.js +116 -0
  96. package/dist/react/functions/transform-block-properties.js +4 -0
  97. package/dist/react/functions/transform-block.js +4 -0
  98. package/dist/react/helpers/ab-tests.js +6 -0
  99. package/dist/react/helpers/cookie.js +70 -0
  100. package/dist/react/helpers/css.js +28 -0
  101. package/dist/react/helpers/flatten.js +32 -0
  102. package/dist/react/helpers/localStorage.js +27 -0
  103. package/dist/react/helpers/nullable.js +2 -0
  104. package/dist/react/helpers/sessionId.js +46 -0
  105. package/dist/react/helpers/time.js +3 -0
  106. package/dist/react/helpers/url.js +11 -0
  107. package/dist/react/helpers/url.test.js +21 -0
  108. package/dist/react/helpers/uuid.js +10 -0
  109. package/dist/react/helpers/visitorId.js +28 -0
  110. package/dist/react/index-helpers/blocks-exports.js +11 -0
  111. package/dist/react/index-helpers/top-of-file.js +2 -0
  112. package/dist/react/index.js +12 -0
  113. package/dist/react/scripts/init-editing.js +93 -0
  114. package/dist/react/types/builder-block.js +1 -0
  115. package/dist/react/types/builder-content.js +1 -0
  116. package/dist/react/types/can-track.js +1 -0
  117. package/dist/react/types/components.js +1 -0
  118. package/dist/react/types/deep-partial.js +1 -0
  119. package/dist/react/types/element.js +1 -0
  120. package/dist/react/types/targets.js +1 -0
  121. package/dist/react/types/typescript.js +1 -0
  122. package/dist/rsc/blocks/BaseText.js +7 -0
  123. package/dist/rsc/blocks/button/button.js +10 -0
  124. package/dist/rsc/blocks/button/component-info.js +39 -0
  125. package/dist/rsc/blocks/columns/columns.js +136 -0
  126. package/dist/rsc/blocks/columns/component-info.js +241 -0
  127. package/dist/rsc/blocks/custom-code/component-info.js +29 -0
  128. package/dist/rsc/blocks/custom-code/custom-code.js +45 -0
  129. package/dist/rsc/blocks/embed/component-info.js +44 -0
  130. package/dist/rsc/blocks/embed/embed.js +36 -0
  131. package/dist/rsc/blocks/embed/helpers.js +7 -0
  132. package/dist/rsc/blocks/form/component-info.js +260 -0
  133. package/dist/rsc/blocks/form/form.js +204 -0
  134. package/dist/rsc/blocks/fragment/component-info.js +9 -0
  135. package/dist/rsc/blocks/fragment/fragment.js +5 -0
  136. package/dist/rsc/blocks/image/component-info.js +149 -0
  137. package/dist/rsc/blocks/image/image.helpers.js +46 -0
  138. package/dist/rsc/blocks/image/image.js +85 -0
  139. package/dist/rsc/blocks/img/component-info.js +18 -0
  140. package/dist/rsc/blocks/img/img.js +9 -0
  141. package/dist/rsc/blocks/input/component-info.js +72 -0
  142. package/dist/rsc/blocks/input/input.js +6 -0
  143. package/dist/rsc/blocks/raw-text/component-info.js +14 -0
  144. package/dist/rsc/blocks/raw-text/raw-text.js +5 -0
  145. package/dist/rsc/blocks/section/component-info.js +47 -0
  146. package/dist/rsc/blocks/section/section.js +18 -0
  147. package/dist/rsc/blocks/select/component-info.js +57 -0
  148. package/dist/rsc/blocks/select/select.js +6 -0
  149. package/dist/rsc/blocks/submit-button/component-info.js +26 -0
  150. package/dist/rsc/blocks/submit-button/submit-button.js +5 -0
  151. package/dist/rsc/blocks/symbol/component-info.js +41 -0
  152. package/dist/rsc/blocks/symbol/symbol.js +37 -0
  153. package/dist/rsc/blocks/text/component-info.js +22 -0
  154. package/dist/rsc/blocks/text/text.js +5 -0
  155. package/dist/rsc/blocks/textarea/component-info.js +45 -0
  156. package/dist/rsc/blocks/textarea/textarea.js +5 -0
  157. package/dist/rsc/blocks/util.js +6 -0
  158. package/dist/rsc/blocks/video/component-info.js +104 -0
  159. package/dist/rsc/blocks/video/video.js +51 -0
  160. package/dist/rsc/components/render-block/block-styles.js +51 -0
  161. package/dist/rsc/components/render-block/render-block.helpers.js +104 -0
  162. package/dist/rsc/components/render-block/render-block.js +126 -0
  163. package/dist/rsc/components/render-block/render-component-with-context.js +27 -0
  164. package/dist/rsc/components/render-block/render-component.js +11 -0
  165. package/dist/rsc/components/render-block/render-repeated-block.js +15 -0
  166. package/dist/rsc/components/render-block/types.js +1 -0
  167. package/dist/rsc/components/render-blocks.js +47 -0
  168. package/dist/rsc/components/render-content/builder-editing.js +5 -0
  169. package/dist/rsc/components/render-content/components/render-styles.js +62 -0
  170. package/dist/rsc/components/render-content/index.js +2 -0
  171. package/dist/rsc/components/render-content/render-content.js +201 -0
  172. package/dist/rsc/components/render-inlined-styles.js +18 -0
  173. package/dist/rsc/constants/builder-registered-components.js +52 -0
  174. package/dist/rsc/constants/device-sizes.js +45 -0
  175. package/dist/rsc/constants/target.js +2 -0
  176. package/dist/rsc/context/builder.context.js +9 -0
  177. package/dist/rsc/context/types.js +1 -0
  178. package/dist/rsc/functions/camel-to-kebab-case.js +2 -0
  179. package/dist/rsc/functions/evaluate.js +4 -0
  180. package/dist/rsc/functions/event-handler-name.js +5 -0
  181. package/dist/rsc/functions/extract-text-styles.js +20 -0
  182. package/dist/rsc/functions/fast-clone.js +2 -0
  183. package/dist/rsc/functions/get-block-actions-handler.js +9 -0
  184. package/dist/rsc/functions/get-block-actions.js +16 -0
  185. package/dist/rsc/functions/get-block-component-options.js +26 -0
  186. package/dist/rsc/functions/get-block-properties.js +48 -0
  187. package/dist/rsc/functions/get-block-tag.js +4 -0
  188. package/dist/rsc/functions/get-builder-search-params/fn.test.js +13 -0
  189. package/dist/rsc/functions/get-builder-search-params/index.js +33 -0
  190. package/dist/rsc/functions/get-content/ab-testing.js +86 -0
  191. package/dist/rsc/functions/get-content/generate-content-url.js +41 -0
  192. package/dist/rsc/functions/get-content/generate-content-url.test.js +31 -0
  193. package/dist/rsc/functions/get-content/index.js +64 -0
  194. package/dist/rsc/functions/get-content/types.js +1 -0
  195. package/dist/rsc/functions/get-fetch.js +12 -0
  196. package/dist/rsc/functions/get-global-this.js +16 -0
  197. package/dist/rsc/functions/get-processed-block.js +49 -0
  198. package/dist/rsc/functions/get-processed-block.test.js +32 -0
  199. package/dist/rsc/functions/get-react-native-block-styles.js +27 -0
  200. package/dist/rsc/functions/if-target.js +10 -0
  201. package/dist/rsc/functions/is-browser.js +4 -0
  202. package/dist/rsc/functions/is-editing.js +5 -0
  203. package/dist/rsc/functions/is-iframe.js +5 -0
  204. package/dist/rsc/functions/is-previewing.js +12 -0
  205. package/dist/rsc/functions/on-change.js +24 -0
  206. package/dist/rsc/functions/on-change.test.js +19 -0
  207. package/dist/rsc/functions/register-component.js +60 -0
  208. package/dist/rsc/functions/register.js +28 -0
  209. package/dist/rsc/functions/sanitize-react-native-block-styles.js +68 -0
  210. package/dist/rsc/functions/set-editor-settings.js +13 -0
  211. package/dist/rsc/functions/set.js +9 -0
  212. package/dist/rsc/functions/set.test.js +16 -0
  213. package/dist/rsc/functions/track/helpers.js +50 -0
  214. package/dist/rsc/functions/track/index.js +120 -0
  215. package/dist/rsc/functions/track/interaction.js +48 -0
  216. package/dist/rsc/functions/track.js +116 -0
  217. package/dist/rsc/functions/transform-block-properties.js +4 -0
  218. package/dist/rsc/functions/transform-block.js +4 -0
  219. package/dist/rsc/helpers/ab-tests.js +6 -0
  220. package/dist/rsc/helpers/cookie.js +70 -0
  221. package/dist/rsc/helpers/css.js +28 -0
  222. package/dist/rsc/helpers/flatten.js +32 -0
  223. package/dist/rsc/helpers/localStorage.js +27 -0
  224. package/dist/rsc/helpers/nullable.js +2 -0
  225. package/dist/rsc/helpers/sessionId.js +46 -0
  226. package/dist/rsc/helpers/time.js +3 -0
  227. package/dist/rsc/helpers/url.js +11 -0
  228. package/dist/rsc/helpers/url.test.js +21 -0
  229. package/dist/rsc/helpers/uuid.js +10 -0
  230. package/dist/rsc/helpers/visitorId.js +28 -0
  231. package/dist/rsc/index-helpers/blocks-exports.js +11 -0
  232. package/dist/rsc/index-helpers/top-of-file.js +2 -0
  233. package/dist/rsc/index.js +12 -0
  234. package/dist/rsc/scripts/init-editing.js +93 -0
  235. package/dist/rsc/types/builder-block.js +1 -0
  236. package/dist/rsc/types/builder-content.js +1 -0
  237. package/dist/rsc/types/can-track.js +1 -0
  238. package/dist/rsc/types/components.js +1 -0
  239. package/dist/rsc/types/deep-partial.js +1 -0
  240. package/dist/rsc/types/element.js +1 -0
  241. package/dist/rsc/types/targets.js +1 -0
  242. package/dist/rsc/types/typescript.js +1 -0
  243. package/package.json +11 -6
  244. package/packages/_rsc/src/blocks/BaseText.jsx +10 -0
  245. package/packages/_rsc/src/blocks/button/button.jsx +29 -0
  246. package/packages/_rsc/src/blocks/columns/{columns.js → columns.jsx} +80 -61
  247. package/packages/_rsc/src/blocks/custom-code/custom-code.jsx +55 -0
  248. package/packages/_rsc/src/blocks/embed/embed.jsx +43 -0
  249. package/packages/_rsc/src/blocks/form/form.jsx +259 -0
  250. package/packages/_rsc/src/blocks/fragment/fragment.jsx +7 -0
  251. package/packages/_rsc/src/blocks/image/image.jsx +124 -0
  252. package/packages/_rsc/src/blocks/img/img.jsx +19 -0
  253. package/packages/_rsc/src/blocks/input/input.jsx +21 -0
  254. package/packages/_rsc/src/blocks/raw-text/raw-text.jsx +12 -0
  255. package/packages/_rsc/src/blocks/section/section.jsx +29 -0
  256. package/packages/_rsc/src/blocks/select/select.jsx +22 -0
  257. package/packages/_rsc/src/blocks/submit-button/submit-button.jsx +11 -0
  258. package/packages/_rsc/src/blocks/symbol/symbol.jsx +56 -0
  259. package/packages/_rsc/src/blocks/text/text.jsx +12 -0
  260. package/packages/_rsc/src/blocks/textarea/textarea.jsx +15 -0
  261. package/packages/_rsc/src/blocks/video/video.jsx +61 -0
  262. package/packages/_rsc/src/components/render-block/block-styles.jsx +72 -0
  263. package/packages/_rsc/src/components/render-block/render-block.jsx +251 -0
  264. package/packages/_rsc/src/components/render-block/render-component-with-context.jsx +38 -0
  265. package/packages/_rsc/src/components/render-block/render-component.jsx +37 -0
  266. package/packages/_rsc/src/components/render-block/render-repeated-block.jsx +36 -0
  267. package/packages/_rsc/src/components/render-blocks.jsx +90 -0
  268. package/packages/_rsc/src/components/render-content/builder-editing.jsx +7 -0
  269. package/packages/_rsc/src/components/render-content/components/render-styles.jsx +70 -0
  270. package/packages/_rsc/src/components/render-content/render-content.jsx +259 -0
  271. package/packages/_rsc/src/components/render-inlined-styles.jsx +33 -0
  272. package/packages/_rsc/src/helpers/cookie.js +4 -2
  273. package/packages/_rsc/src/helpers/localStorage.js +1 -0
  274. package/packages/_rsc/src/helpers/sessionId.js +4 -1
  275. package/packages/_rsc/src/helpers/url.js +3 -0
  276. package/packages/_rsc/src/helpers/url.test.js +6 -0
  277. package/packages/_rsc/src/helpers/visitorId.js +1 -0
  278. package/packages/react/src/blocks/BaseText.jsx +9 -0
  279. package/packages/react/src/blocks/button/button.jsx +27 -0
  280. package/packages/react/src/blocks/button/component-info.js +41 -0
  281. package/packages/react/src/blocks/columns/columns.jsx +172 -0
  282. package/packages/react/src/blocks/columns/component-info.js +242 -0
  283. package/packages/react/src/blocks/custom-code/component-info.js +31 -0
  284. package/packages/react/src/blocks/custom-code/custom-code.jsx +64 -0
  285. package/packages/react/src/blocks/embed/component-info.js +44 -0
  286. package/packages/react/src/blocks/embed/embed.jsx +49 -0
  287. package/packages/react/src/blocks/embed/helpers.js +9 -0
  288. package/packages/react/src/blocks/form/component-info.js +262 -0
  289. package/packages/react/src/blocks/form/form.jsx +253 -0
  290. package/packages/react/src/blocks/fragment/component-info.js +11 -0
  291. package/packages/react/src/blocks/fragment/fragment.jsx +5 -0
  292. package/packages/react/src/blocks/image/component-info.js +151 -0
  293. package/packages/react/src/blocks/image/image.helpers.js +48 -0
  294. package/packages/react/src/blocks/image/image.jsx +120 -0
  295. package/packages/react/src/blocks/img/component-info.js +20 -0
  296. package/packages/react/src/blocks/img/img.jsx +17 -0
  297. package/packages/react/src/blocks/input/component-info.js +74 -0
  298. package/packages/react/src/blocks/input/input.jsx +19 -0
  299. package/packages/react/src/blocks/raw-text/component-info.js +16 -0
  300. package/packages/react/src/blocks/raw-text/raw-text.jsx +10 -0
  301. package/packages/react/src/blocks/section/component-info.js +49 -0
  302. package/packages/react/src/blocks/section/section.jsx +27 -0
  303. package/packages/react/src/blocks/select/component-info.js +59 -0
  304. package/packages/react/src/blocks/select/select.jsx +20 -0
  305. package/packages/react/src/blocks/submit-button/component-info.js +28 -0
  306. package/packages/react/src/blocks/submit-button/submit-button.jsx +9 -0
  307. package/packages/react/src/blocks/symbol/component-info.js +43 -0
  308. package/packages/react/src/blocks/symbol/symbol.jsx +86 -0
  309. package/packages/react/src/blocks/text/component-info.js +24 -0
  310. package/packages/react/src/blocks/text/text.jsx +10 -0
  311. package/packages/react/src/blocks/textarea/component-info.js +47 -0
  312. package/packages/react/src/blocks/textarea/textarea.jsx +13 -0
  313. package/packages/react/src/blocks/util.js +8 -0
  314. package/packages/react/src/blocks/video/component-info.js +106 -0
  315. package/packages/react/src/blocks/video/video.jsx +58 -0
  316. package/packages/react/src/components/render-block/block-styles.jsx +69 -0
  317. package/packages/react/src/components/render-block/render-block.helpers.js +113 -0
  318. package/packages/react/src/components/render-block/render-block.jsx +184 -0
  319. package/packages/react/src/components/render-block/render-component.jsx +33 -0
  320. package/packages/react/src/components/render-block/render-repeated-block.jsx +21 -0
  321. package/packages/react/src/components/render-block/types.js +0 -0
  322. package/packages/react/src/components/render-blocks.jsx +89 -0
  323. package/packages/react/src/components/render-content/builder-editing.jsx +5 -0
  324. package/packages/react/src/components/render-content/components/render-styles.jsx +64 -0
  325. package/packages/react/src/components/render-content/index.js +4 -0
  326. package/packages/react/src/components/render-content/render-content.jsx +372 -0
  327. package/packages/react/src/components/render-inlined-styles.jsx +28 -0
  328. package/packages/react/src/constants/builder-registered-components.js +54 -0
  329. package/packages/react/src/constants/device-sizes.js +48 -0
  330. package/packages/react/src/constants/target.js +4 -0
  331. package/packages/react/src/context/builder.context.js +12 -0
  332. package/packages/react/src/context/types.js +0 -0
  333. package/packages/react/src/functions/camel-to-kebab-case.js +4 -0
  334. package/packages/react/src/functions/evaluate.js +29 -0
  335. package/packages/react/src/functions/event-handler-name.js +7 -0
  336. package/packages/react/src/functions/extract-text-styles.js +22 -0
  337. package/packages/react/src/functions/fast-clone.js +4 -0
  338. package/packages/react/src/functions/get-block-actions-handler.js +11 -0
  339. package/packages/react/src/functions/get-block-actions.js +18 -0
  340. package/packages/{_rsc/src/blocks/textarea/textarea.js → react/src/functions/get-block-component-options.js} +6 -10
  341. package/packages/react/src/functions/get-block-properties.js +50 -0
  342. package/packages/react/src/functions/get-block-tag.js +6 -0
  343. package/packages/react/src/functions/get-builder-search-params/fn.test.js +13 -0
  344. package/packages/react/src/functions/get-builder-search-params/index.js +38 -0
  345. package/packages/react/src/functions/get-content/ab-testing.js +99 -0
  346. package/packages/react/src/functions/get-content/generate-content-url.js +55 -0
  347. package/packages/react/src/functions/get-content/generate-content-url.test.js +31 -0
  348. package/packages/react/src/functions/get-content/index.js +65 -0
  349. package/packages/react/src/functions/get-content/types.js +0 -0
  350. package/packages/react/src/functions/get-fetch.js +14 -0
  351. package/packages/react/src/functions/get-global-this.js +18 -0
  352. package/packages/react/src/functions/get-processed-block.js +59 -0
  353. package/packages/react/src/functions/get-processed-block.test.js +32 -0
  354. package/packages/{_rsc/src/blocks/BaseText.js → react/src/functions/get-react-native-block-styles.js} +14 -8
  355. package/packages/react/src/functions/if-target.js +15 -0
  356. package/packages/react/src/functions/is-browser.js +6 -0
  357. package/packages/react/src/functions/is-editing.js +7 -0
  358. package/packages/react/src/functions/is-iframe.js +7 -0
  359. package/packages/react/src/functions/is-previewing.js +14 -0
  360. package/packages/react/src/functions/on-change.js +27 -0
  361. package/packages/react/src/functions/on-change.test.js +19 -0
  362. package/packages/react/src/functions/register-component.js +68 -0
  363. package/packages/react/src/functions/register.js +29 -0
  364. package/packages/react/src/functions/sanitize-react-native-block-styles.js +66 -0
  365. package/packages/react/src/functions/set-editor-settings.js +15 -0
  366. package/packages/react/src/functions/set.js +11 -0
  367. package/packages/react/src/functions/set.test.js +16 -0
  368. package/packages/react/src/functions/track/helpers.js +50 -0
  369. package/packages/react/src/functions/track/index.js +128 -0
  370. package/packages/react/src/functions/track/interaction.js +53 -0
  371. package/packages/react/src/functions/transform-block-properties.js +6 -0
  372. package/packages/react/src/functions/transform-block.js +6 -0
  373. package/packages/react/src/helpers/ab-tests.js +16 -0
  374. package/packages/react/src/helpers/cookie.js +81 -0
  375. package/packages/react/src/helpers/css.js +34 -0
  376. package/packages/{_rsc/src/blocks/input/input.js → react/src/helpers/flatten.js} +12 -14
  377. package/packages/react/src/helpers/localStorage.js +35 -0
  378. package/packages/react/src/helpers/nullable.js +4 -0
  379. package/packages/react/src/helpers/sessionId.js +52 -0
  380. package/packages/react/src/helpers/time.js +5 -0
  381. package/packages/react/src/helpers/url.js +13 -0
  382. package/packages/react/src/helpers/url.test.js +21 -0
  383. package/packages/react/src/helpers/uuid.js +13 -0
  384. package/packages/react/src/helpers/visitorId.js +34 -0
  385. package/packages/react/src/index-helpers/blocks-exports.js +22 -0
  386. package/packages/react/src/index-helpers/top-of-file.js +4 -0
  387. package/packages/react/src/index.js +14 -0
  388. package/packages/react/src/scripts/init-editing.js +93 -0
  389. package/packages/react/src/types/builder-block.js +0 -0
  390. package/packages/react/src/types/builder-content.js +0 -0
  391. package/packages/react/src/types/can-track.js +0 -0
  392. package/packages/react/src/types/components.js +0 -0
  393. package/packages/react/src/types/deep-partial.js +0 -0
  394. package/packages/react/src/types/element.js +0 -0
  395. package/packages/react/src/types/targets.js +0 -0
  396. package/packages/react/src/types/typescript.js +0 -0
  397. package/packages/rsc/src/blocks/BaseText.jsx +10 -0
  398. package/packages/rsc/src/blocks/button/button.jsx +29 -0
  399. package/packages/rsc/src/blocks/button/component-info.js +41 -0
  400. package/packages/rsc/src/blocks/columns/columns.jsx +172 -0
  401. package/packages/rsc/src/blocks/columns/component-info.js +242 -0
  402. package/packages/rsc/src/blocks/custom-code/component-info.js +31 -0
  403. package/packages/rsc/src/blocks/custom-code/custom-code.jsx +55 -0
  404. package/packages/rsc/src/blocks/embed/component-info.js +44 -0
  405. package/packages/rsc/src/blocks/embed/embed.jsx +43 -0
  406. package/packages/rsc/src/blocks/embed/helpers.js +9 -0
  407. package/packages/rsc/src/blocks/form/component-info.js +262 -0
  408. package/packages/rsc/src/blocks/form/form.jsx +259 -0
  409. package/packages/rsc/src/blocks/fragment/component-info.js +11 -0
  410. package/packages/rsc/src/blocks/fragment/fragment.jsx +7 -0
  411. package/packages/rsc/src/blocks/image/component-info.js +151 -0
  412. package/packages/rsc/src/blocks/image/image.helpers.js +48 -0
  413. package/packages/rsc/src/blocks/image/image.jsx +122 -0
  414. package/packages/rsc/src/blocks/img/component-info.js +20 -0
  415. package/packages/rsc/src/blocks/img/img.jsx +19 -0
  416. package/packages/rsc/src/blocks/input/component-info.js +74 -0
  417. package/packages/rsc/src/blocks/input/input.jsx +21 -0
  418. package/packages/rsc/src/blocks/raw-text/component-info.js +16 -0
  419. package/packages/rsc/src/blocks/raw-text/raw-text.jsx +12 -0
  420. package/packages/rsc/src/blocks/section/component-info.js +49 -0
  421. package/packages/rsc/src/blocks/section/section.jsx +29 -0
  422. package/packages/rsc/src/blocks/select/component-info.js +59 -0
  423. package/packages/rsc/src/blocks/select/select.jsx +22 -0
  424. package/packages/rsc/src/blocks/submit-button/component-info.js +28 -0
  425. package/packages/rsc/src/blocks/submit-button/submit-button.jsx +11 -0
  426. package/packages/rsc/src/blocks/symbol/component-info.js +43 -0
  427. package/packages/rsc/src/blocks/symbol/symbol.jsx +56 -0
  428. package/packages/rsc/src/blocks/text/component-info.js +24 -0
  429. package/packages/rsc/src/blocks/text/text.jsx +12 -0
  430. package/packages/rsc/src/blocks/textarea/component-info.js +47 -0
  431. package/packages/rsc/src/blocks/textarea/textarea.jsx +15 -0
  432. package/packages/rsc/src/blocks/util.js +8 -0
  433. package/packages/rsc/src/blocks/video/component-info.js +106 -0
  434. package/packages/rsc/src/blocks/video/video.jsx +61 -0
  435. package/packages/rsc/src/components/render-block/block-styles.jsx +72 -0
  436. package/packages/rsc/src/components/render-block/render-block.helpers.js +113 -0
  437. package/packages/rsc/src/components/render-block/render-block.jsx +183 -0
  438. package/packages/rsc/src/components/render-block/render-component.jsx +37 -0
  439. package/packages/rsc/src/components/render-block/render-repeated-block.jsx +24 -0
  440. package/packages/rsc/src/components/render-block/types.js +0 -0
  441. package/packages/rsc/src/components/render-blocks.jsx +90 -0
  442. package/packages/rsc/src/components/render-content/builder-editing.jsx +7 -0
  443. package/packages/rsc/src/components/render-content/components/render-styles.jsx +70 -0
  444. package/packages/rsc/src/components/render-content/index.js +4 -0
  445. package/packages/rsc/src/components/render-content/render-content.jsx +245 -0
  446. package/packages/rsc/src/components/render-inlined-styles.jsx +33 -0
  447. package/packages/rsc/src/constants/builder-registered-components.js +54 -0
  448. package/packages/rsc/src/constants/device-sizes.js +48 -0
  449. package/packages/rsc/src/constants/target.js +4 -0
  450. package/packages/rsc/src/context/builder.context.js +11 -0
  451. package/packages/rsc/src/context/types.js +0 -0
  452. package/packages/rsc/src/functions/camel-to-kebab-case.js +4 -0
  453. package/packages/rsc/src/functions/evaluate.js +6 -0
  454. package/packages/rsc/src/functions/event-handler-name.js +7 -0
  455. package/packages/rsc/src/functions/extract-text-styles.js +22 -0
  456. package/packages/rsc/src/functions/fast-clone.js +4 -0
  457. package/packages/rsc/src/functions/get-block-actions-handler.js +11 -0
  458. package/packages/rsc/src/functions/get-block-actions.js +18 -0
  459. package/packages/{_rsc/src/blocks/text/text.js → rsc/src/functions/get-block-component-options.js} +8 -7
  460. package/packages/rsc/src/functions/get-block-properties.js +50 -0
  461. package/packages/rsc/src/functions/get-block-tag.js +6 -0
  462. package/packages/rsc/src/functions/get-builder-search-params/fn.test.js +13 -0
  463. package/packages/rsc/src/functions/get-builder-search-params/index.js +38 -0
  464. package/packages/rsc/src/functions/get-content/ab-testing.js +99 -0
  465. package/packages/rsc/src/functions/get-content/generate-content-url.js +55 -0
  466. package/packages/rsc/src/functions/get-content/generate-content-url.test.js +31 -0
  467. package/packages/rsc/src/functions/get-content/index.js +65 -0
  468. package/packages/rsc/src/functions/get-content/types.js +0 -0
  469. package/packages/rsc/src/functions/get-fetch.js +14 -0
  470. package/packages/rsc/src/functions/get-global-this.js +18 -0
  471. package/packages/rsc/src/functions/get-processed-block.js +59 -0
  472. package/packages/rsc/src/functions/get-processed-block.test.js +32 -0
  473. package/packages/{_rsc/src/blocks/raw-text/raw-text.js → rsc/src/functions/get-react-native-block-styles.js} +14 -9
  474. package/packages/rsc/src/functions/if-target.js +15 -0
  475. package/packages/rsc/src/functions/is-browser.js +6 -0
  476. package/packages/rsc/src/functions/is-editing.js +7 -0
  477. package/packages/rsc/src/functions/is-iframe.js +7 -0
  478. package/packages/rsc/src/functions/is-previewing.js +14 -0
  479. package/packages/rsc/src/functions/on-change.js +27 -0
  480. package/packages/rsc/src/functions/on-change.test.js +19 -0
  481. package/packages/rsc/src/functions/register-component.js +68 -0
  482. package/packages/rsc/src/functions/register.js +29 -0
  483. package/packages/rsc/src/functions/sanitize-react-native-block-styles.js +66 -0
  484. package/packages/rsc/src/functions/set-editor-settings.js +15 -0
  485. package/packages/rsc/src/functions/set.js +11 -0
  486. package/packages/rsc/src/functions/set.test.js +16 -0
  487. package/packages/rsc/src/functions/track/helpers.js +50 -0
  488. package/packages/rsc/src/functions/track/index.js +128 -0
  489. package/packages/rsc/src/functions/track/interaction.js +53 -0
  490. package/packages/rsc/src/functions/transform-block-properties.js +6 -0
  491. package/packages/rsc/src/functions/transform-block.js +6 -0
  492. package/packages/rsc/src/helpers/ab-tests.js +16 -0
  493. package/packages/rsc/src/helpers/cookie.js +81 -0
  494. package/packages/rsc/src/helpers/css.js +34 -0
  495. package/packages/{_rsc/src/blocks/section/section.js → rsc/src/helpers/flatten.js} +12 -18
  496. package/packages/rsc/src/helpers/localStorage.js +35 -0
  497. package/packages/rsc/src/helpers/nullable.js +4 -0
  498. package/packages/rsc/src/helpers/sessionId.js +52 -0
  499. package/packages/rsc/src/helpers/time.js +5 -0
  500. package/packages/rsc/src/helpers/url.js +13 -0
  501. package/packages/rsc/src/helpers/url.test.js +21 -0
  502. package/packages/rsc/src/helpers/uuid.js +13 -0
  503. package/packages/rsc/src/helpers/visitorId.js +34 -0
  504. package/packages/rsc/src/index-helpers/blocks-exports.js +22 -0
  505. package/packages/rsc/src/index-helpers/top-of-file.js +2 -0
  506. package/packages/rsc/src/index.js +14 -0
  507. package/packages/rsc/src/scripts/init-editing.js +93 -0
  508. package/packages/rsc/src/types/builder-block.js +0 -0
  509. package/packages/rsc/src/types/builder-content.js +0 -0
  510. package/packages/rsc/src/types/can-track.js +0 -0
  511. package/packages/rsc/src/types/components.js +0 -0
  512. package/packages/rsc/src/types/deep-partial.js +0 -0
  513. package/packages/rsc/src/types/element.js +0 -0
  514. package/packages/rsc/src/types/targets.js +0 -0
  515. package/packages/rsc/src/types/typescript.js +0 -0
  516. package/src/blocks/BaseText.jsx +4 -7
  517. package/src/blocks/button/button.jsx +25 -32
  518. package/src/blocks/columns/columns.jsx +83 -59
  519. package/src/blocks/custom-code/custom-code.jsx +29 -15
  520. package/src/blocks/embed/embed.jsx +15 -11
  521. package/src/blocks/form/form.jsx +184 -148
  522. package/src/blocks/fragment/fragment.jsx +3 -5
  523. package/src/blocks/image/image.jsx +80 -56
  524. package/src/blocks/img/img.jsx +14 -29
  525. package/src/blocks/input/input.jsx +16 -32
  526. package/src/blocks/raw-text/raw-text.jsx +8 -9
  527. package/src/blocks/section/section.jsx +25 -37
  528. package/src/blocks/select/select.jsx +17 -32
  529. package/src/blocks/submit-button/submit-button.jsx +7 -23
  530. package/src/blocks/symbol/symbol.jsx +59 -48
  531. package/src/blocks/text/text.jsx +8 -8
  532. package/src/blocks/textarea/textarea.jsx +11 -29
  533. package/src/blocks/video/video.jsx +52 -48
  534. package/src/components/render-block/block-styles.jsx +48 -29
  535. package/src/components/render-block/render-block.jsx +150 -100
  536. package/src/components/render-block/render-component-with-context.jsx +35 -32
  537. package/src/components/render-block/render-component.jsx +30 -32
  538. package/src/components/render-block/render-repeated-block.jsx +30 -30
  539. package/src/components/render-blocks.jsx +73 -47
  540. package/src/components/render-content/builder-editing.jsx +3 -5
  541. package/src/components/render-content/components/render-styles.jsx +21 -15
  542. package/src/components/render-content/index.js +1 -1
  543. package/src/components/render-content/render-content.jsx +209 -134
  544. package/src/components/render-inlined-styles.jsx +19 -8
  545. package/src/constants/builder-registered-components.js +11 -11
  546. package/src/helpers/cookie.js +4 -2
  547. package/src/helpers/localStorage.js +1 -0
  548. package/src/helpers/sessionId.js +4 -1
  549. package/src/helpers/url.js +3 -0
  550. package/src/helpers/url.test.js +6 -0
  551. package/src/helpers/visitorId.js +1 -0
  552. package/src/index-helpers/blocks-exports.js +10 -10
  553. package/tsconfig.base.json +18 -0
  554. package/tsconfig.react.json +7 -0
  555. package/tsconfig.rsc.json +7 -0
  556. package/packages/_rsc/src/blocks/button/button.js +0 -35
  557. package/packages/_rsc/src/blocks/custom-code/custom-code.js +0 -63
  558. package/packages/_rsc/src/blocks/embed/embed.js +0 -55
  559. package/packages/_rsc/src/blocks/form/form.js +0 -222
  560. package/packages/_rsc/src/blocks/fragment/fragment.js +0 -24
  561. package/packages/_rsc/src/blocks/image/image.js +0 -101
  562. package/packages/_rsc/src/blocks/img/img.js +0 -33
  563. package/packages/_rsc/src/blocks/select/select.js +0 -36
  564. package/packages/_rsc/src/blocks/submit-button/submit-button.js +0 -26
  565. package/packages/_rsc/src/blocks/symbol/symbol.js +0 -60
  566. package/packages/_rsc/src/blocks/video/video.js +0 -57
  567. package/packages/_rsc/src/components/render-block/block-styles.js +0 -70
  568. package/packages/_rsc/src/components/render-block/render-block.js +0 -211
  569. package/packages/_rsc/src/components/render-block/render-component-with-context.js +0 -51
  570. package/packages/_rsc/src/components/render-block/render-component.js +0 -43
  571. package/packages/_rsc/src/components/render-block/render-repeated-block.js +0 -49
  572. package/packages/_rsc/src/components/render-blocks.js +0 -80
  573. package/packages/_rsc/src/components/render-content/builder-editing.js +0 -35
  574. package/packages/_rsc/src/components/render-content/components/render-styles.js +0 -78
  575. package/packages/_rsc/src/components/render-content/render-content.js +0 -215
  576. package/packages/_rsc/src/components/render-inlined-styles.js +0 -36
@@ -0,0 +1,259 @@
1
+ import * as React from "react";
2
+ import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
3
+ import { TARGET } from "../../constants/target.js";
4
+ import { evaluate } from "../../functions/evaluate.js";
5
+ import { getContent } from "../../functions/get-content/index.js";
6
+ import { fetch } from "../../functions/get-fetch.js";
7
+ import { isBrowser } from "../../functions/is-browser.js";
8
+ import { isEditing } from "../../functions/is-editing.js";
9
+ import { isPreviewing } from "../../functions/is-previewing.js";
10
+ import {
11
+ components,
12
+ createRegisterComponentMessage,
13
+ } from "../../functions/register-component.js";
14
+ import { _track } from "../../functions/track.js";
15
+ import RenderBlocks from "../render-blocks.js";
16
+ import RenderContentStyles from "./components/render-styles.js";
17
+ import BuilderContext from "../../context/builder.context.js";
18
+ import {
19
+ registerInsertMenu,
20
+ setupBrowserForEditing,
21
+ } from "../../scripts/init-editing.js";
22
+ import { checkIsDefined } from "../../helpers/nullable.js";
23
+
24
+ export default function RenderContent(props) {
25
+ const _context = { ...props["_context"] };
26
+
27
+ const state = {
28
+ forceReRenderCount: 0,
29
+ overrideContent: null,
30
+ get useContent() {
31
+ if (!props.content && !state.overrideContent) {
32
+ return undefined;
33
+ }
34
+ const mergedContent = {
35
+ ...props.content,
36
+ ...state.overrideContent,
37
+ data: {
38
+ ...props.content?.data,
39
+ ...props.data,
40
+ ...state.overrideContent?.data,
41
+ },
42
+ meta: {
43
+ ...props.content?.meta,
44
+ ...state.overrideContent?.meta,
45
+ breakpoints:
46
+ state.useBreakpoints ||
47
+ state.overrideContent?.meta?.breakpoints ||
48
+ props.content?.meta?.breakpoints,
49
+ },
50
+ };
51
+ return mergedContent;
52
+ },
53
+ update: 0,
54
+ useBreakpoints: null,
55
+ get canTrackToUse() {
56
+ return checkIsDefined(props.canTrack) ? props.canTrack : true;
57
+ },
58
+ overrideState: {},
59
+ get contentState() {
60
+ return {
61
+ ...props.content?.data?.state,
62
+ ...props.data,
63
+ ...(props.locale
64
+ ? {
65
+ locale: props.locale,
66
+ }
67
+ : {}),
68
+ ...state.overrideState,
69
+ };
70
+ },
71
+ get contextContext() {
72
+ return props.context || {};
73
+ },
74
+ get allRegisteredComponents() {
75
+ const allComponentsArray = [
76
+ ...getDefaultRegisteredComponents(),
77
+ // While this `components` object is deprecated, we must maintain support for it.
78
+ // Since users are able to override our default components, we need to make sure that we do not break such
79
+ // existing usage.
80
+ // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
81
+ // which is the new standard way of providing custom components, and must therefore take precedence.
82
+ ...components,
83
+ ...(props.customComponents || []),
84
+ ];
85
+ const allComponents = allComponentsArray.reduce(
86
+ (acc, curr) => ({
87
+ ...acc,
88
+ [curr.name]: curr,
89
+ }),
90
+ {}
91
+ );
92
+ return allComponents;
93
+ },
94
+ processMessage(event) {
95
+ const { data } = event;
96
+ if (data) {
97
+ switch (data.type) {
98
+ case "builder.configureSdk": {
99
+ const messageContent = data.data;
100
+ const { breakpoints, contentId } = messageContent;
101
+ if (!contentId || contentId !== state.useContent?.id) {
102
+ return;
103
+ }
104
+ state.useBreakpoints = breakpoints;
105
+ state.forceReRenderCount = state.forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
106
+ break;
107
+ }
108
+ case "builder.contentUpdate": {
109
+ const messageContent = data.data;
110
+ const key =
111
+ messageContent.key ||
112
+ messageContent.alias ||
113
+ messageContent.entry ||
114
+ messageContent.modelName;
115
+ const contentData = messageContent.data;
116
+ if (key === props.model) {
117
+ state.overrideContent = contentData;
118
+ state.forceReRenderCount = state.forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
119
+ }
120
+
121
+ break;
122
+ }
123
+ case "builder.patchUpdates": {
124
+ // TODO
125
+ break;
126
+ }
127
+ }
128
+ }
129
+ },
130
+ evaluateJsCode() {
131
+ // run any dynamic JS code attached to content
132
+ const jsCode = state.useContent?.data?.jsCode;
133
+ if (jsCode) {
134
+ evaluate({
135
+ code: jsCode,
136
+ context: state.contextContext,
137
+ state: state.contentState,
138
+ });
139
+ }
140
+ },
141
+ get httpReqsData() {
142
+ return {};
143
+ },
144
+ onClick(_event) {
145
+ if (state.useContent) {
146
+ const variationId = state.useContent?.testVariationId;
147
+ const contentId = state.useContent?.id;
148
+ _track({
149
+ type: "click",
150
+ canTrack: state.canTrackToUse,
151
+ contentId,
152
+ apiKey: props.apiKey,
153
+ variationId: variationId !== contentId ? variationId : undefined,
154
+ });
155
+ }
156
+ },
157
+ evalExpression(expression) {
158
+ return expression.replace(/{{([^}]+)}}/g, (_match, group) =>
159
+ evaluate({
160
+ code: group,
161
+ context: state.contextContext,
162
+ state: state.contentState,
163
+ })
164
+ );
165
+ },
166
+ handleRequest({ url, key }) {
167
+ fetch(url)
168
+ .then((response) => response.json())
169
+ .then((json) => {
170
+ const newOverrideState = {
171
+ ...state.overrideState,
172
+ [key]: json,
173
+ };
174
+ state.overrideState = newOverrideState;
175
+ })
176
+ .catch((err) => {
177
+ console.log("error fetching dynamic data", url, err);
178
+ });
179
+ },
180
+ runHttpRequests() {
181
+ const requests = state.useContent?.data?.httpRequests ?? {};
182
+ Object.entries(requests).forEach(([key, url]) => {
183
+ if (url && (!state.httpReqsData[key] || isEditing())) {
184
+ const evaluatedUrl = state.evalExpression(url);
185
+ state.handleRequest({
186
+ url: evaluatedUrl,
187
+ key,
188
+ });
189
+ }
190
+ });
191
+ },
192
+ emitStateUpdate() {
193
+ if (isEditing()) {
194
+ window.dispatchEvent(
195
+ new CustomEvent("builder:component:stateChange", {
196
+ detail: {
197
+ state: state.contentState,
198
+ ref: {
199
+ name: props.model,
200
+ },
201
+ },
202
+ })
203
+ );
204
+ }
205
+ },
206
+ get shouldRenderContentStyles() {
207
+ return Boolean(
208
+ (state.useContent?.data?.cssCode ||
209
+ state.useContent?.data?.customFonts?.length) &&
210
+ TARGET !== "reactNative"
211
+ );
212
+ },
213
+ };
214
+
215
+ _context.BuilderContext = {
216
+ get content() {
217
+ return state.useContent;
218
+ },
219
+ get state() {
220
+ return state.contentState;
221
+ },
222
+ get context() {
223
+ return state.contextContext;
224
+ },
225
+ get apiKey() {
226
+ return props.apiKey;
227
+ },
228
+ get registeredComponents() {
229
+ return state.allRegisteredComponents;
230
+ },
231
+ };
232
+
233
+ return (
234
+ <>
235
+ {state.useContent ? (
236
+ <>
237
+ <div
238
+ builder-content-id={state.useContent?.id}
239
+ builder-model={props.model}
240
+ >
241
+ {state.shouldRenderContentStyles ? (
242
+ <RenderContentStyles
243
+ cssCode={state.useContent?.data?.cssCode}
244
+ customFonts={state.useContent?.data?.customFonts}
245
+ _context={_context}
246
+ />
247
+ ) : null}
248
+
249
+ <RenderBlocks
250
+ blocks={state.useContent?.data?.blocks}
251
+ key={state.forceReRenderCount}
252
+ _context={_context}
253
+ />
254
+ </div>
255
+ </>
256
+ ) : null}
257
+ </>
258
+ );
259
+ }
@@ -0,0 +1,33 @@
1
+ import * as React from "react";
2
+ import { TARGET } from "../constants/target.js";
3
+
4
+ export default function RenderInlinedStyles(props) {
5
+ const _context = { ...props["_context"] };
6
+
7
+ const state = {
8
+ get injectedStyleScript() {
9
+ return `<${state.tag}>${props.styles}</${state.tag}>`;
10
+ },
11
+ get tag() {
12
+ // NOTE: we have to obfusctate the name of the tag due to a limitation in the svelte-preprocessor plugin.
13
+ // https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
14
+ return "sty" + "le";
15
+ },
16
+ };
17
+
18
+ const TagRef = state.tag;
19
+
20
+ return (
21
+ <>
22
+ {TARGET === "svelte" ? (
23
+ <>
24
+ <div
25
+ dangerouslySetInnerHTML={{ __html: state.injectedStyleScript }}
26
+ />
27
+ </>
28
+ ) : (
29
+ <TagRef>{props.styles}</TagRef>
30
+ )}
31
+ </>
32
+ );
33
+ }
@@ -19,6 +19,7 @@ var __async = (__this, __arguments, generator) => {
19
19
  });
20
20
  };
21
21
  import { isBrowser } from "../functions/is-browser.js";
22
+ import { checkIsDefined } from "./nullable.js";
22
23
  import { getTopLevelDomain } from "./url.js";
23
24
  const getCookie = (_0) => __async(void 0, [_0], function* ({
24
25
  name,
@@ -32,9 +33,10 @@ const getCookie = (_0) => __async(void 0, [_0], function* ({
32
33
  return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
33
34
  } catch (err) {
34
35
  console.debug("[COOKIE] GET error: ", err);
36
+ return void 0;
35
37
  }
36
38
  });
37
- const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).join("; ");
39
+ const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
38
40
  const SECURE_CONFIG = [
39
41
  ["secure", ""],
40
42
  ["SameSite", "None"]
@@ -65,7 +67,7 @@ const setCookie = (_0) => __async(void 0, [_0], function* ({
65
67
  }) {
66
68
  try {
67
69
  if (!canTrack) {
68
- return void 0;
70
+ return;
69
71
  }
70
72
  const cookie = createCookieString({ name, value, expires });
71
73
  document.cookie = cookie;
@@ -12,6 +12,7 @@ const getLocalStorageItem = ({
12
12
  return void 0;
13
13
  } catch (err) {
14
14
  console.debug("[LocalStorage] GET error: ", err);
15
+ return void 0;
15
16
  }
16
17
  };
17
18
  const setLocalStorageItem = ({
@@ -22,7 +22,9 @@ import { getCookie, setCookie } from "./cookie.js";
22
22
  import { checkIsDefined } from "./nullable.js";
23
23
  import { uuid } from "./uuid.js";
24
24
  const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
25
- const getSessionId = (_0) => __async(void 0, [_0], function* ({ canTrack }) {
25
+ const getSessionId = (_0) => __async(void 0, [_0], function* ({
26
+ canTrack
27
+ }) {
26
28
  if (!canTrack) {
27
29
  return void 0;
28
30
  }
@@ -35,6 +37,7 @@ const getSessionId = (_0) => __async(void 0, [_0], function* ({ canTrack }) {
35
37
  } else {
36
38
  const newSessionId = createSessionId();
37
39
  setSessionId({ id: newSessionId, canTrack });
40
+ return newSessionId;
38
41
  }
39
42
  });
40
43
  const createSessionId = () => uuid();
@@ -1,4 +1,7 @@
1
1
  const getTopLevelDomain = (host) => {
2
+ if (host === "localhost" || host === "127.0.0.1") {
3
+ return host;
4
+ }
2
5
  const parts = host.split(".");
3
6
  if (parts.length > 2) {
4
7
  return parts.slice(1).join(".");
@@ -12,4 +12,10 @@ describe("getTopLevelDomain", () => {
12
12
  const output = getTopLevelDomain("www.example.co.uk");
13
13
  expect(output).toBe("example.co.uk");
14
14
  });
15
+ test("handles localhost", () => {
16
+ const output = getTopLevelDomain("localhost");
17
+ expect(output).toBe("localhost");
18
+ const output2 = getTopLevelDomain("127.0.0.1");
19
+ expect(output2).toBe("127.0.0.1");
20
+ });
15
21
  });
@@ -15,6 +15,7 @@ const getVisitorId = ({ canTrack }) => {
15
15
  } else {
16
16
  const newVisitorId = createVisitorId();
17
17
  setVisitorId({ id: newVisitorId, canTrack });
18
+ return newVisitorId;
18
19
  }
19
20
  };
20
21
  const createVisitorId = () => uuid();
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ import { useContext } from "react";
3
+ import BuilderContext from "../context/builder.context.js";
4
+
5
+ export default function BaseText(props) {
6
+ const builderContext = useContext(BuilderContext);
7
+
8
+ return <span style={builderContext.inheritedStyles}>{props.text}</span>;
9
+ }
@@ -0,0 +1,27 @@
1
+ import * as React from "react";
2
+
3
+ export default function Button(props) {
4
+ return (
5
+ <>
6
+ {props.link ? (
7
+ <>
8
+ <a
9
+ role="button"
10
+ {...props.attributes}
11
+ href={props.link}
12
+ target={props.openLinkInNewTab ? "_blank" : undefined}
13
+ >
14
+ {props.text}
15
+ </a>
16
+ </>
17
+ ) : (
18
+ <button className="button-7028b0a4" {...props.attributes}>
19
+ {props.text}
20
+ </button>
21
+ )}
22
+ <style>{`.button-7028b0a4 {
23
+ all: unset;
24
+ }`}</style>
25
+ </>
26
+ );
27
+ }
@@ -0,0 +1,41 @@
1
+ const componentInfo = {
2
+ name: "Core:Button",
3
+ builtIn: true,
4
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
5
+ defaultStyles: {
6
+ appearance: "none",
7
+ paddingTop: "15px",
8
+ paddingBottom: "15px",
9
+ paddingLeft: "25px",
10
+ paddingRight: "25px",
11
+ backgroundColor: "#000000",
12
+ color: "white",
13
+ borderRadius: "4px",
14
+ textAlign: "center",
15
+ cursor: "pointer"
16
+ },
17
+ inputs: [
18
+ {
19
+ name: "text",
20
+ type: "text",
21
+ defaultValue: "Click me!",
22
+ bubble: true
23
+ },
24
+ {
25
+ name: "link",
26
+ type: "url",
27
+ bubble: true
28
+ },
29
+ {
30
+ name: "openLinkInNewTab",
31
+ type: "boolean",
32
+ defaultValue: false,
33
+ friendlyName: "Open link in new tab"
34
+ }
35
+ ],
36
+ static: true,
37
+ noWrap: true
38
+ };
39
+ export {
40
+ componentInfo
41
+ };
@@ -0,0 +1,172 @@
1
+ import * as React from "react";
2
+ import RenderBlocks from "../../components/render-blocks.js";
3
+ import { getSizesForBreakpoints } from "../../constants/device-sizes";
4
+ import RenderInlinedStyles from "../../components/render-inlined-styles.js";
5
+ import { TARGET } from "../../constants/target.js";
6
+ import { convertStyleMapToCSS } from "../../helpers/css";
7
+
8
+ export default function Columns(props) {
9
+ function getGutterSize() {
10
+ return typeof props.space === "number" ? props.space || 0 : 20;
11
+ }
12
+
13
+ function getColumns() {
14
+ return props.columns || [];
15
+ }
16
+
17
+ function getWidth(index) {
18
+ const columns = getColumns();
19
+ return columns[index]?.width || 100 / columns.length;
20
+ }
21
+
22
+ function getColumnCssWidth(index) {
23
+ const columns = getColumns();
24
+ const gutterSize = getGutterSize();
25
+ const subtractWidth = (gutterSize * (columns.length - 1)) / columns.length;
26
+ return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
27
+ }
28
+
29
+ function maybeApplyForTablet(prop) {
30
+ const _stackColumnsAt = props.stackColumnsAt || "tablet";
31
+ return _stackColumnsAt === "tablet" ? prop : "inherit";
32
+ }
33
+
34
+ function columnsCssVars() {
35
+ const flexDir =
36
+ props.stackColumnsAt === "never"
37
+ ? "inherit"
38
+ : props.reverseColumnsWhenStacked
39
+ ? "column-reverse"
40
+ : "column";
41
+ return {
42
+ "--flex-dir": flexDir,
43
+ "--flex-dir-tablet": maybeApplyForTablet(flexDir),
44
+ };
45
+ }
46
+
47
+ function columnCssVars() {
48
+ const width = "100%";
49
+ const marginLeft = "0";
50
+ return {
51
+ "--column-width": width,
52
+ "--column-margin-left": marginLeft,
53
+ "--column-width-tablet": maybeApplyForTablet(width),
54
+ "--column-margin-left-tablet": maybeApplyForTablet(marginLeft),
55
+ };
56
+ }
57
+
58
+ function getWidthForBreakpointSize(size) {
59
+ const breakpointSizes = getSizesForBreakpoints(
60
+ props.customBreakpoints || {}
61
+ );
62
+ return breakpointSizes[size].max;
63
+ }
64
+
65
+ function columnStyleObjects() {
66
+ return {
67
+ columns: {
68
+ small: {
69
+ flexDirection: "var(--flex-dir)",
70
+ alignItems: "stretch",
71
+ },
72
+ medium: {
73
+ flexDirection: "var(--flex-dir-tablet)",
74
+ alignItems: "stretch",
75
+ },
76
+ },
77
+ column: {
78
+ small: {
79
+ width: "var(--column-width) !important",
80
+ marginLeft: "var(--column-margin-left) !important",
81
+ },
82
+ medium: {
83
+ width: "var(--column-width-tablet) !important",
84
+ marginLeft: "var(--column-margin-left-tablet) !important",
85
+ },
86
+ },
87
+ };
88
+ }
89
+
90
+ function columnsStyles() {
91
+ return `
92
+ @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
93
+ .${props.builderBlock.id}-breakpoints {
94
+ ${convertStyleMapToCSS(columnStyleObjects().columns.medium)}
95
+ }
96
+
97
+ .${props.builderBlock.id}-breakpoints > .builder-column {
98
+ ${convertStyleMapToCSS(columnStyleObjects().column.medium)}
99
+ }
100
+ }
101
+
102
+ @media (max-width: ${getWidthForBreakpointSize("small")}px) {
103
+ .${props.builderBlock.id}-breakpoints {
104
+ ${convertStyleMapToCSS(columnStyleObjects().columns.small)}
105
+ }
106
+
107
+ .${props.builderBlock.id}-breakpoints > .builder-column {
108
+ ${convertStyleMapToCSS(columnStyleObjects().column.small)}
109
+ }
110
+ },
111
+ `;
112
+ }
113
+
114
+ function reactNativeColumnsStyles() {
115
+ return columnStyleObjects.columns.small;
116
+ }
117
+
118
+ function reactNativeColumnStyles() {
119
+ return columnStyleObjects.column.small;
120
+ }
121
+
122
+ return (
123
+ <>
124
+ <div
125
+ className={
126
+ `builder-columns ${props.builderBlock.id}-breakpoints` +
127
+ " div-bda7d4e0"
128
+ }
129
+ style={{
130
+ ...(TARGET === "reactNative" ? reactNativeColumnsStyles() : {}),
131
+ ...columnsCssVars(),
132
+ }}
133
+ >
134
+ {TARGET !== "reactNative" ? (
135
+ <>
136
+ <RenderInlinedStyles styles={columnsStyles()} />
137
+ </>
138
+ ) : null}
139
+
140
+ {props.columns?.map((column, index) => (
141
+ <div
142
+ className="builder-column div-bda7d4e0-2"
143
+ style={{
144
+ width: getColumnCssWidth(index),
145
+ marginLeft: `${index === 0 ? 0 : getGutterSize()}px`,
146
+ ...(TARGET === "reactNative" ? reactNativeColumnStyles() : {}),
147
+ ...columnCssVars(),
148
+ }}
149
+ key={index}
150
+ >
151
+ <RenderBlocks
152
+ blocks={column.blocks}
153
+ path={`component.options.columns.${index}.blocks`}
154
+ parent={props.builderBlock.id}
155
+ styleProp={{
156
+ flexGrow: "1",
157
+ }}
158
+ />
159
+ </div>
160
+ ))}
161
+ </div>
162
+ <style>{`.div-bda7d4e0 {
163
+ display: flex;
164
+ line-height: normal;
165
+ }.div-bda7d4e0-2 {
166
+ display: flex;
167
+ flex-direction: column;
168
+ align-items: stretch;
169
+ }`}</style>
170
+ </>
171
+ );
172
+ }