@builder.io/sdk-solid 0.1.6 → 0.1.8
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.
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Show, For, createSignal } from "solid-js";
|
|
1
|
+
import { useContext, Show, For, createSignal } from "solid-js";
|
|
2
2
|
|
|
3
3
|
import { css } from "solid-styled-components";
|
|
4
4
|
|
|
@@ -7,6 +7,7 @@ import { getSizesForBreakpoints } from "../../constants/device-sizes";
|
|
|
7
7
|
import RenderInlinedStyles from "../../components/render-inlined-styles.jsx";
|
|
8
8
|
import { TARGET } from "../../constants/target.js";
|
|
9
9
|
import { convertStyleMapToCSS } from "../../helpers/css";
|
|
10
|
+
import BuilderContext from "../../context/builder.context.js";
|
|
10
11
|
|
|
11
12
|
function Columns(props) {
|
|
12
13
|
function getGutterSize() {
|
|
@@ -60,7 +61,7 @@ function Columns(props) {
|
|
|
60
61
|
|
|
61
62
|
function getWidthForBreakpointSize(size) {
|
|
62
63
|
const breakpointSizes = getSizesForBreakpoints(
|
|
63
|
-
|
|
64
|
+
builderContext.content?.meta?.breakpoints || {}
|
|
64
65
|
);
|
|
65
66
|
return breakpointSizes[size].max;
|
|
66
67
|
}
|
|
@@ -122,6 +123,8 @@ function Columns(props) {
|
|
|
122
123
|
return this.columnStyleObjects.column.small;
|
|
123
124
|
}
|
|
124
125
|
|
|
126
|
+
const builderContext = useContext(BuilderContext);
|
|
127
|
+
|
|
125
128
|
return (
|
|
126
129
|
<div
|
|
127
130
|
class={
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { TARGET } from "../../constants/target.js";
|
|
8
8
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
9
9
|
import { createCssClass } from "../../helpers/css.js";
|
|
10
|
+
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
10
11
|
import RenderInlinedStyles from "../render-inlined-styles.jsx";
|
|
11
12
|
|
|
12
13
|
function BlockStyles(props) {
|
|
@@ -19,6 +20,17 @@ function BlockStyles(props) {
|
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
function canShowBlock() {
|
|
24
|
+
// only render styles for blocks that are visible
|
|
25
|
+
if (checkIsDefined(useBlock().hide)) {
|
|
26
|
+
return !useBlock().hide;
|
|
27
|
+
}
|
|
28
|
+
if (checkIsDefined(useBlock().show)) {
|
|
29
|
+
return useBlock().show;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
22
34
|
function css() {
|
|
23
35
|
const styles = useBlock().responsiveStyles;
|
|
24
36
|
const content = props.context.content;
|
|
@@ -59,7 +71,7 @@ function BlockStyles(props) {
|
|
|
59
71
|
}
|
|
60
72
|
|
|
61
73
|
return (
|
|
62
|
-
<Show when={TARGET !== "reactNative" && css()}>
|
|
74
|
+
<Show when={TARGET !== "reactNative" && css() && canShowBlock()}>
|
|
63
75
|
<RenderInlinedStyles styles={css()}></RenderInlinedStyles>
|
|
64
76
|
</Show>
|
|
65
77
|
);
|
|
@@ -17,6 +17,7 @@ import { TARGET } from "../../constants/target.js";
|
|
|
17
17
|
import { extractTextStyles } from "../../functions/extract-text-styles.js";
|
|
18
18
|
import RenderComponent from "./render-component.jsx";
|
|
19
19
|
import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
|
|
20
|
+
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
20
21
|
|
|
21
22
|
function RenderBlock(props) {
|
|
22
23
|
const [component, setComponent] = createSignal(
|
|
@@ -48,6 +49,16 @@ function RenderBlock(props) {
|
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
function canShowBlock() {
|
|
53
|
+
if (checkIsDefined(useBlock().hide)) {
|
|
54
|
+
return !useBlock().hide;
|
|
55
|
+
}
|
|
56
|
+
if (checkIsDefined(useBlock().show)) {
|
|
57
|
+
return useBlock().show;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
|
|
51
62
|
function proxyState() {
|
|
52
63
|
if (typeof Proxy === "undefined") {
|
|
53
64
|
console.error(
|
|
@@ -110,7 +121,6 @@ function RenderBlock(props) {
|
|
|
110
121
|
...actions(),
|
|
111
122
|
},
|
|
112
123
|
}),
|
|
113
|
-
customBreakpoints: childrenContext()?.content?.meta?.breakpoints,
|
|
114
124
|
},
|
|
115
125
|
context: childrenContext(),
|
|
116
126
|
};
|
|
@@ -153,55 +163,59 @@ function RenderBlock(props) {
|
|
|
153
163
|
}
|
|
154
164
|
|
|
155
165
|
return (
|
|
156
|
-
<Show
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
>
|
|
160
|
-
<Show when={isEmptyHtmlElement(tag())}>
|
|
161
|
-
<Dynamic {...attributes()} {...actions()} component={tag()}></Dynamic>
|
|
162
|
-
</Show>
|
|
163
|
-
<Show when={!isEmptyHtmlElement(tag()) && repeatItemData()}>
|
|
164
|
-
<For each={repeatItemData()}>
|
|
165
|
-
{(data, _index) => {
|
|
166
|
-
const index = _index();
|
|
167
|
-
return (
|
|
168
|
-
<RenderRepeatedBlock
|
|
169
|
-
key={index}
|
|
170
|
-
repeatContext={data.context}
|
|
171
|
-
block={data.block}
|
|
172
|
-
></RenderRepeatedBlock>
|
|
173
|
-
);
|
|
174
|
-
}}
|
|
175
|
-
</For>
|
|
176
|
-
</Show>
|
|
177
|
-
<Show when={!isEmptyHtmlElement(tag()) && !repeatItemData()}>
|
|
178
|
-
<Dynamic {...attributes()} {...actions()} component={tag()}>
|
|
166
|
+
<Show when={canShowBlock()}>
|
|
167
|
+
<Show
|
|
168
|
+
fallback={
|
|
179
169
|
<RenderComponent {...renderComponentProps()}></RenderComponent>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
);
|
|
190
|
-
}}
|
|
191
|
-
</For>
|
|
192
|
-
<For each={childrenWithoutParentComponent()}>
|
|
193
|
-
{(child, _index) => {
|
|
170
|
+
}
|
|
171
|
+
when={!component()?.noWrap}
|
|
172
|
+
>
|
|
173
|
+
<Show when={isEmptyHtmlElement(tag())}>
|
|
174
|
+
<Dynamic {...attributes()} {...actions()} component={tag()}></Dynamic>
|
|
175
|
+
</Show>
|
|
176
|
+
<Show when={!isEmptyHtmlElement(tag()) && repeatItemData()}>
|
|
177
|
+
<For each={repeatItemData()}>
|
|
178
|
+
{(data, _index) => {
|
|
194
179
|
const index = _index();
|
|
195
180
|
return (
|
|
196
|
-
<
|
|
197
|
-
key={
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
></
|
|
181
|
+
<RenderRepeatedBlock
|
|
182
|
+
key={index}
|
|
183
|
+
repeatContext={data.context}
|
|
184
|
+
block={data.block}
|
|
185
|
+
></RenderRepeatedBlock>
|
|
201
186
|
);
|
|
202
187
|
}}
|
|
203
188
|
</For>
|
|
204
|
-
</
|
|
189
|
+
</Show>
|
|
190
|
+
<Show when={!isEmptyHtmlElement(tag()) && !repeatItemData()}>
|
|
191
|
+
<Dynamic {...attributes()} {...actions()} component={tag()}>
|
|
192
|
+
<RenderComponent {...renderComponentProps()}></RenderComponent>
|
|
193
|
+
<For each={childrenWithoutParentComponent()}>
|
|
194
|
+
{(child, _index) => {
|
|
195
|
+
const index = _index();
|
|
196
|
+
return (
|
|
197
|
+
<RenderBlock
|
|
198
|
+
key={"render-block-" + child.id}
|
|
199
|
+
block={child}
|
|
200
|
+
context={childrenContext()}
|
|
201
|
+
></RenderBlock>
|
|
202
|
+
);
|
|
203
|
+
}}
|
|
204
|
+
</For>
|
|
205
|
+
<For each={childrenWithoutParentComponent()}>
|
|
206
|
+
{(child, _index) => {
|
|
207
|
+
const index = _index();
|
|
208
|
+
return (
|
|
209
|
+
<BlockStyles
|
|
210
|
+
key={"block-style-" + child.id}
|
|
211
|
+
block={child}
|
|
212
|
+
context={childrenContext()}
|
|
213
|
+
></BlockStyles>
|
|
214
|
+
);
|
|
215
|
+
}}
|
|
216
|
+
</For>
|
|
217
|
+
</Dynamic>
|
|
218
|
+
</Show>
|
|
205
219
|
</Show>
|
|
206
220
|
</Show>
|
|
207
221
|
);
|