@builder.io/sdk-react 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/package.json +5 -1
  2. package/packages/_rsc/src/blocks/BaseText.js +27 -0
  3. package/packages/_rsc/src/blocks/button/button.js +35 -0
  4. package/packages/_rsc/src/blocks/button/component-info.js +41 -0
  5. package/packages/_rsc/src/blocks/columns/columns.js +96 -0
  6. package/packages/_rsc/src/blocks/columns/component-info.js +242 -0
  7. package/packages/_rsc/src/blocks/custom-code/component-info.js +31 -0
  8. package/packages/_rsc/src/blocks/custom-code/custom-code.js +63 -0
  9. package/packages/_rsc/src/blocks/embed/component-info.js +44 -0
  10. package/packages/_rsc/src/blocks/embed/embed.js +55 -0
  11. package/packages/_rsc/src/blocks/embed/helpers.js +9 -0
  12. package/packages/_rsc/src/blocks/form/component-info.js +262 -0
  13. package/packages/_rsc/src/blocks/form/form.js +222 -0
  14. package/packages/_rsc/src/blocks/fragment/component-info.js +11 -0
  15. package/packages/_rsc/src/blocks/fragment/fragment.js +24 -0
  16. package/packages/_rsc/src/blocks/image/component-info.js +151 -0
  17. package/packages/_rsc/src/blocks/image/image.helpers.js +48 -0
  18. package/packages/_rsc/src/blocks/image/image.js +95 -0
  19. package/packages/_rsc/src/blocks/img/component-info.js +20 -0
  20. package/packages/_rsc/src/blocks/img/img.js +33 -0
  21. package/packages/_rsc/src/blocks/input/component-info.js +74 -0
  22. package/packages/_rsc/src/blocks/input/input.js +36 -0
  23. package/packages/_rsc/src/blocks/raw-text/component-info.js +16 -0
  24. package/packages/_rsc/src/blocks/raw-text/raw-text.js +28 -0
  25. package/packages/_rsc/src/blocks/section/component-info.js +49 -0
  26. package/packages/_rsc/src/blocks/section/section.js +31 -0
  27. package/packages/_rsc/src/blocks/select/component-info.js +59 -0
  28. package/packages/_rsc/src/blocks/select/select.js +36 -0
  29. package/packages/_rsc/src/blocks/submit-button/component-info.js +28 -0
  30. package/packages/_rsc/src/blocks/submit-button/submit-button.js +26 -0
  31. package/packages/_rsc/src/blocks/symbol/component-info.js +43 -0
  32. package/packages/_rsc/src/blocks/symbol/symbol.js +51 -0
  33. package/packages/_rsc/src/blocks/text/component-info.js +24 -0
  34. package/packages/_rsc/src/blocks/text/text.js +27 -0
  35. package/packages/_rsc/src/blocks/textarea/component-info.js +47 -0
  36. package/packages/_rsc/src/blocks/textarea/textarea.js +32 -0
  37. package/packages/_rsc/src/blocks/util.js +8 -0
  38. package/packages/_rsc/src/blocks/video/component-info.js +106 -0
  39. package/packages/_rsc/src/blocks/video/video.js +57 -0
  40. package/packages/_rsc/src/components/render-block/block-styles.js +70 -0
  41. package/packages/_rsc/src/components/render-block/render-block.helpers.js +23 -0
  42. package/packages/_rsc/src/components/render-block/render-block.js +203 -0
  43. package/packages/_rsc/src/components/render-block/render-component-with-context.js +51 -0
  44. package/packages/_rsc/src/components/render-block/render-component.js +43 -0
  45. package/packages/_rsc/src/components/render-block/render-repeated-block.js +49 -0
  46. package/packages/_rsc/src/components/render-block/types.js +0 -0
  47. package/packages/_rsc/src/components/render-blocks.js +80 -0
  48. package/packages/_rsc/src/components/render-content/builder-editing.js +35 -0
  49. package/packages/_rsc/src/components/render-content/components/render-styles.js +78 -0
  50. package/packages/_rsc/src/components/render-content/index.js +4 -0
  51. package/packages/_rsc/src/components/render-content/render-content.js +198 -0
  52. package/packages/_rsc/src/components/render-inlined-styles.js +36 -0
  53. package/packages/_rsc/src/constants/builder-registered-components.js +54 -0
  54. package/packages/_rsc/src/constants/device-sizes.js +48 -0
  55. package/packages/_rsc/src/constants/target.js +4 -0
  56. package/packages/_rsc/src/context/builder.context.js +11 -0
  57. package/packages/_rsc/src/context/types.js +0 -0
  58. package/packages/_rsc/src/functions/camel-to-kebab-case.js +4 -0
  59. package/packages/_rsc/src/functions/evaluate.js +6 -0
  60. package/packages/_rsc/src/functions/event-handler-name.js +7 -0
  61. package/packages/_rsc/src/functions/extract-text-styles.js +22 -0
  62. package/packages/_rsc/src/functions/fast-clone.js +4 -0
  63. package/packages/_rsc/src/functions/get-block-actions-handler.js +12 -0
  64. package/packages/_rsc/src/functions/get-block-actions.js +18 -0
  65. package/packages/_rsc/src/functions/get-block-component-options.js +28 -0
  66. package/packages/_rsc/src/functions/get-block-properties.js +29 -0
  67. package/packages/_rsc/src/functions/get-block-tag.js +6 -0
  68. package/packages/_rsc/src/functions/get-builder-search-params/fn.test.js +13 -0
  69. package/packages/_rsc/src/functions/get-builder-search-params/index.js +37 -0
  70. package/packages/_rsc/src/functions/get-content/ab-testing.js +99 -0
  71. package/packages/_rsc/src/functions/get-content/fn.test.js +31 -0
  72. package/packages/_rsc/src/functions/get-content/index.js +100 -0
  73. package/packages/_rsc/src/functions/get-content/types.js +0 -0
  74. package/packages/_rsc/src/functions/get-fetch.js +34 -0
  75. package/packages/_rsc/src/functions/get-global-this.js +18 -0
  76. package/packages/_rsc/src/functions/get-processed-block.js +59 -0
  77. package/packages/_rsc/src/functions/get-processed-block.test.js +32 -0
  78. package/packages/_rsc/src/functions/get-react-native-block-styles.js +32 -0
  79. package/packages/_rsc/src/functions/if-target.js +15 -0
  80. package/packages/_rsc/src/functions/is-browser.js +6 -0
  81. package/packages/_rsc/src/functions/is-editing.js +7 -0
  82. package/packages/_rsc/src/functions/is-iframe.js +7 -0
  83. package/packages/_rsc/src/functions/is-previewing.js +14 -0
  84. package/packages/_rsc/src/functions/mark-mutable.js +10 -0
  85. package/packages/_rsc/src/functions/on-change.js +27 -0
  86. package/packages/_rsc/src/functions/on-change.test.js +19 -0
  87. package/packages/_rsc/src/functions/register-component.js +68 -0
  88. package/packages/_rsc/src/functions/register.js +29 -0
  89. package/packages/_rsc/src/functions/sanitize-react-native-block-styles.js +66 -0
  90. package/packages/_rsc/src/functions/set-editor-settings.js +15 -0
  91. package/packages/_rsc/src/functions/set.js +11 -0
  92. package/packages/_rsc/src/functions/set.test.js +16 -0
  93. package/packages/_rsc/src/functions/track.js +120 -0
  94. package/packages/_rsc/src/functions/transform-block.js +6 -0
  95. package/packages/_rsc/src/helpers/ab-tests.js +16 -0
  96. package/packages/_rsc/src/helpers/cookie.js +79 -0
  97. package/packages/_rsc/src/helpers/css.js +28 -0
  98. package/packages/_rsc/src/helpers/flatten.js +34 -0
  99. package/packages/_rsc/src/helpers/localStorage.js +34 -0
  100. package/packages/_rsc/src/helpers/nullable.js +4 -0
  101. package/packages/_rsc/src/helpers/sessionId.js +49 -0
  102. package/packages/_rsc/src/helpers/time.js +5 -0
  103. package/packages/_rsc/src/helpers/url.js +10 -0
  104. package/packages/_rsc/src/helpers/url.test.js +15 -0
  105. package/packages/_rsc/src/helpers/uuid.js +13 -0
  106. package/packages/_rsc/src/helpers/visitorId.js +33 -0
  107. package/packages/_rsc/src/index-helpers/blocks-exports.js +22 -0
  108. package/packages/_rsc/src/index-helpers/top-of-file.js +2 -0
  109. package/packages/_rsc/src/index.js +14 -0
  110. package/packages/_rsc/src/scripts/init-editing.js +87 -0
  111. package/packages/_rsc/src/types/builder-block.js +0 -0
  112. package/packages/_rsc/src/types/builder-content.js +0 -0
  113. package/packages/_rsc/src/types/can-track.js +0 -0
  114. package/packages/_rsc/src/types/components.js +0 -0
  115. package/packages/_rsc/src/types/deep-partial.js +0 -0
  116. package/packages/_rsc/src/types/element.js +0 -0
  117. package/packages/_rsc/src/types/targets.js +0 -0
  118. package/packages/_rsc/src/types/typescript.js +0 -0
  119. package/src/blocks/button/button.jsx +6 -5
  120. package/src/blocks/columns/columns.jsx +9 -10
  121. package/src/blocks/columns/component-info.js +2 -2
  122. package/src/blocks/embed/component-info.js +2 -2
  123. package/src/blocks/form/form.jsx +4 -7
  124. package/src/blocks/image/component-info.js +2 -2
  125. package/src/blocks/img/img.jsx +2 -5
  126. package/src/blocks/submit-button/submit-button.jsx +2 -5
  127. package/src/blocks/symbol/symbol.jsx +3 -4
  128. package/src/blocks/util.js +6 -5
  129. package/src/components/render-block/block-styles.jsx +9 -3
  130. package/src/components/render-block/render-block.jsx +7 -7
  131. package/src/components/render-block/render-component.jsx +1 -2
  132. package/src/components/render-content/builder-editing.jsx +7 -0
  133. package/src/components/render-content/render-content.jsx +16 -11
  134. package/src/components/render-inlined-styles.jsx +4 -4
  135. package/src/constants/device-sizes.js +29 -2
  136. package/src/constants/target.js +1 -1
  137. package/src/functions/get-content/index.js +6 -2
  138. package/src/functions/register-component.js +1 -5
  139. package/src/functions/track.js +11 -8
  140. package/src/index.js +5 -1
  141. package/src/scripts/init-editing.js +7 -1
