@builder.io/sdk-react 0.0.1-0

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 (110) hide show
  1. package/README.md +19 -0
  2. package/package.json +15 -0
  3. package/src/blocks/button/button.js +38 -0
  4. package/src/blocks/button/component-info.js +41 -0
  5. package/src/blocks/columns/columns.js +110 -0
  6. package/src/blocks/columns/component-info.js +241 -0
  7. package/src/blocks/custom-code/component-info.js +31 -0
  8. package/src/blocks/custom-code/custom-code.js +50 -0
  9. package/src/blocks/embed/component-info.js +43 -0
  10. package/src/blocks/embed/embed.js +43 -0
  11. package/src/blocks/embed/helpers.js +9 -0
  12. package/src/blocks/form/component-info.js +262 -0
  13. package/src/blocks/form/form.js +225 -0
  14. package/src/blocks/fragment/component-info.js +11 -0
  15. package/src/blocks/fragment/fragment.js +7 -0
  16. package/src/blocks/image/component-info.js +150 -0
  17. package/src/blocks/image/image.helpers.js +48 -0
  18. package/src/blocks/image/image.js +90 -0
  19. package/src/blocks/img/component-info.js +20 -0
  20. package/src/blocks/img/img.js +35 -0
  21. package/src/blocks/input/component-info.js +74 -0
  22. package/src/blocks/input/input.js +35 -0
  23. package/src/blocks/raw-text/component-info.js +16 -0
  24. package/src/blocks/raw-text/raw-text.js +11 -0
  25. package/src/blocks/section/component-info.js +49 -0
  26. package/src/blocks/section/section.js +30 -0
  27. package/src/blocks/select/component-info.js +59 -0
  28. package/src/blocks/select/select.js +35 -0
  29. package/src/blocks/submit-button/component-info.js +28 -0
  30. package/src/blocks/submit-button/submit-button.js +28 -0
  31. package/src/blocks/symbol/component-info.js +43 -0
  32. package/src/blocks/symbol/symbol.js +69 -0
  33. package/src/blocks/text/component-info.js +24 -0
  34. package/src/blocks/text/text.js +10 -0
  35. package/src/blocks/textarea/component-info.js +47 -0
  36. package/src/blocks/textarea/textarea.js +31 -0
  37. package/src/blocks/video/component-info.js +106 -0
  38. package/src/blocks/video/video.js +51 -0
  39. package/src/components/render-block/block-styles.js +40 -0
  40. package/src/components/render-block/render-block.helpers.js +23 -0
  41. package/src/components/render-block/render-block.js +169 -0
  42. package/src/components/render-block/render-component.js +33 -0
  43. package/src/components/render-block/render-repeated-block.js +29 -0
  44. package/src/components/render-block/types.js +0 -0
  45. package/src/components/render-blocks.js +62 -0
  46. package/src/components/render-content/components/render-styles.js +58 -0
  47. package/src/components/render-content/index.js +4 -0
  48. package/src/components/render-content/render-content.js +265 -0
  49. package/src/components/render-inlined-styles.js +17 -0
  50. package/src/constants/builder-registered-components.js +48 -0
  51. package/src/constants/device-sizes.js +21 -0
  52. package/src/constants/target.js +4 -0
  53. package/src/context/builder.context.js +11 -0
  54. package/src/functions/camel-to-kebab-case.js +4 -0
  55. package/src/functions/convert-style-object.js +6 -0
  56. package/src/functions/evaluate.js +28 -0
  57. package/src/functions/event-handler-name.js +7 -0
  58. package/src/functions/get-block-actions.js +23 -0
  59. package/src/functions/get-block-component-options.js +28 -0
  60. package/src/functions/get-block-properties.js +29 -0
  61. package/src/functions/get-block-styles.js +34 -0
  62. package/src/functions/get-block-tag.js +6 -0
  63. package/src/functions/get-builder-search-params/fn.test.js +13 -0
  64. package/src/functions/get-builder-search-params/index.js +33 -0
  65. package/src/functions/get-content/ab-testing.js +38 -0
  66. package/src/functions/get-content/fn.test.js +31 -0
  67. package/src/functions/get-content/index.js +96 -0
  68. package/src/functions/get-content/types.js +0 -0
  69. package/src/functions/get-fetch.js +34 -0
  70. package/src/functions/get-global-this.js +18 -0
  71. package/src/functions/get-processed-block.js +53 -0
  72. package/src/functions/get-processed-block.test.js +32 -0
  73. package/src/functions/if-target.js +15 -0
  74. package/src/functions/is-browser.js +6 -0
  75. package/src/functions/is-editing.js +7 -0
  76. package/src/functions/is-iframe.js +7 -0
  77. package/src/functions/is-previewing.js +14 -0
  78. package/src/functions/on-change.js +27 -0
  79. package/src/functions/on-change.test.js +19 -0
  80. package/src/functions/register-component.js +72 -0
  81. package/src/functions/register.js +29 -0
  82. package/src/functions/sanitize-styles.js +5 -0
  83. package/src/functions/set-editor-settings.js +15 -0
  84. package/src/functions/set.js +11 -0
  85. package/src/functions/set.test.js +16 -0
  86. package/src/functions/track.js +91 -0
  87. package/src/functions/transform-block.js +6 -0
  88. package/src/helpers/cookie.js +59 -0
  89. package/src/helpers/css.js +12 -0
  90. package/src/helpers/flatten.js +34 -0
  91. package/src/helpers/localStorage.js +34 -0
  92. package/src/helpers/nullable.js +4 -0
  93. package/src/helpers/sessionId.js +26 -0
  94. package/src/helpers/time.js +5 -0
  95. package/src/helpers/url.js +10 -0
  96. package/src/helpers/url.test.js +15 -0
  97. package/src/helpers/uuid.js +13 -0
  98. package/src/helpers/visitorId.js +33 -0
  99. package/src/index-helpers/blocks-exports.js +22 -0
  100. package/src/index-helpers/top-of-file.js +4 -0
  101. package/src/index.js +10 -0
  102. package/src/scripts/init-editing.js +80 -0
  103. package/src/types/builder-block.js +0 -0
  104. package/src/types/builder-content.js +0 -0
  105. package/src/types/can-track.js +0 -0
  106. package/src/types/components.js +0 -0
  107. package/src/types/deep-partial.js +0 -0
  108. package/src/types/element.js +0 -0
  109. package/src/types/targets.js +0 -0
  110. package/src/types/typescript.js +0 -0
