@builder.io/sdk-react-native 0.4.3 → 0.4.5

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 (176) hide show
  1. package/dist/blocks/columns/columns.js +2 -2
  2. package/dist/blocks/symbol/symbol.js +8 -6
  3. package/dist/components/block/block.helpers.js +113 -0
  4. package/dist/components/block/block.js +171 -0
  5. package/dist/components/block/components/block-styles.js +95 -0
  6. package/dist/components/block/components/component.js +41 -0
  7. package/dist/components/block/components/repeated-block.js +40 -0
  8. package/dist/components/block/types.js +1 -0
  9. package/dist/components/blocks/blocks-wrapper.js +66 -0
  10. package/dist/components/blocks/blocks.js +41 -0
  11. package/dist/components/content/components/content-styles.helpers.js +55 -0
  12. package/dist/components/content/components/content-styles.js +61 -0
  13. package/dist/components/content/components/enable-editor.js +313 -0
  14. package/dist/components/content/content.helpers.js +42 -0
  15. package/dist/components/content/content.js +127 -0
  16. package/dist/components/content/content.types.js +1 -0
  17. package/dist/components/content/index.js +8 -0
  18. package/dist/components/content/wrap-component-ref.js +5 -0
  19. package/dist/components/content-variants/content-variants.js +73 -0
  20. package/dist/components/content-variants/helpers.js +139 -0
  21. package/dist/components/inlined-script.js +32 -0
  22. package/dist/components/{render-inlined-styles.js → inlined-styles.js} +2 -2
  23. package/dist/components/render-block/block-styles.js +2 -2
  24. package/dist/components/render-content/components/render-styles.js +2 -2
  25. package/dist/components/render-content/render-content.js +10 -8
  26. package/dist/components/render-content-variants/helpers.js +49 -20
  27. package/dist/components/render-content-variants/render-content-variants.js +29 -24
  28. package/dist/components/render-content-variants/render-content-variants.types.js +1 -0
  29. package/dist/constants/sdk-version.js +1 -1
  30. package/dist/functions/track/index.js +1 -1
  31. package/dist/helpers/ab-tests.js +3 -0
  32. package/dist/types/builder-props.js +1 -0
  33. package/dist/types/enforced-partials.js +1 -0
  34. package/package.json +1 -1
  35. package/src/blocks/columns/columns.jsx +2 -2
  36. package/src/blocks/symbol/symbol.jsx +8 -5
  37. package/src/components/inlined-script.jsx +18 -0
  38. package/src/components/{render-inlined-styles.jsx → inlined-styles.jsx} +2 -2
  39. package/src/components/render-block/block-styles.jsx +2 -2
  40. package/src/components/render-content/components/render-styles.jsx +2 -2
  41. package/src/components/render-content/render-content.jsx +8 -6
  42. package/src/components/render-content-variants/helpers.js +49 -20
  43. package/src/components/render-content-variants/render-content-variants.jsx +57 -35
  44. package/src/components/render-content-variants/render-content-variants.types.js +0 -0
  45. package/src/constants/sdk-version.js +1 -1
  46. package/src/functions/track/index.js +1 -1
  47. package/src/helpers/ab-tests.js +3 -0
  48. package/src/types/enforced-partials.js +0 -0
  49. package/dist/blocks/BaseText.d.ts +0 -6
  50. package/dist/blocks/button/button.d.ts +0 -9
  51. package/dist/blocks/button/component-info.d.ts +0 -2
  52. package/dist/blocks/columns/columns.d.ts +0 -16
  53. package/dist/blocks/columns/component-info.d.ts +0 -2
  54. package/dist/blocks/custom-code/component-info.d.ts +0 -2
  55. package/dist/blocks/custom-code/custom-code.d.ts +0 -5
  56. package/dist/blocks/embed/component-info.d.ts +0 -2
  57. package/dist/blocks/embed/embed.d.ts +0 -5
  58. package/dist/blocks/embed/helpers.d.ts +0 -1
  59. package/dist/blocks/form/component-info.d.ts +0 -2
  60. package/dist/blocks/form/form.d.ts +0 -28
  61. package/dist/blocks/fragment/component-info.d.ts +0 -2
  62. package/dist/blocks/fragment/fragment.d.ts +0 -8
  63. package/dist/blocks/image/component-info.d.ts +0 -2
  64. package/dist/blocks/image/image.d.ts +0 -17
  65. package/dist/blocks/image/image.helpers.d.ts +0 -1
  66. package/dist/blocks/img/component-info.d.ts +0 -2
  67. package/dist/blocks/img/img.d.ts +0 -11
  68. package/dist/blocks/input/component-info.d.ts +0 -2
  69. package/dist/blocks/input/input.d.ts +0 -12
  70. package/dist/blocks/raw-text/component-info.d.ts +0 -2
  71. package/dist/blocks/raw-text/raw-text.d.ts +0 -5
  72. package/dist/blocks/section/component-info.d.ts +0 -2
  73. package/dist/blocks/section/section.d.ts +0 -9
  74. package/dist/blocks/select/component-info.d.ts +0 -2
  75. package/dist/blocks/select/select.d.ts +0 -13
  76. package/dist/blocks/submit-button/component-info.d.ts +0 -2
  77. package/dist/blocks/submit-button/submit-button.d.ts +0 -7
  78. package/dist/blocks/symbol/component-info.d.ts +0 -2
  79. package/dist/blocks/symbol/symbol.d.ts +0 -21
  80. package/dist/blocks/text/component-info.d.ts +0 -2
  81. package/dist/blocks/text/text.d.ts +0 -7
  82. package/dist/blocks/textarea/component-info.d.ts +0 -2
  83. package/dist/blocks/textarea/textarea.d.ts +0 -10
  84. package/dist/blocks/util.d.ts +0 -4
  85. package/dist/blocks/video/component-info.d.ts +0 -2
  86. package/dist/blocks/video/video.d.ts +0 -31
  87. package/dist/components/render-block/block-styles.d.ts +0 -9
  88. package/dist/components/render-block/render-block.d.ts +0 -9
  89. package/dist/components/render-block/render-block.helpers.d.ts +0 -12
  90. package/dist/components/render-block/render-component.d.ts +0 -17
  91. package/dist/components/render-block/render-repeated-block.d.ts +0 -9
  92. package/dist/components/render-block/types.d.ts +0 -6
  93. package/dist/components/render-blocks.d.ts +0 -10
  94. package/dist/components/render-content/builder-editing.d.ts +0 -3
  95. package/dist/components/render-content/components/render-styles.d.ts +0 -9
  96. package/dist/components/render-content/components/render-styles.helpers.d.ts +0 -15
  97. package/dist/components/render-content/index.d.ts +0 -1
  98. package/dist/components/render-content/render-content.d.ts +0 -4
  99. package/dist/components/render-content/render-content.helpers.d.ts +0 -7
  100. package/dist/components/render-content/render-content.types.d.ts +0 -38
  101. package/dist/components/render-content/wrap-component-ref.d.ts +0 -6
  102. package/dist/components/render-content-variants/helpers.d.ts +0 -17
  103. package/dist/components/render-content-variants/render-content-variants.d.ts +0 -5
  104. package/dist/components/render-inlined-styles.d.ts +0 -7
  105. package/dist/constants/builder-registered-components.d.ts +0 -6
  106. package/dist/constants/device-sizes.d.ts +0 -13
  107. package/dist/constants/sdk-version.d.ts +0 -1
  108. package/dist/constants/target.d.ts +0 -3
  109. package/dist/context/builder.context.d.ts +0 -3
  110. package/dist/context/types.d.ts +0 -35
  111. package/dist/functions/camel-to-kebab-case.d.ts +0 -1
  112. package/dist/functions/evaluate.d.ts +0 -7
  113. package/dist/functions/evaluate.test.d.ts +0 -1
  114. package/dist/functions/event-handler-name.d.ts +0 -1
  115. package/dist/functions/extract-text-styles.d.ts +0 -4
  116. package/dist/functions/fast-clone.d.ts +0 -4
  117. package/dist/functions/get-block-actions-handler.d.ts +0 -8
  118. package/dist/functions/get-block-actions.d.ts +0 -9
  119. package/dist/functions/get-block-component-options.d.ts +0 -2
  120. package/dist/functions/get-block-properties.d.ts +0 -2
  121. package/dist/functions/get-builder-search-params/fn.test.d.ts +0 -1
  122. package/dist/functions/get-builder-search-params/index.d.ts +0 -12
  123. package/dist/functions/get-content/generate-content-url.d.ts +0 -2
  124. package/dist/functions/get-content/generate-content-url.test.d.ts +0 -1
  125. package/dist/functions/get-content/index.d.ts +0 -16
  126. package/dist/functions/get-content/types.d.ts +0 -51
  127. package/dist/functions/get-fetch.d.ts +0 -1
  128. package/dist/functions/get-processed-block.d.ts +0 -10
  129. package/dist/functions/get-processed-block.test.d.ts +0 -1
  130. package/dist/functions/get-react-native-block-styles.d.ts +0 -7
  131. package/dist/functions/if-target.d.ts +0 -7
  132. package/dist/functions/is-browser.d.ts +0 -1
  133. package/dist/functions/is-editing.d.ts +0 -1
  134. package/dist/functions/is-iframe.d.ts +0 -1
  135. package/dist/functions/is-previewing.d.ts +0 -1
  136. package/dist/functions/on-change.d.ts +0 -7
  137. package/dist/functions/on-change.test.d.ts +0 -1
  138. package/dist/functions/register-component.d.ts +0 -14
  139. package/dist/functions/register.d.ts +0 -16
  140. package/dist/functions/sanitize-react-native-block-styles.d.ts +0 -3
  141. package/dist/functions/set-editor-settings.d.ts +0 -4
  142. package/dist/functions/set.d.ts +0 -7
  143. package/dist/functions/set.test.d.ts +0 -1
  144. package/dist/functions/track/helpers.d.ts +0 -5
  145. package/dist/functions/track/index.d.ts +0 -51
  146. package/dist/functions/track/interaction.d.ts +0 -13
  147. package/dist/functions/transform-block-properties.d.ts +0 -3
  148. package/dist/functions/transform-block.d.ts +0 -2
  149. package/dist/helpers/ab-tests.d.ts +0 -9
  150. package/dist/helpers/canTrack.d.ts +0 -1
  151. package/dist/helpers/cookie.d.ts +0 -9
  152. package/dist/helpers/css.d.ts +0 -7
  153. package/dist/helpers/flatten.d.ts +0 -6
  154. package/dist/helpers/localStorage.d.ts +0 -9
  155. package/dist/helpers/logger.d.ts +0 -6
  156. package/dist/helpers/nullable.d.ts +0 -2
  157. package/dist/helpers/sessionId.d.ts +0 -6
  158. package/dist/helpers/time.d.ts +0 -1
  159. package/dist/helpers/url.d.ts +0 -6
  160. package/dist/helpers/url.test.d.ts +0 -1
  161. package/dist/helpers/uuid.d.ts +0 -8
  162. package/dist/helpers/visitorId.d.ts +0 -6
  163. package/dist/index-helpers/blocks-exports.d.ts +0 -8
  164. package/dist/index-helpers/top-of-file.d.ts +0 -1
  165. package/dist/index.d.ts +0 -15
  166. package/dist/scripts/init-editing.d.ts +0 -6
  167. package/dist/types/api-version.d.ts +0 -2
  168. package/dist/types/builder-block.d.ts +0 -66
  169. package/dist/types/builder-content.d.ts +0 -44
  170. package/dist/types/can-track.d.ts +0 -3
  171. package/dist/types/components.d.ts +0 -105
  172. package/dist/types/deep-partial.d.ts +0 -3
  173. package/dist/types/element.d.ts +0 -59
  174. package/dist/types/input.d.ts +0 -121
  175. package/dist/types/targets.d.ts +0 -3
  176. package/dist/types/typescript.d.ts +0 -5
