@builder.io/sdk-react 0.0.1-6 → 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 (55) hide show
  1. package/package.json +2 -1
  2. package/src/blocks/BaseText.jsx +12 -0
  3. package/src/blocks/button/{button.js → button.jsx} +3 -3
  4. package/src/blocks/columns/{columns.js → columns.jsx} +17 -11
  5. package/src/blocks/custom-code/{custom-code.js → custom-code.jsx} +1 -1
  6. package/src/blocks/embed/{embed.js → embed.jsx} +2 -0
  7. package/src/blocks/form/{form.js → form.jsx} +4 -4
  8. package/src/blocks/fragment/{fragment.js → fragment.jsx} +0 -0
  9. package/src/blocks/image/{image.js → image.jsx} +12 -15
  10. package/src/blocks/img/{img.js → img.jsx} +0 -0
  11. package/src/blocks/input/{input.js → input.jsx} +0 -0
  12. package/src/blocks/raw-text/{raw-text.js → raw-text.jsx} +0 -0
  13. package/src/blocks/section/{section.js → section.jsx} +0 -0
  14. package/src/blocks/select/{select.js → select.jsx} +0 -0
  15. package/src/blocks/submit-button/{submit-button.js → submit-button.jsx} +0 -0
  16. package/src/blocks/symbol/{symbol.js → symbol.jsx} +15 -19
  17. package/src/blocks/text/{text.js → text.jsx} +1 -1
  18. package/src/blocks/textarea/{textarea.js → textarea.jsx} +0 -0
  19. package/src/blocks/video/{video.js → video.jsx} +4 -1
  20. package/src/components/render-block/{block-styles.js → block-styles.jsx} +19 -12
  21. package/src/components/render-block/{render-block.js → render-block.jsx} +60 -37
  22. package/src/components/render-block/render-component-with-context.jsx +35 -0
  23. package/src/components/render-block/{render-component.js → render-component.jsx} +4 -3
  24. package/src/components/render-block/{render-repeated-block.js → render-repeated-block.jsx} +4 -1
  25. package/src/components/{render-blocks.js → render-blocks.jsx} +5 -4
  26. package/src/components/render-content/components/{render-styles.js → render-styles.jsx} +1 -1
  27. package/src/components/render-content/index.js +1 -1
  28. package/src/components/render-content/{render-content.js → render-content.jsx} +25 -35
  29. package/src/components/{render-inlined-styles.js → render-inlined-styles.jsx} +0 -0
  30. package/src/constants/builder-registered-components.js +14 -11
  31. package/src/context/builder.context.js +2 -1
  32. package/src/context/types.js +0 -0
  33. package/src/functions/evaluate.js +1 -1
  34. package/src/functions/extract-text-styles.js +22 -0
  35. package/src/functions/fast-clone.js +4 -0
  36. package/src/functions/get-block-actions-handler.js +12 -0
  37. package/src/functions/get-block-actions.js +2 -7
  38. package/src/functions/get-builder-search-params/index.js +6 -2
  39. package/src/functions/get-content/ab-testing.js +91 -30
  40. package/src/functions/get-content/index.js +5 -5
  41. package/src/functions/get-processed-block.js +5 -3
  42. package/src/functions/get-react-native-block-styles.js +32 -0
  43. package/src/functions/mark-mutable.js +10 -0
  44. package/src/functions/register-component.js +1 -1
  45. package/src/functions/sanitize-react-native-block-styles.js +66 -0
  46. package/src/functions/track.js +9 -7
  47. package/src/helpers/ab-tests.js +16 -0
  48. package/src/helpers/cookie.js +26 -6
  49. package/src/helpers/css.js +17 -1
  50. package/src/helpers/sessionId.js +26 -3
  51. package/src/index-helpers/blocks-exports.js +10 -10
  52. package/src/scripts/init-editing.js +36 -34
  53. package/src/functions/convert-style-object.js +0 -6
  54. package/src/functions/get-block-styles.js +0 -34
  55. package/src/functions/sanitize-styles.js +0 -5
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react",
3
3
  "description": "Builder.io SDK for React",
4
- "version": "0.0.1-6",
4
+ "version": "0.0.1",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
7
7
  "exports": {
@@ -11,6 +11,7 @@
11
11
  }
12
12
  },
13
13
  "scripts": {
14
+ "release:patch": "npm version patch --no-git-tag-version && npm publish --access public",
14
15
  "release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
15
16
  },
