@builder.io/sdk-react-native 0.0.1-8 → 0.0.1

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