@builder.io/sdk-react-native 1.0.32 → 1.0.34

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 (277) hide show
  1. package/lib/browser/commonjs/blocks/text/text.js +1 -1
  2. package/lib/browser/commonjs/constants/sdk-version.js +1 -1
  3. package/lib/browser/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
  4. package/lib/browser/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  5. package/lib/browser/commonjs/functions/is-from-trusted-host.js +3 -0
  6. package/lib/browser/commonjs/functions/is-from-trusted-host.js.map +1 -1
  7. package/lib/browser/commonjs/helpers/cookie.js +12 -2
  8. package/lib/browser/commonjs/helpers/cookie.js.map +1 -1
  9. package/lib/browser/module/blocks/text/text.js +1 -1
  10. package/lib/browser/module/blocks/text/text.js.map +1 -1
  11. package/lib/browser/module/constants/sdk-version.js +1 -1
  12. package/lib/browser/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
  13. package/lib/browser/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  14. package/lib/browser/module/functions/is-from-trusted-host.js +3 -0
  15. package/lib/browser/module/functions/is-from-trusted-host.js.map +1 -1
  16. package/lib/browser/module/helpers/cookie.js +11 -2
  17. package/lib/browser/module/helpers/cookie.js.map +1 -1
  18. package/lib/browser/typescript/constants/sdk-version.d.ts +1 -1
  19. package/lib/browser/typescript/functions/is-from-trusted-host.d.ts.map +1 -1
  20. package/lib/browser/typescript/helpers/cookie.d.ts +1 -0
  21. package/lib/browser/typescript/helpers/cookie.d.ts.map +1 -1
  22. package/lib/edge/commonjs/blocks/text/text.js +1 -1
  23. package/lib/edge/commonjs/constants/sdk-version.js +1 -1
  24. package/lib/edge/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
  25. package/lib/edge/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  26. package/lib/edge/commonjs/functions/is-from-trusted-host.js +3 -0
  27. package/lib/edge/commonjs/functions/is-from-trusted-host.js.map +1 -1
  28. package/lib/edge/commonjs/helpers/cookie.js +12 -2
  29. package/lib/edge/commonjs/helpers/cookie.js.map +1 -1
  30. package/lib/edge/module/blocks/text/text.js +1 -1
  31. package/lib/edge/module/blocks/text/text.js.map +1 -1
  32. package/lib/edge/module/constants/sdk-version.js +1 -1
  33. package/lib/edge/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
  34. package/lib/edge/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  35. package/lib/edge/module/functions/is-from-trusted-host.js +3 -0
  36. package/lib/edge/module/functions/is-from-trusted-host.js.map +1 -1
  37. package/lib/edge/module/helpers/cookie.js +11 -2
  38. package/lib/edge/module/helpers/cookie.js.map +1 -1
  39. package/lib/edge/typescript/constants/sdk-version.d.ts +1 -1
  40. package/lib/edge/typescript/functions/is-from-trusted-host.d.ts.map +1 -1
  41. package/lib/edge/typescript/helpers/cookie.d.ts +1 -0
  42. package/lib/edge/typescript/helpers/cookie.d.ts.map +1 -1
  43. package/lib/node/commonjs/blocks/text/text.js +1 -1
  44. package/lib/node/commonjs/constants/sdk-version.js +1 -1
  45. package/lib/node/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
  46. package/lib/node/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  47. package/lib/node/commonjs/functions/is-from-trusted-host.js +3 -0
  48. package/lib/node/commonjs/functions/is-from-trusted-host.js.map +1 -1
  49. package/lib/node/commonjs/helpers/cookie.js +12 -2
  50. package/lib/node/commonjs/helpers/cookie.js.map +1 -1
  51. package/lib/node/module/blocks/text/text.js +1 -1
  52. package/lib/node/module/blocks/text/text.js.map +1 -1
  53. package/lib/node/module/constants/sdk-version.js +1 -1
  54. package/lib/node/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
  55. package/lib/node/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
  56. package/lib/node/module/functions/is-from-trusted-host.js +3 -0
  57. package/lib/node/module/functions/is-from-trusted-host.js.map +1 -1
  58. package/lib/node/module/helpers/cookie.js +11 -2
  59. package/lib/node/module/helpers/cookie.js.map +1 -1
  60. package/lib/node/typescript/constants/sdk-version.d.ts +1 -1
  61. package/lib/node/typescript/functions/is-from-trusted-host.d.ts.map +1 -1
  62. package/lib/node/typescript/helpers/cookie.d.ts +1 -0
  63. package/lib/node/typescript/helpers/cookie.d.ts.map +1 -1
  64. package/package.json +10 -7
  65. package/src/blocks/BaseText.tsx +17 -0
  66. package/src/blocks/accordion/accordion.tsx +181 -0
  67. package/src/blocks/accordion/accordion.types.ts +12 -0
  68. package/src/blocks/accordion/component-info.ts +124 -0
  69. package/src/blocks/accordion/helpers.ts +3 -0
  70. package/src/blocks/accordion/index.ts +1 -0
  71. package/src/blocks/button/button.tsx +56 -0
  72. package/src/blocks/button/button.types.ts +7 -0
  73. package/src/blocks/button/component-info.ts +35 -0
  74. package/src/blocks/button/index.ts +1 -0
  75. package/src/blocks/columns/columns.tsx +199 -0
  76. package/src/blocks/columns/columns.types.ts +14 -0
  77. package/src/blocks/columns/component-info.ts +219 -0
  78. package/src/blocks/columns/helpers.ts +3 -0
  79. package/src/blocks/columns/index.ts +1 -0
  80. package/src/blocks/custom-code/component-info.ts +24 -0
  81. package/src/blocks/custom-code/custom-code.tsx +71 -0
  82. package/src/blocks/custom-code/index.ts +1 -0
  83. package/src/blocks/embed/component-info.ts +38 -0
  84. package/src/blocks/embed/embed.tsx +62 -0
  85. package/src/blocks/embed/helpers.ts +2 -0
  86. package/src/blocks/embed/index.ts +1 -0
  87. package/src/blocks/form/form/component-info.ts +233 -0
  88. package/src/blocks/form/form/form.tsx +324 -0
  89. package/src/blocks/form/form/index.ts +1 -0
  90. package/src/blocks/form/input/component-info.ts +47 -0
  91. package/src/blocks/form/input/index.ts +1 -0
  92. package/src/blocks/form/input/input.tsx +49 -0
  93. package/src/blocks/form/select/component-info.ts +44 -0
  94. package/src/blocks/form/select/index.ts +1 -0
  95. package/src/blocks/form/select/select.tsx +54 -0
  96. package/src/blocks/form/submit-button/component-info.ts +27 -0
  97. package/src/blocks/form/submit-button/index.ts +1 -0
  98. package/src/blocks/form/submit-button/submit-button.tsx +34 -0
  99. package/src/blocks/fragment/component-info.ts +8 -0
  100. package/src/blocks/fragment/fragment.tsx +18 -0
  101. package/src/blocks/fragment/fragment.types.ts +5 -0
  102. package/src/blocks/fragment/index.ts +1 -0
  103. package/src/blocks/helpers.ts +43 -0
  104. package/src/blocks/image/component-info.ts +129 -0
  105. package/src/blocks/image/image.helpers.ts +47 -0
  106. package/src/blocks/image/image.tsx +65 -0
  107. package/src/blocks/image/image.types.ts +20 -0
  108. package/src/blocks/image/index.ts +1 -0
  109. package/src/blocks/img/component-info.ts +16 -0
  110. package/src/blocks/img/img.tsx +55 -0
  111. package/src/blocks/img/index.ts +1 -0
  112. package/src/blocks/raw-text/component-info.ts +11 -0
  113. package/src/blocks/raw-text/index.ts +1 -0
  114. package/src/blocks/raw-text/raw-text.tsx +1 -0
  115. package/src/blocks/section/component-info.ts +41 -0
  116. package/src/blocks/section/index.ts +1 -0
  117. package/src/blocks/section/section.tsx +39 -0
  118. package/src/blocks/section/section.types.ts +6 -0
  119. package/src/blocks/slot/component-info.ts +15 -0
  120. package/src/blocks/slot/index.ts +1 -0
  121. package/src/blocks/slot/slot.tsx +42 -0
  122. package/src/blocks/symbol/component-info.ts +35 -0
  123. package/src/blocks/symbol/index.ts +1 -0
  124. package/src/blocks/symbol/symbol.helpers.ts +47 -0
  125. package/src/blocks/symbol/symbol.tsx +100 -0
  126. package/src/blocks/symbol/symbol.types.ts +17 -0
  127. package/src/blocks/tabs/component-info.ts +139 -0
  128. package/src/blocks/tabs/index.ts +1 -0
  129. package/src/blocks/tabs/tabs.tsx +79 -0
  130. package/src/blocks/tabs/tabs.types.ts +13 -0
  131. package/src/blocks/text/component-info.ts +20 -0
  132. package/src/blocks/text/index.ts +1 -0
  133. package/src/blocks/text/text.tsx +105 -0
  134. package/src/blocks/text/text.types.ts +4 -0
  135. package/src/blocks/textarea/component-info.ts +38 -0
  136. package/src/blocks/textarea/index.ts +1 -0
  137. package/src/blocks/textarea/textarea.tsx +41 -0
  138. package/src/blocks/video/component-info.ts +83 -0
  139. package/src/blocks/video/index.ts +1 -0
  140. package/src/blocks/video/video.tsx +70 -0
  141. package/src/blocks/video/video.types.ts +21 -0
  142. package/src/components/block/animator.ts +220 -0
  143. package/src/components/block/block.helpers.ts +124 -0
  144. package/src/components/block/block.tsx +232 -0
  145. package/src/components/block/components/block-styles.tsx +136 -0
  146. package/src/components/block/components/block-wrapper.tsx +52 -0
  147. package/src/components/block/components/component-ref/component-ref.helpers.ts +55 -0
  148. package/src/components/block/components/component-ref/component-ref.tsx +66 -0
  149. package/src/components/block/components/interactive-element.tsx +53 -0
  150. package/src/components/block/components/repeated-block.tsx +37 -0
  151. package/src/components/block/types.ts +6 -0
  152. package/src/components/blocks/blocks-wrapper.tsx +93 -0
  153. package/src/components/blocks/blocks.tsx +57 -0
  154. package/src/components/blocks/blocks.types.ts +7 -0
  155. package/src/components/blocks/index.ts +1 -0
  156. package/src/components/content/components/enable-editor.tsx +472 -0
  157. package/src/components/content/components/styles.helpers.ts +101 -0
  158. package/src/components/content/components/styles.tsx +42 -0
  159. package/src/components/content/content.helpers.ts +40 -0
  160. package/src/components/content/content.tsx +150 -0
  161. package/src/components/content/content.types.ts +13 -0
  162. package/src/components/content/contentProps.types.ts +17 -0
  163. package/src/components/content/index.ts +1 -0
  164. package/src/components/content/wrap-component-ref.ts +6 -0
  165. package/src/components/content-variants/content-variants.tsx +146 -0
  166. package/src/components/content-variants/content-variants.types.ts +84 -0
  167. package/src/components/content-variants/helpers.ts +72 -0
  168. package/src/components/content-variants/index.ts +1 -0
  169. package/src/components/content-variants/inlined-fns.ts +22 -0
  170. package/src/components/dynamic-div.tsx +30 -0
  171. package/src/components/dynamic-renderer/dynamic-renderer.helpers.ts +7 -0
  172. package/src/components/dynamic-renderer/dynamic-renderer.tsx +47 -0
  173. package/src/components/error-boundary.tsx +38 -0
  174. package/src/components/inlined-script.tsx +10 -0
  175. package/src/components/inlined-styles.tsx +10 -0
  176. package/src/constants/builder-registered-components.ts +59 -0
  177. package/src/constants/device-sizes.ts +59 -0
  178. package/src/constants/extra-components.ts +1 -0
  179. package/src/constants/sdk-version.ts +1 -0
  180. package/src/constants/target.ts +3 -0
  181. package/src/context/builder.context.ts +15 -0
  182. package/src/context/components.context.ts +3 -0
  183. package/src/context/index.ts +1 -0
  184. package/src/context/types.ts +38 -0
  185. package/src/functions/apply-patch-with-mutation.ts +61 -0
  186. package/src/functions/camel-to-kebab-case.ts +1 -0
  187. package/src/functions/deopt.ts +6 -0
  188. package/src/functions/evaluate/browser-runtime/browser.ts +61 -0
  189. package/src/functions/evaluate/browser-runtime/index.ts +1 -0
  190. package/src/functions/evaluate/choose-eval.ts +23 -0
  191. package/src/functions/evaluate/edge-runtime/acorn-interpreter.ts +2891 -0
  192. package/src/functions/evaluate/edge-runtime/edge-runtime.ts +89 -0
  193. package/src/functions/evaluate/edge-runtime/index.ts +1 -0
  194. package/src/functions/evaluate/evaluate.ts +76 -0
  195. package/src/functions/evaluate/helpers.ts +56 -0
  196. package/src/functions/evaluate/index.ts +1 -0
  197. package/src/functions/evaluate/node-runtime/index.ts +1 -0
  198. package/src/functions/evaluate/node-runtime/init.ts +33 -0
  199. package/src/functions/evaluate/node-runtime/node-runtime.ts +176 -0
  200. package/src/functions/evaluate/node-runtime/safeDynamicRequire.ts +14 -0
  201. package/src/functions/evaluate/placeholder-runtime.ts +4 -0
  202. package/src/functions/evaluate/should-force-browser-runtime-in-node.ts +16 -0
  203. package/src/functions/event-handler-name.ts +4 -0
  204. package/src/functions/extract-text-styles.ts +24 -0
  205. package/src/functions/fast-clone.ts +4 -0
  206. package/src/functions/fetch-builder-props.ts +75 -0
  207. package/src/functions/get-block-actions-handler.ts +17 -0
  208. package/src/functions/get-block-actions.ts +35 -0
  209. package/src/functions/get-block-component-options.ts +7 -0
  210. package/src/functions/get-block-properties.ts +62 -0
  211. package/src/functions/get-builder-search-params/index.ts +33 -0
  212. package/src/functions/get-class-prop-name.ts +15 -0
  213. package/src/functions/get-content/generate-content-url.ts +88 -0
  214. package/src/functions/get-content/index.ts +99 -0
  215. package/src/functions/get-content/types.ts +157 -0
  216. package/src/functions/get-env.ts +5 -0
  217. package/src/functions/get-fetch.ts +11 -0
  218. package/src/functions/get-global-this.ts +16 -0
  219. package/src/functions/get-processed-block.ts +70 -0
  220. package/src/functions/get-style.ts +38 -0
  221. package/src/functions/get.ts +4 -0
  222. package/src/functions/is-browser.ts +3 -0
  223. package/src/functions/is-edge-runtime.ts +9 -0
  224. package/src/functions/is-editing.ts +8 -0
  225. package/src/functions/is-from-trusted-host.ts +11 -0
  226. package/src/functions/is-iframe.ts +4 -0
  227. package/src/functions/is-node-runtime.ts +8 -0
  228. package/src/functions/is-previewing.ts +16 -0
  229. package/src/functions/on-change.ts +29 -0
  230. package/src/functions/register-component.ts +30 -0
  231. package/src/functions/register.ts +44 -0
  232. package/src/functions/set-editor-settings.ts +15 -0
  233. package/src/functions/set.ts +14 -0
  234. package/src/functions/track/helpers.ts +51 -0
  235. package/src/functions/track/index.ts +131 -0
  236. package/src/functions/track/interaction.ts +63 -0
  237. package/src/functions/transform-block-properties.ts +33 -0
  238. package/src/functions/transform-block.ts +30 -0
  239. package/src/functions/transform-style-property.ts +296 -0
  240. package/src/helpers/ab-tests.ts +166 -0
  241. package/src/helpers/canTrack.ts +2 -0
  242. package/src/helpers/cookie.ts +109 -0
  243. package/src/helpers/css.ts +33 -0
  244. package/src/helpers/flatten.ts +41 -0
  245. package/src/helpers/localStorage.ts +36 -0
  246. package/src/helpers/logger.ts +7 -0
  247. package/src/helpers/nullable.ts +2 -0
  248. package/src/helpers/omit.ts +7 -0
  249. package/src/helpers/preview-lru-cache/get.ts +4 -0
  250. package/src/helpers/preview-lru-cache/helpers.ts +1 -0
  251. package/src/helpers/preview-lru-cache/init.ts +7 -0
  252. package/src/helpers/preview-lru-cache/set.ts +12 -0
  253. package/src/helpers/preview-lru-cache/types.ts +1 -0
  254. package/src/helpers/search/search.ts +18 -0
  255. package/src/helpers/sessionId.ts +37 -0
  256. package/src/helpers/subscribe-to-editor.ts +95 -0
  257. package/src/helpers/time.ts +2 -0
  258. package/src/helpers/url.ts +15 -0
  259. package/src/helpers/uuid.ts +17 -0
  260. package/src/helpers/visitorId.ts +37 -0
  261. package/src/index-helpers/blocks-exports.ts +16 -0
  262. package/src/index-helpers/top-of-file.ts +2 -0
  263. package/src/index.ts +15 -0
  264. package/src/scripts/init-editing.ts +119 -0
  265. package/src/server-index.ts +43 -0
  266. package/src/types/api-version.ts +2 -0
  267. package/src/types/builder-block.ts +89 -0
  268. package/src/types/builder-content.ts +47 -0
  269. package/src/types/builder-props.ts +12 -0
  270. package/src/types/can-track.ts +3 -0
  271. package/src/types/components.ts +119 -0
  272. package/src/types/deep-partial.ts +1 -0
  273. package/src/types/element.ts +57 -0
  274. package/src/types/enforced-partials.ts +19 -0
  275. package/src/types/input.ts +123 -0
  276. package/src/types/targets.ts +1 -0
  277. package/src/types/typescript.ts +9 -0