@@ -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
+ import RenderContent from "../../components/render-content/render-content.js";
22
+ function Symbol(props) {
23
+ var _a, _b, _c, _d, _e;
24
+ const _context = __spreadValues({}, props["_context"]);
25
+ const state = {
26
+ className: "builder-symbol",
27
+ fetchedContent: null,
28
+ get contentToUse() {
29
+ var _a2;
30
+ return ((_a2 = props.symbol) == null ? void 0 : _a2.content) || state.fetchedContent;
31
+ }
32
+ };
33
+ const builderContext = _context["BuilderContext"];
34
+ return /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, props.attributes), {
35
+ dataSet: {
36
+ class: state.className
37
+ },
38
+ className: state.className
39
+ }), /* @__PURE__ */ React.createElement(RenderContent, {
40
+ apiKey: builderContext.apiKey,
41
+ context: builderContext.context,
42
+ customComponents: Object.values(builderContext.registeredComponents),
43
+ data: __spreadValues(__spreadValues(__spreadValues({}, (_a = props.symbol) == null ? void 0 : _a.data), builderContext.state), (_d = (_c = (_b = props.symbol) == null ? void 0 : _b.content) == null ? void 0 : _c.data) == null ? void 0 : _d.state),
44
+ model: (_e = props.symbol) == null ? void 0 : _e.model,
45
+ content: state.contentToUse,
46
+ _context
47
+ }));
48
+ }
49
+ export {
50
+ Symbol as default
51
+ };
@@ -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,27 @@
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
+ function Text(props) {
19
+ const _context = __spreadValues({}, props["_context"]);
20
+ return /* @__PURE__ */ React.createElement("span", {
21
+ className: "builder-text",
22
+ dangerouslySetInnerHTML: { __html: props.text }
23
+ });
24
+ }
25
+ export {
26
+ Text as default
27
+ };
@@ -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
+ function Textarea(props) {
22
+ const _context = __spreadValues({}, props["_context"]);
23
+ return /* @__PURE__ */ React.createElement("textarea", __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,8 @@
1
+ const serializeFn = (fnValue) => {
2
+ const fnStr = fnValue.toString().trim();
3
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
4
+ return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
5
+ };
6
+ export {
7
+ serializeFn
8
+ };
@@ -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,57 @@
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
+ const _context = __spreadValues({}, props["_context"]);
24
+ const state = {
25
+ get videoProps() {
26
+ return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, props.autoPlay === true ? {
27
+ autoPlay: true
28
+ } : {}), props.muted === true ? {
29
+ muted: true
30
+ } : {}), props.controls === true ? {
31
+ controls: true
32
+ } : {}), props.loop === true ? {
33
+ loop: true
34
+ } : {}), props.playsInline === true ? {
35
+ playsInline: true
36
+ } : {});
37
+ },
38
+ get spreadProps() {
39
+ return __spreadValues(__spreadValues({}, props.attributes), state.videoProps);
40
+ }
41
+ };
42
+ return /* @__PURE__ */ React.createElement("video", __spreadProps(__spreadValues({}, state.spreadProps), {
43
+ style: __spreadProps(__spreadValues({
44
+ width: "100%",
45
+ height: "100%"
46
+ }, (_a = props.attributes) == null ? void 0 : _a.style), {
47
+ objectFit: props.fit,
48
+ objectPosition: props.position,
49
+ borderRadius: 1
50
+ }),
51
+ src: props.video || "no-src",
52
+ poster: props.posterImage
53
+ }));
54
+ }
55
+ export {
56
+ Video as default
57
+ };
@@ -0,0 +1,70 @@
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 {
19
+ getMaxWidthQueryForSize,
20
+ getSizesForBreakpoints
21
+ } from "../../constants/device-sizes.js";
22
+ import { TARGET } from "../../constants/target.js";
23
+ import { getProcessedBlock } from "../../functions/get-processed-block.js";
24
+ import { createCssClass } from "../../helpers/css.js";
25
+ import RenderInlinedStyles from "../render-inlined-styles.js";
26
+ function BlockStyles(props) {
27
+ const _context = __spreadValues({}, props["_context"]);
28
+ const state = {
29
+ get useBlock() {
30
+ return getProcessedBlock({
31
+ block: props.block,
32
+ state: props.context.state,
33
+ context: props.context.context,
34
+ shouldEvaluateBindings: true
35
+ });
36
+ },
37
+ get css() {
38
+ var _a;
39
+ const styles = state.useBlock.responsiveStyles;
40
+ const content = props.context.content;
41
+ const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(((_a = content == null ? void 0 : content.meta) == null ? void 0 : _a.breakpoints) || {});
42
+ const largeStyles = styles == null ? void 0 : styles.large;
43
+ const mediumStyles = styles == null ? void 0 : styles.medium;
44
+ const smallStyles = styles == null ? void 0 : styles.small;
45
+ const className = state.useBlock.id;
46
+ const largeStylesClass = largeStyles ? createCssClass({
47
+ className,
48
+ styles: largeStyles
49
+ }) : "";
50
+ const mediumStylesClass = mediumStyles ? createCssClass({
51
+ className,
52
+ styles: mediumStyles,
53
+ mediaQuery: getMaxWidthQueryForSize("medium", sizesWithUpdatedBreakpoints)
54
+ }) : "";
55
+ const smallStylesClass = smallStyles ? createCssClass({
56
+ className,
57
+ styles: smallStyles,
58
+ mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
59
+ }) : "";
60
+ return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
61
+ }
62
+ };
63
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET !== "reactNative" && state.css ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
64
+ styles: state.css,
65
+ _context
66
+ })) : null);
67
+ }
68
+ export {
69
+ BlockStyles as default
70
+ };
@@ -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,203 @@
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 { getBlockTag } from "../../functions/get-block-tag.js";
37
+ import { getProcessedBlock } from "../../functions/get-processed-block.js";
38
+ import { evaluate } from "../../functions/evaluate.js";
39
+ import BlockStyles from "./block-styles.js";
40
+ import { isEmptyHtmlElement } from "./render-block.helpers.js";
41
+ import RenderRepeatedBlock from "./render-repeated-block.js";
42
+ import { TARGET } from "../../constants/target.js";
43
+ import { extractTextStyles } from "../../functions/extract-text-styles.js";
44
+ import RenderComponentWithContext from "./render-component-with-context.js";
45
+ import RenderComponent from "./render-component.js";
46
+ import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
47
+ function RenderBlock(props) {
48
+ var _a, _b, _c;
49
+ const _context = __spreadValues({}, props["_context"]);
50
+ const state = {
51
+ get component() {
52
+ var _a2;
53
+ const componentName = (_a2 = getProcessedBlock({
54
+ block: props.block,
55
+ state: props.context.state,
56
+ context: props.context.context,
57
+ shouldEvaluateBindings: false
58
+ }).component) == null ? void 0 : _a2.name;
59
+ if (!componentName) {
60
+ return null;
61
+ }
62
+ const ref = props.context.registeredComponents[componentName];
63
+ if (!ref) {
64
+ console.warn(`
65
+ Could not find a registered component named "${componentName}".
66
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
67
+ return void 0;
68
+ } else {
69
+ return ref;
70
+ }
71
+ },
72
+ get tag() {
73
+ return getBlockTag(state.useBlock);
74
+ },
75
+ get useBlock() {
76
+ return state.repeatItemData ? props.block : getProcessedBlock({
77
+ block: props.block,
78
+ state: props.context.state,
79
+ context: props.context.context,
80
+ shouldEvaluateBindings: true
81
+ });
82
+ },
83
+ get attributes() {
84
+ return __spreadValues(__spreadValues(__spreadValues({}, getBlockProperties(state.useBlock)), getBlockActions({
85
+ block: state.useBlock,
86
+ state: props.context.state,
87
+ context: props.context.context
88
+ })), TARGET === "reactNative" ? {
89
+ style: getReactNativeBlockStyles({
90
+ block: state.useBlock,
91
+ context: props.context
92
+ })
93
+ } : {});
94
+ },
95
+ get shouldWrap() {
96
+ var _a2;
97
+ return !((_a2 = state.component) == null ? void 0 : _a2.noWrap);
98
+ },
99
+ get renderComponentProps() {
100
+ var _a2;
101
+ return {
102
+ blockChildren: state.useChildren,
103
+ componentRef: (_a2 = state.component) == null ? void 0 : _a2.component,
104
+ componentOptions: __spreadValues(__spreadValues({}, getBlockComponentOptions(state.useBlock)), state.shouldWrap ? {} : {
105
+ attributes: state.attributes
106
+ }),
107
+ context: state.childrenContext
108
+ };
109
+ },
110
+ get useChildren() {
111
+ var _a2;
112
+ return (_a2 = state.useBlock.children) != null ? _a2 : [];
113
+ },
114
+ get childrenWithoutParentComponent() {
115
+ var _a2;
116
+ const shouldRenderChildrenOutsideRef = !((_a2 = state.component) == null ? void 0 : _a2.component) && !state.repeatItemData;
117
+ return shouldRenderChildrenOutsideRef ? state.useChildren : [];
118
+ },
119
+ get repeatItemData() {
120
+ const _a2 = props.block, { repeat } = _a2, blockWithoutRepeat = __objRest(_a2, ["repeat"]);
121
+ if (!(repeat == null ? void 0 : repeat.collection)) {
122
+ return void 0;
123
+ }
124
+ const itemsArray = evaluate({
125
+ code: repeat.collection,
126
+ state: props.context.state,
127
+ context: props.context.context
128
+ });
129
+ if (!Array.isArray(itemsArray)) {
130
+ return void 0;
131
+ }
132
+ const collectionName = repeat.collection.split(".").pop();
133
+ const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
134
+ const repeatArray = itemsArray.map((item, index) => ({
135
+ context: __spreadProps(__spreadValues({}, props.context), {
136
+ state: __spreadProps(__spreadValues({}, props.context.state), {
137
+ $index: index,
138
+ $item: item,
139
+ [itemNameToUse]: item,
140
+ [`$${itemNameToUse}Index`]: index
141
+ })
142
+ }),
143
+ block: blockWithoutRepeat
144
+ }));
145
+ return repeatArray;
146
+ },
147
+ get inheritedTextStyles() {
148
+ if (TARGET !== "reactNative") {
149
+ return {};
150
+ }
151
+ const styles = getReactNativeBlockStyles({
152
+ block: state.useBlock,
153
+ context: props.context
154
+ });
155
+ return extractTextStyles(styles);
156
+ },
157
+ get childrenContext() {
158
+ return {
159
+ apiKey: props.context.apiKey,
160
+ state: props.context.state,
161
+ content: props.context.content,
162
+ context: props.context.context,
163
+ registeredComponents: props.context.registeredComponents,
164
+ inheritedStyles: state.inheritedTextStyles
165
+ };
166
+ },
167
+ get renderComponentTag() {
168
+ if (TARGET === "reactNative") {
169
+ return RenderComponentWithContext;
170
+ } else if (TARGET === "vue3") {
171
+ return "RenderComponent";
172
+ } else {
173
+ return RenderComponent;
174
+ }
175
+ },
176
+ componentInfo: null
177
+ };
178
+ const RenderComponentTagRef = state.renderComponentTag;
179
+ const TagRef = state.tag;
180
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, state.shouldWrap ? /* @__PURE__ */ React.createElement(React.Fragment, null, isEmptyHtmlElement(state.tag) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagRef, __spreadValues({}, state.attributes))) : null, !isEmptyHtmlElement(state.tag) && state.repeatItemData ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = state.repeatItemData) == null ? void 0 : _a.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
181
+ key: index,
182
+ repeatContext: data.context,
183
+ block: data.block,
184
+ _context
185
+ }))) : null, !isEmptyHtmlElement(state.tag) && !state.repeatItemData ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagRef, __spreadValues({}, state.attributes), /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadProps(__spreadValues({}, state.renderComponentProps), {
186
+ _context
187
+ })), (_b = state.childrenWithoutParentComponent) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
188
+ key: "render-block-" + child.id,
189
+ block: child,
190
+ context: state.childrenContext,
191
+ _context
192
+ })), (_c = state.childrenWithoutParentComponent) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
193
+ key: "block-style-" + child.id,
194
+ block: child,
195
+ context: state.childrenContext,
196
+ _context
197
+ })))) : null) : /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadProps(__spreadValues({}, state.renderComponentProps), {
198
+ _context
199
+ })));
200
+ }
201
+ export {
202
+ RenderBlock as default
203
+ };