@builder.io/sdk-react-native 0.0.1-6 → 0.0.1-62

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 (138) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +19 -0
  3. package/package.json +6 -4
  4. package/src/blocks/button/button.js +31 -0
  5. package/src/blocks/button/component-info.js +42 -0
  6. package/src/blocks/columns/columns.js +59 -0
  7. package/src/blocks/columns/component-info.js +242 -0
  8. package/src/blocks/custom-code/component-info.js +32 -0
  9. package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.js} +16 -33
  10. package/src/blocks/embed/component-info.js +44 -0
  11. package/src/blocks/embed/embed.js +43 -0
  12. package/src/blocks/embed/helpers.js +10 -0
  13. package/src/blocks/form/component-info.js +263 -0
  14. package/src/blocks/form/form.js +221 -0
  15. package/src/blocks/fragment/component-info.js +12 -0
  16. package/src/blocks/fragment/fragment.js +8 -0
  17. package/src/blocks/image/component-info.js +151 -0
  18. package/src/blocks/image/image.helpers.js +49 -0
  19. package/src/blocks/image/image.js +41 -0
  20. package/src/blocks/img/component-info.js +21 -0
  21. package/src/blocks/img/img.js +36 -0
  22. package/src/blocks/input/component-info.js +75 -0
  23. package/src/blocks/input/input.js +36 -0
  24. package/src/blocks/raw-text/component-info.js +17 -0
  25. package/src/blocks/raw-text/raw-text.js +10 -0
  26. package/src/blocks/section/component-info.js +50 -0
  27. package/src/blocks/section/section.js +31 -0
  28. package/src/blocks/select/component-info.js +60 -0
  29. package/src/blocks/select/select.js +36 -0
  30. package/src/blocks/submit-button/component-info.js +29 -0
  31. package/src/blocks/submit-button/submit-button.js +29 -0
  32. package/src/blocks/symbol/component-info.js +44 -0
  33. package/src/blocks/symbol/symbol.js +69 -0
  34. package/src/blocks/{text.js → text/component-info.js} +4 -10
  35. package/src/blocks/text/text.js +65 -0
  36. package/src/blocks/textarea/component-info.js +48 -0
  37. package/src/blocks/textarea/textarea.js +32 -0
  38. package/src/blocks/video/component-info.js +107 -0
  39. package/src/blocks/video/video.js +33 -0
  40. package/src/components/render-block/block-styles.js +40 -0
  41. package/src/components/render-block/render-block.helpers.js +24 -0
  42. package/src/components/render-block/render-block.js +169 -0
  43. package/src/components/render-block/render-component.js +33 -0
  44. package/src/components/render-block/render-repeated-block.js +29 -0
  45. package/src/components/render-blocks.js +23 -12
  46. package/src/components/render-content/components/render-styles.js +58 -0
  47. package/src/components/render-content/index.js +5 -0
  48. package/src/components/render-content/render-content.js +254 -0
  49. package/src/components/render-inlined-styles.js +18 -0
  50. package/src/constants/builder-registered-components.js +43 -0
  51. package/src/constants/device-sizes.js +3 -21
  52. package/src/constants/target.js +5 -0
  53. package/src/context/builder.context.js +7 -1
  54. package/src/functions/camel-to-kebab-case.js +5 -0
  55. package/src/functions/convert-style-object.js +7 -0
  56. package/src/functions/evaluate.js +17 -8
  57. package/src/functions/event-handler-name.js +8 -0
  58. package/src/functions/get-block-actions.js +14 -13
  59. package/src/functions/get-block-component-options.js +22 -1
  60. package/src/functions/get-block-properties.js +2 -3
  61. package/src/functions/get-block-styles.js +9 -19
  62. package/src/functions/get-block-tag.js +1 -1
  63. package/src/functions/get-builder-search-params/fn.test.js +14 -0
  64. package/src/functions/get-builder-search-params/index.js +23 -0
  65. package/src/functions/get-content/ab-testing.js +39 -0
  66. package/src/functions/get-content/fn.test.js +32 -0
  67. package/src/functions/get-content/index.js +94 -0
  68. package/src/functions/get-content/types.js +1 -0
  69. package/src/functions/get-fetch.js +35 -0
  70. package/src/functions/get-global-this.js +19 -0
  71. package/src/functions/get-processed-block.js +18 -9
  72. package/src/functions/get-processed-block.test.js +14 -8
  73. package/src/functions/if-target.js +11 -2
  74. package/src/functions/is-browser.js +1 -2
  75. package/src/functions/is-editing.js +1 -1
  76. package/src/functions/is-iframe.js +1 -1
  77. package/src/functions/is-previewing.js +15 -0
  78. package/src/functions/is-react-native.js +1 -1
  79. package/src/functions/on-change.test.js +1 -2
  80. package/src/functions/previewing-model-name.js +12 -0
  81. package/src/functions/register-component.js +46 -26
  82. package/src/functions/register.js +30 -0
  83. package/src/functions/sanitize-styles.js +33 -0
  84. package/src/functions/set-editor-settings.js +16 -0
  85. package/src/functions/set.test.js +1 -2
  86. package/src/functions/track.js +7 -3
  87. package/src/functions/transform-block.js +38 -0
  88. package/src/helpers/css.js +13 -0
  89. package/src/helpers/flatten.js +35 -0
  90. package/src/index-helpers/blocks-exports.js +19 -0
  91. package/src/index-helpers/top-of-file.js +2 -0
  92. package/src/index.js +10 -23
  93. package/src/scripts/init-editing.js +73 -49
  94. package/src/types/components.js +1 -0
  95. package/src/types/deep-partial.js +1 -0
  96. package/src/types/element.js +1 -0
  97. package/src/types/targets.js +1 -0
  98. package/src/types/typescript.js +1 -0
  99. package/index.js +0 -11
  100. package/src/blocks/button.js +0 -37
  101. package/src/blocks/button.lite.tsx +0 -29
  102. package/src/blocks/columns.js +0 -42
  103. package/src/blocks/columns.lite.tsx +0 -41
  104. package/src/blocks/custom-code.js +0 -56
  105. package/src/blocks/embed.js +0 -56
  106. package/src/blocks/embed.lite.tsx +0 -65
  107. package/src/blocks/form.js +0 -229
  108. package/src/blocks/form.lite.tsx +0 -257
  109. package/src/blocks/image.js +0 -123
  110. package/src/blocks/image.lite.tsx +0 -35
  111. package/src/blocks/img.js +0 -41
  112. package/src/blocks/img.lite.tsx +0 -19
  113. package/src/blocks/input.js +0 -41
  114. package/src/blocks/input.lite.tsx +0 -23
  115. package/src/blocks/raw-text.js +0 -17
  116. package/src/blocks/raw-text.lite.tsx +0 -12
  117. package/src/blocks/section.js +0 -36
  118. package/src/blocks/section.lite.tsx +0 -20
  119. package/src/blocks/select.js +0 -40
  120. package/src/blocks/select.lite.tsx +0 -24
  121. package/src/blocks/submit-button.js +0 -34
  122. package/src/blocks/submit-button.lite.tsx +0 -11
  123. package/src/blocks/symbol.js +0 -20
  124. package/src/blocks/symbol.lite.tsx +0 -20
  125. package/src/blocks/text.lite.tsx +0 -12
  126. package/src/blocks/textarea.js +0 -37
  127. package/src/blocks/textarea.lite.tsx +0 -15
  128. package/src/blocks/video.js +0 -49
  129. package/src/blocks/video.lite.tsx +0 -28
  130. package/src/components/render-block.js +0 -84
  131. package/src/components/render-block.lite.tsx +0 -92
  132. package/src/components/render-blocks.lite.tsx +0 -56
  133. package/src/components/render-content.js +0 -66
  134. package/src/components/render-content.lite.tsx +0 -95
  135. package/src/functions/get-content.js +0 -103
  136. package/src/functions/get-target.js +0 -7
  137. package/src/functions/macro-eval.js +0 -6
  138. package/src/package.json +0 -18
