@builder.io/sdk-solid 0.1.2 → 0.1.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.
- package/dist/sdk-solid.cjs +34 -0
- package/dist/sdk-solid.js +3937 -0
- package/package.json +5 -6
- package/src/blocks/BaseText.jsx +5 -1
- package/src/blocks/button/button.jsx +25 -7
- package/src/blocks/columns/columns.jsx +84 -38
- package/src/blocks/custom-code/custom-code.jsx +25 -3
- package/src/blocks/embed/embed.jsx +14 -2
- package/src/blocks/form/form.jsx +175 -121
- package/src/blocks/fragment/fragment.jsx +2 -1
- package/src/blocks/image/image.jsx +75 -38
- package/src/blocks/img/img.jsx +15 -5
- package/src/blocks/input/input.jsx +17 -2
- package/src/blocks/raw-text/raw-text.jsx +8 -2
- package/src/blocks/section/section.jsx +24 -14
- package/src/blocks/select/select.jsx +21 -6
- package/src/blocks/submit-button/submit-button.jsx +6 -3
- package/src/blocks/symbol/symbol.jsx +54 -15
- package/src/blocks/text/text.jsx +2 -1
- package/src/blocks/textarea/textarea.jsx +11 -2
- package/src/blocks/video/video.jsx +49 -27
- package/src/components/render-block/block-styles.jsx +45 -21
- package/src/components/render-block/render-block.helpers.js +90 -0
- package/src/components/render-block/render-block.jsx +110 -131
- package/src/components/render-block/render-component.jsx +26 -9
- package/src/components/render-block/render-repeated-block.jsx +20 -24
- package/src/components/render-blocks.jsx +70 -30
- package/src/components/render-content/builder-editing.jsx +2 -1
- package/src/components/render-content/components/render-styles.jsx +17 -8
- package/src/components/render-content/render-content.jsx +234 -148
- package/src/components/render-inlined-styles.jsx +14 -4
- package/src/functions/track/helpers.js +50 -0
- package/src/functions/{track.js → track/index.js} +10 -6
- package/src/functions/track/interaction.js +53 -0
- package/src/index.js +1 -1
- package/vite.config.ts +18 -0
- package/solid-index.jsx +0 -5
- package/src/components/render-block/render-component-with-context.jsx +0 -28
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-solid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./solid
|
|
7
|
-
"module": "./solid
|
|
6
|
+
"main": "./dist/sdk-solid.js",
|
|
7
|
+
"module": "./dist/sdk-solid.js",
|
|
8
8
|
"exports": {
|
|
9
|
-
".": "./solid
|
|
9
|
+
".": "./dist/sdk-solid.js"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "
|
|
12
|
+
"build": "vite build",
|
|
13
13
|
"release:patch": "yarn run build && npm version patch && npm publish",
|
|
14
14
|
"release:minor": "yarn run build && npm version minor && npm publish",
|
|
15
15
|
"release:dev": "yarn run build && npm version prerelease && npm publish --tag dev"
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"solid-js": "^1.5.7"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"babel-preset-solid": "^1.3.17",
|
|
25
24
|
"solid-js": "^1.5.7",
|
|
26
25
|
"vite": "^3.0.4",
|
|
27
26
|
"vite-plugin-solid": "^2.2.6"
|
package/src/blocks/BaseText.jsx
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { useContext } from "solid-js";
|
|
2
|
+
|
|
2
3
|
import BuilderContext from "../context/builder.context.js";
|
|
4
|
+
|
|
3
5
|
function BaseText(props) {
|
|
4
6
|
const builderContext = useContext(BuilderContext);
|
|
7
|
+
|
|
5
8
|
return <span style={builderContext.inheritedStyles}>{props.text}</span>;
|
|
6
9
|
}
|
|
7
|
-
|
|
10
|
+
|
|
11
|
+
export default BaseText;
|
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
import { Show } from "solid-js";
|
|
2
|
+
|
|
2
3
|
import { css } from "solid-styled-components";
|
|
4
|
+
|
|
3
5
|
function Button(props) {
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
return (
|
|
7
|
+
<Show
|
|
8
|
+
fallback={
|
|
9
|
+
<button
|
|
10
|
+
class={css({
|
|
11
|
+
all: "unset",
|
|
12
|
+
})}
|
|
13
|
+
{...props.attributes}
|
|
14
|
+
>
|
|
7
15
|
{props.text}
|
|
8
|
-
</button>
|
|
9
|
-
|
|
16
|
+
</button>
|
|
17
|
+
}
|
|
18
|
+
when={props.link}
|
|
19
|
+
>
|
|
20
|
+
<a
|
|
21
|
+
role="button"
|
|
22
|
+
{...props.attributes}
|
|
23
|
+
href={props.link}
|
|
24
|
+
target={props.openLinkInNewTab ? "_blank" : undefined}
|
|
25
|
+
>
|
|
10
26
|
{props.text}
|
|
11
27
|
</a>
|
|
12
|
-
</Show
|
|
28
|
+
</Show>
|
|
29
|
+
);
|
|
13
30
|
}
|
|
14
|
-
|
|
31
|
+
|
|
32
|
+
export default Button;
|
|
@@ -1,38 +1,52 @@
|
|
|
1
|
-
import { Show, For } from "solid-js";
|
|
1
|
+
import { Show, For, createSignal } from "solid-js";
|
|
2
|
+
|
|
2
3
|
import { css } from "solid-styled-components";
|
|
4
|
+
|
|
3
5
|
import RenderBlocks from "../../components/render-blocks.jsx";
|
|
4
6
|
import { getSizesForBreakpoints } from "../../constants/device-sizes";
|
|
5
7
|
import RenderInlinedStyles from "../../components/render-inlined-styles.jsx";
|
|
6
8
|
import { TARGET } from "../../constants/target.js";
|
|
7
9
|
import { convertStyleMapToCSS } from "../../helpers/css";
|
|
10
|
+
|
|
8
11
|
function Columns(props) {
|
|
9
12
|
function getGutterSize() {
|
|
10
13
|
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
11
14
|
}
|
|
15
|
+
|
|
12
16
|
function getColumns() {
|
|
13
17
|
return props.columns || [];
|
|
14
18
|
}
|
|
19
|
+
|
|
15
20
|
function getWidth(index) {
|
|
16
21
|
const columns = getColumns();
|
|
17
22
|
return columns[index]?.width || 100 / columns.length;
|
|
18
23
|
}
|
|
24
|
+
|
|
19
25
|
function getColumnCssWidth(index) {
|
|
20
26
|
const columns = getColumns();
|
|
21
27
|
const gutterSize = getGutterSize();
|
|
22
|
-
const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
|
|
28
|
+
const subtractWidth = (gutterSize * (columns.length - 1)) / columns.length;
|
|
23
29
|
return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
|
|
24
30
|
}
|
|
31
|
+
|
|
25
32
|
function maybeApplyForTablet(prop) {
|
|
26
33
|
const _stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
27
34
|
return _stackColumnsAt === "tablet" ? prop : "inherit";
|
|
28
35
|
}
|
|
36
|
+
|
|
29
37
|
function columnsCssVars() {
|
|
30
|
-
const flexDir =
|
|
38
|
+
const flexDir =
|
|
39
|
+
props.stackColumnsAt === "never"
|
|
40
|
+
? "inherit"
|
|
41
|
+
: props.reverseColumnsWhenStacked
|
|
42
|
+
? "column-reverse"
|
|
43
|
+
: "column";
|
|
31
44
|
return {
|
|
32
45
|
"--flex-dir": flexDir,
|
|
33
|
-
"--flex-dir-tablet": maybeApplyForTablet(flexDir)
|
|
46
|
+
"--flex-dir-tablet": maybeApplyForTablet(flexDir),
|
|
34
47
|
};
|
|
35
48
|
}
|
|
49
|
+
|
|
36
50
|
function columnCssVars() {
|
|
37
51
|
const width = "100%";
|
|
38
52
|
const marginLeft = "0";
|
|
@@ -40,37 +54,42 @@ function Columns(props) {
|
|
|
40
54
|
"--column-width": width,
|
|
41
55
|
"--column-margin-left": marginLeft,
|
|
42
56
|
"--column-width-tablet": maybeApplyForTablet(width),
|
|
43
|
-
"--column-margin-left-tablet": maybeApplyForTablet(marginLeft)
|
|
57
|
+
"--column-margin-left-tablet": maybeApplyForTablet(marginLeft),
|
|
44
58
|
};
|
|
45
59
|
}
|
|
60
|
+
|
|
46
61
|
function getWidthForBreakpointSize(size) {
|
|
47
|
-
const breakpointSizes = getSizesForBreakpoints(
|
|
62
|
+
const breakpointSizes = getSizesForBreakpoints(
|
|
63
|
+
props.customBreakpoints || {}
|
|
64
|
+
);
|
|
48
65
|
return breakpointSizes[size].max;
|
|
49
66
|
}
|
|
67
|
+
|
|
50
68
|
function columnStyleObjects() {
|
|
51
69
|
return {
|
|
52
70
|
columns: {
|
|
53
71
|
small: {
|
|
54
72
|
flexDirection: "var(--flex-dir)",
|
|
55
|
-
alignItems: "stretch"
|
|
73
|
+
alignItems: "stretch",
|
|
56
74
|
},
|
|
57
75
|
medium: {
|
|
58
76
|
flexDirection: "var(--flex-dir-tablet)",
|
|
59
|
-
alignItems: "stretch"
|
|
60
|
-
}
|
|
77
|
+
alignItems: "stretch",
|
|
78
|
+
},
|
|
61
79
|
},
|
|
62
80
|
column: {
|
|
63
81
|
small: {
|
|
64
82
|
width: "var(--column-width) !important",
|
|
65
|
-
marginLeft: "var(--column-margin-left) !important"
|
|
83
|
+
marginLeft: "var(--column-margin-left) !important",
|
|
66
84
|
},
|
|
67
85
|
medium: {
|
|
68
86
|
width: "var(--column-width-tablet) !important",
|
|
69
|
-
marginLeft: "var(--column-margin-left-tablet) !important"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
87
|
+
marginLeft: "var(--column-margin-left-tablet) !important",
|
|
88
|
+
},
|
|
89
|
+
},
|
|
72
90
|
};
|
|
73
91
|
}
|
|
92
|
+
|
|
74
93
|
function columnsStyles() {
|
|
75
94
|
return `
|
|
76
95
|
@media (max-width: ${getWidthForBreakpointSize("medium")}px) {
|
|
@@ -94,41 +113,68 @@ function Columns(props) {
|
|
|
94
113
|
},
|
|
95
114
|
`;
|
|
96
115
|
}
|
|
116
|
+
|
|
97
117
|
function reactNativeColumnsStyles() {
|
|
98
118
|
return this.columnStyleObjects.columns.small;
|
|
99
119
|
}
|
|
120
|
+
|
|
100
121
|
function reactNativeColumnStyles() {
|
|
101
122
|
return this.columnStyleObjects.column.small;
|
|
102
123
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<div
|
|
127
|
+
class={
|
|
128
|
+
`builder-columns ${props.builderBlock.id}-breakpoints` +
|
|
129
|
+
" " +
|
|
130
|
+
css({
|
|
131
|
+
display: "flex",
|
|
132
|
+
lineHeight: "normal",
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
style={{
|
|
136
|
+
...(TARGET === "reactNative" ? reactNativeColumnsStyles() : {}),
|
|
137
|
+
...columnsCssVars(),
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
110
140
|
<Show when={TARGET !== "reactNative"}>
|
|
111
141
|
<RenderInlinedStyles styles={columnsStyles()}></RenderInlinedStyles>
|
|
112
142
|
</Show>
|
|
113
143
|
<For each={props.columns}>
|
|
114
144
|
{(column, _index) => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
145
|
+
const index = _index();
|
|
146
|
+
return (
|
|
147
|
+
<div
|
|
148
|
+
class={
|
|
149
|
+
"builder-column " +
|
|
150
|
+
css({
|
|
151
|
+
display: "flex",
|
|
152
|
+
flexDirection: "column",
|
|
153
|
+
alignItems: "stretch",
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
style={{
|
|
157
|
+
width: getColumnCssWidth(index),
|
|
158
|
+
"margin-left": `${index === 0 ? 0 : getGutterSize()}px`,
|
|
159
|
+
...(TARGET === "reactNative" ? reactNativeColumnStyles() : {}),
|
|
160
|
+
...columnCssVars(),
|
|
161
|
+
}}
|
|
162
|
+
key={index}
|
|
163
|
+
>
|
|
164
|
+
<RenderBlocks
|
|
165
|
+
blocks={column.blocks}
|
|
166
|
+
path={`component.options.columns.${index}.blocks`}
|
|
167
|
+
parent={props.builderBlock.id}
|
|
168
|
+
styleProp={{
|
|
169
|
+
flexGrow: "1",
|
|
170
|
+
}}
|
|
171
|
+
></RenderBlocks>
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
}}
|
|
131
175
|
</For>
|
|
132
|
-
</div
|
|
176
|
+
</div>
|
|
177
|
+
);
|
|
133
178
|
}
|
|
134
|
-
|
|
179
|
+
|
|
180
|
+
export default Columns;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { onMount, createSignal } from "solid-js";
|
|
2
|
+
|
|
2
3
|
function CustomCode(props) {
|
|
3
4
|
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
5
|
+
|
|
4
6
|
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
7
|
+
|
|
5
8
|
function findAndRunScripts() {
|
|
6
9
|
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
7
10
|
if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
|
|
@@ -17,7 +20,14 @@ function CustomCode(props) {
|
|
|
17
20
|
newScript.async = true;
|
|
18
21
|
newScript.src = script.src;
|
|
19
22
|
document.head.appendChild(newScript);
|
|
20
|
-
} else if (
|
|
23
|
+
} else if (
|
|
24
|
+
!script.type ||
|
|
25
|
+
[
|
|
26
|
+
"text/javascript",
|
|
27
|
+
"application/javascript",
|
|
28
|
+
"application/ecmascript",
|
|
29
|
+
].includes(script.type)
|
|
30
|
+
) {
|
|
21
31
|
if (scriptsRun().includes(script.innerText)) {
|
|
22
32
|
continue;
|
|
23
33
|
}
|
|
@@ -31,10 +41,22 @@ function CustomCode(props) {
|
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
43
|
}
|
|
44
|
+
|
|
34
45
|
let elem;
|
|
46
|
+
|
|
35
47
|
onMount(() => {
|
|
36
48
|
findAndRunScripts();
|
|
37
49
|
});
|
|
38
|
-
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
class={
|
|
54
|
+
"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")
|
|
55
|
+
}
|
|
56
|
+
ref={elem}
|
|
57
|
+
innerHTML={props.code}
|
|
58
|
+
></div>
|
|
59
|
+
);
|
|
39
60
|
}
|
|
40
|
-
|
|
61
|
+
|
|
62
|
+
export default CustomCode;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { on, createEffect, createSignal } from "solid-js";
|
|
2
|
+
|
|
2
3
|
import { isJsScript } from "./helpers.js";
|
|
4
|
+
|
|
3
5
|
function Embed(props) {
|
|
4
6
|
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
7
|
+
|
|
5
8
|
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
9
|
+
|
|
6
10
|
const [ranInitFn, setRanInitFn] = createSignal(false);
|
|
11
|
+
|
|
7
12
|
function findAndRunScripts() {
|
|
8
13
|
if (!elem || !elem.getElementsByTagName) return;
|
|
9
14
|
const scripts = elem.getElementsByTagName("script");
|
|
@@ -15,7 +20,10 @@ function Embed(props) {
|
|
|
15
20
|
newScript.async = true;
|
|
16
21
|
newScript.src = script.src;
|
|
17
22
|
document.head.appendChild(newScript);
|
|
18
|
-
} else if (
|
|
23
|
+
} else if (
|
|
24
|
+
isJsScript(script) &&
|
|
25
|
+
!scriptsRun().includes(script.innerText)
|
|
26
|
+
) {
|
|
19
27
|
try {
|
|
20
28
|
scriptsRun().push(script.innerText);
|
|
21
29
|
new Function(script.innerText)();
|
|
@@ -25,7 +33,9 @@ function Embed(props) {
|
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
35
|
}
|
|
36
|
+
|
|
28
37
|
let elem;
|
|
38
|
+
|
|
29
39
|
function onUpdateFn_0() {
|
|
30
40
|
if (elem && !ranInitFn()) {
|
|
31
41
|
setRanInitFn(true);
|
|
@@ -33,6 +43,8 @@ function Embed(props) {
|
|
|
33
43
|
}
|
|
34
44
|
}
|
|
35
45
|
createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
|
|
46
|
+
|
|
36
47
|
return <div class="builder-embed" ref={elem} innerHTML={props.content}></div>;
|
|
37
48
|
}
|
|
38
|
-
|
|
49
|
+
|
|
50
|
+
export default Embed;
|