@builder.io/sdk-react-native 0.1.1 → 0.1.3

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 (183) hide show
  1. package/dist/blocks/BaseText.js +40 -0
  2. package/dist/blocks/button/button.js +39 -0
  3. package/dist/blocks/button/component-info.js +42 -0
  4. package/dist/blocks/columns/columns.js +149 -0
  5. package/dist/blocks/columns/component-info.js +244 -0
  6. package/dist/blocks/custom-code/component-info.js +32 -0
  7. package/dist/blocks/custom-code/custom-code.js +76 -0
  8. package/dist/blocks/embed/component-info.js +47 -0
  9. package/dist/blocks/embed/embed.js +67 -0
  10. package/dist/blocks/embed/helpers.js +10 -0
  11. package/dist/blocks/form/component-info.js +263 -0
  12. package/dist/blocks/form/form.js +232 -0
  13. package/dist/blocks/fragment/component-info.js +12 -0
  14. package/dist/blocks/fragment/fragment.js +36 -0
  15. package/dist/blocks/image/component-info.js +152 -0
  16. package/dist/blocks/image/image.helpers.js +49 -0
  17. package/dist/blocks/image/image.js +81 -0
  18. package/dist/blocks/img/component-info.js +21 -0
  19. package/dist/blocks/img/img.js +35 -0
  20. package/dist/blocks/input/component-info.js +75 -0
  21. package/dist/blocks/input/input.js +32 -0
  22. package/dist/blocks/raw-text/component-info.js +17 -0
  23. package/dist/blocks/raw-text/raw-text.js +31 -0
  24. package/dist/blocks/section/component-info.js +50 -0
  25. package/dist/blocks/section/section.js +49 -0
  26. package/dist/blocks/select/component-info.js +60 -0
  27. package/dist/blocks/select/select.js +38 -0
  28. package/dist/blocks/submit-button/component-info.js +29 -0
  29. package/dist/blocks/submit-button/submit-button.js +36 -0
  30. package/dist/blocks/symbol/component-info.js +44 -0
  31. package/dist/blocks/symbol/symbol.js +97 -0
  32. package/dist/blocks/text/component-info.js +25 -0
  33. package/dist/blocks/text/text.js +112 -0
  34. package/dist/blocks/textarea/component-info.js +48 -0
  35. package/dist/blocks/textarea/textarea.js +31 -0
  36. package/dist/blocks/util.js +9 -0
  37. package/dist/blocks/video/component-info.js +107 -0
  38. package/dist/blocks/video/video.js +81 -0
  39. package/dist/components/render-block/block-styles.js +79 -0
  40. package/dist/components/render-block/render-block.helpers.js +109 -0
  41. package/dist/components/render-block/render-block.js +154 -0
  42. package/dist/components/render-block/render-component-with-context.js +45 -0
  43. package/dist/components/render-block/render-component.js +50 -0
  44. package/dist/components/render-block/render-repeated-block.js +45 -0
  45. package/dist/components/render-block/types.js +1 -0
  46. package/dist/components/render-blocks.js +76 -0
  47. package/dist/components/render-content/builder-editing.js +31 -0
  48. package/dist/components/render-content/components/render-styles.js +91 -0
  49. package/dist/components/render-content/index.js +8 -0
  50. package/dist/components/render-content/render-content.js +325 -0
  51. package/dist/components/render-inlined-styles.js +42 -0
  52. package/dist/constants/builder-registered-components.js +46 -0
  53. package/dist/constants/device-sizes.js +49 -0
  54. package/dist/constants/target.js +5 -0
  55. package/dist/context/builder.context.js +13 -0
  56. package/dist/context/types.js +1 -0
  57. package/dist/functions/camel-to-kebab-case.js +5 -0
  58. package/dist/functions/evaluate.js +25 -0
  59. package/dist/functions/event-handler-name.js +8 -0
  60. package/dist/functions/extract-text-styles.js +23 -0
  61. package/dist/functions/fast-clone.js +5 -0
  62. package/dist/functions/get-block-actions-handler.js +12 -0
  63. package/dist/functions/get-block-actions.js +19 -0
  64. package/dist/functions/get-block-component-options.js +29 -0
  65. package/dist/functions/get-block-properties.js +51 -0
  66. package/dist/functions/get-block-tag.js +8 -0
  67. package/dist/functions/get-builder-search-params/fn.test.js +15 -0
  68. package/dist/functions/get-builder-search-params/index.js +39 -0
  69. package/dist/functions/get-content/ab-testing.js +89 -0
  70. package/dist/functions/get-content/generate-content-url.js +44 -0
  71. package/dist/functions/get-content/generate-content-url.test.js +33 -0
  72. package/dist/functions/get-content/index.js +68 -0
  73. package/dist/functions/get-content/types.js +1 -0
  74. package/dist/functions/get-fetch.js +15 -0
  75. package/dist/functions/get-global-this.js +19 -0
  76. package/dist/functions/get-processed-block.js +52 -0
  77. package/dist/functions/get-processed-block.test.js +34 -0
  78. package/dist/functions/get-react-native-block-styles.js +30 -0
  79. package/dist/functions/if-target.js +13 -0
  80. package/dist/functions/is-browser.js +7 -0
  81. package/dist/functions/is-editing.js +8 -0
  82. package/dist/functions/is-iframe.js +8 -0
  83. package/dist/functions/is-previewing.js +15 -0
  84. package/dist/functions/on-change.js +28 -0
  85. package/dist/functions/on-change.test.js +21 -0
  86. package/dist/functions/register-component.js +65 -0
  87. package/dist/functions/register.js +31 -0
  88. package/dist/functions/sanitize-react-native-block-styles.js +71 -0
  89. package/dist/functions/set-editor-settings.js +16 -0
  90. package/dist/functions/set.js +12 -0
  91. package/dist/functions/set.test.js +18 -0
  92. package/dist/functions/track/helpers.js +53 -0
  93. package/dist/functions/track/index.js +124 -0
  94. package/dist/functions/track/interaction.js +51 -0
  95. package/dist/functions/track.js +120 -0
  96. package/dist/functions/transform-block-properties.js +18 -0
  97. package/dist/functions/transform-block.js +38 -0
  98. package/dist/helpers/ab-tests.js +10 -0
  99. package/dist/helpers/cookie.js +70 -0
  100. package/dist/helpers/css.js +33 -0
  101. package/dist/helpers/flatten.js +35 -0
  102. package/dist/helpers/localStorage.js +31 -0
  103. package/dist/helpers/nullable.js +5 -0
  104. package/dist/helpers/sessionId.js +51 -0
  105. package/dist/helpers/time.js +6 -0
  106. package/dist/helpers/url.js +14 -0
  107. package/dist/helpers/url.test.js +23 -0
  108. package/dist/helpers/uuid.js +14 -0
  109. package/dist/helpers/visitorId.js +33 -0
  110. package/dist/index-helpers/blocks-exports.js +22 -0
  111. package/dist/index-helpers/top-of-file.js +3 -0
  112. package/dist/index.js +29 -0
  113. package/dist/scripts/init-editing.js +97 -0
  114. package/dist/types/builder-block.js +1 -0
  115. package/dist/types/builder-content.js +1 -0
  116. package/dist/types/can-track.js +1 -0
  117. package/dist/types/components.js +1 -0
  118. package/dist/types/deep-partial.js +1 -0
  119. package/dist/types/element.js +1 -0
  120. package/dist/types/targets.js +1 -0
  121. package/dist/types/typescript.js +1 -0
  122. package/package.json +13 -5
  123. package/src/blocks/BaseText.jsx +17 -0
  124. package/src/blocks/button/button.jsx +28 -0
  125. package/src/blocks/columns/{columns.js → columns.jsx} +59 -36
  126. package/src/blocks/custom-code/{custom-code.js → custom-code.jsx} +22 -15
  127. package/src/blocks/embed/{embed.js → embed.jsx} +12 -11
  128. package/src/blocks/form/form.jsx +251 -0
  129. package/src/blocks/fragment/fragment.jsx +11 -0
  130. package/src/blocks/image/image.jsx +78 -0
  131. package/src/blocks/img/img.jsx +18 -0
  132. package/src/blocks/input/input.jsx +20 -0
  133. package/src/blocks/raw-text/raw-text.jsx +6 -0
  134. package/src/blocks/section/section.jsx +29 -0
  135. package/src/blocks/select/select.jsx +24 -0
  136. package/src/blocks/submit-button/submit-button.jsx +11 -0
  137. package/src/blocks/symbol/symbol.jsx +86 -0
  138. package/src/blocks/text/text.jsx +100 -0
  139. package/src/blocks/textarea/textarea.jsx +14 -0
  140. package/src/blocks/video/video.jsx +70 -0
  141. package/src/components/render-block/block-styles.jsx +70 -0
  142. package/src/components/render-block/render-block.helpers.js +90 -0
  143. package/src/components/render-block/render-block.jsx +183 -0
  144. package/src/components/render-block/render-component.jsx +45 -0
  145. package/src/components/render-block/render-repeated-block.jsx +22 -0
  146. package/src/components/render-blocks.jsx +86 -0
  147. package/src/components/render-content/builder-editing.jsx +6 -0
  148. package/src/components/render-content/components/{render-styles.js → render-styles.jsx} +21 -14
  149. package/src/components/render-content/render-content.jsx +373 -0
  150. package/src/components/render-inlined-styles.jsx +29 -0
  151. package/src/functions/track/helpers.js +50 -0
  152. package/src/functions/{track.js → track/index.js} +10 -6
  153. package/src/functions/track/interaction.js +53 -0
  154. package/src/helpers/localStorage.js +1 -0
  155. package/src/helpers/sessionId.js +4 -1
  156. package/src/helpers/url.js +3 -0
  157. package/src/helpers/url.test.js +6 -0
  158. package/src/helpers/visitorId.js +1 -0
  159. package/src/index.js +1 -1
  160. package/src/blocks/BaseText.js +0 -31
  161. package/src/blocks/button/button.js +0 -36
  162. package/src/blocks/form/form.js +0 -222
  163. package/src/blocks/fragment/fragment.js +0 -9
  164. package/src/blocks/image/image.js +0 -55
  165. package/src/blocks/img/img.js +0 -33
  166. package/src/blocks/input/input.js +0 -36
  167. package/src/blocks/raw-text/raw-text.js +0 -10
  168. package/src/blocks/section/section.js +0 -41
  169. package/src/blocks/select/select.js +0 -37
  170. package/src/blocks/submit-button/submit-button.js +0 -27
  171. package/src/blocks/symbol/symbol.js +0 -73
  172. package/src/blocks/text/text.js +0 -67
  173. package/src/blocks/textarea/textarea.js +0 -32
  174. package/src/blocks/video/video.js +0 -55
  175. package/src/components/render-block/block-styles.js +0 -50
  176. package/src/components/render-block/render-block.js +0 -202
  177. package/src/components/render-block/render-component-with-context.js +0 -35
  178. package/src/components/render-block/render-component.js +0 -35
  179. package/src/components/render-block/render-repeated-block.js +0 -33
  180. package/src/components/render-blocks.js +0 -63
  181. package/src/components/render-content/builder-editing.js +0 -8
  182. package/src/components/render-content/render-content.js +0 -296
  183. package/src/components/render-inlined-styles.js +0 -17