@@ -0,0 +1,124 @@
1
+ import type { ComponentInfo } from '../../types/components';
2
+ const defaultTitle = {
3
+ '@type': '@builder.io/sdk:Element',
4
+ layerName: 'Accordion item title',
5
+ responsiveStyles: {
6
+ large: {
7
+ marginTop: '10px',
8
+ position: 'relative',
9
+ display: 'flex',
10
+ alignItems: 'stretch',
11
+ flexDirection: 'column',
12
+ paddingBottom: '10px'
13
+ }
14
+ },
15
+ children: [{
16
+ '@type': '@builder.io/sdk:Element',
17
+ responsiveStyles: {
18
+ large: {
19
+ textAlign: 'left',
20
+ display: 'flex',
21
+ flexDirection: 'column'
22
+ }
23
+ },
24
+ component: {
25
+ name: 'Text',
26
+ options: {
27
+ text: 'I am an accordion title. Click me!'
28
+ }
29
+ }
30
+ }]
31
+ };
32
+ const defaultDetail = {
33
+ '@type': '@builder.io/sdk:Element',
34
+ layerName: 'Accordion item detail',
35
+ responsiveStyles: {
36
+ large: {
37
+ position: 'relative',
38
+ display: 'flex',
39
+ alignItems: 'stretch',
40
+ flexDirection: 'column',
41
+ marginTop: '10px',
42
+ paddingBottom: '10px'
43
+ }
44
+ },
45
+ children: [{
46
+ '@type': '@builder.io/sdk:Element',
47
+ responsiveStyles: {
48
+ large: {
49
+ paddingTop: '50px',
50
+ textAlign: 'left',
51
+ display: 'flex',
52
+ flexDirection: 'column',
53
+ paddingBottom: '50px'
54
+ }
55
+ },
56
+ component: {
57
+ name: 'Text',
58
+ options: {
59
+ text: 'I am an accordion detail, hello!'
60
+ }
61
+ }
62
+ }]
63
+ };
64
+ export const componentInfo: ComponentInfo = {
65
+ name: 'Builder:Accordion',
66
+ canHaveChildren: true,
67
+ image: 'https://cdn.builder.io/api/v1/image/assets%2FagZ9n5CUKRfbL9t6CaJOyVSK4Es2%2Ffab6c1fd3fe542408cbdec078bca7f35',
68
+ defaultStyles: {
69
+ display: 'flex',
70
+ flexDirection: 'column',
71
+ alignItems: 'stretch'
72
+ },
73
+ inputs: [{
74
+ name: 'items',
75
+ type: 'list',
76
+ broadcast: true,
77
+ subFields: [{
78
+ name: 'title',
79
+ type: 'uiBlocks',
80
+ hideFromUI: true,
81
+ defaultValue: [defaultTitle]
82
+ }, {
83
+ name: 'detail',
84
+ type: 'uiBlocks',
85
+ hideFromUI: true,
86
+ defaultValue: [defaultDetail]
87
+ }],
88
+ defaultValue: [{
89
+ title: [defaultTitle],
90
+ detail: [defaultDetail]
91
+ }, {
92
+ title: [defaultTitle],
93
+ detail: [defaultDetail]
94
+ }],
95
+ showIf: (options: Map<string, any>) => !options.get('useChildrenForItems')
96
+ }, {
97
+ name: 'oneAtATime',
98
+ helperText: 'Only allow opening one at a time (collapse all others when new item openned)',
99
+ type: 'boolean',
100
+ defaultValue: false
101
+ }, {
102
+ name: 'grid',
103
+ helperText: 'Display as a grid',
104
+ type: 'boolean',
105
+ defaultValue: false
106
+ }, {
107
+ name: 'gridRowWidth',
108
+ helperText: 'Display as a grid',
109
+ type: 'string',
110
+ showIf: (options: Map<string, any>) => options.get('grid'),
111
+ defaultValue: '25%'
112
+ }, {
113
+ name: 'useChildrenForItems',
114
+ type: 'boolean',
115
+ helperText: 'Use child elements for each slide, instead of the array. Useful for dynamically repeating items',
116
+ advanced: true,
117
+ defaultValue: false,
118
+ onChange: (options: Map<string, any>) => {
119
+ if (options.get('useChildrenForItems') === true) {
120
+ options.set('items', []);
121
+ }
122
+ }
123
+ }]
124
+ }
@@ -0,0 +1,3 @@
1
+ export const convertOrderNumberToString = (order: number) => {
2
+ return order.toString();
3
+ }
@@ -0,0 +1 @@
1
+ export { default } from './accordion'
@@ -0,0 +1,56 @@
1
+ import BaseText from "../../blocks/BaseText";
2
+ import * as React from "react";
3
+ import {
4
+ FlatList,
5
+ ScrollView,
6
+ View,
7
+ StyleSheet,
8
+ Image,
9
+ Text,
10
+ Pressable,
11
+ TextInput,
12
+ } from "react-native";
13
+ import DynamicRenderer from "../../components/dynamic-renderer/dynamic-renderer";
14
+ import { getClassPropName } from "../../functions/get-class-prop-name";
15
+ import { filterAttrs } from "../helpers";
16
+ import type { ButtonProps } from "./button.types";
17
+
18
+ function Button(props: ButtonProps) {
19
+ function attrs() {
20
+ return {
21
+ ...props.attributes,
22
+ [getClassPropName()]: `${props.link ? "" : "builder-button"} ${
23
+ props.attributes[getClassPropName()] || ""
24
+ }`,
25
+ ...(props.link
26
+ ? {
27
+ href: props.link,
28
+ target: props.openLinkInNewTab ? "_blank" : undefined,
29
+ role: "link",
30
+ }
31
+ : {
32
+ role: "button",
33
+ }),
34
+ };
35
+ }
36
+
37
+ return (
38
+ <DynamicRenderer
39
+ attributes={attrs()}
40
+ TagName={
41
+ props.link
42
+ ? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
43
+ // @ts-ignore
44
+ props.builderLinkComponent || BaseText
45
+ : // eslint-disable-next-line @typescript-eslint/ban-ts-comment
46
+ // @ts-ignore
47
+ BaseText
48
+ }
49
+ actionAttributes={{}}
50
+ >
51
+ <Text>{props.text}</Text>
52
+ </DynamicRenderer>
53
+ );
54
+ }
55
+
56
+ export default Button;
@@ -0,0 +1,7 @@
1
+ import type { BuilderLinkComponentProp } from '../../types/builder-props';
2
+ export interface ButtonProps extends BuilderLinkComponentProp {
3
+ attributes?: any;
4
+ text?: string;
5
+ link?: string;
6
+ openLinkInNewTab?: boolean;
7
+ }
@@ -0,0 +1,35 @@
1
+ import type { ComponentInfo } from '../../types/components';
2
+ export const componentInfo: ComponentInfo = {
3
+ name: 'Core:Button',
4
+ image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13',
5
+ defaultStyles: {
6
+ // TODO: make min width more intuitive and set one
7
+ appearance: 'none',
8
+ paddingTop: '15px',
9
+ paddingBottom: '15px',
10
+ paddingLeft: '25px',
11
+ paddingRight: '25px',
12
+ backgroundColor: '#000000',
13
+ color: 'white',
14
+ borderRadius: '4px',
15
+ textAlign: 'center',
16
+ cursor: 'pointer'
17
+ },
18
+ inputs: [{
19
+ name: 'text',
20
+ type: 'text',
21
+ defaultValue: 'Click me!',
22
+ bubble: true
23
+ }, {
24
+ name: 'link',
25
+ type: 'url',
26
+ bubble: true
27
+ }, {
28
+ name: 'openLinkInNewTab',
29
+ type: 'boolean',
30
+ defaultValue: false,
31
+ friendlyName: 'Open link in new tab'
32
+ }],
33
+ static: true,
34
+ noWrap: true
35
+ }
@@ -0,0 +1 @@
1
+ export { default } from './button'
@@ -0,0 +1,199 @@
1
+ import BaseText from "../../blocks/BaseText";
2
+ import * as React from "react";
3
+ import {
4
+ FlatList,
5
+ ScrollView,
6
+ View,
7
+ StyleSheet,
8
+ Image,
9
+ Text,
10
+ Pressable,
11
+ TextInput,
12
+ } from "react-native";
13
+ import { useState } from "react";
14
+
15
+ type CSSVal = string | number;
16
+ import Blocks from "../../components/blocks/blocks";
17
+ import DynamicDiv from "../../components/dynamic-div";
18
+ import DynamicRenderer from "../../components/dynamic-renderer/dynamic-renderer";
19
+ import InlinedStyles from "../../components/inlined-styles";
20
+ import type { SizeName } from "../../constants/device-sizes";
21
+ import { getSizesForBreakpoints } from "../../constants/device-sizes";
22
+ import { TARGET } from "../../constants/target";
23
+ import { deoptSignal } from "../../functions/deopt";
24
+ import { getClassPropName } from "../../functions/get-class-prop-name";
25
+ import { mapStyleObjToStrIfNeeded } from "../../functions/get-style";
26
+ import type { Dictionary } from "../../types/typescript";
27
+ import type { Column, ColumnProps } from "./columns.types";
28
+ import { getColumnsClass } from "./helpers";
29
+
30
+ function Columns(props: ColumnProps) {
31
+ const [gutterSize, setGutterSize] = useState(() =>
32
+ typeof props.space === "number" ? props.space || 0 : 20
33
+ );
34
+
35
+ const [cols, setCols] = useState(() => props.columns || []);
36
+
37
+ const [stackAt, setStackAt] = useState(
38
+ () => props.stackColumnsAt || "tablet"
39
+ );
40
+
41
+ function getTagName(column: Column) {
42
+ return column.link ? props.builderLinkComponent || BaseText : View;
43
+ }
44
+
45
+ function getWidth(index: number) {
46
+ return cols[index]?.width || 100 / cols.length;
47
+ }
48
+
49
+ function getColumnCssWidth(index: number) {
50
+ const subtractWidth = (gutterSize * (cols.length - 1)) / cols.length;
51
+ return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
52
+ }
53
+
54
+ function getTabletStyle({
55
+ stackedStyle,
56
+ desktopStyle,
57
+ }: {
58
+ stackedStyle: CSSVal;
59
+ desktopStyle: CSSVal;
60
+ }) {
61
+ return stackAt === "tablet" ? stackedStyle : desktopStyle;
62
+ }
63
+
64
+ function getMobileStyle({
65
+ stackedStyle,
66
+ desktopStyle,
67
+ }: {
68
+ stackedStyle: CSSVal;
69
+ desktopStyle: CSSVal;
70
+ }) {
71
+ return stackAt === "never" ? desktopStyle : stackedStyle;
72
+ }
73
+
74
+ const [flexDir, setFlexDir] = useState(() =>
75
+ props.stackColumnsAt === "never"
76
+ ? "row"
77
+ : props.reverseColumnsWhenStacked
78
+ ? "column-reverse"
79
+ : "column"
80
+ );
81
+
82
+ function columnsCssVars() {
83
+ return {
84
+ flexDirection: flexDir as "row" | "column" | "column-reverse",
85
+ };
86
+ }
87
+
88
+ function columnCssVars(index: number) {
89
+ const gutter = index === 0 ? 0 : gutterSize;
90
+ const width = getColumnCssWidth(index);
91
+ const gutterPixels = `${gutter}px`;
92
+ const mobileWidth = "100%";
93
+ const mobileMarginLeft = 0;
94
+ const marginLeftKey = "margin-left";
95
+ const sharedStyles = {
96
+ display: "flex",
97
+ flexDirection: "column",
98
+ alignItems: "stretch",
99
+ };
100
+ return {
101
+ ...sharedStyles,
102
+ marginLeft: props.stackColumnsAt === "never" ? gutter : 0,
103
+ } as any as Dictionary<string>;
104
+ }
105
+
106
+ function getWidthForBreakpointSize(size: SizeName) {
107
+ const breakpointSizes = getSizesForBreakpoints(
108
+ props.builderContext.content?.meta?.breakpoints || {}
109
+ );
110
+ return breakpointSizes[size].max;
111
+ }
112
+
113
+ function columnsStyles() {
114
+ return `
115
+ @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
116
+ .${props.builderBlock.id}-breakpoints {
117
+ flex-direction: var(--flex-dir-tablet);
118
+ align-items: stretch;
119
+ }
120
+
121
+ .${props.builderBlock.id}-breakpoints > .builder-column {
122
+ width: var(--column-width-tablet) !important;
123
+ margin-left: var(--column-margin-left-tablet) !important;
124
+ }
125
+ }
126
+
127
+ @media (max-width: ${getWidthForBreakpointSize("small")}px) {
128
+ .${props.builderBlock.id}-breakpoints {
129
+ flex-direction: var(--flex-dir);
130
+ align-items: stretch;
131
+ }
132
+
133
+ .${props.builderBlock.id}-breakpoints > .builder-column {
134
+ width: var(--column-width-mobile) !important;
135
+ margin-left: var(--column-margin-left-mobile) !important;
136
+ }
137
+ },
138
+ `;
139
+ }
140
+
141
+ function getAttributes(column: any, index: number) {
142
+ return {
143
+ ...{
144
+ dataSet: {
145
+ "builder-block-name": "builder-column",
146
+ },
147
+ },
148
+ ...(column.link
149
+ ? {
150
+ href: column.link,
151
+ }
152
+ : {}),
153
+ [getClassPropName()]: "builder-column",
154
+ style: mapStyleObjToStrIfNeeded(columnCssVars(index)),
155
+ };
156
+ }
157
+
158
+ return (
159
+ <View
160
+ style={{
161
+ ...styles.view1,
162
+ ...columnsCssVars(),
163
+ }}
164
+ {...{
165
+ dataSet: {
166
+ "builder-block-name": "builder-columns",
167
+ },
168
+ }}
169
+ >
170
+ {TARGET !== "reactNative" ? (
171
+ <InlinedStyles id="builderio-columns" styles={columnsStyles()} />
172
+ ) : null}
173
+ {props.columns?.map((column, index) => (
174
+ <DynamicRenderer
175
+ key={index}
176
+ TagName={getTagName(column)}
177
+ actionAttributes={{}}
178
+ attributes={getAttributes(column, index)}
179
+ >
180
+ <Blocks
181
+ path={`component.options.columns.${index}.blocks`}
182
+ parent={props.builderBlock.id}
183
+ styleProp={{
184
+ flexGrow: 1,
185
+ }}
186
+ context={props.builderContext}
187
+ registeredComponents={props.builderComponents}
188
+ linkComponent={props.builderLinkComponent}
189
+ blocks={column.blocks}
190
+ />
191
+ </DynamicRenderer>
192
+ ))}
193
+ </View>
194
+ );
195
+ }
196
+
197
+ const styles = StyleSheet.create({ view1: { display: "flex" } });
198
+
199
+ export default Columns;
@@ -0,0 +1,14 @@
1
+ import type { BuilderBlock } from '../../types/builder-block';
2
+ import type { BuilderComponentsProp, BuilderDataProps, BuilderLinkComponentProp } from '../../types/builder-props';
3
+ export type Column = {
4
+ blocks: BuilderBlock[];
5
+ width?: number;
6
+ link?: string;
7
+ };
8
+ type StackColumnsAt = 'tablet' | 'mobile' | 'never';
9
+ export interface ColumnProps extends BuilderComponentsProp, BuilderLinkComponentProp, BuilderDataProps {
10
+ columns?: Column[];
11
+ space?: number;
12
+ stackColumnsAt?: StackColumnsAt;
13
+ reverseColumnsWhenStacked?: boolean;
14
+ }
@@ -0,0 +1,219 @@
1
+ import type { ComponentInfo } from '../../types/components';
2
+ export const componentInfo: ComponentInfo = {
3
+ // TODO: ways to statically preprocess JSON for references, functions, etc
4
+ name: 'Columns',
5
+ isRSC: true,
6
+ inputs: [{
7
+ name: 'columns',
8
+ type: 'array',
9
+ broadcast: true,
10
+ subFields: [{
11
+ name: 'blocks',
12
+ type: 'array',
13
+ hideFromUI: true,
14
+ defaultValue: [{
15
+ '@type': '@builder.io/sdk:Element',
16
+ responsiveStyles: {
17
+ large: {
18
+ display: 'flex',
19
+ flexDirection: 'column',
20
+ alignItems: 'stretch',
21
+ flexShrink: '0',
22
+ position: 'relative',
23
+ marginTop: '30px',
24
+ textAlign: 'center',
25
+ lineHeight: 'normal',
26
+ height: 'auto',
27
+ minHeight: '20px',
28
+ minWidth: '20px',
29
+ overflow: 'hidden'
30
+ }
31
+ },
32
+ component: {
33
+ name: 'Image',
34
+ options: {
35
+ image: 'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
36
+ backgroundPosition: 'center',
37
+ backgroundSize: 'cover',
38
+ aspectRatio: 0.7004048582995948
39
+ }
40
+ }
41
+ }, {
42
+ '@type': '@builder.io/sdk:Element',
43
+ responsiveStyles: {
44
+ large: {
45
+ display: 'flex',
46
+ flexDirection: 'column',
47
+ alignItems: 'stretch',
48
+ flexShrink: '0',
49
+ position: 'relative',
50
+ marginTop: '30px',
51
+ textAlign: 'center',
52
+ lineHeight: 'normal',
53
+ height: 'auto'
54
+ }
55
+ },
56
+ component: {
57
+ name: 'Text',
58
+ options: {
59
+ text: '<p>Enter some text...</p>'
60
+ }
61
+ }
62
+ }]
63
+ }, {
64
+ name: 'width',
65
+ type: 'number',
66
+ hideFromUI: true,
67
+ helperText: 'Width %, e.g. set to 50 to fill half of the space'
68
+ }, {
69
+ name: 'link',
70
+ type: 'url',
71
+ helperText: 'Optionally set a url that clicking this column will link to'
72
+ }],
73
+ defaultValue: [{
74
+ blocks: [{
75
+ '@type': '@builder.io/sdk:Element',
76
+ responsiveStyles: {
77
+ large: {
78
+ display: 'flex',
79
+ flexDirection: 'column',
80
+ alignItems: 'stretch',
81
+ flexShrink: '0',
82
+ position: 'relative',
83
+ marginTop: '30px',
84
+ textAlign: 'center',
85
+ lineHeight: 'normal',
86
+ height: 'auto',
87
+ minHeight: '20px',
88
+ minWidth: '20px',
89
+ overflow: 'hidden'
90
+ }
91
+ },
92
+ component: {
93
+ name: 'Image',
94
+ options: {
95
+ image: 'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
96
+ backgroundPosition: 'center',
97
+ backgroundSize: 'cover',
98
+ aspectRatio: 0.7004048582995948
99
+ }
100
+ }
101
+ }, {
102
+ '@type': '@builder.io/sdk:Element',
103
+ responsiveStyles: {
104
+ large: {
105
+ display: 'flex',
106
+ flexDirection: 'column',
107
+ alignItems: 'stretch',
108
+ flexShrink: '0',
109
+ position: 'relative',
110
+ marginTop: '30px',
111
+ textAlign: 'center',
112
+ lineHeight: 'normal',
113
+ height: 'auto'
114
+ }
115
+ },
116
+ component: {
117
+ name: 'Text',
118
+ options: {
119
+ text: '<p>Enter some text...</p>'
120
+ }
121
+ }
122
+ }]
123
+ }, {
124
+ blocks: [{
125
+ '@type': '@builder.io/sdk:Element',
126
+ responsiveStyles: {
127
+ large: {
128
+ display: 'flex',
129
+ flexDirection: 'column',
130
+ alignItems: 'stretch',
131
+ flexShrink: '0',
132
+ position: 'relative',
133
+ marginTop: '30px',
134
+ textAlign: 'center',
135
+ lineHeight: 'normal',
136
+ height: 'auto',
137
+ minHeight: '20px',
138
+ minWidth: '20px',
139
+ overflow: 'hidden'
140
+ }
141
+ },
142
+ component: {
143
+ name: 'Image',
144
+ options: {
145
+ image: 'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
146
+ backgroundPosition: 'center',
147
+ backgroundSize: 'cover',
148
+ aspectRatio: 0.7004048582995948
149
+ }
150
+ }
151
+ }, {
152
+ '@type': '@builder.io/sdk:Element',
153
+ responsiveStyles: {
154
+ large: {
155
+ display: 'flex',
156
+ flexDirection: 'column',
157
+ alignItems: 'stretch',
158
+ flexShrink: '0',
159
+ position: 'relative',
160
+ marginTop: '30px',
161
+ textAlign: 'center',
162
+ lineHeight: 'normal',
163
+ height: 'auto'
164
+ }
165
+ },
166
+ component: {
167
+ name: 'Text',
168
+ options: {
169
+ text: '<p>Enter some text...</p>'
170
+ }
171
+ }
172
+ }]
173
+ }],
174
+ onChange: (options: Map<string, any>) => {
175
+ function clearWidths() {
176
+ columns.forEach(col => {
177
+ col.delete('width');
178
+ });
179
+ }
180
+ const columns: Array<Map<string, any>> = options.get('columns');
181
+ if (Array.isArray(columns)) {
182
+ const containsColumnWithWidth = !!columns.find(col => col.get('width'));
183
+ if (containsColumnWithWidth) {
184
+ const containsColumnWithoutWidth = !!columns.find(col => !col.get('width'));
185
+ if (containsColumnWithoutWidth) {
186
+ clearWidths();
187
+ } else {
188
+ const sumWidths = columns.reduce((memo, col) => {
189
+ return memo + col.get('width');
190
+ }, 0);
191
+ const widthsDontAddUp = sumWidths !== 100;
192
+ if (widthsDontAddUp) {
193
+ clearWidths();
194
+ }
195
+ }
196
+ }
197
+ }
198
+ }
199
+ }, {
200
+ name: 'space',
201
+ type: 'number',
202
+ defaultValue: 20,
203
+ helperText: 'Size of gap between columns',
204
+ advanced: true
205
+ }, {
206
+ name: 'stackColumnsAt',
207
+ type: 'string',
208
+ defaultValue: 'tablet',
209
+ helperText: 'Convert horizontal columns to vertical at what device size',
210
+ enum: ['tablet', 'mobile', 'never'],
211
+ advanced: true
212
+ }, {
213
+ name: 'reverseColumnsWhenStacked',
214
+ type: 'boolean',
215
+ defaultValue: false,
216
+ helperText: 'When stacking columns for mobile devices, reverse the ordering',
217
+ advanced: true
218
+ }]
219
+ }
@@ -0,0 +1,3 @@
1
+ export const getColumnsClass = (id?: string) => {
2
+ return `builder-columns ${id}-breakpoints`;
3
+ }
@@ -0,0 +1 @@
1
+ export { default } from './columns'