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

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 (131) 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 +218 -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 +25 -0
  11. package/src/blocks/{embed.lite.tsx → embed/embed.js} +16 -31
  12. package/src/blocks/form/component-info.js +263 -0
  13. package/src/blocks/form/form.js +221 -0
  14. package/src/blocks/fragment/component-info.js +12 -0
  15. package/src/blocks/fragment/fragment.js +8 -0
  16. package/src/blocks/{image.js → image/component-info.js} +5 -23
  17. package/src/blocks/image/image.js +41 -0
  18. package/src/blocks/img/component-info.js +21 -0
  19. package/src/blocks/img/img.js +36 -0
  20. package/src/blocks/input/component-info.js +75 -0
  21. package/src/blocks/input/input.js +36 -0
  22. package/src/blocks/raw-text/component-info.js +17 -0
  23. package/src/blocks/raw-text/raw-text.js +10 -0
  24. package/src/blocks/section/component-info.js +50 -0
  25. package/src/blocks/section/section.js +31 -0
  26. package/src/blocks/select/component-info.js +60 -0
  27. package/src/blocks/select/select.js +36 -0
  28. package/src/blocks/submit-button/component-info.js +29 -0
  29. package/src/blocks/submit-button/submit-button.js +29 -0
  30. package/src/blocks/symbol/component-info.js +44 -0
  31. package/src/blocks/symbol/symbol.js +68 -0
  32. package/src/blocks/{text.js → text/component-info.js} +4 -10
  33. package/src/blocks/text/text.js +65 -0
  34. package/src/blocks/textarea/component-info.js +48 -0
  35. package/src/blocks/textarea/textarea.js +32 -0
  36. package/src/blocks/video/component-info.js +107 -0
  37. package/src/blocks/video/video.js +33 -0
  38. package/src/components/render-block/block-styles.js +40 -0
  39. package/src/components/render-block/render-block.helpers.js +24 -0
  40. package/src/components/render-block/render-block.js +171 -0
  41. package/src/components/render-block/render-component.js +33 -0
  42. package/src/components/render-block/render-repeated-block.js +29 -0
  43. package/src/components/render-blocks.js +23 -12
  44. package/src/components/render-content/components/render-styles.js +58 -0
  45. package/src/components/render-content/index.js +5 -0
  46. package/src/components/render-content/render-content.js +254 -0
  47. package/src/components/render-inlined-styles.js +18 -0
  48. package/src/constants/builder-registered-components.js +43 -0
  49. package/src/constants/device-sizes.js +3 -21
  50. package/src/constants/target.js +5 -0
  51. package/src/context/builder.context.js +7 -1
  52. package/src/functions/camel-to-kebab-case.js +5 -0
  53. package/src/functions/convert-style-object.js +7 -0
  54. package/src/functions/evaluate.js +17 -8
  55. package/src/functions/event-handler-name.js +8 -0
  56. package/src/functions/fast-clone.js +5 -0
  57. package/src/functions/get-block-actions.js +14 -13
  58. package/src/functions/get-block-component-options.js +22 -1
  59. package/src/functions/get-block-properties.js +2 -3
  60. package/src/functions/get-block-styles.js +9 -19
  61. package/src/functions/get-builder-search-params/fn.test.js +14 -0
  62. package/src/functions/get-builder-search-params/index.js +23 -0
  63. package/src/functions/get-content/fn.test.js +32 -0
  64. package/src/functions/get-content/index.js +139 -0
  65. package/src/functions/get-fetch.js +35 -0
  66. package/src/functions/get-global-this.js +19 -0
  67. package/src/functions/get-processed-block.js +18 -9
  68. package/src/functions/get-processed-block.test.js +14 -8
  69. package/src/functions/if-target.js +11 -2
  70. package/src/functions/is-browser.js +1 -2
  71. package/src/functions/is-editing.js +1 -1
  72. package/src/functions/is-iframe.js +1 -1
  73. package/src/functions/is-previewing.js +15 -0
  74. package/src/functions/is-react-native.js +1 -1
  75. package/src/functions/on-change.test.js +1 -2
  76. package/src/functions/previewing-model-name.js +12 -0
  77. package/src/functions/register-component.js +31 -13
  78. package/src/functions/register.js +30 -0
  79. package/src/functions/sanitize-styles.js +33 -0
  80. package/src/functions/set-editor-settings.js +16 -0
  81. package/src/functions/set.test.js +1 -2
  82. package/src/functions/track.js +7 -3
  83. package/src/functions/transform-block.js +38 -0
  84. package/src/helpers/css.js +13 -0
  85. package/src/index-helpers/blocks-exports.js +19 -0
  86. package/src/index-helpers/top-of-file.js +2 -0
  87. package/src/index.js +10 -23
  88. package/src/scripts/init-editing.js +73 -49
  89. package/src/types/components.js +1 -0
  90. package/src/types/deep-partial.js +1 -0
  91. package/src/types/element.js +1 -0
  92. package/src/types/targets.js +1 -0
  93. package/src/types/typescript.js +1 -0
  94. package/index.js +0 -11
  95. package/src/blocks/button.js +0 -37
  96. package/src/blocks/button.lite.tsx +0 -29
  97. package/src/blocks/columns.js +0 -42
  98. package/src/blocks/columns.lite.tsx +0 -41
  99. package/src/blocks/custom-code.js +0 -56
  100. package/src/blocks/embed.js +0 -56
  101. package/src/blocks/form.js +0 -229
  102. package/src/blocks/form.lite.tsx +0 -257
  103. package/src/blocks/image.lite.tsx +0 -35
  104. package/src/blocks/img.js +0 -41
  105. package/src/blocks/img.lite.tsx +0 -19
  106. package/src/blocks/input.js +0 -41
  107. package/src/blocks/input.lite.tsx +0 -23
  108. package/src/blocks/raw-text.js +0 -17
  109. package/src/blocks/raw-text.lite.tsx +0 -12
  110. package/src/blocks/section.js +0 -36
  111. package/src/blocks/section.lite.tsx +0 -20
  112. package/src/blocks/select.js +0 -40
  113. package/src/blocks/select.lite.tsx +0 -24
  114. package/src/blocks/submit-button.js +0 -34
  115. package/src/blocks/submit-button.lite.tsx +0 -11
  116. package/src/blocks/symbol.js +0 -20
  117. package/src/blocks/symbol.lite.tsx +0 -20
  118. package/src/blocks/text.lite.tsx +0 -12
  119. package/src/blocks/textarea.js +0 -37
  120. package/src/blocks/textarea.lite.tsx +0 -15
  121. package/src/blocks/video.js +0 -49
  122. package/src/blocks/video.lite.tsx +0 -28
  123. package/src/components/render-block.js +0 -84
  124. package/src/components/render-block.lite.tsx +0 -92
  125. package/src/components/render-blocks.lite.tsx +0 -56
  126. package/src/components/render-content.js +0 -66
  127. package/src/components/render-content.lite.tsx +0 -95
  128. package/src/functions/get-content.js +0 -103
  129. package/src/functions/get-target.js +0 -7
  130. package/src/functions/macro-eval.js +0 -6
  131. package/src/package.json +0 -18
