@builder.io/sdk-react-native 1.0.29 → 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 (216) hide show
  1. package/lib/node/index.cjs +6910 -0
  2. package/lib/node/index.mjs +7477 -0
  3. package/package.json +10 -6
  4. package/src/blocks/BaseText.tsx +17 -0
  5. package/src/blocks/accordion/accordion.tsx +181 -0
  6. package/src/blocks/accordion/accordion.types.ts +12 -0
  7. package/src/blocks/accordion/component-info.ts +124 -0
  8. package/src/blocks/accordion/helpers.ts +3 -0
  9. package/src/blocks/accordion/index.ts +1 -0
  10. package/src/blocks/button/button.tsx +56 -0
  11. package/src/blocks/button/button.types.ts +7 -0
  12. package/src/blocks/button/component-info.ts +35 -0
  13. package/src/blocks/button/index.ts +1 -0
  14. package/src/blocks/columns/columns.tsx +199 -0
  15. package/src/blocks/columns/columns.types.ts +14 -0
  16. package/src/blocks/columns/component-info.ts +219 -0
  17. package/src/blocks/columns/helpers.ts +3 -0
  18. package/src/blocks/columns/index.ts +1 -0
  19. package/src/blocks/custom-code/component-info.ts +24 -0
  20. package/src/blocks/custom-code/custom-code.tsx +71 -0
  21. package/src/blocks/custom-code/index.ts +1 -0
  22. package/src/blocks/embed/component-info.ts +38 -0
  23. package/src/blocks/embed/embed.tsx +62 -0
  24. package/src/blocks/embed/helpers.ts +2 -0
  25. package/src/blocks/embed/index.ts +1 -0
  26. package/src/blocks/form/form/component-info.ts +233 -0
  27. package/src/blocks/form/form/form.tsx +324 -0
  28. package/src/blocks/form/form/index.ts +1 -0
  29. package/src/blocks/form/input/component-info.ts +47 -0
  30. package/src/blocks/form/input/index.ts +1 -0
  31. package/src/blocks/form/input/input.tsx +49 -0
  32. package/src/blocks/form/select/component-info.ts +44 -0
  33. package/src/blocks/form/select/index.ts +1 -0
  34. package/src/blocks/form/select/select.tsx +54 -0
  35. package/src/blocks/form/submit-button/component-info.ts +27 -0
  36. package/src/blocks/form/submit-button/index.ts +1 -0
  37. package/src/blocks/form/submit-button/submit-button.tsx +34 -0
  38. package/src/blocks/fragment/component-info.ts +8 -0
  39. package/src/blocks/fragment/fragment.tsx +18 -0
  40. package/src/blocks/fragment/fragment.types.ts +5 -0
  41. package/src/blocks/fragment/index.ts +1 -0
  42. package/src/blocks/helpers.ts +43 -0
  43. package/src/blocks/image/component-info.ts +124 -0
  44. package/src/blocks/image/image.helpers.ts +47 -0
  45. package/src/blocks/image/image.tsx +65 -0
  46. package/src/blocks/image/image.types.ts +19 -0
  47. package/src/blocks/image/index.ts +1 -0
  48. package/src/blocks/img/component-info.ts +16 -0
  49. package/src/blocks/img/img.tsx +55 -0
  50. package/src/blocks/img/index.ts +1 -0
  51. package/src/blocks/raw-text/component-info.ts +11 -0
  52. package/src/blocks/raw-text/index.ts +1 -0
  53. package/src/blocks/raw-text/raw-text.tsx +1 -0
  54. package/src/blocks/section/component-info.ts +41 -0
  55. package/src/blocks/section/index.ts +1 -0
  56. package/src/blocks/section/section.tsx +39 -0
  57. package/src/blocks/section/section.types.ts +6 -0
  58. package/src/blocks/slot/component-info.ts +15 -0
  59. package/src/blocks/slot/index.ts +1 -0
  60. package/src/blocks/slot/slot.tsx +42 -0
  61. package/src/blocks/symbol/component-info.ts +35 -0
  62. package/src/blocks/symbol/index.ts +1 -0
  63. package/src/blocks/symbol/symbol.helpers.ts +47 -0
  64. package/src/blocks/symbol/symbol.tsx +99 -0
  65. package/src/blocks/symbol/symbol.types.ts +17 -0
  66. package/src/blocks/tabs/component-info.ts +139 -0
  67. package/src/blocks/tabs/index.ts +1 -0
  68. package/src/blocks/tabs/tabs.tsx +79 -0
  69. package/src/blocks/tabs/tabs.types.ts +13 -0
  70. package/src/blocks/text/component-info.ts +20 -0
  71. package/src/blocks/text/index.ts +1 -0
  72. package/src/blocks/text/text.tsx +105 -0
  73. package/src/blocks/text/text.types.ts +4 -0
  74. package/src/blocks/textarea/component-info.ts +38 -0
  75. package/src/blocks/textarea/index.ts +1 -0
  76. package/src/blocks/textarea/textarea.tsx +41 -0
  77. package/src/blocks/video/component-info.ts +83 -0
  78. package/src/blocks/video/index.ts +1 -0
  79. package/src/blocks/video/video.tsx +70 -0
  80. package/src/blocks/video/video.types.ts +21 -0
  81. package/src/components/block/animator.ts +220 -0
  82. package/src/components/block/block.helpers.ts +106 -0
  83. package/src/components/block/block.tsx +235 -0
  84. package/src/components/block/components/block-styles.tsx +136 -0
  85. package/src/components/block/components/block-wrapper.tsx +53 -0
  86. package/src/components/block/components/component-ref/component-ref.helpers.ts +55 -0
  87. package/src/components/block/components/component-ref/component-ref.tsx +66 -0
  88. package/src/components/block/components/interactive-element.tsx +53 -0
  89. package/src/components/block/components/repeated-block.tsx +37 -0
  90. package/src/components/block/types.ts +6 -0
  91. package/src/components/blocks/blocks-wrapper.tsx +93 -0
  92. package/src/components/blocks/blocks.tsx +57 -0
  93. package/src/components/blocks/blocks.types.ts +7 -0
  94. package/src/components/blocks/index.ts +1 -0
  95. package/src/components/content/components/enable-editor.tsx +471 -0
  96. package/src/components/content/components/styles.helpers.ts +101 -0
  97. package/src/components/content/components/styles.tsx +42 -0
  98. package/src/components/content/content.helpers.ts +40 -0
  99. package/src/components/content/content.tsx +150 -0
  100. package/src/components/content/content.types.ts +13 -0
  101. package/src/components/content/contentProps.types.ts +17 -0
  102. package/src/components/content/index.ts +1 -0
  103. package/src/components/content/wrap-component-ref.ts +6 -0
  104. package/src/components/content-variants/content-variants.tsx +146 -0
  105. package/src/components/content-variants/content-variants.types.ts +84 -0
  106. package/src/components/content-variants/helpers.ts +72 -0
  107. package/src/components/content-variants/index.ts +1 -0
  108. package/src/components/content-variants/inlined-fns.ts +22 -0
  109. package/src/components/dynamic-div.tsx +30 -0
  110. package/src/components/dynamic-renderer/dynamic-renderer.helpers.ts +7 -0
  111. package/src/components/dynamic-renderer/dynamic-renderer.tsx +47 -0
  112. package/src/components/error-boundary.tsx +38 -0
  113. package/src/components/inlined-script.tsx +10 -0
  114. package/src/components/inlined-styles.tsx +10 -0
  115. package/src/constants/builder-registered-components.ts +59 -0
  116. package/src/constants/device-sizes.ts +59 -0
  117. package/src/constants/extra-components.ts +1 -0
  118. package/src/constants/sdk-version.ts +1 -0
  119. package/src/constants/target.ts +3 -0
  120. package/src/context/builder.context.ts +15 -0
  121. package/src/context/components.context.ts +3 -0
  122. package/src/context/index.ts +1 -0
  123. package/src/context/types.ts +37 -0
  124. package/src/functions/apply-patch-with-mutation.ts +61 -0
  125. package/src/functions/camel-to-kebab-case.ts +1 -0
  126. package/src/functions/deopt.ts +6 -0
  127. package/src/functions/evaluate/browser-runtime/browser.ts +61 -0
  128. package/src/functions/evaluate/browser-runtime/index.ts +1 -0
  129. package/src/functions/evaluate/choose-eval.ts +23 -0
  130. package/src/functions/evaluate/edge-runtime/acorn-interpreter.ts +2891 -0
  131. package/src/functions/evaluate/edge-runtime/edge-runtime.ts +96 -0
  132. package/src/functions/evaluate/edge-runtime/index.ts +1 -0
  133. package/src/functions/evaluate/evaluate.ts +76 -0
  134. package/src/functions/evaluate/helpers.ts +56 -0
  135. package/src/functions/evaluate/index.ts +1 -0
  136. package/src/functions/evaluate/node-runtime/index.ts +1 -0
  137. package/src/functions/evaluate/node-runtime/init.ts +33 -0
  138. package/src/functions/evaluate/node-runtime/node-runtime.ts +176 -0
  139. package/src/functions/evaluate/node-runtime/safeDynamicRequire.ts +24 -0
  140. package/src/functions/evaluate/placeholder-runtime.ts +4 -0
  141. package/src/functions/evaluate/should-force-browser-runtime-in-node.ts +16 -0
  142. package/src/functions/event-handler-name.ts +4 -0
  143. package/src/functions/extract-text-styles.ts +24 -0
  144. package/src/functions/fast-clone.ts +4 -0
  145. package/src/functions/fetch-builder-props.ts +75 -0
  146. package/src/functions/get-block-actions-handler.ts +17 -0
  147. package/src/functions/get-block-actions.ts +35 -0
  148. package/src/functions/get-block-component-options.ts +11 -0
  149. package/src/functions/get-block-properties.ts +62 -0
  150. package/src/functions/get-builder-search-params/index.ts +33 -0
  151. package/src/functions/get-class-prop-name.ts +15 -0
  152. package/src/functions/get-content/generate-content-url.ts +88 -0
  153. package/src/functions/get-content/index.ts +99 -0
  154. package/src/functions/get-content/types.ts +157 -0
  155. package/src/functions/get-env.ts +5 -0
  156. package/src/functions/get-fetch.ts +11 -0
  157. package/src/functions/get-global-this.ts +16 -0
  158. package/src/functions/get-processed-block.ts +70 -0
  159. package/src/functions/get-style.ts +38 -0
  160. package/src/functions/get.ts +4 -0
  161. package/src/functions/is-browser.ts +3 -0
  162. package/src/functions/is-edge-runtime.ts +9 -0
  163. package/src/functions/is-editing.ts +8 -0
  164. package/src/functions/is-from-trusted-host.ts +8 -0
  165. package/src/functions/is-iframe.ts +4 -0
  166. package/src/functions/is-node-runtime.ts +8 -0
  167. package/src/functions/is-previewing.ts +16 -0
  168. package/src/functions/on-change.ts +29 -0
  169. package/src/functions/register-component.ts +30 -0
  170. package/src/functions/register.ts +44 -0
  171. package/src/functions/set-editor-settings.ts +15 -0
  172. package/src/functions/set.ts +14 -0
  173. package/src/functions/track/helpers.ts +51 -0
  174. package/src/functions/track/index.ts +131 -0
  175. package/src/functions/track/interaction.ts +63 -0
  176. package/src/functions/transform-block-properties.ts +33 -0
  177. package/src/functions/transform-block.ts +30 -0
  178. package/src/functions/transform-style-property.ts +296 -0
  179. package/src/helpers/ab-tests.ts +166 -0
  180. package/src/helpers/canTrack.ts +2 -0
  181. package/src/helpers/cookie.ts +97 -0
  182. package/src/helpers/css.ts +33 -0
  183. package/src/helpers/flatten.ts +41 -0
  184. package/src/helpers/localStorage.ts +36 -0
  185. package/src/helpers/logger.ts +7 -0
  186. package/src/helpers/nullable.ts +2 -0
  187. package/src/helpers/omit.ts +7 -0
  188. package/src/helpers/preview-lru-cache/get.ts +4 -0
  189. package/src/helpers/preview-lru-cache/helpers.ts +1 -0
  190. package/src/helpers/preview-lru-cache/init.ts +7 -0
  191. package/src/helpers/preview-lru-cache/set.ts +12 -0
  192. package/src/helpers/preview-lru-cache/types.ts +1 -0
  193. package/src/helpers/search/search.ts +18 -0
  194. package/src/helpers/sessionId.ts +37 -0
  195. package/src/helpers/subscribe-to-editor.ts +95 -0
  196. package/src/helpers/time.ts +2 -0
  197. package/src/helpers/url.ts +15 -0
  198. package/src/helpers/uuid.ts +17 -0
  199. package/src/helpers/visitorId.ts +37 -0
  200. package/src/index-helpers/blocks-exports.ts +16 -0
  201. package/src/index-helpers/top-of-file.ts +2 -0
  202. package/src/index.ts +15 -0
  203. package/src/scripts/init-editing.ts +119 -0
  204. package/src/server-index.ts +43 -0
  205. package/src/types/api-version.ts +2 -0
  206. package/src/types/builder-block.ts +89 -0
  207. package/src/types/builder-content.ts +47 -0
  208. package/src/types/builder-props.ts +12 -0
  209. package/src/types/can-track.ts +3 -0
  210. package/src/types/components.ts +119 -0
  211. package/src/types/deep-partial.ts +1 -0
  212. package/src/types/element.ts +57 -0
  213. package/src/types/enforced-partials.ts +19 -0
  214. package/src/types/input.ts +123 -0
  215. package/src/types/targets.ts +1 -0
  216. package/src/types/typescript.ts +9 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react-native",
