@builder.io/sdk-solid 0.0.8-4 → 0.0.8-7
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 +6 -6
- package/src/blocks/columns/columns.jsx +3 -3
- package/src/blocks/columns/columns.lite.tsx +29 -22
- package/src/blocks/embed/embed.jsx +1 -1
- package/src/blocks/embed/embed.lite.tsx +1 -1
- package/src/blocks/form/form.jsx +1 -1
- package/src/blocks/form/form.lite.tsx +8 -5
- package/src/blocks/image/image.jsx +2 -2
- package/src/blocks/image/image.lite.tsx +9 -6
- package/src/blocks/text/text.jsx +1 -1
- package/src/blocks/text/text.lite.tsx +1 -1
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.jsx +14 -13
- package/src/components/render-block/render-block.lite.tsx +29 -17
- package/src/components/render-content/render-content.jsx +9 -7
- package/src/components/render-content/render-content.lite.tsx +14 -12
- package/src/functions/get-block-styles.js +2 -2
- package/{entry-point/index.jsx → src/solid-index.jsx} +1 -1
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-solid",
|
|
3
|
-
"version": "0.0.8-
|
|
3
|
+
"version": "0.0.8-7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./
|
|
7
|
-
"module": "./
|
|
6
|
+
"main": "./src/solid-index.jsx",
|
|
7
|
+
"module": "./src/solid-index.jsx",
|
|
8
8
|
"exports": {
|
|
9
|
-
".": "./
|
|
9
|
+
".": "./src/solid-index.jsx"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"solid-styled-components": "^0.27.6"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"solid-js": "^1.3
|
|
19
|
+
"solid-js": "^1.4.3"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"babel-preset-solid": "^1.3.17",
|
|
23
|
-
"solid-js": "^1.3
|
|
23
|
+
"solid-js": "^1.4.3",
|
|
24
24
|
"vite": "^2.9.8",
|
|
25
25
|
"vite-plugin-solid": "^2.2.6"
|
|
26
26
|
}
|
|
@@ -51,7 +51,7 @@ function Columns(props) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
});
|
|
54
|
-
return <div class={css({
|
|
54
|
+
return <div class={"builder-columns " + css({
|
|
55
55
|
display: "flex",
|
|
56
56
|
alignItems: "stretch",
|
|
57
57
|
lineHeight: "normal",
|
|
@@ -66,7 +66,7 @@ function Columns(props) {
|
|
|
66
66
|
{(column, _index) => {
|
|
67
67
|
const index = _index();
|
|
68
68
|
|
|
69
|
-
return <div class={css({
|
|
69
|
+
return <div class={"builder-column " + css({
|
|
70
70
|
flexGrow: "1",
|
|
71
71
|
"@media (max-width: 999px)": {
|
|
72
72
|
width: "var(--column-width-tablet) !important",
|
|
@@ -80,7 +80,7 @@ function Columns(props) {
|
|
|
80
80
|
width: state.getColumnCssWidth(index),
|
|
81
81
|
"margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
|
|
82
82
|
...state.columnCssVars
|
|
83
|
-
}}>
|
|
83
|
+
}} key={index}>
|
|
84
84
|
<RenderBlocks blocks={column.blocks}></RenderBlocks>
|
|
85
85
|
</div>;
|
|
86
86
|
}}
|
|
@@ -55,17 +55,20 @@ function Columns(props) {
|
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
57
|
<div
|
|
58
|
-
class={
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
class={
|
|
59
|
+
"builder-columns " +
|
|
60
|
+
css({
|
|
61
|
+
display: "flex",
|
|
62
|
+
alignItems: "stretch",
|
|
63
|
+
lineHeight: "normal",
|
|
64
|
+
"@media (max-width: 999px)": {
|
|
65
|
+
flexDirection: "var(--flex-dir-tablet)",
|
|
66
|
+
},
|
|
67
|
+
"@media (max-width: 639px)": {
|
|
68
|
+
flexDirection: "var(--flex-dir)",
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
}
|
|
69
72
|
style={state.columnsCssVars}
|
|
70
73
|
>
|
|
71
74
|
<For each={props.columns}>
|
|
@@ -73,22 +76,26 @@ function Columns(props) {
|
|
|
73
76
|
const index = _index();
|
|
74
77
|
return (
|
|
75
78
|
<div
|
|
76
|
-
class={
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
class={
|
|
80
|
+
"builder-column " +
|
|
81
|
+
css({
|
|
82
|
+
flexGrow: "1",
|
|
83
|
+
"@media (max-width: 999px)": {
|
|
84
|
+
width: "var(--column-width-tablet) !important",
|
|
85
|
+
marginLeft: "var(--column-margin-left-tablet) !important",
|
|
86
|
+
},
|
|
87
|
+
"@media (max-width: 639px)": {
|
|
88
|
+
width: "var(--column-width) !important",
|
|
89
|
+
marginLeft: "var(--column-margin-left) !important",
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
}
|
|
87
93
|
style={{
|
|
88
94
|
width: state.getColumnCssWidth(index),
|
|
89
95
|
"margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
|
|
90
96
|
...state.columnCssVars,
|
|
91
97
|
}}
|
|
98
|
+
key={index}
|
|
92
99
|
>
|
|
93
100
|
<RenderBlocks blocks={column.blocks}></RenderBlocks>
|
|
94
101
|
</div>
|
package/src/blocks/form/form.jsx
CHANGED
|
@@ -236,7 +236,7 @@ function FormComponent(props) {
|
|
|
236
236
|
<BuilderBlocks dataPath="sendingMessage" blocks={props.sendingMessage}></BuilderBlocks>
|
|
237
237
|
</Show>
|
|
238
238
|
<Show when={state.submissionState === "error" && state.responseData}>
|
|
239
|
-
<pre class={css({
|
|
239
|
+
<pre class={"builder-form-error-text " + css({
|
|
240
240
|
padding: "10px",
|
|
241
241
|
color: "red",
|
|
242
242
|
textAlign: "center"
|
|
@@ -271,11 +271,14 @@ function FormComponent(props) {
|
|
|
271
271
|
</Show>
|
|
272
272
|
<Show when={state.submissionState === "error" && state.responseData}>
|
|
273
273
|
<pre
|
|
274
|
-
class={
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
274
|
+
class={
|
|
275
|
+
"builder-form-error-text " +
|
|
276
|
+
css({
|
|
277
|
+
padding: "10px",
|
|
278
|
+
color: "red",
|
|
279
|
+
textAlign: "center",
|
|
280
|
+
})
|
|
281
|
+
}
|
|
279
282
|
>
|
|
280
283
|
{JSON.stringify(state.responseData, null, 2)}
|
|
281
284
|
</pre>
|
|
@@ -14,14 +14,14 @@ function Image(props) {
|
|
|
14
14
|
width: "100%",
|
|
15
15
|
top: "0px",
|
|
16
16
|
left: "0px"
|
|
17
|
-
})} loading="lazy" alt={props.altText}
|
|
17
|
+
})} loading="lazy" alt={props.altText} role={props.altText ? "presentation" : undefined} style={{
|
|
18
18
|
"object-position": props.backgroundSize || "center",
|
|
19
19
|
"object-fit": props.backgroundSize || "cover"
|
|
20
20
|
}} src={props.image} srcset={props.srcset} sizes={props.sizes} />
|
|
21
21
|
<source srcSet={props.srcset} />
|
|
22
22
|
</picture>
|
|
23
23
|
<Show when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}>
|
|
24
|
-
<div class={css({
|
|
24
|
+
<div class={"builder-image-sizer " + css({
|
|
25
25
|
width: "100%",
|
|
26
26
|
pointerEvents: "none",
|
|
27
27
|
fontSize: "0"
|
|
@@ -27,7 +27,7 @@ function Image(props) {
|
|
|
27
27
|
}
|
|
28
28
|
loading="lazy"
|
|
29
29
|
alt={props.altText}
|
|
30
|
-
|
|
30
|
+
role={props.altText ? "presentation" : undefined}
|
|
31
31
|
style={{
|
|
32
32
|
"object-position": props.backgroundSize || "center",
|
|
33
33
|
"object-fit": props.backgroundSize || "cover",
|
|
@@ -45,11 +45,14 @@ function Image(props) {
|
|
|
45
45
|
}
|
|
46
46
|
>
|
|
47
47
|
<div
|
|
48
|
-
class={
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
class={
|
|
49
|
+
"builder-image-sizer " +
|
|
50
|
+
css({
|
|
51
|
+
width: "100%",
|
|
52
|
+
pointerEvents: "none",
|
|
53
|
+
fontSize: "0",
|
|
54
|
+
})
|
|
55
|
+
}
|
|
53
56
|
style={{
|
|
54
57
|
"padding-top": props.aspectRatio * 100 + "%",
|
|
55
58
|
}}
|
package/src/blocks/text/text.jsx
CHANGED
|
@@ -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
|
+
};
|
|
@@ -10,6 +10,7 @@ import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
|
10
10
|
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
11
11
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
12
12
|
import BlockStyles from "./block-styles";
|
|
13
|
+
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
13
14
|
|
|
14
15
|
function RenderBlock(props) {
|
|
15
16
|
const state = createMutable({
|
|
@@ -85,16 +86,16 @@ function RenderBlock(props) {
|
|
|
85
86
|
|
|
86
87
|
});
|
|
87
88
|
const builderContext = useContext(BuilderContext);
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
return <Show fallback={<Dynamic {...state.componentOptions} attributes={state.propertiesAndActions} builderBlock={state.useBlock} style={state.css} component={state.componentRef}>
|
|
90
|
+
<For each={state.children}>
|
|
91
|
+
{(child, _index) => {
|
|
92
|
+
const index = _index();
|
|
93
|
+
|
|
94
|
+
return <RenderBlock key={child.id} block={child}></RenderBlock>;
|
|
95
|
+
}}
|
|
96
|
+
</For>
|
|
97
|
+
</Dynamic>} when={!state.componentInfo?.noWrap}>
|
|
98
|
+
<Show fallback={<Dynamic {...state.propertiesAndActions} style={state.css} component={state.tagName}></Dynamic>} when={!isEmptyHtmlElement(state.tagName)}>
|
|
98
99
|
<Dynamic {...state.propertiesAndActions} style={state.css} component={state.tagName}>
|
|
99
100
|
<Show when={TARGET === "vue" || TARGET === "svelte"}>
|
|
100
101
|
<BlockStyles block={state.useBlock}></BlockStyles>
|
|
@@ -105,7 +106,7 @@ function RenderBlock(props) {
|
|
|
105
106
|
{(child, _index) => {
|
|
106
107
|
const index = _index();
|
|
107
108
|
|
|
108
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
109
|
+
return <RenderBlock key={child.id} block={child}></RenderBlock>;
|
|
109
110
|
}}
|
|
110
111
|
</For>
|
|
111
112
|
</Dynamic>
|
|
@@ -114,12 +115,12 @@ function RenderBlock(props) {
|
|
|
114
115
|
{(child, _index) => {
|
|
115
116
|
const index = _index();
|
|
116
117
|
|
|
117
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
118
|
+
return <RenderBlock key={child.id} block={child}></RenderBlock>;
|
|
118
119
|
}}
|
|
119
120
|
</For>
|
|
120
121
|
</Dynamic>
|
|
121
122
|
</Show>
|
|
122
|
-
|
|
123
|
+
</Show>;
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
export default RenderBlock;
|
|
@@ -11,6 +11,7 @@ import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
|
11
11
|
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
12
12
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
13
13
|
import BlockStyles from "./block-styles.lite";
|
|
14
|
+
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
14
15
|
|
|
15
16
|
function RenderBlock(props) {
|
|
16
17
|
const state = createMutable({
|
|
@@ -80,25 +81,34 @@ function RenderBlock(props) {
|
|
|
80
81
|
const builderContext = useContext(BuilderContext);
|
|
81
82
|
|
|
82
83
|
return (
|
|
83
|
-
|
|
84
|
+
<Show
|
|
85
|
+
fallback={
|
|
86
|
+
<Dynamic
|
|
87
|
+
{...state.componentOptions}
|
|
88
|
+
attributes={state.propertiesAndActions}
|
|
89
|
+
builderBlock={state.useBlock}
|
|
90
|
+
style={state.css}
|
|
91
|
+
component={state.componentRef}
|
|
92
|
+
>
|
|
93
|
+
<For each={state.children}>
|
|
94
|
+
{(child, _index) => {
|
|
95
|
+
const index = _index();
|
|
96
|
+
return <RenderBlock key={child.id} block={child}></RenderBlock>;
|
|
97
|
+
}}
|
|
98
|
+
</For>
|
|
99
|
+
</Dynamic>
|
|
100
|
+
}
|
|
101
|
+
when={!state.componentInfo?.noWrap}
|
|
102
|
+
>
|
|
84
103
|
<Show
|
|
85
104
|
fallback={
|
|
86
105
|
<Dynamic
|
|
87
|
-
{...state.
|
|
88
|
-
attributes={state.propertiesAndActions}
|
|
89
|
-
builderBlock={state.useBlock}
|
|
106
|
+
{...state.propertiesAndActions}
|
|
90
107
|
style={state.css}
|
|
91
|
-
component={state.
|
|
92
|
-
>
|
|
93
|
-
<For each={state.children}>
|
|
94
|
-
{(child, _index) => {
|
|
95
|
-
const index = _index();
|
|
96
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
97
|
-
}}
|
|
98
|
-
</For>
|
|
99
|
-
</Dynamic>
|
|
108
|
+
component={state.tagName}
|
|
109
|
+
></Dynamic>
|
|
100
110
|
}
|
|
101
|
-
when={!state.
|
|
111
|
+
when={!isEmptyHtmlElement(state.tagName)}
|
|
102
112
|
>
|
|
103
113
|
<Dynamic
|
|
104
114
|
{...state.propertiesAndActions}
|
|
@@ -117,7 +127,9 @@ function RenderBlock(props) {
|
|
|
117
127
|
<For each={state.children}>
|
|
118
128
|
{(child, _index) => {
|
|
119
129
|
const index = _index();
|
|
120
|
-
return
|
|
130
|
+
return (
|
|
131
|
+
<RenderBlock key={child.id} block={child}></RenderBlock>
|
|
132
|
+
);
|
|
121
133
|
}}
|
|
122
134
|
</For>
|
|
123
135
|
</Dynamic>
|
|
@@ -125,12 +137,12 @@ function RenderBlock(props) {
|
|
|
125
137
|
<For each={state.noCompRefChildren}>
|
|
126
138
|
{(child, _index) => {
|
|
127
139
|
const index = _index();
|
|
128
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
140
|
+
return <RenderBlock key={child.id} block={child}></RenderBlock>;
|
|
129
141
|
}}
|
|
130
142
|
</For>
|
|
131
143
|
</Dynamic>
|
|
132
144
|
</Show>
|
|
133
|
-
|
|
145
|
+
</Show>
|
|
134
146
|
);
|
|
135
147
|
}
|
|
136
148
|
|
|
@@ -143,14 +143,16 @@ function RenderContent(props) {
|
|
|
143
143
|
},
|
|
144
144
|
|
|
145
145
|
emitStateUpdate() {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
if (isEditing()) {
|
|
147
|
+
window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
|
|
148
|
+
detail: {
|
|
149
|
+
state: state.contentState,
|
|
150
|
+
ref: {
|
|
151
|
+
name: props.model
|
|
152
|
+
}
|
|
151
153
|
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
});
|
|
@@ -143,19 +143,21 @@ function RenderContent(props) {
|
|
|
143
143
|
});
|
|
144
144
|
},
|
|
145
145
|
emitStateUpdate() {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
146
|
+
if (isEditing()) {
|
|
147
|
+
window.dispatchEvent(
|
|
148
|
+
new CustomEvent<BuilderComponentStateChange>(
|
|
149
|
+
"builder:component:stateChange",
|
|
150
|
+
{
|
|
151
|
+
detail: {
|
|
152
|
+
state: state.contentState,
|
|
153
|
+
ref: {
|
|
154
|
+
name: props.model,
|
|
155
|
+
},
|
|
154
156
|
},
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
)
|
|
158
|
-
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
159
161
|
},
|
|
160
162
|
});
|
|
161
163
|
|
|
@@ -30,10 +30,10 @@ function getBlockStyles(block) {
|
|
|
30
30
|
var _a, _b, _c, _d, _e;
|
|
31
31
|
const styles = __spreadValues({}, convertStyleObject((_a = block.responsiveStyles) == null ? void 0 : _a.large));
|
|
32
32
|
if ((_b = block.responsiveStyles) == null ? void 0 : _b.medium) {
|
|
33
|
-
styles[`@media (max-width: ${sizes.medium})`] = convertStyleObject((_c = block.responsiveStyles) == null ? void 0 : _c.medium);
|
|
33
|
+
styles[`@media (max-width: ${sizes.medium.max})`] = convertStyleObject((_c = block.responsiveStyles) == null ? void 0 : _c.medium);
|
|
34
34
|
}
|
|
35
35
|
if ((_d = block.responsiveStyles) == null ? void 0 : _d.small) {
|
|
36
|
-
styles[`@media (max-width: ${sizes.small})`] = convertStyleObject((_e = block.responsiveStyles) == null ? void 0 : _e.small);
|
|
36
|
+
styles[`@media (max-width: ${sizes.small.max})`] = convertStyleObject((_e = block.responsiveStyles) == null ? void 0 : _e.small);
|
|
37
37
|
}
|
|
38
38
|
return styles;
|
|
39
39
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* We need to have a `.jsx` entry point for our SolidJS SDK. To avoid enforcing this to all other frameworks,
|
|
3
3
|
* we add this file and use it to re-export the index.js file from the Mitosis-generated code.
|
|
4
4
|
*/
|
|
5
|
-
export * from '../src/index.js'
|
|
5
|
+
export * from '../src/index.js';
|