16
17
  "peerDependencies": {
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ import { useContext } from "react";
3
+ import BuilderContext from "../context/builder.context.js";
4
+ function BaseText(props) {
5
+ const builderContext = useContext(BuilderContext);
6
+ return /* @__PURE__ */ React.createElement("span", {
7
+ style: builderContext.inheritedStyles
8
+ }, props.text);
9
+ }
10
+ export {
11
+ BaseText as default
12
+ };
@@ -19,13 +19,13 @@ var __spreadValues = (a, b) => {
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import * as React from "react";
21
21
  function Button(props) {
22
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(React.Fragment, null, props.link ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("a", __spreadProps(__spreadValues({}, props.attributes), {
22
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, props.link ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("a", __spreadProps(__spreadValues({}, props.attributes), {
23
23
  role: "button",
24
24
  href: props.link,
25
25
  target: props.openLinkInNewTab ? "_blank" : void 0
26
26
  }), props.text)) : /* @__PURE__ */ React.createElement("button", __spreadProps(__spreadValues({}, props.attributes), {
27
- className: "button-7c88bfd8"
28
- }), props.text)), /* @__PURE__ */ React.createElement("style", null, `.button-7c88bfd8 {
27
+ className: "button-31efdaa8"
28
+ }), props.text), /* @__PURE__ */ React.createElement("style", null, `.button-31efdaa8 {
29
29
  all: unset; }`));
30
30
  }
31
31
  export {
@@ -15,7 +15,8 @@ var __spreadValues = (a, b) => {
15
15
  return a;
16
16
  };
17
17
  import * as React from "react";
18
- import RenderBlocks from "../../components/render-blocks.js";
18
+ import RenderBlocks from "../../components/render-blocks.jsx";
19
+ import { markMutable } from "../../functions/mark-mutable";
19
20
  function Columns(props) {
20
21
  var _a;
21
22
  function getGutterSize() {
@@ -57,28 +58,33 @@ function Columns(props) {
57
58
  };
58
59
  }
59
60
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
60
- className: "builder-columns div-6588dcca",
61
+ className: "builder-columns div-4fe0d43b",
61
62
  style: columnsCssVars()
62
63
  }, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement("div", {
63
- className: "builder-column div-6588dcca-2",
64
+ className: "builder-column div-4fe0d43b-2",
64
65
  style: __spreadValues({
65
66
  width: getColumnCssWidth(index),
66
67
  marginLeft: `${index === 0 ? 0 : getGutterSize()}px`
67
68
  }, columnCssVars()),
68
69
  key: index
69
70
  }, /* @__PURE__ */ React.createElement(RenderBlocks, {
70
- blocks: column.blocks,
71
+ blocks: markMutable(column.blocks),
71
72
  path: `component.options.columns.${index}.blocks`,
72
- parent: props.builderBlock.id
73
- })))), /* @__PURE__ */ React.createElement("style", null, `.div-6588dcca {
73
+ parent: props.builderBlock.id,
74
+ styleProp: {
75
+ flexGrow: "1"
76
+ }
77
+ })))), /* @__PURE__ */ React.createElement("style", null, `.div-4fe0d43b {
74
78
  display: flex;
75
79
  align-items: stretch;
76
- line-height: normal; }@media (max-width: 991px) { .div-6588dcca {
77
- flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-6588dcca {
78
- flex-direction: var(--flex-dir); } }.div-6588dcca-2 {
79
- flex-grow: 1; }@media (max-width: 991px) { .div-6588dcca-2 {
80
+ line-height: normal; }@media (max-width: 991px) { .div-4fe0d43b {
81
+ flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-4fe0d43b {
82
+ flex-direction: var(--flex-dir); } }.div-4fe0d43b-2 {
83
+ display: flex;
84
+ flex-direction: column;
85
+ align-items: stretch; }@media (max-width: 991px) { .div-4fe0d43b-2 {
80
86
  width: var(--column-width-tablet) !important;
81
- margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-6588dcca-2 {
87
+ margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-4fe0d43b-2 {
82
88
  width: var(--column-width) !important;
83
89
  margin-left: var(--column-margin-left) !important; } }`));
84
90
  }