@@ -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,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 { 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 { collection, itemName } = repeat;
131
+ const itemsArray = evaluate({
132
+ code: collection,
133
+ state: builderContext.state,
134
+ context: builderContext.context
135
+ });
136
+ if (Array.isArray(itemsArray)) {
137
+ const collectionName = collection.split(".").pop();
138
+ const itemNameToUse = itemName || (collectionName ? collectionName + "Item" : "item");
139
+ const repeatArray = itemsArray.map((item, index) => ({
140
+ context: __spreadProps(__spreadValues({}, builderContext), {
141
+ state: __spreadProps(__spreadValues({}, builderContext.state), {
142
+ $index: index,
143
+ $item: item,
144
+ [itemNameToUse]: item,
145
+ [`$${itemNameToUse}Index`]: index
146
+ })
147
+ }),
148
+ block: blockWithoutRepeat
149
+ }));
150
+ return repeatArray;
151
+ } else {
152
+ return void 0;
153
+ }
154
+ }
155
+ const builderContext = useContext(BuilderContext);
156
+ const TagNameRef = tagName();
157
+ 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, {
158
+ key: index,
159
+ repeatContext: data.context,
160
+ block: data.block
161
+ }))) : /* @__PURE__ */ React.createElement(RenderComponent, __spreadValues({}, renderComponentProps())), (_b = childrenWithoutParentComponent()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
162
+ key: "render-block-" + child.id,
163
+ block: child
164
+ })), (_c = childrenWithoutParentComponent()) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
165
+ key: "block-style-" + child.id,
166
+ block: child
167
+ })))) : /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()))) : /* @__PURE__ */ React.createElement(RenderComponent, __spreadValues({}, renderComponentProps())));
168
+ }
169
+ export {
170
+ RenderBlock as default
171
+ };
@@ -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" }
@@ -0,0 +1,58 @@
1
+ import * as React from "react";
2
+ import RenderInlinedStyles from "../../render-inlined-styles.js";
3
+ function RenderContentStyles(props) {
4
+ function getCssFromFont(font) {
5
+ var _a, _b;
6
+ const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
7
+ const name = family.split(",")[0];
8
+ const url = (_b = font.fileUrl) != null ? _b : (_a = font == null ? void 0 : font.files) == null ? void 0 : _a.regular;
9
+ let str = "";
10
+ if (url && family && name) {
11
+ str += `
12
+ @font-face {
13
+ font-family: "${family}";
14
+ src: local("${name}"), url('${url}') format('woff2');
15
+ font-display: fallback;
16
+ font-weight: 400;
17
+ }
18
+ `.trim();
19
+ }
20
+ if (font.files) {
21
+ for (const weight in font.files) {
22
+ const isNumber = String(Number(weight)) === weight;
23
+ if (!isNumber) {
24
+ continue;
25
+ }
26
+ const weightUrl = font.files[weight];
27
+ if (weightUrl && weightUrl !== url) {
28
+ str += `
29
+ @font-face {
30
+ font-family: "${family}";
31
+ src: url('${weightUrl}') format('woff2');
32
+ font-display: fallback;
33
+ font-weight: ${weight};
34
+ }
35
+ `.trim();
36
+ }
37
+ }
38
+ }
39
+ return str;
40
+ }
41
+ function getFontCss({ customFonts }) {
42
+ var _a;
43
+ return ((_a = customFonts == null ? void 0 : customFonts.map((font) => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
44
+ }
45
+ function injectedStyles() {
46
+ return `
47
+ ${props.cssCode || ""}
48
+ ${getFontCss({
49
+ customFonts: props.customFonts
50
+ })}`;
51
+ }
52
+ return /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
53
+ styles: injectedStyles()
54
+ });
55
+ }
56
+ export {
57
+ RenderContentStyles as default
58
+ };
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import { default as default2 } from "./render-content.js";
3
+ export {
4
+ default2 as default
5
+ };