@builder.io/sdk-solid 0.0.15 → 0.0.17

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 (119) hide show
  1. package/README.md +5 -1
  2. package/package.json +17 -5
  3. package/solid-index.jsx +5 -0
  4. package/src/blocks/BaseText.jsx +9 -0
  5. package/src/blocks/button/button.jsx +9 -6
  6. package/src/blocks/columns/columns.jsx +54 -52
  7. package/src/blocks/columns/component-info.js +26 -1
  8. package/src/blocks/custom-code/custom-code.jsx +35 -38
  9. package/src/blocks/embed/component-info.js +21 -1
  10. package/src/blocks/embed/embed.jsx +37 -42
  11. package/src/blocks/embed/helpers.js +9 -0
  12. package/src/blocks/form/form.jsx +175 -176
  13. package/src/blocks/image/component-info.js +48 -1
  14. package/src/blocks/image/image.helpers.js +48 -0
  15. package/src/blocks/image/image.jsx +44 -13
  16. package/src/blocks/img/img.jsx +1 -1
  17. package/src/blocks/symbol/component-info.js +1 -0
  18. package/src/blocks/symbol/symbol.jsx +40 -13
  19. package/src/blocks/text/text.jsx +1 -1
  20. package/src/blocks/util.js +7 -0
  21. package/src/blocks/video/video.jsx +21 -2
  22. package/src/components/render-block/block-styles.jsx +41 -31
  23. package/src/components/render-block/render-block.helpers.js +23 -0
  24. package/src/components/render-block/render-block.jsx +205 -90
  25. package/src/components/render-block/render-component-with-context.jsx +36 -0
  26. package/src/components/render-block/render-component.jsx +28 -0
  27. package/src/components/render-block/render-repeated-block.jsx +36 -0
  28. package/src/components/render-block/types.js +0 -0
  29. package/src/components/render-blocks.jsx +42 -33
  30. package/src/components/render-content/components/render-styles.jsx +39 -42
  31. package/src/components/render-content/index.js +4 -0
  32. package/src/components/render-content/render-content.jsx +200 -129
  33. package/src/components/render-inlined-styles.jsx +21 -5
  34. package/src/constants/builder-registered-components.js +54 -0
  35. package/src/constants/device-sizes.js +3 -21
  36. package/src/context/builder.context.js +3 -1
  37. package/src/context/types.js +0 -0
  38. package/src/functions/camel-to-kebab-case.js +4 -0
  39. package/src/functions/convert-style-object.js +14 -0
  40. package/src/functions/evaluate.js +1 -1
  41. package/src/functions/extract-text-styles.js +22 -0
  42. package/src/functions/fast-clone.js +4 -0
  43. package/src/functions/get-block-actions-handler.js +12 -0
  44. package/src/functions/get-block-actions.js +2 -7
  45. package/src/functions/get-block-component-options.js +6 -1
  46. package/src/functions/get-block-styles.js +27 -19
  47. package/src/functions/get-builder-search-params/index.js +17 -2
  48. package/src/functions/get-content/ab-testing.js +99 -0
  49. package/src/functions/get-content/fn.test.js +1 -1
  50. package/src/functions/get-content/index.js +20 -62
  51. package/src/functions/get-content/types.js +0 -0
  52. package/src/functions/get-fetch.js +2 -2
  53. package/src/functions/get-processed-block.js +24 -11
  54. package/src/functions/get-processed-block.test.js +2 -1
  55. package/src/functions/mark-mutable.js +10 -0
  56. package/src/functions/register-component.js +45 -26
  57. package/src/functions/sanitize-styles.js +4 -0
  58. package/src/functions/track.js +108 -13
  59. package/src/helpers/ab-tests.js +16 -0
  60. package/src/helpers/cookie.js +79 -0
  61. package/src/helpers/css.js +28 -0
  62. package/src/helpers/flatten.js +34 -0
  63. package/src/helpers/localStorage.js +34 -0
  64. package/src/helpers/nullable.js +4 -0
  65. package/src/helpers/sessionId.js +49 -0
  66. package/src/helpers/time.js +5 -0
  67. package/src/helpers/url.js +10 -0
  68. package/src/helpers/url.test.js +15 -0
  69. package/src/helpers/uuid.js +13 -0
  70. package/src/helpers/visitorId.js +33 -0
  71. package/src/index-helpers/blocks-exports.js +11 -9
  72. package/src/scripts/init-editing.js +4 -5
  73. package/src/types/can-track.js +0 -0
  74. package/src/types/components.js +0 -0
  75. package/src/types/element.js +0 -0
  76. package/src/blocks/button/button.lite.tsx +0 -20
  77. package/src/blocks/button/index.js +0 -7
  78. package/src/blocks/columns/columns.lite.tsx +0 -102
  79. package/src/blocks/columns/index.js +0 -7
  80. package/src/blocks/custom-code/custom-code.lite.tsx +0 -67
  81. package/src/blocks/custom-code/index.js +0 -7
  82. package/src/blocks/embed/embed.lite.tsx +0 -59
  83. package/src/blocks/embed/index.js +0 -7
  84. package/src/blocks/form/form.lite.tsx +0 -293
  85. package/src/blocks/form/index.js +0 -7
  86. package/src/blocks/fragment/fragment.lite.tsx +0 -5
  87. package/src/blocks/fragment/index.js +0 -7
  88. package/src/blocks/image/image.lite.tsx +0 -83
  89. package/src/blocks/image/index.js +0 -7
  90. package/src/blocks/img/img.lite.tsx +0 -18
  91. package/src/blocks/img/index.js +0 -7
  92. package/src/blocks/input/index.js +0 -7
  93. package/src/blocks/input/input.lite.tsx +0 -20
  94. package/src/blocks/raw-text/index.js +0 -7
  95. package/src/blocks/raw-text/raw-text.lite.tsx +0 -10
  96. package/src/blocks/section/index.js +0 -7
  97. package/src/blocks/section/section.lite.tsx +0 -18
  98. package/src/blocks/select/index.js +0 -7
  99. package/src/blocks/select/select.lite.tsx +0 -28
  100. package/src/blocks/submit-button/index.js +0 -7
  101. package/src/blocks/submit-button/submit-button.lite.tsx +0 -9
  102. package/src/blocks/symbol/index.js +0 -7
  103. package/src/blocks/symbol/symbol.lite.tsx +0 -39
  104. package/src/blocks/text/index.js +0 -7
  105. package/src/blocks/text/text.lite.tsx +0 -5
  106. package/src/blocks/textarea/index.js +0 -7
  107. package/src/blocks/textarea/textarea.lite.tsx +0 -13
  108. package/src/blocks/video/index.js +0 -7
  109. package/src/blocks/video/video.lite.tsx +0 -26
  110. package/src/components/error-boundary.jsx +0 -5
  111. package/src/components/error-boundary.lite.tsx +0 -5
  112. package/src/components/render-block/block-styles.lite.tsx +0 -38
  113. package/src/components/render-block/render-block.lite.tsx +0 -119
  114. package/src/components/render-blocks.lite.tsx +0 -75
  115. package/src/components/render-content/components/render-styles.lite.tsx +0 -76
  116. package/src/components/render-content/render-content.lite.tsx +0 -232
  117. package/src/components/render-inlined-styles.lite.tsx +0 -5
  118. package/src/functions/macro-eval.js +0 -5
  119. package/src/functions/previewing-model-name.js +0 -11