@@ -5,7 +5,7 @@ function CustomCode(props) {
5
5
  const [scriptsInserted, setScriptsInserted] = useState(() => []);
6
6
  const [scriptsRun, setScriptsRun] = useState(() => []);
7
7
  function findAndRunScripts() {
8
- if (elem.current && typeof window !== "undefined") {
8
+ if (elem.current && elem.current.getElementsByTagName && typeof window !== "undefined") {
9
9
  const scripts = elem.current.getElementsByTagName("script");
10
10
  for (let i = 0; i < scripts.length; i++) {
11
11
  const script = scripts[i];
@@ -7,6 +7,8 @@ function Embed(props) {
7
7
  const [scriptsRun, setScriptsRun] = useState(() => []);
8
8
  const [ranInitFn, setRanInitFn] = useState(() => false);
9
9
  function findAndRunScripts() {
10
+ if (!elem.current || !elem.current.getElementsByTagName)
11
+ return;
10
12
  const scripts = elem.current.getElementsByTagName("script");
11
13
  for (let i = 0; i < scripts.length; i++) {
12
14
  const script = scripts[i];
@@ -39,8 +39,8 @@ var __async = (__this, __arguments, generator) => {
39
39
  };
40
40
  import * as React from "react";
41
41
  import { useState, useContext, useRef } from "react";
42
- import RenderBlock from "../../components/render-block/render-block.js";
43
- import BuilderBlocks from "../../components/render-blocks.js";
42
+ import RenderBlock from "../../components/render-block/render-block.jsx";
43
+ import BuilderBlocks from "../../components/render-blocks.jsx";
44
44
  import { isEditing } from "../../functions/is-editing.js";
45
45
  function FormComponent(props) {
46
46
  var _a, _b;
@@ -209,11 +209,11 @@ function FormComponent(props) {
209
209
  dataPath: "sendingMessage",
210
210
  blocks: props.sendingMessage
211
211
  })) : null, " ", submissionState() === "error" && responseData ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("pre", {
212
- className: "builder-form-error-text pre-79359d0a"
212
+ className: "builder-form-error-text pre-928514ea"
213
213
  }, " ", JSON.stringify(responseData, null, 2), " ")) : null, " ", submissionState() === "success" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
214
214
  dataPath: "successMessage",
215
215
  blocks: props.successMessage
216
- })) : null, " "), " ", /* @__PURE__ */ React.createElement("style", null, `.pre-79359d0a { padding: 10px; color: red; text-align: center; }`), " ");
216
+ })) : null, " "), " ", /* @__PURE__ */ React.createElement("style", null, `.pre-928514ea { padding: 10px; color: red; text-align: center; }`), " ");
217
217
  }
218
218
  export {
219
219
  FormComponent as default
@@ -27,11 +27,9 @@ function Image(props) {
27
27
  return "";
28
28
  }
29
29
  }
