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

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 (261) hide show
  1. package/lib/browser/commonjs/blocks/symbol/symbol.js +1 -0
  2. package/lib/browser/commonjs/blocks/symbol/symbol.js.map +1 -1
  3. package/lib/browser/commonjs/components/content/content.js +1 -0
  4. package/lib/browser/commonjs/components/content/content.js.map +1 -1
  5. package/lib/browser/commonjs/constants/sdk-version.js +1 -1
  6. package/lib/browser/module/blocks/symbol/symbol.js +1 -0
  7. package/lib/browser/module/blocks/symbol/symbol.js.map +1 -1
  8. package/lib/browser/module/components/content/content.js +1 -0
  9. package/lib/browser/module/components/content/content.js.map +1 -1
  10. package/lib/browser/module/constants/sdk-version.js +1 -1
  11. package/lib/browser/typescript/blocks/symbol/symbol.d.ts.map +1 -1
  12. package/lib/browser/typescript/components/content/content.d.ts.map +1 -1
  13. package/lib/browser/typescript/constants/sdk-version.d.ts +1 -1
  14. package/lib/browser/typescript/context/types.d.ts +1 -0
  15. package/lib/browser/typescript/context/types.d.ts.map +1 -1
  16. package/lib/edge/commonjs/blocks/symbol/symbol.js +1 -0
  17. package/lib/edge/commonjs/blocks/symbol/symbol.js.map +1 -1
  18. package/lib/edge/commonjs/components/content/content.js +1 -0
  19. package/lib/edge/commonjs/components/content/content.js.map +1 -1
  20. package/lib/edge/commonjs/constants/sdk-version.js +1 -1
  21. package/lib/edge/module/blocks/symbol/symbol.js +1 -0
  22. package/lib/edge/module/blocks/symbol/symbol.js.map +1 -1
  23. package/lib/edge/module/components/content/content.js +1 -0
  24. package/lib/edge/module/components/content/content.js.map +1 -1
  25. package/lib/edge/module/constants/sdk-version.js +1 -1
  26. package/lib/edge/typescript/blocks/symbol/symbol.d.ts.map +1 -1
  27. package/lib/edge/typescript/components/content/content.d.ts.map +1 -1
  28. package/lib/edge/typescript/constants/sdk-version.d.ts +1 -1
  29. package/lib/edge/typescript/context/types.d.ts +1 -0
  30. package/lib/edge/typescript/context/types.d.ts.map +1 -1
  31. package/lib/node/commonjs/blocks/symbol/symbol.js +1 -0
  32. package/lib/node/commonjs/blocks/symbol/symbol.js.map +1 -1
  33. package/lib/node/commonjs/components/content/content.js +1 -0
  34. package/lib/node/commonjs/components/content/content.js.map +1 -1
  35. package/lib/node/commonjs/constants/sdk-version.js +1 -1
  36. package/lib/node/module/blocks/symbol/symbol.js +1 -0
  37. package/lib/node/module/blocks/symbol/symbol.js.map +1 -1
  38. package/lib/node/module/components/content/content.js +1 -0
  39. package/lib/node/module/components/content/content.js.map +1 -1
  40. package/lib/node/module/constants/sdk-version.js +1 -1
  41. package/lib/node/typescript/blocks/symbol/symbol.d.ts.map +1 -1
  42. package/lib/node/typescript/components/content/content.d.ts.map +1 -1
  43. package/lib/node/typescript/constants/sdk-version.d.ts +1 -1
  44. package/lib/node/typescript/context/types.d.ts +1 -0
  45. package/lib/node/typescript/context/types.d.ts.map +1 -1
  46. package/package.json +5 -9
  47. package/lib/node/index.cjs +0 -6910
  48. package/lib/node/index.mjs +0 -7477
  49. package/src/blocks/BaseText.tsx +0 -17
  50. package/src/blocks/accordion/accordion.tsx +0 -181
  51. package/src/blocks/accordion/accordion.types.ts +0 -12
  52. package/src/blocks/accordion/component-info.ts +0 -124
  53. package/src/blocks/accordion/helpers.ts +0 -3
  54. package/src/blocks/accordion/index.ts +0 -1
  55. package/src/blocks/button/button.tsx +0 -56
  56. package/src/blocks/button/button.types.ts +0 -7
  57. package/src/blocks/button/component-info.ts +0 -35
  58. package/src/blocks/button/index.ts +0 -1
  59. package/src/blocks/columns/columns.tsx +0 -199
  60. package/src/blocks/columns/columns.types.ts +0 -14
  61. package/src/blocks/columns/component-info.ts +0 -219
  62. package/src/blocks/columns/helpers.ts +0 -3
  63. package/src/blocks/columns/index.ts +0 -1
  64. package/src/blocks/custom-code/component-info.ts +0 -24
  65. package/src/blocks/custom-code/custom-code.tsx +0 -71
  66. package/src/blocks/custom-code/index.ts +0 -1
  67. package/src/blocks/embed/component-info.ts +0 -38
  68. package/src/blocks/embed/embed.tsx +0 -62
  69. package/src/blocks/embed/helpers.ts +0 -2
  70. package/src/blocks/embed/index.ts +0 -1
  71. package/src/blocks/form/form/component-info.ts +0 -233
  72. package/src/blocks/form/form/form.tsx +0 -324
  73. package/src/blocks/form/form/index.ts +0 -1
  74. package/src/blocks/form/input/component-info.ts +0 -47
  75. package/src/blocks/form/input/index.ts +0 -1
  76. package/src/blocks/form/input/input.tsx +0 -49
  77. package/src/blocks/form/select/component-info.ts +0 -44
  78. package/src/blocks/form/select/index.ts +0 -1
  79. package/src/blocks/form/select/select.tsx +0 -54
  80. package/src/blocks/form/submit-button/component-info.ts +0 -27
  81. package/src/blocks/form/submit-button/index.ts +0 -1
  82. package/src/blocks/form/submit-button/submit-button.tsx +0 -34
  83. package/src/blocks/fragment/component-info.ts +0 -8
  84. package/src/blocks/fragment/fragment.tsx +0 -18
  85. package/src/blocks/fragment/fragment.types.ts +0 -5
  86. package/src/blocks/fragment/index.ts +0 -1
  87. package/src/blocks/helpers.ts +0 -43
  88. package/src/blocks/image/component-info.ts +0 -124
  89. package/src/blocks/image/image.helpers.ts +0 -47
  90. package/src/blocks/image/image.tsx +0 -65
  91. package/src/blocks/image/image.types.ts +0 -19
  92. package/src/blocks/image/index.ts +0 -1
  93. package/src/blocks/img/component-info.ts +0 -16
  94. package/src/blocks/img/img.tsx +0 -55
  95. package/src/blocks/img/index.ts +0 -1
  96. package/src/blocks/raw-text/component-info.ts +0 -11
  97. package/src/blocks/raw-text/index.ts +0 -1
  98. package/src/blocks/raw-text/raw-text.tsx +0 -1
  99. package/src/blocks/section/component-info.ts +0 -41
  100. package/src/blocks/section/index.ts +0 -1
  101. package/src/blocks/section/section.tsx +0 -39
  102. package/src/blocks/section/section.types.ts +0 -6
  103. package/src/blocks/slot/component-info.ts +0 -15
  104. package/src/blocks/slot/index.ts +0 -1
  105. package/src/blocks/slot/slot.tsx +0 -42
  106. package/src/blocks/symbol/component-info.ts +0 -35
  107. package/src/blocks/symbol/index.ts +0 -1
  108. package/src/blocks/symbol/symbol.helpers.ts +0 -47
  109. package/src/blocks/symbol/symbol.tsx +0 -99
  110. package/src/blocks/symbol/symbol.types.ts +0 -17
  111. package/src/blocks/tabs/component-info.ts +0 -139
  112. package/src/blocks/tabs/index.ts +0 -1
  113. package/src/blocks/tabs/tabs.tsx +0 -79
  114. package/src/blocks/tabs/tabs.types.ts +0 -13
  115. package/src/blocks/text/component-info.ts +0 -20
  116. package/src/blocks/text/index.ts +0 -1
  117. package/src/blocks/text/text.tsx +0 -105
  118. package/src/blocks/text/text.types.ts +0 -4
  119. package/src/blocks/textarea/component-info.ts +0 -38
  120. package/src/blocks/textarea/index.ts +0 -1
  121. package/src/blocks/textarea/textarea.tsx +0 -41
  122. package/src/blocks/video/component-info.ts +0 -83
  123. package/src/blocks/video/index.ts +0 -1
  124. package/src/blocks/video/video.tsx +0 -70
  125. package/src/blocks/video/video.types.ts +0 -21
  126. package/src/components/block/animator.ts +0 -220
  127. package/src/components/block/block.helpers.ts +0 -106
  128. package/src/components/block/block.tsx +0 -235
  129. package/src/components/block/components/block-styles.tsx +0 -136
  130. package/src/components/block/components/block-wrapper.tsx +0 -53
  131. package/src/components/block/components/component-ref/component-ref.helpers.ts +0 -55
  132. package/src/components/block/components/component-ref/component-ref.tsx +0 -66
  133. package/src/components/block/components/interactive-element.tsx +0 -53
  134. package/src/components/block/components/repeated-block.tsx +0 -37
  135. package/src/components/block/types.ts +0 -6
  136. package/src/components/blocks/blocks-wrapper.tsx +0 -93
  137. package/src/components/blocks/blocks.tsx +0 -57
  138. package/src/components/blocks/blocks.types.ts +0 -7
  139. package/src/components/blocks/index.ts +0 -1
  140. package/src/components/content/components/enable-editor.tsx +0 -471
  141. package/src/components/content/components/styles.helpers.ts +0 -101
  142. package/src/components/content/components/styles.tsx +0 -42
  143. package/src/components/content/content.helpers.ts +0 -40
  144. package/src/components/content/content.tsx +0 -150
  145. package/src/components/content/content.types.ts +0 -13
  146. package/src/components/content/contentProps.types.ts +0 -17
  147. package/src/components/content/index.ts +0 -1
  148. package/src/components/content/wrap-component-ref.ts +0 -6
  149. package/src/components/content-variants/content-variants.tsx +0 -146
  150. package/src/components/content-variants/content-variants.types.ts +0 -84
  151. package/src/components/content-variants/helpers.ts +0 -72
  152. package/src/components/content-variants/index.ts +0 -1
  153. package/src/components/content-variants/inlined-fns.ts +0 -22
  154. package/src/components/dynamic-div.tsx +0 -30
  155. package/src/components/dynamic-renderer/dynamic-renderer.helpers.ts +0 -7
  156. package/src/components/dynamic-renderer/dynamic-renderer.tsx +0 -47
  157. package/src/components/error-boundary.tsx +0 -38
  158. package/src/components/inlined-script.tsx +0 -10
  159. package/src/components/inlined-styles.tsx +0 -10
  160. package/src/constants/builder-registered-components.ts +0 -59
  161. package/src/constants/device-sizes.ts +0 -59
  162. package/src/constants/extra-components.ts +0 -1
  163. package/src/constants/sdk-version.ts +0 -1
  164. package/src/constants/target.ts +0 -3
  165. package/src/context/builder.context.ts +0 -15
  166. package/src/context/components.context.ts +0 -3
  167. package/src/context/index.ts +0 -1
  168. package/src/context/types.ts +0 -37
  169. package/src/functions/apply-patch-with-mutation.ts +0 -61
  170. package/src/functions/camel-to-kebab-case.ts +0 -1
  171. package/src/functions/deopt.ts +0 -6
  172. package/src/functions/evaluate/browser-runtime/browser.ts +0 -61
  173. package/src/functions/evaluate/browser-runtime/index.ts +0 -1
  174. package/src/functions/evaluate/choose-eval.ts +0 -23
  175. package/src/functions/evaluate/edge-runtime/acorn-interpreter.ts +0 -2891
  176. package/src/functions/evaluate/edge-runtime/edge-runtime.ts +0 -96
  177. package/src/functions/evaluate/edge-runtime/index.ts +0 -1
  178. package/src/functions/evaluate/evaluate.ts +0 -76
  179. package/src/functions/evaluate/helpers.ts +0 -56
  180. package/src/functions/evaluate/index.ts +0 -1
  181. package/src/functions/evaluate/node-runtime/index.ts +0 -1
  182. package/src/functions/evaluate/node-runtime/init.ts +0 -33
  183. package/src/functions/evaluate/node-runtime/node-runtime.ts +0 -176
  184. package/src/functions/evaluate/node-runtime/safeDynamicRequire.ts +0 -24
  185. package/src/functions/evaluate/placeholder-runtime.ts +0 -4
  186. package/src/functions/evaluate/should-force-browser-runtime-in-node.ts +0 -16
  187. package/src/functions/event-handler-name.ts +0 -4
  188. package/src/functions/extract-text-styles.ts +0 -24
  189. package/src/functions/fast-clone.ts +0 -4
  190. package/src/functions/fetch-builder-props.ts +0 -75
  191. package/src/functions/get-block-actions-handler.ts +0 -17
  192. package/src/functions/get-block-actions.ts +0 -35
  193. package/src/functions/get-block-component-options.ts +0 -11
  194. package/src/functions/get-block-properties.ts +0 -62
  195. package/src/functions/get-builder-search-params/index.ts +0 -33
  196. package/src/functions/get-class-prop-name.ts +0 -15
  197. package/src/functions/get-content/generate-content-url.ts +0 -88
  198. package/src/functions/get-content/index.ts +0 -99
  199. package/src/functions/get-content/types.ts +0 -157
  200. package/src/functions/get-env.ts +0 -5
  201. package/src/functions/get-fetch.ts +0 -11
  202. package/src/functions/get-global-this.ts +0 -16
  203. package/src/functions/get-processed-block.ts +0 -70
  204. package/src/functions/get-style.ts +0 -38
  205. package/src/functions/get.ts +0 -4
  206. package/src/functions/is-browser.ts +0 -3
  207. package/src/functions/is-edge-runtime.ts +0 -9
  208. package/src/functions/is-editing.ts +0 -8
  209. package/src/functions/is-from-trusted-host.ts +0 -8
  210. package/src/functions/is-iframe.ts +0 -4
  211. package/src/functions/is-node-runtime.ts +0 -8
  212. package/src/functions/is-previewing.ts +0 -16
  213. package/src/functions/on-change.ts +0 -29
  214. package/src/functions/register-component.ts +0 -30
  215. package/src/functions/register.ts +0 -44
  216. package/src/functions/set-editor-settings.ts +0 -15
  217. package/src/functions/set.ts +0 -14
  218. package/src/functions/track/helpers.ts +0 -51
  219. package/src/functions/track/index.ts +0 -131
  220. package/src/functions/track/interaction.ts +0 -63
  221. package/src/functions/transform-block-properties.ts +0 -33
  222. package/src/functions/transform-block.ts +0 -30
  223. package/src/functions/transform-style-property.ts +0 -296
  224. package/src/helpers/ab-tests.ts +0 -166
  225. package/src/helpers/canTrack.ts +0 -2
  226. package/src/helpers/cookie.ts +0 -97
  227. package/src/helpers/css.ts +0 -33
  228. package/src/helpers/flatten.ts +0 -41
  229. package/src/helpers/localStorage.ts +0 -36
  230. package/src/helpers/logger.ts +0 -7
  231. package/src/helpers/nullable.ts +0 -2
  232. package/src/helpers/omit.ts +0 -7
  233. package/src/helpers/preview-lru-cache/get.ts +0 -4
  234. package/src/helpers/preview-lru-cache/helpers.ts +0 -1
  235. package/src/helpers/preview-lru-cache/init.ts +0 -7
  236. package/src/helpers/preview-lru-cache/set.ts +0 -12
  237. package/src/helpers/preview-lru-cache/types.ts +0 -1
  238. package/src/helpers/search/search.ts +0 -18
  239. package/src/helpers/sessionId.ts +0 -37
  240. package/src/helpers/subscribe-to-editor.ts +0 -95
  241. package/src/helpers/time.ts +0 -2
  242. package/src/helpers/url.ts +0 -15
  243. package/src/helpers/uuid.ts +0 -17
  244. package/src/helpers/visitorId.ts +0 -37
  245. package/src/index-helpers/blocks-exports.ts +0 -16
  246. package/src/index-helpers/top-of-file.ts +0 -2
  247. package/src/index.ts +0 -15
  248. package/src/scripts/init-editing.ts +0 -119
  249. package/src/server-index.ts +0 -43
  250. package/src/types/api-version.ts +0 -2
  251. package/src/types/builder-block.ts +0 -89
  252. package/src/types/builder-content.ts +0 -47
  253. package/src/types/builder-props.ts +0 -12
  254. package/src/types/can-track.ts +0 -3
  255. package/src/types/components.ts +0 -119
  256. package/src/types/deep-partial.ts +0 -1
  257. package/src/types/element.ts +0 -57
  258. package/src/types/enforced-partials.ts +0 -19
  259. package/src/types/input.ts +0 -123
  260. package/src/types/targets.ts +0 -1
  261. package/src/types/typescript.ts +0 -9
@@ -1,17 +0,0 @@
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
- }
@@ -1,181 +0,0 @@
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;
@@ -1,12 +0,0 @@
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
- }
@@ -1,124 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- export const convertOrderNumberToString = (order: number) => {
2
- return order.toString();
3
- }
@@ -1 +0,0 @@
1
- export { default } from './accordion'
@@ -1,56 +0,0 @@
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;
@@ -1,7 +0,0 @@
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
- }
@@ -1,35 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export { default } from './button'
@@ -1,199 +0,0 @@
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;
@@ -1,14 +0,0 @@
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
- }