3
3
  "description": "Builder.io SDK for React Native",
4
- "version": "1.0.29",
4
+ "version": "1.0.31-0",
5
5
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/react-native",
6
6
  "repository": {
7
7
  "type": "git",
@@ -11,7 +11,8 @@
11
11
  "type": "module",
12
12
  "main": "lib/browser/commonjs/index.js",
13
13
  "module": "lib/browser/module/index.js",
14
- "react-native": "lib/browser/commonjs/index.js",
14
+ "react-native": "src/index.ts",
15
+ "source": "src/index.ts",
15
16
  "types": "lib/browser/typescript/index.d.ts",
16
17
  "exports": {
17
18
  ".": {
@@ -93,7 +94,8 @@
93
94
  }
94
95
  },
95
96
  "files": [
96
- "lib/"
97
+ "lib",
98
+ "src"
97
99
  ],
98
100
  "scripts": {
99
101
  "release": "npm publish",
@@ -108,7 +110,7 @@
108
110
  "dependencies": {
109
111
  "@react-native-async-storage/async-storage": "^1.17.10",
110
112
  "css-to-react-native": "^3.2.0",
111
- "isolated-vm": "^4.6.0",
113
+ "isolated-vm": "^5.0.0",
112
114
  "react-native-render-html": "^6.3.4",
113
115
  "react-native-storage": "^1.0.1",
114
116
  "react-native-video": "^5.1.1"
@@ -117,7 +119,8 @@
117
119
  "react": "^18.0.0",
118
120
  "react-dom": "^18.0.0",
119
121
  "react-native": ">=0.64.3",
120
- "react-native-url-polyfill": "^2.0.0"
122
+ "react-native-url-polyfill": "^2.0.0",
123
+ "regenerator-runtime": "^0.14.1"
121
124
  },
122
125
  "devDependencies": {
123
126
  "@babel/preset-env": "^7.22.10",
@@ -156,5 +159,6 @@
156
159
  ]
157
160
  }
158
161
  }
