@builder.io/sdk-react-native 1.0.30 → 1.0.31-0

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 (225) hide show
  1. package/lib/browser/commonjs/constants/sdk-version.js +1 -1
  2. package/lib/browser/module/constants/sdk-version.js +1 -1
  3. package/lib/browser/typescript/constants/sdk-version.d.ts +1 -1
  4. package/lib/edge/commonjs/constants/sdk-version.js +1 -1
  5. package/lib/edge/module/constants/sdk-version.js +1 -1
  6. package/lib/edge/typescript/constants/sdk-version.d.ts +1 -1
  7. package/lib/node/commonjs/constants/sdk-version.js +1 -1
  8. package/lib/node/index.cjs +6910 -0
  9. package/lib/node/index.mjs +7477 -0
  10. package/lib/node/module/constants/sdk-version.js +1 -1
  11. package/lib/node/typescript/constants/sdk-version.d.ts +1 -1
  12. package/package.json +9 -5
  13. package/src/blocks/BaseText.tsx +17 -0
  14. package/src/blocks/accordion/accordion.tsx +181 -0
  15. package/src/blocks/accordion/accordion.types.ts +12 -0
  16. package/src/blocks/accordion/component-info.ts +124 -0
  17. package/src/blocks/accordion/helpers.ts +3 -0
  18. package/src/blocks/accordion/index.ts +1 -0
  19. package/src/blocks/button/button.tsx +56 -0
  20. package/src/blocks/button/button.types.ts +7 -0
  21. package/src/blocks/button/component-info.ts +35 -0
  22. package/src/blocks/button/index.ts +1 -0
  23. package/src/blocks/columns/columns.tsx +199 -0
  24. package/src/blocks/columns/columns.types.ts +14 -0
  25. package/src/blocks/columns/component-info.ts +219 -0
  26. package/src/blocks/columns/helpers.ts +3 -0
  27. package/src/blocks/columns/index.ts +1 -0
  28. package/src/blocks/custom-code/component-info.ts +24 -0
  29. package/src/blocks/custom-code/custom-code.tsx +71 -0
  30. package/src/blocks/custom-code/index.ts +1 -0
  31. package/src/blocks/embed/component-info.ts +38 -0
  32. package/src/blocks/embed/embed.tsx +62 -0
  33. package/src/blocks/embed/helpers.ts +2 -0
  34. package/src/blocks/embed/index.ts +1 -0
  35. package/src/blocks/form/form/component-info.ts +233 -0
  36. package/src/blocks/form/form/form.tsx +324 -0
  37. package/src/blocks/form/form/index.ts +1 -0
  38. package/src/blocks/form/input/component-info.ts +47 -0
  39. package/src/blocks/form/input/index.ts +1 -0
  40. package/src/blocks/form/input/input.tsx +49 -0
  41. package/src/blocks/form/select/component-info.ts +44 -0
  42. package/src/blocks/form/select/index.ts +1 -0
  43. package/src/blocks/form/select/select.tsx +54 -0
  44. package/src/blocks/form/submit-button/component-info.ts +27 -0
  45. package/src/blocks/form/submit-button/index.ts +1 -0
  46. package/src/blocks/form/submit-button/submit-button.tsx +34 -0
  47. package/src/blocks/fragment/component-info.ts +8 -0
  48. package/src/blocks/fragment/fragment.tsx +18 -0
  49. package/src/blocks/fragment/fragment.types.ts +5 -0
  50. package/src/blocks/fragment/index.ts +1 -0
  51. package/src/blocks/helpers.ts +43 -0
  52. package/src/blocks/image/component-info.ts +124 -0
  53. package/src/blocks/image/image.helpers.ts +47 -0
  54. package/src/blocks/image/image.tsx +65 -0
  55. package/src/blocks/image/image.types.ts +19 -0
  56. package/src/blocks/image/index.ts +1 -0
  57. package/src/blocks/img/component-info.ts +16 -0
  58. package/src/blocks/img/img.tsx +55 -0
  59. package/src/blocks/img/index.ts +1 -0
  60. package/src/blocks/raw-text/component-info.ts +11 -0
  61. package/src/blocks/raw-text/index.ts +1 -0
  62. package/src/blocks/raw-text/raw-text.tsx +1 -0
  63. package/src/blocks/section/component-info.ts +41 -0
  64. package/src/blocks/section/index.ts +1 -0
  65. package/src/blocks/section/section.tsx +39 -0
  66. package/src/blocks/section/section.types.ts +6 -0
  67. package/src/blocks/slot/component-info.ts +15 -0
  68. package/src/blocks/slot/index.ts +1 -0
  69. package/src/blocks/slot/slot.tsx +42 -0
  70. package/src/blocks/symbol/component-info.ts +35 -0
  71. package/src/blocks/symbol/index.ts +1 -0
  72. package/src/blocks/symbol/symbol.helpers.ts +47 -0
  73. package/src/blocks/symbol/symbol.tsx +99 -0
  74. package/src/blocks/symbol/symbol.types.ts +17 -0
  75. package/src/blocks/tabs/component-info.ts +139 -0
  76. package/src/blocks/tabs/index.ts +1 -0
  77. package/src/blocks/tabs/tabs.tsx +79 -0
  78. package/src/blocks/tabs/tabs.types.ts +13 -0
  79. package/src/blocks/text/component-info.ts +20 -0
  80. package/src/blocks/text/index.ts +1 -0
  81. package/src/blocks/text/text.tsx +105 -0
  82. package/src/blocks/text/text.types.ts +4 -0
  83. package/src/blocks/textarea/component-info.ts +38 -0
  84. package/src/blocks/textarea/index.ts +1 -0
  85. package/src/blocks/textarea/textarea.tsx +41 -0
  86. package/src/blocks/video/component-info.ts +83 -0
  87. package/src/blocks/video/index.ts +1 -0
  88. package/src/blocks/video/video.tsx +70 -0
  89. package/src/blocks/video/video.types.ts +21 -0
  90. package/src/components/block/animator.ts +220 -0
  91. package/src/components/block/block.helpers.ts +106 -0
  92. package/src/components/block/block.tsx +235 -0
  93. package/src/components/block/components/block-styles.tsx +136 -0
  94. package/src/components/block/components/block-wrapper.tsx +53 -0
  95. package/src/components/block/components/component-ref/component-ref.helpers.ts +55 -0
  96. package/src/components/block/components/component-ref/component-ref.tsx +66 -0
  97. package/src/components/block/components/interactive-element.tsx +53 -0
  98. package/src/components/block/components/repeated-block.tsx +37 -0
  99. package/src/components/block/types.ts +6 -0
  100. package/src/components/blocks/blocks-wrapper.tsx +93 -0
  101. package/src/components/blocks/blocks.tsx +57 -0
  102. package/src/components/blocks/blocks.types.ts +7 -0
  103. package/src/components/blocks/index.ts +1 -0
  104. package/src/components/content/components/enable-editor.tsx +471 -0
  105. package/src/components/content/components/styles.helpers.ts +101 -0
  106. package/src/components/content/components/styles.tsx +42 -0
  107. package/src/components/content/content.helpers.ts +40 -0
  108. package/src/components/content/content.tsx +150 -0
  109. package/src/components/content/content.types.ts +13 -0
  110. package/src/components/content/contentProps.types.ts +17 -0
  111. package/src/components/content/index.ts +1 -0
  112. package/src/components/content/wrap-component-ref.ts +6 -0
  113. package/src/components/content-variants/content-variants.tsx +146 -0
  114. package/src/components/content-variants/content-variants.types.ts +84 -0
  115. package/src/components/content-variants/helpers.ts +72 -0
  116. package/src/components/content-variants/index.ts +1 -0
  117. package/src/components/content-variants/inlined-fns.ts +22 -0
  118. package/src/components/dynamic-div.tsx +30 -0
  119. package/src/components/dynamic-renderer/dynamic-renderer.helpers.ts +7 -0
  120. package/src/components/dynamic-renderer/dynamic-renderer.tsx +47 -0
  121. package/src/components/error-boundary.tsx +38 -0
  122. package/src/components/inlined-script.tsx +10 -0
  123. package/src/components/inlined-styles.tsx +10 -0
  124. package/src/constants/builder-registered-components.ts +59 -0
  125. package/src/constants/device-sizes.ts +59 -0
  126. package/src/constants/extra-components.ts +1 -0
  127. package/src/constants/sdk-version.ts +1 -0
  128. package/src/constants/target.ts +3 -0
  129. package/src/context/builder.context.ts +15 -0
  130. package/src/context/components.context.ts +3 -0
  131. package/src/context/index.ts +1 -0
  132. package/src/context/types.ts +37 -0
  133. package/src/functions/apply-patch-with-mutation.ts +61 -0
  134. package/src/functions/camel-to-kebab-case.ts +1 -0
  135. package/src/functions/deopt.ts +6 -0
  136. package/src/functions/evaluate/browser-runtime/browser.ts +61 -0
  137. package/src/functions/evaluate/browser-runtime/index.ts +1 -0
  138. package/src/functions/evaluate/choose-eval.ts +23 -0
  139. package/src/functions/evaluate/edge-runtime/acorn-interpreter.ts +2891 -0
  140. package/src/functions/evaluate/edge-runtime/edge-runtime.ts +96 -0
  141. package/src/functions/evaluate/edge-runtime/index.ts +1 -0
  142. package/src/functions/evaluate/evaluate.ts +76 -0
  143. package/src/functions/evaluate/helpers.ts +56 -0
  144. package/src/functions/evaluate/index.ts +1 -0
  145. package/src/functions/evaluate/node-runtime/index.ts +1 -0
  146. package/src/functions/evaluate/node-runtime/init.ts +33 -0
  147. package/src/functions/evaluate/node-runtime/node-runtime.ts +176 -0
  148. package/src/functions/evaluate/node-runtime/safeDynamicRequire.ts +24 -0
  149. package/src/functions/evaluate/placeholder-runtime.ts +4 -0
  150. package/src/functions/evaluate/should-force-browser-runtime-in-node.ts +16 -0
  151. package/src/functions/event-handler-name.ts +4 -0
  152. package/src/functions/extract-text-styles.ts +24 -0
  153. package/src/functions/fast-clone.ts +4 -0
  154. package/src/functions/fetch-builder-props.ts +75 -0
  155. package/src/functions/get-block-actions-handler.ts +17 -0
  156. package/src/functions/get-block-actions.ts +35 -0
  157. package/src/functions/get-block-component-options.ts +11 -0
  158. package/src/functions/get-block-properties.ts +62 -0
  159. package/src/functions/get-builder-search-params/index.ts +33 -0
  160. package/src/functions/get-class-prop-name.ts +15 -0
  161. package/src/functions/get-content/generate-content-url.ts +88 -0
  162. package/src/functions/get-content/index.ts +99 -0
  163. package/src/functions/get-content/types.ts +157 -0
  164. package/src/functions/get-env.ts +5 -0
  165. package/src/functions/get-fetch.ts +11 -0
  166. package/src/functions/get-global-this.ts +16 -0
  167. package/src/functions/get-processed-block.ts +70 -0
  168. package/src/functions/get-style.ts +38 -0
  169. package/src/functions/get.ts +4 -0
  170. package/src/functions/is-browser.ts +3 -0
  171. package/src/functions/is-edge-runtime.ts +9 -0
  172. package/src/functions/is-editing.ts +8 -0
  173. package/src/functions/is-from-trusted-host.ts +8 -0
  174. package/src/functions/is-iframe.ts +4 -0
  175. package/src/functions/is-node-runtime.ts +8 -0
  176. package/src/functions/is-previewing.ts +16 -0
  177. package/src/functions/on-change.ts +29 -0
  178. package/src/functions/register-component.ts +30 -0
  179. package/src/functions/register.ts +44 -0
  180. package/src/functions/set-editor-settings.ts +15 -0
  181. package/src/functions/set.ts +14 -0
  182. package/src/functions/track/helpers.ts +51 -0
  183. package/src/functions/track/index.ts +131 -0
  184. package/src/functions/track/interaction.ts +63 -0
  185. package/src/functions/transform-block-properties.ts +33 -0
  186. package/src/functions/transform-block.ts +30 -0
  187. package/src/functions/transform-style-property.ts +296 -0
  188. package/src/helpers/ab-tests.ts +166 -0
  189. package/src/helpers/canTrack.ts +2 -0
  190. package/src/helpers/cookie.ts +97 -0
  191. package/src/helpers/css.ts +33 -0
  192. package/src/helpers/flatten.ts +41 -0
  193. package/src/helpers/localStorage.ts +36 -0
  194. package/src/helpers/logger.ts +7 -0
  195. package/src/helpers/nullable.ts +2 -0
  196. package/src/helpers/omit.ts +7 -0
  197. package/src/helpers/preview-lru-cache/get.ts +4 -0
  198. package/src/helpers/preview-lru-cache/helpers.ts +1 -0
  199. package/src/helpers/preview-lru-cache/init.ts +7 -0
  200. package/src/helpers/preview-lru-cache/set.ts +12 -0
  201. package/src/helpers/preview-lru-cache/types.ts +1 -0
  202. package/src/helpers/search/search.ts +18 -0
  203. package/src/helpers/sessionId.ts +37 -0
  204. package/src/helpers/subscribe-to-editor.ts +95 -0
  205. package/src/helpers/time.ts +2 -0
  206. package/src/helpers/url.ts +15 -0
  207. package/src/helpers/uuid.ts +17 -0
  208. package/src/helpers/visitorId.ts +37 -0
  209. package/src/index-helpers/blocks-exports.ts +16 -0
  210. package/src/index-helpers/top-of-file.ts +2 -0
  211. package/src/index.ts +15 -0
  212. package/src/scripts/init-editing.ts +119 -0
  213. package/src/server-index.ts +43 -0
  214. package/src/types/api-version.ts +2 -0
  215. package/src/types/builder-block.ts +89 -0
  216. package/src/types/builder-content.ts +47 -0
  217. package/src/types/builder-props.ts +12 -0
  218. package/src/types/can-track.ts +3 -0
  219. package/src/types/components.ts +119 -0
  220. package/src/types/deep-partial.ts +1 -0
  221. package/src/types/element.ts +57 -0
  222. package/src/types/enforced-partials.ts +19 -0
  223. package/src/types/input.ts +123 -0
  224. package/src/types/targets.ts +1 -0
  225. package/src/types/typescript.ts +9 -0