@@ -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,31 @@
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
+ function Textarea(props) {
22
+ return /* @__PURE__ */ React.createElement("textarea", __spreadProps(__spreadValues({}, props.attributes), {
23
+ placeholder: props.placeholder,
24
+ name: props.name,
25
+ value: props.value,
26
+ defaultValue: props.defaultValue
27
+ }));
28
+ }
29
+ export {
30
+ Textarea as default
31
+ };
@@ -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,51 @@
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
+ function Video(props) {
22
+ var _a;
23
+ function videoProps() {
24
+ return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, props.autoPlay === true ? {
25
+ autoPlay: true
26
+ } : {}), props.muted === true ? {
27
+ muted: true
28
+ } : {}), props.controls === true ? {
29
+ controls: true
30
+ } : {}), props.loop === true ? {
31
+ loop: true
32
+ } : {}), props.playsInline === true ? {
33
+ playsInline: true
34
+ } : {});
35
+ }
36
+ return /* @__PURE__ */ React.createElement("video", __spreadProps(__spreadValues({}, videoProps()), {
37
+ style: __spreadProps(__spreadValues({
38
+ width: "100%",
39
+ height: "100%"
40
+ }, (_a = props.attributes) == null ? void 0 : _a.style), {
41
+ objectFit: props.fit,
42
+ objectPosition: props.position,
43
+ borderRadius: 1
44
+ }),
45
+ src: props.video || "no-src",
46
+ poster: props.posterImage
47
+ }));
48
+ }
49
+ export {
50
+ Video as default
51
+ };
@@ -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,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,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
+ }))) : 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, {
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
+ };
File without changes
@@ -0,0 +1,62 @@
1
+ import * as React from "react";
2
+ import { isEditing } from "../functions/is-editing.js";
3
+ import BlockStyles from "./render-block/block-styles.js";
4
+ import RenderBlock from "./render-block/render-block.js";
5
+ function RenderBlocks(props) {
6
+ var _a, _b;
7
+ function className() {
8
+ var _a2;
9
+ return "builder-blocks" + (!((_a2 = props.blocks) == null ? void 0 : _a2.length) ? " no-blocks" : "");
10
+ }
11
+ function onClick() {
12
+ var _a2, _b2;
13
+ if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
14
+ (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
15
+ type: "builder.clickEmptyBlocks",
16
+ data: {
17
+ parentElementId: props.parent,
18
+ dataPath: props.path
19
+ }
20
+ }, "*");
21
+ }
22
+ }
23
+ function onMouseEnter() {
24
+ var _a2, _b2;
25
+ if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
26
+ (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
27
+ type: "builder.hoverEmptyBlocks",
28
+ data: {
29
+ parentElementId: props.parent,
30
+ dataPath: props.path
31
+ }
32
+ }, "*");
33
+ }
34
+ }
35
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
36
+ className: className() + " div",
37
+ "builder-path": props.path,
38
+ "builder-parent-id": props.parent,
39
+ dataSet: {
40
+ class: className()
41
+ },
42
+ onClick: (event) => onClick(),
43
+ onMouseEnter: (event) => onMouseEnter()
44
+ }, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
45
+ key: "render-block-" + block.id,
46
+ block
47
+ }))) : null, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = props.blocks) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(BlockStyles, {
48
+ key: "block-style-" + block.id,
49
+ block
50
+ }))) : null), /* @__PURE__ */ React.createElement("style", {
51
+ jsx: true
52
+ }, `
53
+ .div {
54
+ display: flex;
55
+ flex-direction: column;
56
+ align-items: stretch;
57
+ }
58
+ `));
59
+ }
60
+ export {
61
+ RenderBlocks as default
62
+ };
@@ -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,4 @@
1
+ import { default as default2 } from "./render-content.js";
2
+ export {
3
+ default2 as default
4
+ };