159
- }
162
+ },
163
+ "stableVersion": "1.0.30"
160
164
  }
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ import { Text } from 'react-native';
3
+ import BuilderContext from '../context/builder.context';
4
+
5
+ /**
6
+ * Implements CSS-like inheritance for `Text` by replacing all calls to `Text` with a custom `BaseText` component that
7
+ * applies the `inheritedStyles` context styles, which contain all styles from all parents that might apply to a `Text`.
8
+ */
9
+ export default function BaseText(props) {
10
+ const builderContext = React.useContext(BuilderContext);
11
+ return (
12
+ <Text
13
+ {...props}
14
+ style={{ ...builderContext.inheritedStyles, ...props.style }}
15
+ />
16
+ );
17
+ }
@@ -0,0 +1,181 @@
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 } from "react";
13
+ import Blocks from "../../components/blocks/index";
14
+ import { camelToKebabCase } from "../../functions/camel-to-kebab-case";
15
+ import type { Dictionary } from "../../types/typescript";
16
+ import type { AccordionProps } from "./accordion.types";
17
+ import { convertOrderNumberToString } from "./helpers";
18
+
19
+ function Accordion(props: AccordionProps) {
20
+ const [open, setOpen] = useState(() => []);
21
+
22
+ function onlyOneAtATime() {
23
+ return Boolean(props.grid || props.oneAtATime);
24
+ }
25
+
26
+ function accordionStyles() {
27
+ const styles = {
28
+ display: "flex" as "flex" | "none",
29
+ alignItems: "stretch" as
30
+ | "stretch"
31
+ | "flex-start"
32
+ | "flex-end"
33
+ | "center"
34
+ | "baseline",
35
+ flexDirection: "column" as
36
+ | "column"
37
+ | "row"
38
+ | "column-reverse"
39
+ | "row-reverse",
40
+ ...(props.grid && {
41
+ flexDirection: "row" as
42
+ | "column"
43
+ | "row"
44
+ | "column-reverse"
45
+ | "row-reverse",
46
+ alignItems: "flex-start" as
47
+ | "stretch"
48
+ | "flex-start"
49
+ | "flex-end"
50
+ | "center"
51
+ | "baseline",
52
+ flexWrap: "wrap" as "nowrap" | "wrap",
53
+ }),
54
+ };
55
+ return styles;
56
+ }
57
+
58
+ function accordionTitleStyles() {
59
+ const shared = {
60
+ display: "flex",
61
+ flexDirection: "column",
62
+ };
63
+ const styles = shared;
64
+ return Object.fromEntries(
65
+ Object.entries(styles).filter(([_, value]) => value !== undefined)
66
+ ) as Dictionary<string>;
67
+ }
68
+
69
+ function getAccordionTitleClassName(index: number) {
70
+ return `builder-accordion-title builder-accordion-title-${
71
+ open.includes(index) ? "open" : "closed"
72
+ }`;
73
+ }
74
+
75
+ function getAccordionDetailClassName(index: number) {
76
+ return `builder-accordion-detail builder-accordion-detail-${
77
+ open.includes(index) ? "open" : "closed"
78
+ }`;
79
+ }
80
+
81
+ function openGridItemOrder() {
82
+ let itemOrder: number | null = null;
83
+ const getOpenGridItemPosition = props.grid && open.length;
84
+ if (getOpenGridItemPosition && document) {
85
+ const openItemIndex = open[0];
86
+ const openItem = document.querySelector(
87
+ `.builder-accordion-title[data-index="${openItemIndex}"]`
88
+ );
89
+ let subjectItem = openItem;
90
+ itemOrder = openItemIndex;
91
+ if (subjectItem) {
92
+ let prevItemRect = subjectItem.getBoundingClientRect();
93
+ while ((subjectItem = subjectItem && subjectItem.nextElementSibling)) {
94
+ if (subjectItem) {
95
+ if (subjectItem.classList.contains("builder-accordion-detail")) {
96
+ continue;
97
+ }
98
+ const subjectItemRect = subjectItem.getBoundingClientRect();
99
+ if (subjectItemRect.left > prevItemRect.left) {
100
+ const index = parseInt(
101
+ subjectItem.getAttribute("data-index") || "",
102
+ 10
103
+ );
104
+ if (!isNaN(index)) {
105
+ prevItemRect = subjectItemRect;
106
+ itemOrder = index;
107
+ }
108
+ } else {
109
+ break;
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+ if (typeof itemOrder === "number") {
116
+ itemOrder = itemOrder + 1;
117
+ }
118
+ return itemOrder;
119
+ }
120
+
121
+ function accordionDetailStyles() {
122
+ const styles = {
123
+ ...{},
124
+ ...(props.grid && {
125
+ width: "100%",
126
+ }),
127
+ };
128
+ return Object.fromEntries(
129
+ Object.entries(styles).filter(([_, value]) => value !== undefined)
130
+ ) as Dictionary<string>;
131
+ }
132
+
133
+ function onClick(index: number) {
134
+ if (open.includes(index)) {
135
+ setOpen(onlyOneAtATime() ? [] : open.filter((item) => item !== index));
136
+ } else {
137
+ setOpen(onlyOneAtATime() ? [index] : open.concat(index));
138
+ }
139
+ }
140
+
141
+ return (
142
+ <View style={accordionStyles()}>
143
+ {props.items?.map((item, index) => (
144
+ <>
145
+ <Pressable
146
+ style={{
147
+ ...accordionTitleStyles(),
148
+ width: props.grid ? props.gridRowWidth : undefined,
149
+ ...({} as any),
150
+ }}
151
+ data-index={index}
152
+ onPress={(event) => onClick(index)}
153
+ >
154
+ <Blocks
155
+ blocks={item.title}
156
+ path={`items.${index}.title`}
157
+ parent={props.builderBlock.id}
158
+ context={props.builderContext}
159
+ registeredComponents={props.builderComponents}
160
+ linkComponent={props.builderLinkComponent}
161
+ />
162
+ </Pressable>
163
+ {open.includes(index) ? (
164
+ <View style={accordionDetailStyles()}>
165
+ <Blocks
166
+ blocks={item.detail}
167
+ path={`items.${index}.detail`}
168
+ parent={props.builderBlock.id}
169
+ context={props.builderContext}
170
+ registeredComponents={props.builderComponents}
171
+ linkComponent={props.builderLinkComponent}
172
+ />
173
+ </View>
174
+ ) : null}
175
+ </>
176
+ ))}
177
+ </View>
178
+ );
179
+ }
180
+
181
+ export default Accordion;
@@ -0,0 +1,12 @@
1
+ import type { BuilderBlock } from '../../types/builder-block';
2
+ import type { BuilderComponentsProp, BuilderDataProps, BuilderLinkComponentProp } from '../../types/builder-props';
3
+ export interface AccordionProps extends BuilderComponentsProp, BuilderLinkComponentProp, BuilderDataProps {
4
+ items: {
5
+ title: BuilderBlock[];
6
+ detail: BuilderBlock[];
7
+ }[];
8
+ oneAtATime?: boolean;
9
+ grid?: boolean;
10
+ gridRowWidth?: string;
11
+ useChildrenForItems?: boolean;
12
+ }
@@ -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;