@@ -0,0 +1,235 @@
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 { useEffect } from "react";
14
+
15
+ export type BlockProps = {
16
+ block: BuilderBlock;
17
+ context: BuilderContextInterface;
18
+ registeredComponents: RegisteredComponents;
19
+ linkComponent: any;
20
+ };
21
+ import type {
22
+ BuilderContextInterface,
23
+ RegisteredComponents,
24
+ } from "../../context/types";
25
+ import { getBlockComponentOptions } from "../../functions/get-block-component-options";
26
+ import { getProcessedBlock } from "../../functions/get-processed-block";
27
+ import type { BuilderBlock } from "../../types/builder-block";
28
+ import DynamicDiv from "../dynamic-div";
29
+ import { bindAnimations } from "./animator";
30
+ import {
31
+ getComponent,
32
+ getInheritedStyles,
33
+ getRepeatItemData,
34
+ shouldPassLinkComponent,
35
+ shouldPassRegisteredComponents,
36
+ } from "./block.helpers";
37
+ import BlockStyles from "./components/block-styles";
38
+ import BlockWrapper from "./components/block-wrapper";
39
+ import type { ComponentProps } from "./components/component-ref/component-ref.helpers";
40
+ import ComponentRef from "./components/component-ref/component-ref";
41
+ import RepeatedBlock from "./components/repeated-block";
42
+
43
+ function Block(props: BlockProps) {
44
+ function blockComponent() {
45
+ return getComponent({
46
+ block: props.block,
47
+ context: props.context,
48
+ registeredComponents: props.registeredComponents,
49
+ });
50
+ }
51
+
52
+ function repeatItem() {
53
+ return getRepeatItemData({
54
+ block: props.block,
55
+ context: props.context,
56
+ });
57
+ }
58
+
59
+ function processedBlock() {
60
+ return props.block.repeat?.collection
61
+ ? props.block
62
+ : getProcessedBlock({
63
+ block: props.block,
64
+ localState: props.context.localState,
65
+ rootState: props.context.rootState,
66
+ rootSetState: props.context.rootSetState,
67
+ context: props.context.context,
68
+ shouldEvaluateBindings: true,
69
+ });
70
+ }
71
+
72
+ function Tag() {
73
+ const shouldUseLink =
74
+ props.block.tagName === "a" ||
75
+ processedBlock().properties?.href ||
76
+ processedBlock().href;
77
+ if (shouldUseLink) {
78
+ return props.linkComponent || BaseText;
79
+ }
80
+ return View;
81
+ }
82
+
83
+ function canShowBlock() {
84
+ if (props.block.repeat?.collection) {
85
+ if (repeatItem?.()?.length) return true;
86
+ return false;
87
+ }
88
+ const shouldHide =
89
+ "hide" in processedBlock() ? processedBlock().hide : false;
90
+ const shouldShow =
91
+ "show" in processedBlock() ? processedBlock().show : true;
92
+ return shouldShow && !shouldHide;
93
+ }
94
+
95
+ function childrenWithoutParentComponent() {
96
+ /**
97
+ * When there is no `componentRef`, there might still be children that need to be rendered. In this case,
98
+ * we render them outside of `componentRef`.
99
+ * NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
100
+ * blocks, and the children will be repeated within those blocks.
101
+ */
102
+ const shouldRenderChildrenOutsideRef =
103
+ !blockComponent?.()?.component && !repeatItem();
104
+ return shouldRenderChildrenOutsideRef
105
+ ? processedBlock().children ?? []
106
+ : [];
107
+ }
108
+
109
+ function componentRefProps() {
110
+ return {
111
+ blockChildren: processedBlock().children ?? [],
112
+ componentRef: blockComponent?.()?.component,
113
+ componentOptions: {
114
+ ...getBlockComponentOptions(processedBlock()),
115
+ builderContext: props.context,
116
+ ...(shouldPassLinkComponent(blockComponent())
117
+ ? {
118
+ builderLinkComponent: props.linkComponent,
119
+ }
120
+ : {}),
121
+ ...(shouldPassRegisteredComponents(blockComponent())
122
+ ? {
123
+ builderComponents: props.registeredComponents,
124
+ }
125
+ : {}),
126
+ },
127
+ context: {
128
+ ...props.context,
129
+ inheritedStyles: getInheritedStyles({
130
+ block: processedBlock(),
131
+ context: props.context,
132
+ }),
133
+ } as any,
134
+ linkComponent: props.linkComponent,
135
+ registeredComponents: props.registeredComponents,
136
+ builderBlock: processedBlock(),
137
+ includeBlockProps: blockComponent?.()?.noWrap === true,
138
+ isInteractive: !blockComponent?.()?.isRSC,
139
+ };
140
+ }
141
+
142
+ useEffect(() => {
143
+ const blockId = processedBlock().id;
144
+ const animations = processedBlock().animations;
145
+ if (animations && blockId) {
146
+ bindAnimations(
147
+ animations.map((animation) => ({
148
+ ...animation,
149
+ elementId: blockId,
150
+ }))
151
+ );
152
+ }
153
+ }, []);
154
+
155
+ return (
156
+ <>
157
+ {canShowBlock() ? (
158
+ <>
159
+ <BlockStyles block={props.block} context={props.context} />
160
+ {!blockComponent?.()?.noWrap ? (
161
+ <>
162
+ {!repeatItem() ? (
163
+ <BlockWrapper
164
+ Wrapper={Tag()}
165
+ block={processedBlock()}
166
+ context={props.context}
167
+ linkComponent={props.linkComponent}
168
+ >
169
+ <ComponentRef
170
+ componentRef={componentRefProps().componentRef}
171
+ componentOptions={componentRefProps().componentOptions}
172
+ blockChildren={componentRefProps().blockChildren}
173
+ context={componentRefProps().context}
174
+ registeredComponents={
175
+ componentRefProps().registeredComponents
176
+ }
177
+ linkComponent={componentRefProps().linkComponent}
178
+ builderBlock={componentRefProps().builderBlock}
179
+ includeBlockProps={componentRefProps().includeBlockProps}
180
+ isInteractive={componentRefProps().isInteractive}
181
+ />
182
+ {childrenWithoutParentComponent()?.map((child) => (
183
+ <Block
184
+ key={child.id}
185
+ block={child}
186
+ registeredComponents={props.registeredComponents}
187
+ linkComponent={props.linkComponent}
188
+ context={
189
+ {
190
+ ...props.context,
191
+ inheritedStyles: getInheritedStyles({
192
+ block: processedBlock(),
193
+ context: props.context,
194
+ }),
195
+ } as any
196
+ }
197
+ />
198
+ ))}
199
+ </BlockWrapper>
200
+ ) : (
201
+ <>
202
+ {repeatItem()?.map((data, index) => (
203
+ <RepeatedBlock
204
+ key={index}
205
+ repeatContext={data.context}
206
+ block={data.block}
207
+ registeredComponents={props.registeredComponents}
208
+ linkComponent={props.linkComponent}
209
+ />
210
+ ))}
211
+ </>
212
+ )}
213
+ </>
214
+ ) : (
215
+ <>
216
+ <ComponentRef
217
+ componentRef={componentRefProps().componentRef}
218
+ componentOptions={componentRefProps().componentOptions}
219
+ blockChildren={componentRefProps().blockChildren}
220
+ context={componentRefProps().context}
221
+ registeredComponents={componentRefProps().registeredComponents}
222
+ linkComponent={componentRefProps().linkComponent}
223
+ builderBlock={componentRefProps().builderBlock}
224
+ includeBlockProps={componentRefProps().includeBlockProps}
225
+ isInteractive={componentRefProps().isInteractive}
226
+ />
227
+ </>
228
+ )}
229
+ </>
230
+ ) : null}
231
+ </>
232
+ );
233
+ }
234
+
235
+ export default Block;
@@ -0,0 +1,136 @@
1
+ import * as React from "react";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ Pressable,
10
+ TextInput,
11
+ } from "react-native";
12
+
13
+ export type BlockStylesProps = {
14
+ block: BuilderBlock;
15
+ context: BuilderContextInterface;
16
+ };
17
+ import {
18
+ getMaxWidthQueryForSize,
19
+ getSizesForBreakpoints,
20
+ } from "../../../constants/device-sizes";
21
+ import { TARGET } from "../../../constants/target";
22
+ import type { BuilderContextInterface } from "../../../context/types";
23
+ import { camelToKebabCase } from "../../../functions/camel-to-kebab-case";
24
+ import { getProcessedBlock } from "../../../functions/get-processed-block";
25
+ import { createCssClass } from "../../../helpers/css";
26
+ import { checkIsDefined } from "../../../helpers/nullable";
27
+ import type { BuilderBlock } from "../../../types/builder-block";
28
+ import InlinedStyles from "../../inlined-styles";
29
+
30
+ function BlockStyles(props: BlockStylesProps) {
31
+ function canShowBlock() {
32
+ const processedBlock = getProcessedBlock({
33
+ block: props.block,
34
+ localState: props.context.localState,
35
+ rootState: props.context.rootState,
36
+ rootSetState: props.context.rootSetState,
37
+ context: props.context.context,
38
+ shouldEvaluateBindings: true,
39
+ });
40
+ // only render styles for blocks that are visible
41
+ if (checkIsDefined(processedBlock.hide)) {
42
+ return !processedBlock.hide;
43
+ }
44
+ if (checkIsDefined(processedBlock.show)) {
45
+ return processedBlock.show;
46
+ }
47
+ return true;
48
+ }
49
+
50
+ function css() {
51
+ const processedBlock = getProcessedBlock({
52
+ block: props.block,
53
+ localState: props.context.localState,
54
+ rootState: props.context.rootState,
55
+ rootSetState: props.context.rootSetState,
56
+ context: props.context.context,
57
+ shouldEvaluateBindings: true,
58
+ });
59
+ const styles = processedBlock.responsiveStyles;
60
+ const content = props.context.content;
61
+ const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(
62
+ content?.meta?.breakpoints || {}
63
+ );
64
+ const largeStyles = styles?.large;
65
+ const mediumStyles = styles?.medium;
66
+ const smallStyles = styles?.small;
67
+ const className = processedBlock.id;
68
+ if (!className) {
69
+ return "";
70
+ }
71
+ const largeStylesClass = largeStyles
72
+ ? createCssClass({
73
+ className,
74
+ styles: largeStyles,
75
+ })
76
+ : "";
77
+ const mediumStylesClass = mediumStyles
78
+ ? createCssClass({
79
+ className,
80
+ styles: mediumStyles,
81
+ mediaQuery: getMaxWidthQueryForSize(
82
+ "medium",
83
+ sizesWithUpdatedBreakpoints
84
+ ),
85
+ })
86
+ : "";
87
+ const smallStylesClass = smallStyles
88
+ ? createCssClass({
89
+ className,
90
+ styles: smallStyles,
91
+ mediaQuery: getMaxWidthQueryForSize(
92
+ "small",
93
+ sizesWithUpdatedBreakpoints
94
+ ),
95
+ })
96
+ : "";
97
+ const hoverAnimation =
98
+ processedBlock.animations &&
99
+ processedBlock.animations.find((item) => item.trigger === "hover");
100
+ let hoverStylesClass = "";
101
+ if (hoverAnimation) {
102
+ const hoverStyles = hoverAnimation.steps?.[1]?.styles || {};
103
+ hoverStylesClass =
104
+ createCssClass({
105
+ className: `${className}:hover`,
106
+ styles: {
107
+ ...hoverStyles,
108
+ transition: `all ${hoverAnimation.duration}s ${camelToKebabCase(
109
+ hoverAnimation.easing
110
+ )}`,
111
+ transitionDelay: hoverAnimation.delay
112
+ ? `${hoverAnimation.delay}s`
113
+ : "0s",
114
+ },
115
+ }) || "";
116
+ }
117
+ return [
118
+ largeStylesClass,
119
+ mediumStylesClass,
120
+ smallStylesClass,
121
+ hoverStylesClass,
122
+ ].join(" ");
123
+ }
124
+
125
+ return (
126
+ <>
127
+ {TARGET !== "reactNative" && css() && canShowBlock() ? (
128
+ <>
129
+ <InlinedStyles id="builderio-block" styles={css()} />
130
+ </>
131
+ ) : null}
132
+ </>
133
+ );
134
+ }
135
+
136
+ export default BlockStyles;
@@ -0,0 +1,53 @@
1
+ import * as React from "react";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ Pressable,
10
+ TextInput,
11
+ } from "react-native";
12
+
13
+ type BlockWrapperProps = {
14
+ Wrapper: string;
15
+ block: BuilderBlock;
16
+ context: BuilderContextInterface;
17
+ linkComponent: any;
18
+ children?: any;
19
+ };
20
+
21
+ /**
22
+ * This component renders a block's wrapper HTML element (from the block's `tagName` property).
23
+ */
24
+
25
+ import type { BuilderContextInterface } from "../../../context/types";
26
+ import { getBlockActions } from "../../../functions/get-block-actions";
27
+ import { getBlockProperties } from "../../../functions/get-block-properties";
28
+ import type { BuilderBlock } from "../../../types/builder-block";
29
+ import DynamicRenderer from "../../dynamic-renderer/dynamic-renderer";
30
+
31
+ function BlockWrapper(props: BlockWrapperProps) {
32
+ return (
33
+ <DynamicRenderer
34
+ TagName={props.Wrapper}
35
+ attributes={getBlockProperties({
36
+ block: props.block,
37
+ context: props.context,
38
+ })}
39
+ actionAttributes={getBlockActions({
40
+ block: props.block,
41
+ rootState: props.context.rootState,
42
+ rootSetState: props.context.rootSetState,
43
+ localState: props.context.localState,
44
+ context: props.context.context,
45
+ stripPrefix: true,
46
+ })}
47
+ >
48
+ {props.children}
49
+ </DynamicRenderer>
50
+ );
51
+ }
52
+
53
+ export default BlockWrapper;
@@ -0,0 +1,55 @@
1
+ import type { BuilderContextInterface, RegisteredComponents } from '../../../../context/types';
2
+ import { getBlockProperties } from '../../../../functions/get-block-properties';
3
+ import type { BuilderBlock } from '../../../../types/builder-block';
4
+ import type { BuilderDataProps } from '../../../../types/builder-props';
5
+ import type { InteractiveElementProps } from '../interactive-element';
6
+ type ComponentOptions = BuilderDataProps & {
7
+ [index: string]: any;
8
+ attributes?: {
9
+ [index: string]: any;
10
+ };
11
+ };
12
+ export interface ComponentProps {
13
+ componentRef: any;
14
+ componentOptions: ComponentOptions;
15
+ blockChildren: BuilderBlock[];
16
+ context: BuilderContextInterface;
17
+ registeredComponents: RegisteredComponents;
18
+ linkComponent: any;
19
+ builderBlock: BuilderBlock;
20
+ includeBlockProps: boolean;
21
+ isInteractive: boolean | undefined;
22
+ }
23
+ export const getWrapperProps = ({
24
+ componentOptions,
25
+ builderBlock,
26
+ context,
27
+ componentRef,
28
+ includeBlockProps,
29
+ isInteractive,
30
+ contextValue
31
+ }: Omit<ComponentProps, 'blockChildren' | 'registeredComponents'> & {
32
+ contextValue: BuilderContextInterface;
33
+ }) => {
34
+ const wrapperPropsWithAttributes = {
35
+ ...componentOptions,
36
+ /**
37
+ * If `noWrap` is set to `true`, then the block's props/attributes are provided to the
38
+ * component itself directly. Otherwise, they are provided to the wrapper element.
39
+ */
40
+ ...(includeBlockProps ? {
41
+ attributes: getBlockProperties({
42
+ block: builderBlock,
43
+ context: contextValue
44
+ })
45
+ } : {})
46
+ };
47
+ const interactiveElementProps: InteractiveElementProps = {
48
+ Wrapper: componentRef,
49
+ block: builderBlock,
50
+ context,
51
+ wrapperProps: componentOptions,
52
+ includeBlockProps
53
+ };
54
+ return isInteractive ? interactiveElementProps : wrapperPropsWithAttributes;
55
+ }
@@ -0,0 +1,66 @@
1
+ import * as React from "react";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ Pressable,
10
+ TextInput,
11
+ } from "react-native";
12
+ import { useState, useContext } from "react";
13
+ import { wrapComponentRef } from "../../../content/wrap-component-ref";
14
+ import Block from "../../block";
15
+ import InteractiveElement from "../interactive-element";
16
+ import type { ComponentProps } from "./component-ref.helpers";
17
+ import { getWrapperProps } from "./component-ref.helpers";
18
+ import BuilderContext from "../../../../context/builder.context";
19
+
20
+ function ComponentRef(props: ComponentProps) {
21
+ const [Wrapper, setWrapper] = useState(() =>
22
+ props.isInteractive ? InteractiveElement : props.componentRef
23
+ );
24
+
25
+ return (
26
+ <BuilderContext.Provider
27
+ value={{
28
+ content: props.context.content,
29
+ rootState: props.context.rootState,
30
+ localState: props.context.localState,
31
+ context: props.context.context,
32
+ apiKey: props.context.apiKey,
33
+ componentInfos: props.context.componentInfos,
34
+ inheritedStyles: props.context.inheritedStyles,
35
+ apiVersion: props.context.apiVersion,
36
+ }}
37
+ >
38
+ {props.componentRef ? (
39
+ <Wrapper
40
+ {...getWrapperProps({
41
+ componentOptions: props.componentOptions,
42
+ builderBlock: props.builderBlock,
43
+ context: props.context,
44
+ componentRef: props.componentRef,
45
+ linkComponent: props.linkComponent,
46
+ includeBlockProps: props.includeBlockProps,
47
+ isInteractive: props.isInteractive,
48
+ contextValue: props.context,
49
+ })}
50
+ >
51
+ {props.blockChildren?.map((child) => (
52
+ <Block
53
+ key={child.id}
54
+ block={child}
55
+ context={props.context}
56
+ registeredComponents={props.registeredComponents}
57
+ linkComponent={props.linkComponent}
58
+ />
59
+ ))}
60
+ </Wrapper>
61
+ ) : null}
62
+ </BuilderContext.Provider>
63
+ );
64
+ }
65
+
66
+ export default ComponentRef;
@@ -0,0 +1,53 @@
1
+ import * as React from "react";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ Pressable,
10
+ TextInput,
11
+ } from "react-native";
12
+
13
+ export type InteractiveElementProps = {
14
+ Wrapper: any;
15
+ block: BuilderBlock;
16
+ context: BuilderContextInterface;
17
+ wrapperProps: Dictionary<any>;
18
+ includeBlockProps: boolean;
19
+ children?: any;
20
+ };
21
+ import type { BuilderContextInterface } from "../../../context/types";
22
+ import { getBlockActions } from "../../../functions/get-block-actions";
23
+ import { getBlockProperties } from "../../../functions/get-block-properties";
24
+ import type { BuilderBlock } from "../../../types/builder-block";
25
+ import type { Dictionary } from "../../../types/typescript";
26
+
27
+ function InteractiveElement(props: InteractiveElementProps) {
28
+ function attributes() {
29
+ return props.includeBlockProps
30
+ ? {
31
+ ...getBlockProperties({
32
+ block: props.block,
33
+ context: props.context,
34
+ }),
35
+ ...getBlockActions({
36
+ block: props.block,
37
+ rootState: props.context.rootState,
38
+ rootSetState: props.context.rootSetState,
39
+ localState: props.context.localState,
40
+ context: props.context.context,
41
+ }),
42
+ }
43
+ : {};
44
+ }
45
+
46
+ return (
47
+ <props.Wrapper {...props.wrapperProps} attributes={attributes()}>
48
+ {props.children}
49
+ </props.Wrapper>
50
+ );
51
+ }
52
+
53
+ export default InteractiveElement;
@@ -0,0 +1,37 @@
1
+ import * as React from "react";
2
+ import {
3
+ FlatList,
4
+ ScrollView,
5
+ View,
6
+ StyleSheet,
7
+ Image,
8
+ Text,
9
+ Pressable,
10
+ TextInput,
11
+ } from "react-native";
12
+ import { useState, useContext } from "react";
13
+
14
+ type Props = Omit<BlockProps, "context"> & {
15
+ repeatContext: BuilderContextInterface;
16
+ };
17
+ import BuilderContext from "../../../context/builder.context";
18
+ import type { BuilderContextInterface } from "../../../context/types";
19
+ import type { BlockProps } from "../block";
20
+ import Block from "../block";
21
+
22
+ function RepeatedBlock(props: Props) {
23
+ const [store, setStore] = useState(() => props.repeatContext);
24
+
25
+ return (
26
+ <BuilderContext.Provider value={store}>
27
+ <Block
28
+ block={props.block}
29
+ context={store}
30
+ registeredComponents={props.registeredComponents}
31
+ linkComponent={props.linkComponent}
32
+ />
33
+ </BuilderContext.Provider>
34
+ );
35
+ }
36
+
37
+ export default RepeatedBlock;
@@ -0,0 +1,6 @@
1
+ import type { BuilderContextInterface } from '../../context/types';
2
+ import type { BuilderBlock } from '../../types/builder-block';
3
+ export interface RepeatData {
4
+ block: BuilderBlock;
5
+ context: BuilderContextInterface;
6
+ }