30
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
31
- className: "div-95472e7c"
32
- }, /* @__PURE__ */ React.createElement("picture", null, webpSrcSet() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("source", {
30
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("picture", null, webpSrcSet() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("source", {
33
31
  type: "image/webp",
34
- srcset: webpSrcSet()
32
+ srcSet: webpSrcSet()
35
33
  })) : null, /* @__PURE__ */ React.createElement("img", {
36
34
  loading: "lazy",
37
35
  alt: props.altText,
@@ -40,31 +38,30 @@ function Image(props) {
40
38
  objectPosition: props.backgroundSize || "center",
41
39
  objectFit: props.backgroundSize || "cover"
42
40
  },
43
- className: "builder-image" + (props.className ? " " + props.className : "") + " img-95472e7c",
41
+ className: "builder-image" + (props.className ? " " + props.className : "") + " img-6cfc0cdc",
44
42
  src: props.image,
45
- srcset: srcSetToUse(),
43
+ srcSet: srcSetToUse(),
46
44
  sizes: props.sizes
47
45
  }), /* @__PURE__ */ React.createElement("source", {
48
- srcset: srcSetToUse()
49
- })), props.aspectRatio && !(props.fitContent && ((_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.length)) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
50
- className: "builder-image-sizer div-95472e7c-2",
46
+ srcSet: srcSetToUse()
47
+ })), props.aspectRatio && !(((_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.length) && props.fitContent) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
48
+ className: "builder-image-sizer div-6cfc0cdc",
51
49
  style: {
52
50
  paddingTop: props.aspectRatio * 100 + "%"
53
51
  }
54
- })) : null, ((_d = (_c = props.builderBlock) == null ? void 0 : _c.children) == null ? void 0 : _d.length) && props.fitContent ? /* @__PURE__ */ React.createElement(React.Fragment, null, props.children) : null, !props.fitContent ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
55
- className: "div-95472e7c-3"
56
- }, props.children)) : null), /* @__PURE__ */ React.createElement("style", null, `.div-95472e7c {
57
- position: relative; }.img-95472e7c {
52
+ })) : null, ((_d = (_c = props.builderBlock) == null ? void 0 : _c.children) == null ? void 0 : _d.length) && props.fitContent ? /* @__PURE__ */ React.createElement(React.Fragment, null, props.children) : null, !props.fitContent && props.children ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
53
+ className: "div-6cfc0cdc-2"
54
+ }, props.children)) : null), /* @__PURE__ */ React.createElement("style", null, `.img-6cfc0cdc {
58
55
  opacity: 1;
59
56
  transition: opacity 0.2s ease-in-out;
60
57
  position: absolute;
61
58
  height: 100%;
62
59
  width: 100%;
63
60
  top: 0px;
64
- left: 0px; }.div-95472e7c-2 {
61
+ left: 0px; }.div-6cfc0cdc {
65
62
  width: 100%;
66
63
  pointer-events: none;
67
- font-size: 0; }.div-95472e7c-3 {
64
+ font-size: 0; }.div-6cfc0cdc-2 {
68
65
  display: flex;
69
66
  flex-direction: column;
70
67
  align-items: stretch;
File without changes
File without changes
File without changes
File without changes
@@ -19,21 +19,22 @@ var __spreadValues = (a, b) => {
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import * as React from "react";
21
21
  import { useState, useContext, useEffect } from "react";
22
- import RenderContent from "../../components/render-content/render-content.js";
22
+ import RenderContent from "../../components/render-content/render-content.jsx";
23
23
  import BuilderContext from "../../context/builder.context.js";
24
24
  import { getContent } from "../../functions/get-content/index.js";
25
+ import { markMutable } from "../../functions/mark-mutable";
25
26
  function Symbol(props) {
26
- var _a, _b, _c, _d, _e, _f, _g, _h;
27
+ var _a, _b, _c, _d, _e;
27
28
  const [className, setClassName] = useState(() => "builder-symbol");
28
- const [content, setContent] = useState(() => null);
29
- const builderContext = useContext(BuilderContext);
30
- useEffect(() => {
29
+ const [fetchedContent, setFetchedContent] = useState(() => null);
30
+ function contentToUse() {
31
31
  var _a2;
32
- setContent((_a2 = props.symbol) == null ? void 0 : _a2.content);
33
- }, []);
32
+ return ((_a2 = props.symbol) == null ? void 0 : _a2.content) || fetchedContent;
33
+ }
34
+ const builderContext = useContext(BuilderContext);
34
35
  useEffect(() => {
35
36
  const symbolToUse = props.symbol;
36
- if (symbolToUse && !symbolToUse.content && !content && symbolToUse.model) {
37
+ if (symbolToUse && !symbolToUse.content && !fetchedContent && symbolToUse.model) {
37
38
  getContent({
38
39
  model: symbolToUse.model,
39
40
  apiKey: builderContext.apiKey,
@@ -41,15 +42,10 @@ function Symbol(props) {
41
42
  id: symbolToUse.entry
42
43
  }
43
44
  }).then((response) => {
44
- setContent(response);
45
+ setFetchedContent(response);
45
46
  });
46
47
  }
47
- }, [
48
- (_a = props.symbol) == null ? void 0 : _a.content,
49
- (_b = props.symbol) == null ? void 0 : _b.model,
50
- (_c = props.symbol) == null ? void 0 : _c.entry,
51
- content
52
- ]);
48
+ }, [props.symbol, fetchedContent]);
53
49
  return /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, props.attributes), {
54
50
  dataSet: {
55
51
  class: className
@@ -58,10 +54,10 @@ function Symbol(props) {
58
54
  }), /* @__PURE__ */ React.createElement(RenderContent, {
59
55
  apiKey: builderContext.apiKey,
60
56
  context: builderContext.context,
61
- customComponents: Object.values(builderContext.registeredComponents),
62
- data: __spreadValues(__spreadValues(__spreadValues({}, (_d = props.symbol) == null ? void 0 : _d.data), builderContext.state), (_g = (_f = (_e = props.symbol) == null ? void 0 : _e.content) == null ? void 0 : _f.data) == null ? void 0 : _g.state),
63
- model: (_h = props.symbol) == null ? void 0 : _h.model,
64
- content
57
+ customComponents: markMutable(Object.values(builderContext.registeredComponents)),
58
+ data: markMutable(__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)),
59
+ model: (_e = props.symbol) == null ? void 0 : _e.model,
60
+ content: markMutable(contentToUse())
65
61
  }));
66
62
  }