@@ -0,0 +1,18 @@
1
+ 'use client';
2
+ import * as React from "react";
3
+ import {
4
+ FlatList,
5
+ ScrollView,
6
+ View,
7
+ StyleSheet,
8
+ Image,
9
+ Text,
10
+ } from "react-native";
11
+
12
+ function InlinedScript(props) {
13
+ return (
14
+ <View dangerouslySetInnerHTML={{ __html: props.scriptStr }} id={props.id} />
15
+ );
16
+ }
17
+
18
+ export default InlinedScript;
@@ -9,10 +9,10 @@ import {
9
9
  Text,
10
10
  } from "react-native";
11
11
 
12
- function RenderInlinedStyles(props) {
12
+ function InlinedStyles(props) {
13
13
  return (
14
14
  <View dangerouslySetInnerHTML={{ __html: props.styles }} id={props.id} />
15
15
  );
16
16
  }
17
17
 
18
- export default RenderInlinedStyles;
18
+ export default InlinedStyles;
@@ -16,7 +16,7 @@ import { TARGET } from "../../constants/target.js";
16
16
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
17
17
  import { createCssClass } from "../../helpers/css.js";
18
18
  import { checkIsDefined } from "../../helpers/nullable.js";
19
- import RenderInlinedStyles from "../render-inlined-styles";
19
+ import InlinedStyles from "../inlined-styles";
20
20
 
21
21
  function BlockStyles(props) {
22
22
  function useBlock() {
@@ -87,7 +87,7 @@ function BlockStyles(props) {
87
87
  <>
88
88
  {TARGET !== "reactNative" && css() && canShowBlock() ? (
89
89
  <>
90
- <RenderInlinedStyles styles={css()} />
90
+ <InlinedStyles styles={css()} />
91
91
  </>
92
92
  ) : null}
93
93
  </>
@@ -9,7 +9,7 @@ import {
9
9
  Text,
10
10
  } from "react-native";
11
11
  import { useState } from "react";
12
- import RenderInlinedStyles from "../../render-inlined-styles";
12
+ import InlinedStyles from "../../inlined-styles";
13
13
  import { getCss } from "./render-styles.helpers";
14
14
  import { getFontCss } from "./render-styles.helpers";
15
15
 
@@ -39,7 +39,7 @@ ${getFontCss({
39
39
  `.trim()
40
40
  );
41
41
 
42
- return <RenderInlinedStyles styles={injectedStyles} />;
42
+ return <InlinedStyles styles={injectedStyles} />;
43
43
  }
44
44
 
45
45
  export default RenderContentStyles;
@@ -38,6 +38,7 @@ import { TARGET } from "../../constants/target.js";
38
38
  import { logger } from "../../helpers/logger.js";
39
39
  import { getRenderContentScriptString } from "../render-content-variants/helpers.js";
40
40
  import { wrapComponentRef } from "./wrap-component-ref.js";
41
+ import InlinedScript from "../inlined-script";
41
42
 
42
43
  function RenderContent(props) {
43
44
  const elementRef = useRef(null);
@@ -216,9 +217,10 @@ function RenderContent(props) {
216
217
 
217
218
  const [scriptStr, setScriptStr] = useState(() =>
218
219
  getRenderContentScriptString({
220
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
221
+ variationId: props.content?.testVariationId,
219
222
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
220
223
  contentId: props.content?.id,
221
- parentContentId: props.parentContentId,
222
224
  })
223
225
  );
224
226
 
@@ -397,16 +399,16 @@ function RenderContent(props) {
397
399
  },
398
400
  }
399
401
  : {})}
400
- {...(props.hideContent
401
- ? {
402
+ {...(props.showContent
403
+ ? {}
404
+ : {
402
405
  hidden: true,
403
406
  "aria-hidden": true,
404
- }
405
- : {})}
407
+ })}
406
408
  >
407
409
  {props.isSsrAbTest ? (
408
410
  <>
409
- <ScrollView dangerouslySetInnerHTML={{ __html: scriptStr }} />
411
+ <InlinedScript scriptStr={scriptStr} />
410
412
  </>
411
413
  ) : null}
412
414
 
@@ -1,23 +1,47 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1
20
  import { TARGET } from "../../constants/target";
2
21
  import { isBrowser } from "../../functions/is-browser";
3
- const getVariants = (content) => Object.values((content == null ? void 0 : content.variations) || {});
22
+ const getVariants = (content) => Object.values((content == null ? void 0 : content.variations) || {}).map((variant) => __spreadProps(__spreadValues({}, variant), {
23
+ testVariationId: variant.id,
24
+ id: content == null ? void 0 : content.id
25
+ }));
4
26
  const checkShouldRunVariants = ({
5
27
  canTrack,
6
28
  content
7
29
  }) => {
8
30
  const hasVariants = getVariants(content).length > 0;
9
- if (!hasVariants) {
31
+ if (TARGET === "reactNative")
10
32
  return false;
11
- }
12
- if (!canTrack) {
33
+ if (!hasVariants)
13
34
  return false;
14
- }
15
- if (isBrowser()) {
35
+ if (!canTrack)
36
+ return false;
37
+ if (TARGET === "vue2" || TARGET === "vue3")
38
+ return true;
39
+ if (isBrowser())
16
40
  return false;
17
- }
18
41
  return true;
19
42
  };
20
43
  function bldrAbTest(contentId, variants, isHydrationTarget2) {
44
+ var _a;
21
45
  function getAndSetVariantId() {
22
46
  function setCookie(name, value, days) {
23
47
  let expires = "";
@@ -61,10 +85,10 @@ function bldrAbTest(contentId, variants, isHydrationTarget2) {
61
85
  return contentId;
62
86
  }
63
87
  const winningVariantId = getAndSetVariantId();
64
- const styleEl = document.getElementById(`variants-styles-${contentId}`);
88
+ const styleEl = (_a = document.currentScript) == null ? void 0 : _a.previousElementSibling;
65
89
  if (isHydrationTarget2) {
66
90
  styleEl.remove();
67
- const thisScriptEl = document.getElementById(`variants-script-${contentId}`);
91
+ const thisScriptEl = document.currentScript;
68
92
  thisScriptEl == null ? void 0 : thisScriptEl.remove();
69
93
  } else {
70
94
  const newStyleStr = variants.concat({ id: contentId }).filter((variant) => variant.id !== winningVariantId).map((value) => {
@@ -75,6 +99,7 @@ function bldrAbTest(contentId, variants, isHydrationTarget2) {
75
99
  }
76
100
  }
77
101
  function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
102
+ var _a;
78
103
  if (!navigator.cookieEnabled) {
79
104
  return;
80
105
  }
@@ -92,7 +117,7 @@ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2)
92
117
  }
93
118
  const cookieName = `builder.tests.${defaultContentId}`;
94
119
  const variantId = getCookie(cookieName);
95
- const parentDiv = document.querySelector(`[builder-content-id="${variantContentId}"]`);
120
+ const parentDiv = (_a = document.currentScript) == null ? void 0 : _a.parentElement;
96
121
  const variantIsDefaultContent = variantContentId === defaultContentId;
97
122
  if (variantId === variantContentId) {
98
123
  if (variantIsDefaultContent) {
@@ -113,29 +138,33 @@ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2)
113
138
  }
114
139
  return;
115
140
  }
116
- const getIsHydrationTarget = (target) => target === "react" || target === "reactNative" || target === "vue3" || target === "vue2";
141
+ const getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
117
142
  const isHydrationTarget = getIsHydrationTarget(TARGET);
118
- const AB_TEST_FN_NAME = "bldrAbTest";
119
- const CONTENT_FN_NAME = "bldrCntntScrpt";
120
- const getVariantsScriptString = (variants, contentId) => {
143
+ const AB_TEST_FN_NAME = "builderIoAbTest";
144
+ const CONTENT_FN_NAME = "builderIoRenderContent";
145
+ const getScriptString = () => {
121
146
  const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
122
147
  const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
123
148
  return `
124
- const ${AB_TEST_FN_NAME} = ${fnStr}
125
- const ${CONTENT_FN_NAME} = ${fnStr2}
126
- ${AB_TEST_FN_NAME}("${contentId}", ${JSON.stringify(variants)}, ${isHydrationTarget})
149
+ window.${AB_TEST_FN_NAME} = ${fnStr}
150
+ window.${CONTENT_FN_NAME} = ${fnStr2}
127
151
  `;
128
152
  };
153
+ const getVariantsScriptString = (variants, contentId) => {
154
+ return `
155
+ window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
156
+ };
129
157
  const getRenderContentScriptString = ({
130
- parentContentId,
131
- contentId
158
+ contentId,
159
+ variationId
132
160
  }) => {
133
161
  return `
134
- ${CONTENT_FN_NAME}("${contentId}", "${parentContentId}", ${isHydrationTarget})`;
162
+ window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
135
163
  };
136
164
  export {
137
165
  checkShouldRunVariants,
138
166
  getRenderContentScriptString,
167
+ getScriptString,
139
168
  getVariants,
140
169
  getVariantsScriptString
141
170
  };
@@ -8,75 +8,84 @@ import {
8
8
  Image,
9
9
  Text,
10
10
  } from "react-native";
11
- import { useState } from "react";
11
+ import { useState, useEffect } from "react";
12
12
  import {
13
13
  checkShouldRunVariants,
14
+ getScriptString,
14
15
  getVariants,
15
16
  getVariantsScriptString,
16
17
  } from "./helpers";
17
18
  import RenderContent from "../render-content/render-content";
18
19
  import { getDefaultCanTrack } from "../../helpers/canTrack";
19
- import RenderInlinedStyles from "../render-inlined-styles";
20
+ import InlinedStyles from "../inlined-styles";
20
21
  import { handleABTestingSync } from "../../helpers/ab-tests";
22
+ import InlinedScript from "../inlined-script";
23
+ import { TARGET } from "../../constants/target";
21
24
 
22
25
  function RenderContentVariants(props) {
26
+ const [shouldRenderVariants, setShouldRenderVariants] = useState(() =>
27
+ checkShouldRunVariants({
28
+ canTrack: getDefaultCanTrack(props.canTrack),
29
+ content: props.content,
30
+ })
31
+ );
32
+
23
33
  const [variantScriptStr, setVariantScriptStr] = useState(() =>
24
34
  getVariantsScriptString(
25
35
  getVariants(props.content).map((value) => ({
26
- id: value.id,
36
+ id: value.testVariationId,
27
37
  testRatio: value.testRatio,
28
38
  })),
29
39
  props.content?.id || ""
30
40
  )
31
41
  );
32
42
 
33
- const [shouldRenderVariants, setShouldRenderVariants] = useState(() =>
34
- checkShouldRunVariants({
35
- canTrack: getDefaultCanTrack(props.canTrack),
36
- content: props.content,
37
- })
38
- );
39
-
40
43
  const [hideVariantsStyleString, setHideVariantsStyleString] = useState(() =>
41
44
  getVariants(props.content)
42
- .map((value) => `.variant-${value.id} { display: none; } `)
45
+ .map((value) => `.variant-${value.testVariationId} { display: none; } `)
43
46
  .join("")
44
47
  );
45
48
 
46
- const [contentToRender, setContentToRender] = useState(() =>
47
- checkShouldRunVariants({
48
- canTrack: getDefaultCanTrack(props.canTrack),
49
- content: props.content,
50
- })
51
- ? props.content
52
- : handleABTestingSync({
53
- item: props.content,
54
- canTrack: getDefaultCanTrack(props.canTrack),
55
- })
56
- );
49
+ useEffect(() => {
50
+ /**
51
+ * We unmount the non-winning variants post-hydration in Vue.
52
+ */
53
+ if (TARGET === "vue2" || TARGET === "vue3") {
54
+ setShouldRenderVariants(false);
55
+ }
56
+ }, []);
57
57
 
58
58
  return (
59
59
  <>
60
+ {!props.__isNestedRender && TARGET !== "reactNative" ? (
61
+ <>
62
+ <InlinedScript scriptStr={getScriptString()} />
63
+ </>
64
+ ) : null}
65
+
60
66
  {shouldRenderVariants ? (
61
67
  <>
62
- <RenderInlinedStyles
68
+ <InlinedStyles
63
69
  id={`variants-styles-${props.content?.id}`}
64
70
  styles={hideVariantsStyleString}
65
71
  />
66
- <View
67
- id={`variants-script-${props.content?.id}`}
68
- dangerouslySetInnerHTML={{ __html: variantScriptStr }}
69
- />
72
+ <InlinedScript scriptStr={variantScriptStr} />
70
73
  {getVariants(props.content)?.map((variant) => (
71
74
  <RenderContent
72
- key={variant.id}
75
+ key={variant.testVariationId}
73
76
  content={variant}
77
+ showContent={false}
78
+ classNameProp={undefined}
79
+ model={props.model}
80
+ data={props.data}
81
+ context={props.context}
74
82
  apiKey={props.apiKey}
75
83
  apiVersion={props.apiVersion}
76
- canTrack={props.canTrack}
77
84
  customComponents={props.customComponents}
78
- hideContent={true}
79
- parentContentId={props.content?.id}
85
+ canTrack={props.canTrack}
86
+ locale={props.locale}
87
+ includeRefs={props.includeRefs}
88
+ enrich={props.enrich}
80
89
  isSsrAbTest={shouldRenderVariants}
81
90
  />
82
91
  ))}
@@ -84,14 +93,27 @@ function RenderContentVariants(props) {
84
93
  ) : null}
85
94
 
86
95
  <RenderContent
96
+ {...{}}
97
+ content={
98
+ shouldRenderVariants
99
+ ? props.content
100
+ : handleABTestingSync({
101
+ item: props.content,
102
+ canTrack: getDefaultCanTrack(props.canTrack),
103
+ })
104
+ }
105
+ classNameProp={`variant-${props.content?.id}`}
106
+ showContent={true}
87
107
  model={props.model}
88
- content={contentToRender}
108
+ data={props.data}
109
+ context={props.context}
89
110
  apiKey={props.apiKey}
90
111
  apiVersion={props.apiVersion}
91
- canTrack={props.canTrack}
92
112
  customComponents={props.customComponents}
93
- classNameProp={`variant-${props.content?.id}`}
94
- parentContentId={props.content?.id}
113
+ canTrack={props.canTrack}
114
+ locale={props.locale}
115
+ includeRefs={props.includeRefs}
116
+ enrich={props.enrich}
95
117
  isSsrAbTest={shouldRenderVariants}
96
118
  />
97
119
  </>
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.4.3"
1
+ export const SDK_VERSION = "0.4.5"
@@ -108,7 +108,7 @@ function _track(eventProps) {
108
108
  if (!(isBrowser() || TARGET === "reactNative")) {
109
109
  return;
110
110
  }
111
- return fetch(`https://builder.io/api/v1/track`, {
111
+ return fetch(`https://cdn.builder.io/api/v1/track`, {
112
112
  method: "POST",
113
113
  body: JSON.stringify({
114
114
  events: [yield createEvent(eventProps)]
@@ -37,6 +37,7 @@ var __async = (__this, __arguments, generator) => {
37
37
  import { getCookie, getCookieSync, setCookie } from "./cookie.js";
38
38
  import { checkIsDefined } from "../helpers/nullable.js";
39
39
  import { logger } from "./logger.js";
40
+ import { TARGET } from "../constants/target.js";
40
41
  const BUILDER_STORE_PREFIX = "builder.tests";
41
42
  const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
42
43
  const getContentVariationCookie = ({ contentId }) => getCookie({ name: getContentTestKey(contentId), canTrack: true });
@@ -94,6 +95,8 @@ const handleABTestingSync = ({
94
95
  item,
95
96
  canTrack
96
97
  }) => {
98
+ if (TARGET === "reactNative")
99
+ return item;
97
100
  if (!canTrack) {
98
101
  return item;
99
102
  }
File without changes
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * Implements CSS-like inheritance for `Text` by replacing all calls to `Text` with a custom `BaseText` component that
4
- * applies the `inheritedStyles` context styles, which contain all styles from all parents that might apply to a `Text`.
5
- */
6
- export default function BaseText(props: any): JSX.Element;
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- export interface ButtonProps {
3
- attributes?: any;
4
- text?: string;
5
- link?: string;
6
- openLinkInNewTab?: boolean;
7
- }
8
- declare function Button(props: ButtonProps): JSX.Element;
9
- export default Button;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- type Column = {
3
- blocks: BuilderBlock[];
4
- width?: number;
5
- };
6
- type StackColumnsAt = "tablet" | "mobile" | "never";
7
- export interface ColumnProps {
8
- columns?: Column[];
9
- builderBlock: BuilderBlock;
10
- space?: number;
11
- stackColumnsAt?: StackColumnsAt;
12
- reverseColumnsWhenStacked?: boolean;
13
- }
14
- import type { BuilderBlock } from "../../types/builder-block";
15
- declare function Columns(props: ColumnProps): JSX.Element;
16
- export default Columns;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * TO-DO: need to add way to embed JS code
4
- */
5
- export default function Embed(): JSX.Element;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * TO-DO: need to add way to embed JS code
4
- */
5
- export default function Embed(): JSX.Element;
@@ -1 +0,0 @@
1
- export declare const isJsScript: (script: HTMLScriptElement) => boolean;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,28 +0,0 @@
1
- /// <reference types="react" />
2
- interface BuilderElement {
3
- }
4
- export interface FormProps {
5
- attributes?: any;
6
- name?: string;
7
- action?: string;
8
- validate?: boolean;
9
- method?: string;
10
- builderBlock?: BuilderElement;
11
- sendSubmissionsTo?: string;
12
- sendSubmissionsToEmail?: string;
13
- sendWithJs?: boolean;
14
- contentType?: string;
15
- customHeaders?: {
16
- [key: string]: string;
17
- };
18
- successUrl?: string;
19
- previewState?: FormState;
20
- successMessage?: BuilderElement[];
21
- errorMessage?: BuilderElement[];
22
- sendingMessage?: BuilderElement[];
23
- resetFormOnSubmit?: boolean;
24
- errorMessagePath?: string;
25
- }
26
- export type FormState = "unsubmitted" | "sending" | "success" | "error";
27
- declare function FormComponent(props: any): JSX.Element;
28
- export default FormComponent;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- export interface FragmentProps {
3
- maxWidth?: number;
4
- attributes?: any;
5
- children?: any;
6
- }
7
- declare function FragmentComponent(props: FragmentProps): JSX.Element;
8
- export default FragmentComponent;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,17 +0,0 @@
1
- /// <reference types="react" />
2
- type ImageProps = {
3
- image: string;
4
- backgroundSize?: 'cover' | 'contain';
5
- backgroundPosition?: string;
6
- aspectRatio?: number;
7
- width?: number;
8
- height?: number;
9
- children?: any;
10
- builderBlock: any;
11
- fitContent?: boolean;
12
- };
13
- /**
14
- * @param {ImageProps} props
15
- */
16
- export default function Image(props: ImageProps): JSX.Element;
17
- export {};
@@ -1 +0,0 @@
1
- export declare function getSrcSet(url: string): string;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,11 +0,0 @@
1
- /// <reference types="react" />
2
- export interface ImgProps {
3
- attributes?: any;
4
- imgSrc?: string;
5
- image?: string;
6
- altText?: string;
7
- backgroundSize?: "cover" | "contain";
8
- backgroundPosition?: "center" | "top" | "left" | "right" | "bottom" | "top left" | "top right" | "bottom left" | "bottom right";
9
- }
10
- declare function ImgComponent(props: ImgProps): JSX.Element;
11
- export default ImgComponent;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,12 +0,0 @@
1
- /// <reference types="react" />
2
- export interface FormInputProps {
3
- type?: string;
4
- attributes?: any;
5
- name?: string;
6
- value?: string;
7
- placeholder?: string;
8
- defaultValue?: string;
9
- required?: boolean;
10
- }
11
- declare function FormInputComponent(props: FormInputProps): JSX.Element;
12
- export default FormInputComponent;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * TO-DO: Implement
4
- */
5
- export default function RawText(): JSX.Element;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- export interface SectionProps {
3
- maxWidth?: number;
4
- attributes?: any;
5
- children?: any;
6
- builderBlock?: any;
7
- }
8
- declare function SectionComponent(props: SectionProps): JSX.Element;
9
- export default SectionComponent;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;
@@ -1,13 +0,0 @@
1
- /// <reference types="react" />
2
- export interface FormSelectProps {
3
- options?: {
4
- name?: string;
5
- value: string;
6
- }[];
7
- attributes?: any;
8
- name?: string;
9
- value?: string;
10
- defaultValue?: string;
11
- }
12
- declare function SelectComponent(props: any): JSX.Element;
13
- export default SelectComponent;
@@ -1,2 +0,0 @@
1
- import type { ComponentInfo } from '../../types/components';
2
- export declare const componentInfo: ComponentInfo;