@@ -1,27 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- import BaseText from "../BaseText";
18
- import * as React from "react";
19
- import { View } from "react-native";
20
- function SubmitButton(props) {
21
- return /* @__PURE__ */ React.createElement(View, __spreadValues({
22
- type: "submit"
23
- }, props.attributes), /* @__PURE__ */ React.createElement(BaseText, null, props.text));
24
- }
25
- export {
26
- SubmitButton as default
27
- };
@@ -1,73 +0,0 @@
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));
20
- import * as React from "react";
21
- import { View } from "react-native";
22
- import { useState, useContext, useEffect } from "react";
23
- import RenderContent from "../../components/render-content/render-content.js";
24
- import BuilderContext from "../../context/builder.context.js";
25
- import { getContent } from "../../functions/get-content/index.js";
26
- import { TARGET } from "../../constants/target";
27
- function Symbol(props) {
28
- var _a, _b, _c, _d, _e;
29
- function className() {
30
- var _a2, _b2;
31
- return [
32
- ...TARGET === "vue2" || TARGET === "vue3" ? Object.keys(props.attributes.class) : [props.attributes.class],
33
- "builder-symbol",
34
- ((_a2 = props.symbol) == null ? void 0 : _a2.inline) ? "builder-inline-symbol" : void 0,
35
- ((_b2 = props.symbol) == null ? void 0 : _b2.dynamic) || props.dynamic ? "builder-dynamic-symbol" : void 0
36
- ].filter(Boolean).join(" ");
37
- }
38
- const [fetchedContent, setFetchedContent] = useState(() => null);
39
- function contentToUse() {
40
- var _a2;
41
- return ((_a2 = props.symbol) == null ? void 0 : _a2.content) || fetchedContent;
42
- }
43
- const builderContext = useContext(BuilderContext);
44
- useEffect(() => {
45
- const symbolToUse = props.symbol;
46
- if (symbolToUse && !symbolToUse.content && !fetchedContent && symbolToUse.model) {
47
- getContent({
48
- model: symbolToUse.model,
49
- apiKey: builderContext.apiKey,
50
- query: {
51
- id: symbolToUse.entry
52
- }
53
- }).then((response) => {
54
- setFetchedContent(response);
55
- });
56
- }
57
- }, [props.symbol, fetchedContent]);
58
- return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
59
- dataSet: {
60
- class: className()
61
- }
62
- }), /* @__PURE__ */ React.createElement(RenderContent, {
63
- apiKey: builderContext.apiKey,
64
- context: builderContext.context,
65
- customComponents: Object.values(builderContext.registeredComponents),
66
- data: __spreadValues(__spreadValues(__spreadValues({}, (_a = props.symbol) == null ? void 0 : _a.data), builderContext.state), (_d = (_c = (_b = props.symbol) == null ? void 0 : _b.content) == null ? void 0 : _c.data) == null ? void 0 : _d.state),
67
- model: (_e = props.symbol) == null ? void 0 : _e.model,
68
- content: contentToUse()
69
- }));
70
- }
71
- export {
72
- Symbol as default
73
- };
@@ -1,67 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- import * as React from "react";
18
- import HTML from "react-native-render-html";
19
- import BuilderContext from "../../context/builder.context";
20
- function camelToKebabCase(string) {
21
- return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
22
- }
23
- function pick(object, keys) {
24
- return keys.reduce((obj, key) => {
25
- if (object && object.hasOwnProperty(key)) {
26
- obj[key] = object[key];
27
- }
28
- return obj;
29
- }, {});
30
- }
31
- const PICK_STYLES = ["textAlign"];
32
- function getBlockStyles(block) {
33
- var _a, _b, _c;
34
- const styles = __spreadValues(__spreadValues({}, (_a = block.responsiveStyles) == null ? void 0 : _a.large), block.styles);
35
- if ((_b = block.responsiveStyles) == null ? void 0 : _b.medium) {
36
- Object.assign(styles, block.responsiveStyles.medium);
37
- }
38
- if ((_c = block.responsiveStyles) == null ? void 0 : _c.small) {
39
- Object.assign(styles, block.responsiveStyles.small);
40
- }
41
- return styles;
42
- }
43
- function getCss(block, inheritedStyles) {
44
- const styleObject = __spreadValues(__spreadValues({}, inheritedStyles), pick(getBlockStyles(block), PICK_STYLES));
45
- if (!styleObject) {
46
- return "";
47
- }
48
- let str = ``;
49
- for (const key in styleObject) {
50
- const value = styleObject[key];
51
- if (typeof value === "string") {
52
- str += `${camelToKebabCase(key)}: ${value};`;
53
- }
54
- }
55
- return str;
56
- }
57
- function Text(props) {
58
- const builderContext = React.useContext(BuilderContext);
59
- return /* @__PURE__ */ React.createElement(HTML, {
60
- source: {
61
- html: `<div style="${getCss(props.builderBlock, builderContext.inheritedStyles)}">${props.text || ""}</div>`
62
- }
63
- });
64
- }
65
- export {
66
- Text as default
67
- };
@@ -1,32 +0,0 @@
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));
20
- import * as React from "react";
21
- import { View } from "react-native";
22
- function Textarea(props) {
23
- return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
24
- placeholder: props.placeholder,
25
- name: props.name,
26
- value: props.value,
27
- defaultValue: props.defaultValue
28
- }));
29
- }
30
- export {
31
- Textarea as default
32
- };
@@ -1,55 +0,0 @@
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));
20
- import * as React from "react";
21
- import { View } from "react-native";
22
- function Video(props) {
23
- var _a;
24
- function videoProps() {
25
- return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, props.autoPlay === true ? {
26
- autoPlay: true
27
- } : {}), props.muted === true ? {
28
- muted: true
29
- } : {}), props.controls === true ? {
30
- controls: true
31
- } : {}), props.loop === true ? {
32
- loop: true
33
- } : {}), props.playsInline === true ? {
34
- playsInline: true
35
- } : {});
36
- }
37
- function spreadProps() {
38
- return __spreadValues(__spreadValues({}, props.attributes), videoProps());
39
- }
40
- return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, spreadProps()), {
41
- style: __spreadProps(__spreadValues({
42
- width: "100%",
43
- height: "100%"
44
- }, (_a = props.attributes) == null ? void 0 : _a.style), {
45
- objectFit: props.fit,
46
- objectPosition: props.position,
47
- borderRadius: 1
48
- }),
49
- src: props.video || "no-src",
50
- poster: props.posterImage
51
- }));
52
- }
53
- export {
54
- Video as default
55
- };
@@ -1,50 +0,0 @@
1
- import * as React from "react";
2
- import {
3
- getMaxWidthQueryForSize,
4
- getSizesForBreakpoints
5
- } from "../../constants/device-sizes.js";
6
- import { TARGET } from "../../constants/target.js";
7
- import { getProcessedBlock } from "../../functions/get-processed-block.js";
8
- import { createCssClass } from "../../helpers/css.js";
9
- import RenderInlinedStyles from "../render-inlined-styles.js";
10
- function BlockStyles(props) {
11
- function useBlock() {
12
- return getProcessedBlock({
13
- block: props.block,
14
- state: props.context.state,
15
- context: props.context.context,
16
- shouldEvaluateBindings: true
17
- });
18
- }
19
- function css() {
20
- var _a;
21
- const styles = useBlock().responsiveStyles;
22
- const content = props.context.content;
23
- const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(((_a = content == null ? void 0 : content.meta) == null ? void 0 : _a.breakpoints) || {});
24
- const largeStyles = styles == null ? void 0 : styles.large;
25
- const mediumStyles = styles == null ? void 0 : styles.medium;
26
- const smallStyles = styles == null ? void 0 : styles.small;
27
- const className = useBlock().id;
28
- const largeStylesClass = largeStyles ? createCssClass({
29
- className,
30
- styles: largeStyles
31
- }) : "";
32
- const mediumStylesClass = mediumStyles ? createCssClass({
33
- className,
34
- styles: mediumStyles,
35
- mediaQuery: getMaxWidthQueryForSize("medium", sizesWithUpdatedBreakpoints)
36
- }) : "";
37
- const smallStylesClass = smallStyles ? createCssClass({
38
- className,
39
- styles: smallStyles,
40
- mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
41
- }) : "";
42
- return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
43
- }
44
- return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET !== "reactNative" && css() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
45
- styles: css()
46
- })) : null);
47
- }
48
- export {
49
- BlockStyles as default
50
- };
@@ -1,202 +0,0 @@
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));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- import * as React from "react";
33
- import { View } from "react-native";
34
- import { useState } from "react";
35
- import { getBlockActions } from "../../functions/get-block-actions.js";
36
- import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
37
- import { getBlockProperties } from "../../functions/get-block-properties.js";
38
- import { getBlockTag } from "../../functions/get-block-tag.js";
39
- import { getProcessedBlock } from "../../functions/get-processed-block.js";
40
- import { evaluate } from "../../functions/evaluate.js";
41
- import BlockStyles from "./block-styles.js";
42
- import { isEmptyHtmlElement } from "./render-block.helpers.js";
43
- import RenderRepeatedBlock from "./render-repeated-block.js";
44
- import { TARGET } from "../../constants/target.js";
45
- import { extractTextStyles } from "../../functions/extract-text-styles.js";
46
- import RenderComponentWithContext from "./render-component-with-context.js";
47
- import RenderComponent from "./render-component.js";
48
- import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
49
- function RenderBlock(props) {
50
- var _a, _b, _c;
51
- function component() {
52
- var _a2;
53
- const componentName = (_a2 = getProcessedBlock({
54
- block: props.block,
55
- state: props.context.state,
56
- context: props.context.context,
57
- shouldEvaluateBindings: false
58
- }).component) == null ? void 0 : _a2.name;
59
- if (!componentName) {
60
- return null;
61
- }
62
- const ref = props.context.registeredComponents[componentName];
63
- if (!ref) {
64
- console.warn(`
65
- Could not find a registered component named "${componentName}".
66
- If you registered it, is the file that registered it imported by the file that needs to render it?`);
67
- return void 0;
68
- } else {
69
- return ref;
70
- }
71
- }
72
- function tag() {
73
- return getBlockTag(useBlock());
74
- }
75
- function useBlock() {
76
- return repeatItemData() ? props.block : getProcessedBlock({
77
- block: props.block,
78
- state: props.context.state,
79
- context: props.context.context,
80
- shouldEvaluateBindings: true
81
- });
82
- }
83
- function actions() {
84
- return getBlockActions({
85
- block: useBlock(),
86
- state: props.context.state,
87
- context: props.context.context
88
- });
89
- }
90
- function attributes() {
91
- const blockProperties = getBlockProperties(useBlock());
92
- return __spreadValues(__spreadValues({}, blockProperties), TARGET === "reactNative" ? {
93
- style: getReactNativeBlockStyles({
94
- block: useBlock(),
95
- context: props.context,
96
- blockStyles: blockProperties.style
97
- })
98
- } : {});
99
- }
100
- function shouldWrap() {
101
- var _a2;
102
- return !((_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.noWrap);
103
- }
104
- function renderComponentProps() {
105
- var _a2, _b2, _c2, _d;
106
- return {
107
- blockChildren: useChildren(),
108
- componentRef: (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component,
109
- componentOptions: __spreadProps(__spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
110
- attributes: __spreadValues(__spreadValues({}, attributes()), actions())
111
- }), {
112
- customBreakpoints: (_d = (_c2 = (_b2 = childrenContext == null ? void 0 : childrenContext()) == null ? void 0 : _b2.content) == null ? void 0 : _c2.meta) == null ? void 0 : _d.breakpoints
113
- }),
114
- context: childrenContext()
115
- };
116
- }
117
- function useChildren() {
118
- var _a2;
119
- return (_a2 = useBlock().children) != null ? _a2 : [];
120
- }
121
- function childrenWithoutParentComponent() {
122
- var _a2;
123
- const shouldRenderChildrenOutsideRef = !((_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component) && !repeatItemData();
124
- return shouldRenderChildrenOutsideRef ? useChildren() : [];
125
- }
126
- function repeatItemData() {
127
- const _a2 = props.block, { repeat } = _a2, blockWithoutRepeat = __objRest(_a2, ["repeat"]);
128
- if (!(repeat == null ? void 0 : repeat.collection)) {
129
- return void 0;
130
- }
131
- const itemsArray = evaluate({
132
- code: repeat.collection,
133
- state: props.context.state,
134
- context: props.context.context
135
- });
136
- if (!Array.isArray(itemsArray)) {
137
- return void 0;
138
- }
139
- const collectionName = repeat.collection.split(".").pop();
140
- const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
141
- const repeatArray = itemsArray.map((item, index) => ({
142
- context: __spreadProps(__spreadValues({}, props.context), {
143
- state: __spreadProps(__spreadValues({}, props.context.state), {
144
- $index: index,
145
- $item: item,
146
- [itemNameToUse]: item,
147
- [`$${itemNameToUse}Index`]: index
148
- })
149
- }),
150
- block: blockWithoutRepeat
151
- }));
152
- return repeatArray;
153
- }
154
- function inheritedTextStyles() {
155
- if (TARGET !== "reactNative") {
156
- return {};
157
- }
158
- const styles = getReactNativeBlockStyles({
159
- block: useBlock(),
160
- context: props.context,
161
- blockStyles: attributes().style
162
- });
163
- return extractTextStyles(styles);
164
- }
165
- function childrenContext() {
166
- return {
167
- apiKey: props.context.apiKey,
168
- state: props.context.state,
169
- content: props.context.content,
170
- context: props.context.context,
171
- registeredComponents: props.context.registeredComponents,
172
- inheritedStyles: inheritedTextStyles()
173
- };
174
- }
175
- function renderComponentTag() {
176
- if (TARGET === "reactNative") {
177
- return RenderComponentWithContext;
178
- } else if (TARGET === "vue3") {
179
- return "RenderComponent";
180
- } else {
181
- return RenderComponent;
182
- }
183
- }
184
- const [componentInfo, setComponentInfo] = useState(() => null);
185
- const RenderComponentTagRef = renderComponentTag();
186
- return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldWrap() ? /* @__PURE__ */ React.createElement(React.Fragment, null, isEmptyHtmlElement(tag()) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadValues(__spreadValues({}, attributes()), actions()))) : null, !isEmptyHtmlElement(tag()) && repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = repeatItemData()) == null ? void 0 : _a.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
187
- key: index,
188
- repeatContext: data.context,
189
- block: data.block
190
- }))) : null, !isEmptyHtmlElement(tag()) && !repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadValues(__spreadValues({}, attributes()), actions()), /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadValues({}, renderComponentProps())), (_b = childrenWithoutParentComponent()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
191
- key: "render-block-" + child.id,
192
- block: child,
193
- context: childrenContext()
194
- })), (_c = childrenWithoutParentComponent()) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
195
- key: "block-style-" + child.id,
196
- block: child,
197
- context: childrenContext()
198
- })))) : null) : /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadValues({}, renderComponentProps())));
199
- }
200
- export {
201
- RenderBlock as default
202
- };
@@ -1,35 +0,0 @@
1
- import * as React from "react";
2
- import BuilderContext from "../../context/builder.context.js";
3
- import RenderComponent from "./render-component.js";
4
- function RenderComponentWithContext(props) {
5
- return /* @__PURE__ */ React.createElement(BuilderContext.Provider, {
6
- value: {
7
- get content() {
8
- return props.context.content;
9
- },
10
- get state() {
11
- return props.context.state;
12
- },
13
- get context() {
14
- return props.context.context;
15
- },
16
- get apiKey() {
17
- return props.context.apiKey;
18
- },
19
- get registeredComponents() {
20
- return props.context.registeredComponents;
21
- },
22
- get inheritedStyles() {
23
- return props.context.inheritedStyles;
24
- }
25
- }
26
- }, /* @__PURE__ */ React.createElement(RenderComponent, {
27
- componentRef: props.componentRef,
28
- componentOptions: props.componentOptions,
29
- blockChildren: props.blockChildren,
30
- context: props.context
31
- }));
32
- }
33
- export {
34
- RenderComponentWithContext as default
35
- };
@@ -1,35 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- import * as React from "react";
18
- import BlockStyles from "./block-styles.js";
19
- import RenderBlock from "./render-block.js";
20
- function RenderComponent(props) {
21
- var _a, _b;
22
- const ComponentRefRef = props.componentRef;
23
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.componentRef ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadValues({}, props.componentOptions), (_a = props.blockChildren) == null ? void 0 : _a.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
24
- key: "render-block-" + child.id,
25
- block: child,
26
- context: props.context
27
- })), (_b = props.blockChildren) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
28
- key: "block-style-" + child.id,
29
- block: child,
30
- context: props.context
31
- })))) : null);
32
- }
33
- export {
34
- RenderComponent as default
35
- };
@@ -1,33 +0,0 @@
1
- import * as React from "react";
2
- import BuilderContext from "../../context/builder.context.js";
3
- import RenderBlock from "./render-block.js";
4
- function RenderRepeatedBlock(props) {
5
- return /* @__PURE__ */ React.createElement(BuilderContext.Provider, {
6
- value: {
7
- get content() {
8
- return props.repeatContext.content;
9
- },
10
- get state() {
11
- return props.repeatContext.state;
12
- },
13
- get context() {
14
- return props.repeatContext.context;
15
- },
16
- get apiKey() {
17
- return props.repeatContext.apiKey;
18
- },
19
- get registeredComponents() {
20
- return props.repeatContext.registeredComponents;
21
- },
22
- get inheritedStyles() {
23
- return props.repeatContext.inheritedStyles;
24
- }
25
- }
26
- }, /* @__PURE__ */ React.createElement(RenderBlock, {
27
- block: props.block,
28
- context: props.repeatContext
29
- }));
30
- }
31
- export {
32
- RenderRepeatedBlock as default
33
- };
@@ -1,63 +0,0 @@
1
- import * as React from "react";
2
- import { View, StyleSheet } from "react-native";
3
- import { useContext } from "react";
4
- import BuilderContext from "../context/builder.context.js";
5
- import { isEditing } from "../functions/is-editing.js";
6
- import BlockStyles from "./render-block/block-styles.js";
7
- import RenderBlock from "./render-block/render-block.js";
8
- function RenderBlocks(props) {
9
- var _a, _b;
10
- function className() {
11
- var _a2;
12
- return "builder-blocks" + (!((_a2 = props.blocks) == null ? void 0 : _a2.length) ? " no-blocks" : "");
13
- }
14
- function onClick() {
15
- var _a2, _b2;
16
- if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
17
- (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
18
- type: "builder.clickEmptyBlocks",
19
- data: {
20
- parentElementId: props.parent,
21
- dataPath: props.path
22
- }
23
- }, "*");
24
- }
25
- }
26
- function onMouseEnter() {
27
- var _a2, _b2;
28
- if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
29
- (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
30
- type: "builder.hoverEmptyBlocks",
31
- data: {
32
- parentElementId: props.parent,
33
- dataPath: props.path
34
- }
35
- }, "*");
36
- }
37
- }
38
- const builderContext = useContext(BuilderContext);
39
- return /* @__PURE__ */ React.createElement(View, {
40
- "builder-path": props.path,
41
- "builder-parent-id": props.parent,
42
- dataSet: {
43
- class: className()
44
- },
45
- style: styles.view1,
46
- onClick: (event) => onClick(),
47
- onMouseEnter: (event) => onMouseEnter()
48
- }, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
49
- key: "render-block-" + block.id,
50
- block,
51
- context: builderContext
52
- }))) : null, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = props.blocks) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(BlockStyles, {
53
- key: "block-style-" + block.id,
54
- block,
55
- context: builderContext
56
- }))) : null);
57
- }
58
- const styles = StyleSheet.create({
59
- view1: { display: "flex", flexDirection: "column", alignItems: "stretch" }
60
- });
61
- export {
62
- RenderBlocks as default
63
- };