@@ -1,23 +1,50 @@
1
- import { createMutable } from "solid-js/store";
2
- import RenderContent from "../../components/render-content/render-content..js";
3
- import BuilderContext from "../../context/builder.context..js";
1
+ import { useContext, onMount, on, createEffect, createSignal } from "solid-js";
2
+ import RenderContent from "../../components/render-content/render-content.jsx";
3
+ import BuilderContext from "../../context/builder.context.js";
4
+ import { getContent } from "../../functions/get-content/index.js";
5
+ import { markMutable } from "../../functions/mark-mutable";
4
6
 
5
7
  function Symbol(props) {
6
- const state = createMutable({
7
- className: "builder-symbol",
8
- content: null
9
- });
8
+ const [className, setClassName] = createSignal("builder-symbol");
9
+ const [content, setContent] = createSignal(null);
10
10
  const builderContext = useContext(BuilderContext);
11
11
  onMount(() => {
12
- state.content = props.symbol?.content;
12
+ setContent(props.symbol?.content);
13
13
  });
14
- return <div class={state.className} {...props.attributes} dataSet={{
15
- class: state.className
14
+
15
+ function onUpdateFn_0() {
16
+ const symbolToUse = props.symbol;
17
+ /**
18
+ * If:
19
+ * - we have a symbol prop
20
+ * - yet it does not have any content
21
+ * - and we have not already stored content from before
22
+ * - and it has a model name
23
+ *
24
+ * then we want to re-fetch the symbol content.
25
+ */
26
+
27
+ if (symbolToUse && !symbolToUse.content && !content() && symbolToUse.model) {
28
+ getContent({
29
+ model: symbolToUse.model,
30
+ apiKey: builderContext.apiKey,
31
+ query: {
32
+ id: symbolToUse.entry
33
+ }
34
+ }).then(response => {
35
+ setContent(response);
36
+ });
37
+ }
38
+ }
39
+
40
+ createEffect(on(() => [props.symbol, content()], onUpdateFn_0));
41
+ return <div class={className()} {...props.attributes} dataSet={{
42
+ class: className()
16
43
  }}>
17
- <RenderContent apiKey={builderContext.apiKey} context={builderContext.context} data={{ ...props.symbol?.data,
44
+ <RenderContent apiKey={builderContext.apiKey} context={builderContext.context} customComponents={markMutable(Object.values(builderContext.registeredComponents))} data={markMutable({ ...props.symbol?.data,
18
45
  ...builderContext.state,
19
- ...props.symbol?.state.content?.data?.state
20
- }} model={props.symbol?.model} content={state.content}></RenderContent>
46
+ ...props.symbol?.content?.data?.state
47
+ })} model={props.symbol?.model} content={markMutable(content())}></RenderContent>
21
48
  </div>;
22
49
  }
23
50
 
@@ -1,5 +1,5 @@
1
1
  function Text(props) {
2
- return <div innerHTML={props.text}></div>;
2
+ return <span class="builder-text" innerHTML={props.text}></span>;
3
3
  }
4
4
 
5
5
  export default Text;
@@ -0,0 +1,7 @@
1
+ function markSerializable(fn) {
2
+ fn.__qwik_serializable__ = true;
3
+ return fn;
4
+ }
5
+ export {
6
+ markSerializable
7
+ };
@@ -1,5 +1,24 @@
1
1
  function Video(props) {
2
- return <video {...props.attributes} preload="none" style={{
2
+ function videoProps() {
3
+ return { ...(props.autoPlay === true ? {
4
+ autoPlay: true
5
+ } : {}),
6
+ ...(props.muted === true ? {
7
+ muted: true
8
+ } : {}),
9
+ ...(props.controls === true ? {
10
+ controls: true
11
+ } : {}),
12
+ ...(props.loop === true ? {
13
+ loop: true
14
+ } : {}),
15
+ ...(props.playsInline === true ? {
16
+ playsInline: true
17
+ } : {})
18
+ };
19
+ }
20
+
21
+ return <video {...videoProps()} style={{
3
22
  width: "100%",
4
23
  height: "100%",
5
24
  ...props.attributes?.style,
@@ -8,7 +27,7 @@ function Video(props) {
8
27
  // Hack to get object fit to work as expected and
9
28
  // not have the video overflow
10
29
  "border-radius": 1
11
- }} key={props.video || "no-src"} poster={props.posterImage} autoPlay={props.autoPlay} muted={props.muted} controls={props.controls} loop={props.loop}></video>;
30
+ }} src={props.video || "no-src"} poster={props.posterImage}></video>;
12
31
  }
13
32
 
14
33
  export default Video;
@@ -1,36 +1,46 @@
1
- import { createMutable } from "solid-js/store";
2
- import RenderInlinedStyles from "../render-inlined-styles..js";
1
+ import { Show } from "solid-js";
2
+ import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
3
+ import { TARGET } from "../../constants/target.js";
4
+ import { getProcessedBlock } from "../../functions/get-processed-block.js";
5
+ import { createCssClass } from "../../helpers/css.js";
6
+ import RenderInlinedStyles from "../render-inlined-styles.jsx";
3
7
 
4
8
  function BlockStyles(props) {
5
- const state = createMutable({
6
- camelToKebabCase(string) {
7
- return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
8
- },
9
-
10
- get css() {
11
- // TODO: media queries
12
- const styleObject = props.block.responsiveStyles?.large;
13
-
14
- if (!styleObject) {
15
- return "";
16
- }
17
-
18
- let str = `.${props.block.id} {`;
19
-
20
- for (const key in styleObject) {
21
- const value = styleObject[key];
22
-
23
- if (typeof value === "string") {
24
- str += `${state.camelToKebabCase(key)}: ${value};`;
25
- }
26
- }
27
-
28
- str += "}";
29
- return str;
30
- }
31
-
32
- });
33
- return <RenderInlinedStyles styles={state.css}></RenderInlinedStyles>;
9
+ function useBlock() {
10
+ return getProcessedBlock({
11
+ block: props.block,
12
+ state: props.context.state,
13
+ context: props.context.context,
14
+ shouldEvaluateBindings: true
15
+ });
16
+ }
17
+
18
+ function css() {
19
+ const styles = useBlock().responsiveStyles;
20
+ const largeStyles = styles?.large;
21
+ const mediumStyles = styles?.medium;
22
+ const smallStyles = styles?.small;
23
+ const className = useBlock().id;
24
+ const largeStylesClass = largeStyles ? createCssClass({
25
+ className,
26
+ styles: largeStyles
27
+ }) : "";
28
+ const mediumStylesClass = mediumStyles ? createCssClass({
29
+ className,
30
+ styles: mediumStyles,
31
+ mediaQuery: getMaxWidthQueryForSize("medium")
32
+ }) : "";
33
+ const smallStylesClass = smallStyles ? createCssClass({
34
+ className,
35
+ styles: smallStyles,
36
+ mediaQuery: getMaxWidthQueryForSize("small")
37
+ }) : "";
38
+ return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
39
+ }
40
+
41
+ return <Show when={TARGET !== "reactNative" && css()}>
42
+ <RenderInlinedStyles styles={css()}></RenderInlinedStyles>
43
+ </Show>;
34
44
  }
35
45
 
36
46
  export default BlockStyles;
@@ -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
+ };
@@ -1,117 +1,232 @@
1
- import { useContext, Show, For } from "solid-js";
1
+ import { Show, For } from "solid-js";
2
2
  import { Dynamic } from "solid-js/web";
3
- import { createMutable } from "solid-js/store";
4
- import { TARGET } from "../../constants/target.js";
5
- import BuilderContext from "../../context/builder.context..js";
6
3
  import { getBlockActions } from "../../functions/get-block-actions.js";
7
4
  import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
8
5
  import { getBlockProperties } from "../../functions/get-block-properties.js";
9
6
  import { getBlockStyles } from "../../functions/get-block-styles.js";
10
7
  import { getBlockTag } from "../../functions/get-block-tag.js";
11
8
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
12
- import { components } from "../../functions/register-component.js";
13
- import BlockStyles from "./block-styles..js";
9
+ import { evaluate } from "../../functions/evaluate.js";
10
+ import BlockStyles from "./block-styles.jsx";
11
+ import { isEmptyHtmlElement } from "./render-block.helpers.js";
12
+ import RenderRepeatedBlock from "./render-repeated-block.jsx";
13
+ import { TARGET } from "../../constants/target.js";
14
+ import { extractTextStyles } from "../../functions/extract-text-styles.js";
15
+ import RenderComponentWithContext from "./render-component-with-context.jsx";
16
+ import RenderComponent from "./render-component.jsx";
14
17
 
15
18
  function RenderBlock(props) {
16
- const state = createMutable({
17
- get component() {
18
- const componentName = state.useBlock.component?.name;
19
-
20
- if (!componentName) {
21
- return null;
22
- }
19
+ function component() {
20
+ const componentName = getProcessedBlock({
21
+ block: props.block,
22
+ state: props.context.state,
23
+ context: props.context.context,
24
+ shouldEvaluateBindings: false
25
+ }).component?.name;
26
+
27
+ if (!componentName) {
28
+ return null;
29
+ }
23
30
 
24
- const ref = components[componentName];
31
+ const ref = props.context.registeredComponents[componentName];
25
32
 
26
- if (componentName && !ref) {
27
- // TODO: Public doc page with more info about this message
28
- console.warn(`
33
+ if (!ref) {
34
+ // TODO: Public doc page with more info about this message
35
+ console.warn(`
29
36
  Could not find a registered component named "${componentName}".
30
37
  If you registered it, is the file that registered it imported by the file that needs to render it?`);
31
- }
32
-
38
+ return undefined;
39
+ } else {
33
40
  return ref;
34
- },
35
-
36
- get componentInfo() {
37
- return state.component?.info;
38
- },
39
-
40
- get componentRef() {
41
- return state.component?.component;
42
- },
43
-
44
- get tagName() {
45
- return getBlockTag(state.useBlock);
46
- },
47
-
48
- get useBlock() {
49
- return getProcessedBlock({
50
- block: props.block,
51
- state: builderContext.state,
52
- context: builderContext.context
53
- });
54
- },
55
-
56
- get propertiesAndActions() {
57
- return { ...getBlockProperties(state.useBlock),
58
- ...getBlockActions({
59
- block: state.useBlock,
60
- state: builderContext.state,
61
- context: builderContext.context
41
+ }
42
+ }
43
+
44
+ function tagName() {
45
+ return getBlockTag(useBlock());
46
+ }
47
+
48
+ function useBlock() {
49
+ return repeatItemData() ? props.block : getProcessedBlock({
50
+ block: props.block,
51
+ state: props.context.state,
52
+ context: props.context.context,
53
+ shouldEvaluateBindings: true
54
+ });
55
+ }
56
+
57
+ function attributes() {
58
+ return { ...getBlockProperties(useBlock()),
59
+ ...getBlockActions({
60
+ block: useBlock(),
61
+ state: props.context.state,
62
+ context: props.context.context
63
+ }),
64
+ style: getBlockStyles({
65
+ block: useBlock(),
66
+ context: props.context
67
+ })
68
+ };
69
+ }
70
+
71
+ function shouldWrap() {
72
+ return !component()?.noWrap;
73
+ }
74
+
75
+ function renderComponentProps() {
76
+ return {
77
+ blockChildren: children(),
78
+ componentRef: component()?.component,
79
+ componentOptions: { ...getBlockComponentOptions(useBlock()),
80
+
81
+ /**
82
+ * These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
83
+ * they are provided to the component itself directly.
84
+ */
85
+ ...(shouldWrap() ? {} : {
86
+ attributes: attributes()
62
87
  })
63
- };
64
- },
65
-
66
- get css() {
67
- return getBlockStyles(state.useBlock);
68
- },
69
-
70
- get componentOptions() {
71
- return getBlockComponentOptions(state.useBlock);
72
- },
73
-
74
- get children() {
75
- // TO-DO: When should `canHaveChildren` dictate rendering?
76
- // This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
77
- // but still receive and need to render children.
78
- // return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
79
- return state.useBlock.children ?? [];
80
- },
81
-
82
- get noCompRefChildren() {
83
- return state.componentRef ? [] : state.children;
88
+ },
89
+ context: childrenContext()
90
+ };
91
+ }
92
+
93
+ function children() {
94
+ // TO-DO: When should `canHaveChildren` dictate rendering?
95
+ // This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
96
+ // but still receive and need to render children.
97
+ // return componentInfo?.canHaveChildren ? useBlock().children : [];
98
+ return useBlock().children ?? [];
99
+ }
100
+
101
+ function childrenWithoutParentComponent() {
102
+ /**
103
+ * When there is no `componentRef`, there might still be children that need to be rendered. In this case,
104
+ * we render them outside of `componentRef`.
105
+ * NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
106
+ * blocks, and the children will be repeated within those blocks.
107
+ */
108
+ const shouldRenderChildrenOutsideRef = !component()?.component && !repeatItemData();
109
+ return shouldRenderChildrenOutsideRef ? children() : [];
110
+ }
111
+
112
+ function repeatItemData() {
113
+ /**
114
+ * we don't use `useBlock()` here because the processing done within its logic includes evaluating the block's bindings,
115
+ * which will not work if there is a repeat.
116
+ */
117
+ const {
118
+ repeat,
119
+ ...blockWithoutRepeat
120
+ } = props.block;
121
+
122
+ if (!repeat?.collection) {
123
+ return undefined;
124
+ }
125
+
126
+ const itemsArray = evaluate({
127
+ code: repeat.collection,
128
+ state: props.context.state,
129
+ context: props.context.context
130
+ });
131
+
132
+ if (!Array.isArray(itemsArray)) {
133
+ return undefined;
134
+ }
135
+
136
+ const collectionName = repeat.collection.split(".").pop();
137
+ const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
138
+ const repeatArray = itemsArray.map((item, index) => ({
139
+ context: { ...props.context,
140
+ state: { ...props.context.state,
141
+ $index: index,
142
+ $item: item,
143
+ [itemNameToUse]: item,
144
+ [`$${itemNameToUse}Index`]: index
145
+ }
146
+ },
147
+ block: blockWithoutRepeat
148
+ }));
149
+ return repeatArray;
150
+ }
151
+
152
+ function inheritedTextStyles() {
153
+ if (TARGET !== "reactNative") {
154
+ return {};
155
+ }
156
+
157
+ const styles = getBlockStyles({
158
+ block: useBlock(),
159
+ context: props.context
160
+ });
161
+ return extractTextStyles(styles);
162
+ }
163
+
164
+ function childrenContext() {
165
+ return {
166
+ apiKey: props.context.apiKey,
167
+ state: props.context.state,
168
+ content: props.context.content,
169
+ context: props.context.context,
170
+ registeredComponents: props.context.registeredComponents,
171
+ inheritedStyles: inheritedTextStyles()
172
+ };
173
+ }
174
+
175
+ function renderComponentTag() {
176
+ if (TARGET === "reactNative") {
177
+ return RenderComponentWithContext;
178
+ } else if (TARGET === "vue3") {
179
+ // vue3 expects a string for the component tag
180
+ return "RenderComponent";
181
+ } else {
182
+ return RenderComponent;
84
183
  }
184
+ }
85
185
 
86
- });
87
- const builderContext = useContext(BuilderContext);
88
- return <>
89
- <Show when={!state.componentInfo?.noWrap}>
90
- <Dynamic {...state.propertiesAndActions} style={state.css} component={state.tagName}>
91
- <Show when={TARGET === "vue" || TARGET === "svelte"}>
92
- <BlockStyles block={state.useBlock}></BlockStyles>
93
- </Show>
94
- <Show when={state.componentRef}>
95
- <Dynamic {...state.componentOptions} builderBlock={state.useBlock} component={state.componentRef}>
96
- <For each={state.children}>
97
- {(child, _index) => {
98
- const index = _index();
99
-
100
- return <RenderBlock block={child}></RenderBlock>;
101
- }}
102
- </For>
103
- </Dynamic>
104
- </Show>
105
- <For each={state.noCompRefChildren}>
186
+ return <Show fallback={<Dynamic {...renderComponentProps()} component={renderComponentTag()}></Dynamic>} when={shouldWrap()}>
187
+ <Show when={isEmptyHtmlElement(tagName())}>
188
+ <Dynamic {...attributes()} component={tagName()}></Dynamic>
189
+ </Show>
190
+ <Show when={!isEmptyHtmlElement(tagName()) && TARGET === "vue2" && repeatItemData()}>
191
+ <div class="vue2-root-element-workaround">
192
+ <For each={repeatItemData()}>
193
+ {(data, _index) => {
194
+ const index = _index();
195
+
196
+ return <RenderRepeatedBlock key={index} repeatContext={data.context} block={data.block}></RenderRepeatedBlock>;
197
+ }}
198
+ </For>
199
+ </div>
200
+ </Show>
201
+ <Show when={!isEmptyHtmlElement(tagName()) && TARGET !== "vue2" && repeatItemData()}>
202
+ <For each={repeatItemData()}>
203
+ {(data, _index) => {
204
+ const index = _index();
205
+
206
+ return <RenderRepeatedBlock key={index} repeatContext={data.context} block={data.block}></RenderRepeatedBlock>;
207
+ }}
208
+ </For>
209
+ </Show>
210
+ <Show when={!isEmptyHtmlElement(tagName()) && !repeatItemData()}>
211
+ <Dynamic {...attributes()} component={tagName()}>
212
+ <Dynamic {...renderComponentProps()} component={renderComponentTag()}></Dynamic>
213
+ <For each={childrenWithoutParentComponent()}>
214
+ {(child, _index) => {
215
+ const index = _index();
216
+
217
+ return <RenderBlock key={"render-block-" + child.id} block={child} context={childrenContext()}></RenderBlock>;
218
+ }}
219
+ </For>
220
+ <For each={childrenWithoutParentComponent()}>
106
221
  {(child, _index) => {
107
222
  const index = _index();
108
223
 
109
- return <RenderBlock block={child}></RenderBlock>;
224
+ return <BlockStyles key={"block-style-" + child.id} block={child} context={childrenContext()}></BlockStyles>;
110
225
  }}
111
226
  </For>
112
227
  </Dynamic>
113
228
  </Show>
114
- </>;
229
+ </Show>;
115
230
  }
116
231
 
117
232
  export default RenderBlock;
@@ -0,0 +1,36 @@
1
+ import { Dynamic } from "solid-js/web";
2
+ import BuilderContext from "../../context/builder.context.js";
3
+ import RenderComponent from "./render-component.jsx";
4
+
5
+ function RenderComponentWithContext(props) {
6
+ return <Dynamic value={{
7
+ get content() {
8
+ return props.context.content;
9
+ },
10
+
11
+ get state() {
12
+ return props.context.state;
13
+ },
14
+
15
+ get context() {
16
+ return props.context.context;
17
+ },
18
+
19
+ get apiKey() {
20
+ return props.context.apiKey;
21
+ },
22
+
23
+ get registeredComponents() {
24
+ return props.context.registeredComponents;
25
+ },
26
+
27
+ get inheritedStyles() {
28
+ return props.context.inheritedStyles;
29
+ }
30
+
31
+ }} component={BuilderContext.Provider}>
32
+ <RenderComponent {...props}></RenderComponent>
33
+ </Dynamic>;
34
+ }
35
+
36
+ export default RenderComponentWithContext;
@@ -0,0 +1,28 @@
1
+ import { Show, For } from "solid-js";
2
+ import { Dynamic } from "solid-js/web";
3
+ import BlockStyles from "./block-styles.jsx";
4
+ import RenderBlock from "./render-block.jsx";
5
+ import { markPropsMutable } from "../../functions/mark-mutable.js";
6
+
7
+ function RenderComponent(props) {
8
+ return <Show when={props.componentRef}>
9
+ <Dynamic {...markPropsMutable(props.componentOptions)} component={props.componentRef}>
10
+ <For each={props.blockChildren}>
11
+ {(child, _index) => {
12
+ const index = _index();
13
+
14
+ return <RenderBlock key={"render-block-" + child.id} block={child} context={props.context}></RenderBlock>;
15
+ }}
16
+ </For>
17
+ <For each={props.blockChildren}>
18
+ {(child, _index) => {
19
+ const index = _index();
20
+
21
+ return <BlockStyles key={"block-style-" + child.id} block={child} context={props.context}></BlockStyles>;
22
+ }}
23
+ </For>
24
+ </Dynamic>
25
+ </Show>;
26
+ }
27
+
28
+ export default RenderComponent;
@@ -0,0 +1,36 @@
1
+ import { Dynamic } from "solid-js/web";
2
+ import BuilderContext from "../../context/builder.context.js";
3
+ import RenderBlock from "./render-block.jsx";
4
+
5
+ function RenderRepeatedBlock(props) {
6
+ return <Dynamic value={{
7
+ get content() {
8
+ return props.repeatContext.content;
9
+ },
10
+
11
+ get state() {
12
+ return props.repeatContext.state;
13
+ },
14
+
15
+ get context() {
16
+ return props.repeatContext.context;
17
+ },
18
+
19
+ get apiKey() {
20
+ return props.repeatContext.apiKey;
21
+ },
22
+
23
+ get registeredComponents() {
24
+ return props.repeatContext.registeredComponents;
25
+ },
26
+
27
+ get inheritedStyles() {
28
+ return props.repeatContext.inheritedStyles;
29
+ }
30
+
31
+ }} component={BuilderContext.Provider}>
32
+ <RenderBlock block={props.block} context={props.repeatContext}></RenderBlock>
33
+ </Dynamic>;
34
+ }
35
+
36
+ export default RenderRepeatedBlock;
File without changes