@@ -0,0 +1,65 @@
1
+ import * as React from 'react';
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __spreadValues = (a, b) => {
8
+ for (var prop in b || (b = {}))
9
+ if (__hasOwnProp.call(b, prop))
10
+ __defNormalProp(a, prop, b[prop]);
11
+ if (__getOwnPropSymbols)
12
+ for (var prop of __getOwnPropSymbols(b)) {
13
+ if (__propIsEnum.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ }
16
+ return a;
17
+ };
18
+ import HTML from "react-native-render-html";
19
+ function camelToKebabCase(string) {
20
+ return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
21
+ }
22
+ function pick(object, keys) {
23
+ return keys.reduce((obj, key) => {
24
+ if (object && object.hasOwnProperty(key)) {
25
+ obj[key] = object[key];
26
+ }
27
+ return obj;
28
+ }, {});
29
+ }
30
+ const PICK_STYLES = ["textAlign"];
31
+ function getBlockStyles(block) {
32
+ var _a, _b, _c;
33
+ const styles = __spreadValues(__spreadValues({}, (_a = block.responsiveStyles) == null ? void 0 : _a.large), block.styles);
34
+ if ((_b = block.responsiveStyles) == null ? void 0 : _b.medium) {
35
+ Object.assign(styles, block.responsiveStyles.medium);
36
+ }
37
+ if ((_c = block.responsiveStyles) == null ? void 0 : _c.small) {
38
+ Object.assign(styles, block.responsiveStyles.small);
39
+ }
40
+ return styles;
41
+ }
42
+ function getCss(block) {
43
+ const styleObject = pick(getBlockStyles(block), PICK_STYLES);
44
+ if (!styleObject) {
45
+ return "";
46
+ }
47
+ let str = ``;
48
+ for (const key in styleObject) {
49
+ const value = styleObject[key];
50
+ if (typeof value === "string") {
51
+ str += `${camelToKebabCase(key)}: ${value};`;
52
+ }
53
+ }
54
+ return str;
55
+ }
56
+ function Text(props) {
57
+ return /* @__PURE__ */ React.createElement(HTML, {
58
+ source: {
59
+ html: `<div style="${getCss(props.builderBlock)}">${props.text || ""}</div>`
60
+ }
61
+ });
62
+ }
63
+ export {
64
+ Text as default
65
+ };
@@ -0,0 +1,48 @@
1
+ import * as React from 'react';
2
+ const componentInfo = {
3
+ name: "Form:TextArea",
4
+ builtIn: true,
5
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3",
6
+ inputs: [
7
+ {
8
+ advanced: true,
9
+ name: "value",
10
+ type: "string"
11
+ },
12
+ {
13
+ name: "name",
14
+ type: "string",
15
+ required: true,
16
+ helperText: 'Every input in a form needs a unique name describing what it gets, e.g. "email"'
17
+ },
18
+ {
19
+ name: "defaultValue",
20
+ type: "string"
21
+ },
22
+ {
23
+ name: "placeholder",
24
+ type: "string",
25
+ defaultValue: "Hello there"
26
+ },
27
+ {
28
+ name: "required",
29
+ type: "boolean",
30
+ defaultValue: false
31
+ }
32
+ ],
33
+ defaultStyles: {
34
+ paddingTop: "10px",
35
+ paddingBottom: "10px",
36
+ paddingLeft: "10px",
37
+ paddingRight: "10px",
38
+ borderRadius: "3px",
39
+ borderWidth: "1px",
40
+ borderStyle: "solid",
41
+ borderColor: "#ccc"
42
+ },
43
+ static: true,
44
+ noWrap: true
45
+ };
46
+ export {
47
+ componentInfo
48
+ };
@@ -0,0 +1,32 @@
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
+ };
@@ -0,0 +1,107 @@
1
+ import * as React from 'react';
2
+ const componentInfo = {
3
+ name: "Video",
4
+ canHaveChildren: true,
5
+ builtIn: true,
6
+ defaultStyles: {
7
+ minHeight: "20px",
8
+ minWidth: "20px"
9
+ },
10
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb",
11
+ inputs: [
12
+ {
13
+ name: "video",
14
+ type: "file",
15
+ allowedFileTypes: ["mp4"],
16
+ bubble: true,
17
+ defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
18
+ required: true
19
+ },
20
+ {
21
+ name: "posterImage",
22
+ type: "file",
23
+ allowedFileTypes: ["jpeg", "png"],
24
+ helperText: "Image to show before the video plays"
25
+ },
26
+ {
27
+ name: "autoPlay",
28
+ type: "boolean",
29
+ defaultValue: true
30
+ },
31
+ {
32
+ name: "controls",
33
+ type: "boolean",
34
+ defaultValue: false
35
+ },
36
+ {
37
+ name: "muted",
38
+ type: "boolean",
39
+ defaultValue: true
40
+ },
41
+ {
42
+ name: "loop",
43
+ type: "boolean",
44
+ defaultValue: true
45
+ },
46
+ {
47
+ name: "playsInline",
48
+ type: "boolean",
49
+ defaultValue: true
50
+ },
51
+ {
52
+ name: "fit",
53
+ type: "text",
54
+ defaultValue: "cover",
55
+ enum: ["contain", "cover", "fill", "auto"]
56
+ },
57
+ {
58
+ name: "fitContent",
59
+ type: "boolean",
60
+ helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
61
+ defaultValue: true,
62
+ advanced: true
63
+ },
64
+ {
65
+ name: "position",
66
+ type: "text",
67
+ defaultValue: "center",
68
+ enum: [
69
+ "center",
70
+ "top",
71
+ "left",
72
+ "right",
73
+ "bottom",
74
+ "top left",
75
+ "top right",
76
+ "bottom left",
77
+ "bottom right"
78
+ ]
79
+ },
80
+ {
81
+ name: "height",
82
+ type: "number",
83
+ advanced: true
84
+ },
85
+ {
86
+ name: "width",
87
+ type: "number",
88
+ advanced: true
89
+ },
90
+ {
91
+ name: "aspectRatio",
92
+ type: "number",
93
+ advanced: true,
94
+ defaultValue: 0.7004048582995948
95
+ },
96
+ {
97
+ name: "lazyLoad",
98
+ type: "boolean",
99
+ helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
100
+ defaultValue: true,
101
+ advanced: true
102
+ }
103
+ ]
104
+ };
105
+ export {
106
+ componentInfo
107
+ };
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import { View } from "react-native";
3
+ import ReactVideo from "react-native-video";
4
+ function Video(props) {
5
+ return /* @__PURE__ */ React.createElement(View, {
6
+ style: { position: "relative" }
7
+ }, /* @__PURE__ */ React.createElement(ReactVideo, {
8
+ paused: !props.autoPlay,
9
+ controls: props.controls,
10
+ muted: props.muted,
11
+ repeat: props.loop,
12
+ poster: props.posterImage,
13
+ posterResizeMode: props.fit || "contain",
14
+ resizeMode: props.fit || "contain",
15
+ style: {
16
+ position: "absolute",
17
+ top: 0,
18
+ bottom: 0,
19
+ left: 0,
20
+ right: 0,
21
+ zIndex: 1
22
+ },
23
+ source: { uri: props.video }
24
+ }), /* @__PURE__ */ React.createElement(View, {
25
+ style: {
26
+ width: "100%",
27
+ paddingTop: `${props.aspectRatio * 100}%`
28
+ }
29
+ }));
30
+ }
31
+ export {
32
+ Video as default
33
+ };
@@ -0,0 +1,40 @@
1
+ import * as React from "react";
2
+ import { useContext } from "react";
3
+ import { TARGET } from "../../constants/target.js";
4
+ import BuilderContext from "../../context/builder.context";
5
+ import { getProcessedBlock } from "../../functions/get-processed-block.js";
6
+ import RenderInlinedStyles from "../render-inlined-styles.js";
7
+ import { convertStyleMaptoCSS } from "../../helpers/css.js";
8
+ import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
9
+ function BlockStyles(props) {
10
+ function useBlock() {
11
+ return getProcessedBlock({
12
+ block: props.block,
13
+ state: builderContext.state,
14
+ context: builderContext.context,
15
+ evaluateBindings: true
16
+ });
17
+ }
18
+ function css() {
19
+ const styles = useBlock().responsiveStyles;
20
+ const largeStyles = styles == null ? void 0 : styles.large;
21
+ const mediumStyles = styles == null ? void 0 : styles.medium;
22
+ const smallStyles = styles == null ? void 0 : styles.small;
23
+ return `
24
+ ${largeStyles ? `.${useBlock().id} {${convertStyleMaptoCSS(largeStyles)}}` : ""}
25
+ ${mediumStyles ? `${getMaxWidthQueryForSize("medium")} {
26
+ .${useBlock().id} {${convertStyleMaptoCSS(mediumStyles)}}
27
+ }` : ""}
28
+ ${smallStyles ? `${getMaxWidthQueryForSize("small")} {
29
+ .${useBlock().id} {${convertStyleMaptoCSS(smallStyles)}}
30
+ }` : ""}
31
+ }`;
32
+ }
33
+ const builderContext = useContext(BuilderContext);
34
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
35
+ styles: css()
36
+ })) : null);
37
+ }
38
+ export {
39
+ BlockStyles as default
40
+ };
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ const EMPTY_HTML_ELEMENTS = [
3
+ "area",
4
+ "base",
5
+ "br",
6
+ "col",
7
+ "embed",
8
+ "hr",
9
+ "img",
10
+ "input",
11
+ "keygen",
12
+ "link",
13
+ "meta",
14
+ "param",
15
+ "source",
16
+ "track",
17
+ "wbr"
18
+ ];
19
+ const isEmptyHtmlElement = (tagName) => {
20
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
21
+ };
22
+ export {
23
+ isEmptyHtmlElement
24
+ };
@@ -0,0 +1,169 @@
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 { useContext } from "react";
34
+ import BuilderContext from "../../context/builder.context";
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 { getBlockStyles } from "../../functions/get-block-styles.js";
39
+ import { getBlockTag } from "../../functions/get-block-tag.js";
40
+ import { getProcessedBlock } from "../../functions/get-processed-block.js";
41
+ import { evaluate } from "../../functions/evaluate.js";
42
+ import BlockStyles from "./block-styles.js";
43
+ import { isEmptyHtmlElement } from "./render-block.helpers.js";
44
+ import RenderComponent from "./render-component.js";
45
+ import RenderRepeatedBlock from "./render-repeated-block.js";
46
+ function RenderBlock(props) {
47
+ var _a, _b, _c;
48
+ function component() {
49
+ var _a2;
50
+ const componentName = (_a2 = getProcessedBlock({
51
+ block: props.block,
52
+ state: builderContext.state,
53
+ context: builderContext.context,
54
+ evaluateBindings: false
55
+ }).component) == null ? void 0 : _a2.name;
56
+ if (!componentName) {
57
+ return null;
58
+ }
59
+ const ref = builderContext.registeredComponents[componentName];
60
+ if (!ref) {
61
+ console.warn(`
62
+ Could not find a registered component named "${componentName}".
63
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
64
+ return void 0;
65
+ } else {
66
+ return ref;
67
+ }
68
+ }
69
+ function componentInfo() {
70
+ if (component()) {
71
+ const _a2 = component(), { component: _ } = _a2, info = __objRest(_a2, ["component"]);
72
+ return info;
73
+ } else {
74
+ return void 0;
75
+ }
76
+ }
77
+ function componentRef() {
78
+ var _a2;
79
+ return (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component;
80
+ }
81
+ function tagName() {
82
+ return getBlockTag(useBlock());
83
+ }
84
+ function useBlock() {
85
+ return repeatItemData() ? props.block : getProcessedBlock({
86
+ block: props.block,
87
+ state: builderContext.state,
88
+ context: builderContext.context,
89
+ evaluateBindings: true
90
+ });
91
+ }
92
+ function attributes() {
93
+ return __spreadProps(__spreadValues(__spreadValues({}, getBlockProperties(useBlock())), getBlockActions({
94
+ block: useBlock(),
95
+ state: builderContext.state,
96
+ context: builderContext.context
97
+ })), {
98
+ style: getBlockStyles(useBlock())
99
+ });
100
+ }
101
+ function shouldWrap() {
102
+ var _a2;
103
+ return !((_a2 = componentInfo == null ? void 0 : componentInfo()) == null ? void 0 : _a2.noWrap);
104
+ }
105
+ function componentOptions() {
106
+ return __spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
107
+ attributes: attributes()
108
+ });
109
+ }
110
+ function renderComponentProps() {
111
+ return {
112
+ blockChildren: children(),
113
+ componentRef: componentRef(),
114
+ componentOptions: componentOptions()
115
+ };
116
+ }
117
+ function children() {
118
+ var _a2;
119
+ return (_a2 = useBlock().children) != null ? _a2 : [];
120
+ }
121
+ function childrenWithoutParentComponent() {
122
+ const shouldRenderChildrenOutsideRef = !componentRef() && !repeatItemData();
123
+ return shouldRenderChildrenOutsideRef ? children() : [];
124
+ }
125
+ function repeatItemData() {
126
+ const _a2 = props.block, { repeat } = _a2, blockWithoutRepeat = __objRest(_a2, ["repeat"]);
127
+ if (!(repeat == null ? void 0 : repeat.collection)) {
128
+ return void 0;
129
+ }
130
+ const itemsArray = evaluate({
131
+ code: repeat.collection,
132
+ state: builderContext.state,
133
+ context: builderContext.context
134
+ });
135
+ if (!Array.isArray(itemsArray)) {
136
+ return void 0;
137
+ }
138
+ const collectionName = repeat.collection.split(".").pop();
139
+ const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
140
+ const repeatArray = itemsArray.map((item, index) => ({
141
+ context: __spreadProps(__spreadValues({}, builderContext), {
142
+ state: __spreadProps(__spreadValues({}, builderContext.state), {
143
+ $index: index,
144
+ $item: item,
145
+ [itemNameToUse]: item,
146
+ [`$${itemNameToUse}Index`]: index
147
+ })
148
+ }),
149
+ block: blockWithoutRepeat
150
+ }));
151
+ return repeatArray;
152
+ }
153
+ const builderContext = useContext(BuilderContext);
154
+ const TagNameRef = tagName();
155
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldWrap() ? /* @__PURE__ */ React.createElement(React.Fragment, null, !isEmptyHtmlElement(tagName()) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()), repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = repeatItemData()) == null ? void 0 : _a.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
156
+ key: index,
157
+ repeatContext: data.context,
158
+ block: data.block
159
+ }))) : /* @__PURE__ */ React.createElement(RenderComponent, __spreadValues({}, renderComponentProps())), (_b = childrenWithoutParentComponent()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
160
+ key: "render-block-" + child.id,
161
+ block: child
162
+ })), (_c = childrenWithoutParentComponent()) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
163
+ key: "block-style-" + child.id,
164
+ block: child
165
+ })))) : /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()))) : /* @__PURE__ */ React.createElement(RenderComponent, __spreadValues({}, renderComponentProps())));
166
+ }
167
+ export {
168
+ RenderBlock as default
169
+ };
@@ -0,0 +1,33 @@
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
+ })), (_b = props.blockChildren) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
27
+ key: "block-style-" + child.id,
28
+ block: child
29
+ })))) : null);
30
+ }
31
+ export {
32
+ RenderComponent as default
33
+ };
@@ -0,0 +1,29 @@
1
+ import * as React from "react";
2
+ import BuilderContext from "../../context/builder.context";
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
+ }
23
+ }, /* @__PURE__ */ React.createElement(RenderBlock, {
24
+ block: props.block
25
+ }));
26
+ }
27
+ export {
28
+ RenderRepeatedBlock as default
29
+ };
@@ -1,13 +1,18 @@
1
1
  import * as React from "react";
2
2
  import { View, StyleSheet } from "react-native";
3
- import { isEditing } from "../functions/is-editing";
4
- import RenderBlock from "./render-block";
3
+ import { isEditing } from "../functions/is-editing.js";
4
+ import BlockStyles from "./render-block/block-styles.js";
5
+ import RenderBlock from "./render-block/render-block.js";
5
6
  function RenderBlocks(props) {
6
- var _a;
7
+ var _a, _b;
8
+ function className() {
9
+ var _a2;
10
+ return "builder-blocks" + (!((_a2 = props.blocks) == null ? void 0 : _a2.length) ? " no-blocks" : "");
11
+ }
7
12
  function onClick() {
8
- var _a2, _b;
13
+ var _a2, _b2;
9
14
  if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
10
- (_b = window.parent) == null ? void 0 : _b.postMessage({
15
+ (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
11
16
  type: "builder.clickEmptyBlocks",
12
17
  data: {
13
18
  parentElementId: props.parent,
@@ -17,9 +22,9 @@ function RenderBlocks(props) {
17
22
  }
18
23
  }
19
24
  function onMouseEnter() {
20
- var _a2, _b;
25
+ var _a2, _b2;
21
26
  if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
22
- (_b = window.parent) == null ? void 0 : _b.postMessage({
27
+ (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
23
28
  type: "builder.hoverEmptyBlocks",
24
29
  data: {
25
30
  parentElementId: props.parent,
@@ -29,15 +34,21 @@ function RenderBlocks(props) {
29
34
  }
30
35
  }
31
36
  return /* @__PURE__ */ React.createElement(View, {
32
- className: "builder-blocks" + (!((_a = props.blocks) == null ? void 0 : _a.length) ? " no-blocks" : ""),
33
37
  "builder-path": props.path,
34
38
  "builder-parent-id": props.parent,
35
- onClick: (event) => onClick,
36
- onMouseEnter: (event) => onMouseEnter,
39
+ dataSet: {
40
+ class: className()
41
+ },
42
+ onClick: (event) => onClick(),
43
+ onMouseEnter: (event) => onMouseEnter(),
37
44
  style: styles.view1
38
- }, props.blocks.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
45
+ }, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
46
+ key: "render-block-" + block.id,
47
+ block
48
+ }))) : null, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = props.blocks) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(BlockStyles, {
49
+ key: "block-style-" + block.id,
39
50
  block
40
- })));
51
+ }))) : null);
41
52
  }
42
53
  const styles = StyleSheet.create({
43
54
  view1: { display: "flex", flexDirection: "column", alignItems: "stretch" }