67
63
  export {
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  function Text(props) {
3
- return /* @__PURE__ */ React.createElement("div", {
3
+ return /* @__PURE__ */ React.createElement("span", {
4
4
  className: "builder-text",
5
5
  dangerouslySetInnerHTML: { __html: props.text }
6
6
  });
@@ -33,7 +33,10 @@ function Video(props) {
33
33
  playsInline: true
34
34
  } : {});
35
35
  }
36
- return /* @__PURE__ */ React.createElement("video", __spreadProps(__spreadValues({}, videoProps()), {
36
+ function spreadProps() {
37
+ return __spreadValues(__spreadValues({}, props.attributes), videoProps());
38
+ }
39
+ return /* @__PURE__ */ React.createElement("video", __spreadProps(__spreadValues({}, spreadProps()), {
37
40
  style: __spreadProps(__spreadValues({
38
41
  width: "100%",
39
42
  height: "100%"
@@ -2,8 +2,8 @@ import * as React from "react";
2
2
  import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
3
3
  import { TARGET } from "../../constants/target.js";
4
4
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
5
- import { convertStyleMaptoCSS } from "../../helpers/css.js";
6
- import RenderInlinedStyles from "../render-inlined-styles.js";
5
+ import { createCssClass } from "../../helpers/css.js";
6
+ import RenderInlinedStyles from "../render-inlined-styles.jsx";
7
7
  function BlockStyles(props) {
8
8
  function useBlock() {
9
9
  return getProcessedBlock({
@@ -18,17 +18,24 @@ function BlockStyles(props) {
18
18
  const largeStyles = styles == null ? void 0 : styles.large;
19
19
  const mediumStyles = styles == null ? void 0 : styles.medium;
20
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
- }`;
21
+ const className = useBlock().id;
22
+ const largeStylesClass = largeStyles ? createCssClass({
23
+ className,
24
+ styles: largeStyles
25
+ }) : "";
26
+ const mediumStylesClass = mediumStyles ? createCssClass({
27
+ className,
28
+ styles: mediumStyles,
29
+ mediaQuery: getMaxWidthQueryForSize("medium")
30
+ }) : "";
31
+ const smallStylesClass = smallStyles ? createCssClass({
32
+ className,
33
+ styles: smallStyles,
34
+ mediaQuery: getMaxWidthQueryForSize("small")
35
+ }) : "";
36
+ return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
30
37
  }
31
- return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
38
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET !== "reactNative" && css() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
32
39
  styles: css()
33
40
  })) : null);
34
41
  }
@@ -30,17 +30,21 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
  import * as React from "react";
33
+ import { useState } from "react";
33
34
  import { getBlockActions } from "../../functions/get-block-actions.js";
34
35
  import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
35
36
  import { getBlockProperties } from "../../functions/get-block-properties.js";
36
- import { getBlockStyles } from "../../functions/get-block-styles.js";
37
37
  import { getBlockTag } from "../../functions/get-block-tag.js";
38
38
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
39
39
  import { evaluate } from "../../functions/evaluate.js";
40
- import BlockStyles from "./block-styles.js";
40
+ import BlockStyles from "./block-styles.jsx";
41
41
  import { isEmptyHtmlElement } from "./render-block.helpers.js";
42
- import RenderComponent from "./render-component.js";
43
- import RenderRepeatedBlock from "./render-repeated-block.js";
42
+ import RenderRepeatedBlock from "./render-repeated-block.jsx";
43
+ import { TARGET } from "../../constants/target.js";
44
+ import { extractTextStyles } from "../../functions/extract-text-styles.js";
45
+ import RenderComponentWithContext from "./render-component-with-context.jsx";
46
+ import RenderComponent from "./render-component.jsx";
47
+ import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
44
48
  function RenderBlock(props) {
45
49
  var _a, _b, _c;
46
50
  function component() {
@@ -64,18 +68,6 @@ function RenderBlock(props) {
64
68
  return ref;
65
69
  }
66
70
  }
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
71
  function tagName() {
80
72
  return getBlockTag(useBlock());
81
73
  }
@@ -88,29 +80,30 @@ function RenderBlock(props) {
88
80
  });
89
81
  }
90
82
  function attributes() {
91
- return __spreadProps(__spreadValues(__spreadValues({}, getBlockProperties(useBlock())), getBlockActions({
83
+ return __spreadValues(__spreadValues(__spreadValues({}, getBlockProperties(useBlock())), getBlockActions({
92
84
  block: useBlock(),
93
85
  state: props.context.state,
94
86
  context: props.context.context
95
- })), {
96
- style: getBlockStyles(useBlock())
97
- });
87
+ })), TARGET === "reactNative" ? {
88
+ style: getReactNativeBlockStyles({
89
+ block: useBlock(),
90
+ context: props.context
91
+ })
92
+ } : {});
98
93
  }
99
94
  function shouldWrap() {
100
95
  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
- });
96
+ return !((_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.noWrap);
107
97
  }
108
98
  function renderComponentProps() {
99
+ var _a2;
109
100
  return {
110
101
  blockChildren: children(),
111
- componentRef: componentRef(),
112
- componentOptions: componentOptions(),
113
- context: props.context
102
+ componentRef: (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component,
103
+ componentOptions: __spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
104
+ attributes: attributes()
105
+ }),
106
+ context: childrenContext()
114
107
  };
115
108
  }
116
109
  function children() {
@@ -118,7 +111,8 @@ function RenderBlock(props) {
118
111
  return (_a2 = useBlock().children) != null ? _a2 : [];
119
112
  }
120
113
  function childrenWithoutParentComponent() {
121
- const shouldRenderChildrenOutsideRef = !componentRef() && !repeatItemData();
114
+ var _a2;
115
+ const shouldRenderChildrenOutsideRef = !((_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component) && !repeatItemData();
122
116
  return shouldRenderChildrenOutsideRef ? children() : [];
123
117
  }
124
118
  function repeatItemData() {
@@ -149,22 +143,51 @@ function RenderBlock(props) {
149
143
  }));
150
144
  return repeatArray;
151
145
  }
146
+ function inheritedTextStyles() {
147
+ if (TARGET !== "reactNative") {
148
+ return {};
149
+ }
150
+ const styles = getReactNativeBlockStyles({
151
+ block: useBlock(),
152
+ context: props.context
153
+ });
154
+ return extractTextStyles(styles);
155
+ }
156
+ function childrenContext() {
157
+ return {
158
+ apiKey: props.context.apiKey,
159
+ state: props.context.state,
160
+ content: props.context.content,
161
+ context: props.context.context,
162
+ registeredComponents: props.context.registeredComponents,
163
+ inheritedStyles: inheritedTextStyles()
164
+ };
165
+ }
166
+ function renderComponentTag() {
167
+ if (TARGET === "reactNative") {
168
+ return RenderComponentWithContext;
169
+ } else if (TARGET === "vue3") {
170
+ return "RenderComponent";
171
+ } else {
172
+ return RenderComponent;
173
+ }
174
+ }
175
+ const [componentInfo, setComponentInfo] = useState(() => null);
176
+ const RenderComponentTagRef = renderComponentTag();
152
177
  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, {
178
+ 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()))) : null, !isEmptyHtmlElement(tagName()) && repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = repeatItemData()) == null ? void 0 : _a.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
154
179
  key: index,
155
180
  repeatContext: data.context,
156
181
  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, {
182
+ }))) : null, !isEmptyHtmlElement(tagName()) && !repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()), /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadValues({}, renderComponentProps())), (_b = childrenWithoutParentComponent()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
158
183
  key: "render-block-" + child.id,
159
184
  block: child,
160
- context: props.context
185
+ context: childrenContext()
161
186
  })), (_c = childrenWithoutParentComponent()) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
162
187
  key: "block-style-" + child.id,
163
188
  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
- })));
189
+ context: childrenContext()
190
+ })))) : null) : /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadValues({}, renderComponentProps())));
168
191
  }
169
192
  export {
170
193
  RenderBlock as default
@@ -0,0 +1,35 @@
1
+ import * as React from "react";
2
+ import BuilderContext from "../../context/builder.context.js";
3
+ import RenderComponent from "./render-component.jsx";
4
+ function RenderComponentWithContext(props) {
5
+ return /* @__PURE__ */ React.createElement(BuilderContext.Provider, {
6
+ value: {
7
+ get content() {
8
+ return props.context.content;
9
+ },
10
+ get state() {
11
+ return props.context.state;
12
+ },
13
+ get context() {
14
+ return props.context.context;
15
+ },
16
+ get apiKey() {
17
+ return props.context.apiKey;
18
+ },
19
+ get registeredComponents() {
20
+ return props.context.registeredComponents;
21
+ },
22
+ get inheritedStyles() {
23
+ return props.context.inheritedStyles;
24
+ }
25
+ }
26
+ }, /* @__PURE__ */ React.createElement(RenderComponent, {
27
+ componentRef: props.componentRef,
28
+ componentOptions: props.componentOptions,
29
+ blockChildren: props.blockChildren,
30
+ context: props.context
31
+ }));
32
+ }
33
+ export {
34
+ RenderComponentWithContext as default
35
+ };
@@ -15,12 +15,13 @@ var __spreadValues = (a, b) => {
15
15
  return a;
16
16
  };
17
17
  import * as React from "react";
18
- import BlockStyles from "./block-styles.js";
19
- import RenderBlock from "./render-block.js";
18
+ import BlockStyles from "./block-styles.jsx";
19
+ import RenderBlock from "./render-block.jsx";
20
+ import { markPropsMutable } from "../../functions/mark-mutable.js";
20
21
  function RenderComponent(props) {
21
22
  var _a, _b;
22
23
  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
+ 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, {
24
25
  key: "render-block-" + child.id,
25
26
  block: child,
26
27
  context: props.context
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import BuilderContext from "../../context/builder.context.js";
3
- import RenderBlock from "./render-block.js";
3
+ import RenderBlock from "./render-block.jsx";
4
4
  function RenderRepeatedBlock(props) {
5
5
  return /* @__PURE__ */ React.createElement(BuilderContext.Provider, {
6
6
  value: {
@@ -18,6 +18,9 @@ function RenderRepeatedBlock(props) {
18
18
  },
19
19
  get registeredComponents() {
20
20
  return props.repeatContext.registeredComponents;
21
+ },
22
+ get inheritedStyles() {
23
+ return props.repeatContext.inheritedStyles;
21
24
  }
22
25
  }
23
26
  }, /* @__PURE__ */ React.createElement(RenderBlock, {
@@ -2,8 +2,8 @@ import * as React from "react";
2
2
  import { useContext } from "react";
3
3
  import BuilderContext from "../context/builder.context.js";
4
4
  import { isEditing } from "../functions/is-editing.js";
5
- import BlockStyles from "./render-block/block-styles.js";
6
- import RenderBlock from "./render-block/render-block.js";
5
+ import BlockStyles from "./render-block/block-styles.jsx";
6
+ import RenderBlock from "./render-block/render-block.jsx";
7
7
  function RenderBlocks(props) {
8
8
  var _a, _b;
9
9
  function className() {
@@ -36,12 +36,13 @@ function RenderBlocks(props) {
36
36
  }
37
37
  const builderContext = useContext(BuilderContext);
38
38
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
39
- className: className() + " div-452eb7d0",
39
+ className: className() + " div-05727d92",
40
40
  "builder-path": props.path,
41
41
  "builder-parent-id": props.parent,
42
42
  dataSet: {
43
43
  class: className()
44
44
  },
45
+ style: props.styleProp,
45
46
  onClick: (event) => onClick(),
46
47
  onMouseEnter: (event) => onMouseEnter()
47
48
  }, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
@@ -52,7 +53,7 @@ function RenderBlocks(props) {
52
53
  key: "block-style-" + block.id,
53
54
  block,
54
55
  context: builderContext
55
- }))) : null), /* @__PURE__ */ React.createElement("style", null, `.div-452eb7d0 {
56
+ }))) : null), /* @__PURE__ */ React.createElement("style", null, `.div-05727d92 {
56
57
  display: flex;
57
58
  flex-direction: column;
58
59
  align-items: stretch; }`));
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import RenderInlinedStyles from "../../render-inlined-styles.js";
2
+ import RenderInlinedStyles from "../../render-inlined-styles.jsx";
3
3
  function RenderContentStyles(props) {
4
4
  function getCssFromFont(font) {
5
5
  var _a, _b;