@builder.io/sdk-solid 0.0.5 → 0.0.8-0
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 +9 -2
- package/src/blocks/button/button.jsx +13 -0
- package/src/blocks/button/button.lite.tsx +20 -0
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/button/index.js +7 -0
- package/src/blocks/columns/columns.jsx +91 -0
- package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +32 -26
- package/src/blocks/columns/component-info.js +217 -0
- package/src/blocks/columns/index.js +7 -0
- package/src/blocks/custom-code/component-info.js +31 -0
- package/src/blocks/{custom-code.js → custom-code/custom-code.jsx} +5 -26
- package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +3 -1
- package/src/blocks/custom-code/index.js +7 -0
- package/src/blocks/embed/component-info.js +24 -0
- package/src/blocks/embed/embed.jsx +51 -0
- package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +3 -1
- package/src/blocks/embed/index.js +7 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/form/form.jsx +253 -0
- package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +14 -8
- package/src/blocks/form/index.js +7 -0
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/fragment/fragment.jsx +5 -0
- package/src/blocks/fragment/fragment.lite.tsx +5 -0
- package/src/blocks/fragment/index.js +7 -0
- package/src/blocks/image/component-info.js +104 -0
- package/src/blocks/image/image.jsx +54 -0
- package/src/blocks/image/image.lite.tsx +83 -0
- package/src/blocks/image/index.js +7 -0
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/img/img.jsx +10 -0
- package/src/blocks/{img.lite.tsx → img/img.lite.tsx} +4 -2
- package/src/blocks/img/index.js +7 -0
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/input/index.js +7 -0
- package/src/blocks/input/input.jsx +7 -0
- package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +4 -2
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/raw-text/index.js +7 -0
- package/src/blocks/raw-text/raw-text.jsx +5 -0
- package/src/blocks/{raw-text.lite.tsx → raw-text/raw-text.lite.tsx} +3 -1
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/section/index.js +7 -0
- package/src/blocks/section/section.jsx +9 -0
- package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +3 -1
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/select/index.js +7 -0
- package/src/blocks/select/select.jsx +16 -0
- package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +10 -5
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/submit-button/index.js +7 -0
- package/src/blocks/submit-button/submit-button.jsx +7 -0
- package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +3 -1
- package/src/blocks/symbol/component-info.js +42 -0
- package/src/blocks/symbol/index.js +7 -0
- package/src/blocks/symbol/symbol.jsx +24 -0
- package/src/blocks/{symbol.lite.tsx → symbol/symbol.lite.tsx} +6 -4
- package/src/blocks/text/component-info.js +24 -0
- package/src/blocks/text/index.js +7 -0
- package/src/blocks/{text.lite.tsx → text/text.jsx} +3 -1
- package/src/blocks/text/text.lite.tsx +5 -0
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/textarea/index.js +7 -0
- package/src/blocks/textarea/textarea.jsx +5 -0
- package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +3 -1
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/video/index.js +7 -0
- package/src/blocks/video/video.jsx +14 -0
- package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +3 -1
- package/src/components/error-boundary.jsx +5 -0
- package/src/components/error-boundary.lite.tsx +3 -1
- package/src/components/render-block/block-styles.jsx +36 -0
- package/src/components/render-block/block-styles.lite.tsx +38 -0
- package/src/components/render-block/render-block.jsx +117 -0
- package/src/components/{render-block.lite.tsx → render-block/render-block.lite.tsx} +24 -13
- package/src/components/render-blocks.jsx +57 -0
- package/src/components/render-blocks.lite.tsx +9 -6
- package/src/components/render-content/components/{render-styles.js → render-styles.jsx} +8 -15
- package/src/components/render-content/components/render-styles.lite.tsx +10 -4
- package/src/components/render-content/{render-content.js → render-content.jsx} +42 -94
- package/src/components/render-content/render-content.lite.tsx +23 -20
- package/src/components/render-inlined-styles.jsx +23 -0
- package/src/components/render-inlined-styles.lite.tsx +26 -0
- package/src/functions/evaluate.js +2 -2
- package/src/functions/get-block-actions.js +2 -2
- package/src/functions/get-builder-search-params/fn.test.js +1 -1
- package/src/functions/get-content/index.js +3 -2
- package/src/functions/get-fetch.js +29 -7
- package/src/functions/get-processed-block.js +3 -3
- package/src/functions/get-processed-block.test.js +1 -1
- package/src/functions/if-target.js +1 -1
- package/src/functions/is-editing.js +1 -1
- package/src/functions/is-iframe.js +1 -1
- package/src/functions/is-previewing.js +2 -2
- package/src/functions/on-change.test.js +1 -1
- package/src/functions/previewing-model-name.js +1 -1
- package/src/functions/register-component.js +1 -1
- package/src/functions/register.js +1 -1
- package/src/functions/set-editor-settings.js +1 -1
- package/src/functions/set.test.js +1 -1
- package/src/functions/track.js +3 -3
- package/src/index-helpers/blocks-exports.js +8 -8
- package/src/index.js +10 -13
- package/src/scripts/init-editing.js +72 -63
- package/src/blocks/button.js +0 -32
- package/src/blocks/button.lite.tsx +0 -12
- package/src/blocks/columns.js +0 -133
- package/src/blocks/embed.js +0 -62
- package/src/blocks/form.js +0 -355
- package/src/blocks/fragment.js +0 -15
- package/src/blocks/fragment.lite.tsx +0 -3
- package/src/blocks/image.js +0 -211
- package/src/blocks/image.lite.tsx +0 -169
- package/src/blocks/img.js +0 -39
- package/src/blocks/input.js +0 -45
- package/src/blocks/raw-text.js +0 -25
- package/src/blocks/section.js +0 -24
- package/src/blocks/select.js +0 -57
- package/src/blocks/submit-button.js +0 -18
- package/src/blocks/symbol.js +0 -69
- package/src/blocks/text.js +0 -15
- package/src/blocks/textarea.js +0 -34
- package/src/blocks/video.js +0 -54
- package/src/components/block-styles.js +0 -3
- package/src/components/block-styles.lite.tsx +0 -3
- package/src/components/error-boundary.js +0 -3
- package/src/components/render-block.js +0 -154
- package/src/components/render-blocks.js +0 -104
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-solid",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8-0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "",
|
|
5
|
-
"
|
|
6
|
+
"module": "src/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
|
|
12
|
+
},
|
|
6
13
|
"dependencies": {
|
|
7
14
|
"solid-styled-components": "^0.27.6"
|
|
8
15
|
},
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Show } from "solid-js";
|
|
2
|
+
|
|
3
|
+
function Button(props) {
|
|
4
|
+
return <>
|
|
5
|
+
<Show when={props.link}>
|
|
6
|
+
<a {...props.attributes} role="button" href={props.link} target={props.openLinkInNewTab ? "_blank" : undefined}>
|
|
7
|
+
{props.text}
|
|
8
|
+
</a>
|
|
9
|
+
</Show>
|
|
10
|
+
</>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default Button;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Show } from "solid-js";
|
|
2
|
+
|
|
3
|
+
function Button(props) {
|
|
4
|
+
return (
|
|
5
|
+
<>
|
|
6
|
+
<Show when={props.link}>
|
|
7
|
+
<a
|
|
8
|
+
{...props.attributes}
|
|
9
|
+
role="button"
|
|
10
|
+
href={props.link}
|
|
11
|
+
target={props.openLinkInNewTab ? "_blank" : undefined}
|
|
12
|
+
>
|
|
13
|
+
{props.text}
|
|
14
|
+
</a>
|
|
15
|
+
</Show>
|
|
16
|
+
</>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default Button;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Core:Button",
|
|
3
|
+
builtIn: true,
|
|
4
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
|
|
5
|
+
defaultStyles: {
|
|
6
|
+
appearance: "none",
|
|
7
|
+
paddingTop: "15px",
|
|
8
|
+
paddingBottom: "15px",
|
|
9
|
+
paddingLeft: "25px",
|
|
10
|
+
paddingRight: "25px",
|
|
11
|
+
backgroundColor: "#000000",
|
|
12
|
+
color: "white",
|
|
13
|
+
borderRadius: "4px",
|
|
14
|
+
textAlign: "center",
|
|
15
|
+
cursor: "pointer"
|
|
16
|
+
},
|
|
17
|
+
inputs: [
|
|
18
|
+
{
|
|
19
|
+
name: "text",
|
|
20
|
+
type: "text",
|
|
21
|
+
defaultValue: "Click me!",
|
|
22
|
+
bubble: true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "link",
|
|
26
|
+
type: "url",
|
|
27
|
+
bubble: true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "openLinkInNewTab",
|
|
31
|
+
type: "boolean",
|
|
32
|
+
defaultValue: false,
|
|
33
|
+
friendlyName: "Open link in new tab"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
static: true,
|
|
37
|
+
noWrap: true
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
componentInfo
|
|
41
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
+
import component from "./button";
|
|
3
|
+
import { componentInfo } from "./component-info.js";
|
|
4
|
+
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
+
export {
|
|
6
|
+
stdin_default as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { For } from "solid-js";
|
|
2
|
+
import { createMutable } from "solid-js/store";
|
|
3
|
+
import { css } from "solid-styled-components";
|
|
4
|
+
import RenderBlocks from "../../components/render-blocks";
|
|
5
|
+
|
|
6
|
+
function Columns(props) {
|
|
7
|
+
const state = createMutable({
|
|
8
|
+
getGutterSize() {
|
|
9
|
+
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
getColumns() {
|
|
13
|
+
return props.columns || [];
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
getWidth(index) {
|
|
17
|
+
const columns = this.getColumns();
|
|
18
|
+
return columns[index]?.width || 100 / columns.length;
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
getColumnCssWidth(index) {
|
|
22
|
+
const columns = this.getColumns();
|
|
23
|
+
const gutterSize = this.getGutterSize();
|
|
24
|
+
const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
|
|
25
|
+
return `calc(${this.getWidth(index)}% - ${subtractWidth}px)`;
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
maybeApplyForTablet(prop) {
|
|
29
|
+
const _stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
30
|
+
|
|
31
|
+
return _stackColumnsAt === "tablet" ? prop : "inherit";
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
get columnsCssVars() {
|
|
35
|
+
const flexDir = props.stackColumnsAt === "never" ? "inherit" : props.reverseColumnsWhenStacked ? "column-reverse" : "column";
|
|
36
|
+
return {
|
|
37
|
+
"--flex-dir": flexDir,
|
|
38
|
+
"--flex-dir-tablet": this.maybeApplyForTablet(flexDir)
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
get columnCssVars() {
|
|
43
|
+
const width = "100%";
|
|
44
|
+
const marginLeft = "0";
|
|
45
|
+
return {
|
|
46
|
+
"--column-width": width,
|
|
47
|
+
"--column-margin-left": marginLeft,
|
|
48
|
+
"--column-width-tablet": this.maybeApplyForTablet(width),
|
|
49
|
+
"--column-margin-left-tablet": this.maybeApplyForTablet(marginLeft)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
});
|
|
54
|
+
return <div class={css({
|
|
55
|
+
display: "flex",
|
|
56
|
+
alignItems: "stretch",
|
|
57
|
+
lineHeight: "normal",
|
|
58
|
+
"@media (max-width: 999px)": {
|
|
59
|
+
flexDirection: "var(--flex-dir-tablet)"
|
|
60
|
+
},
|
|
61
|
+
"@media (max-width: 639px)": {
|
|
62
|
+
flexDirection: "var(--flex-dir)"
|
|
63
|
+
}
|
|
64
|
+
})} style={state.columnsCssVars}>
|
|
65
|
+
<For each={props.columns}>
|
|
66
|
+
{(column, _index) => {
|
|
67
|
+
const index = _index();
|
|
68
|
+
|
|
69
|
+
return <div class={css({
|
|
70
|
+
flexGrow: "1",
|
|
71
|
+
"@media (max-width: 999px)": {
|
|
72
|
+
width: "var(--column-width-tablet) !important",
|
|
73
|
+
marginLeft: "var(--column-margin-left-tablet) !important"
|
|
74
|
+
},
|
|
75
|
+
"@media (max-width: 639px)": {
|
|
76
|
+
width: "var(--column-width) !important",
|
|
77
|
+
marginLeft: "var(--column-margin-left) !important"
|
|
78
|
+
}
|
|
79
|
+
})} style={{
|
|
80
|
+
width: state.getColumnCssWidth(index),
|
|
81
|
+
"margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
|
|
82
|
+
...state.columnCssVars
|
|
83
|
+
}}>
|
|
84
|
+
<RenderBlocks blocks={column.blocks}></RenderBlocks>
|
|
85
|
+
</div>;
|
|
86
|
+
}}
|
|
87
|
+
</For>
|
|
88
|
+
</div>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default Columns;
|
|
@@ -3,9 +3,9 @@ import { For } from "solid-js";
|
|
|
3
3
|
import { createMutable } from "solid-js/store";
|
|
4
4
|
import { css } from "solid-styled-components";
|
|
5
5
|
|
|
6
|
-
import RenderBlocks from "
|
|
6
|
+
import RenderBlocks from "../../components/render-blocks.lite";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function Columns(props) {
|
|
9
9
|
const state = createMutable({
|
|
10
10
|
getGutterSize() {
|
|
11
11
|
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
@@ -25,8 +25,9 @@ export default function Columns(props) {
|
|
|
25
25
|
return `calc(${this.getWidth(index)}% - ${subtractWidth}px)`;
|
|
26
26
|
},
|
|
27
27
|
maybeApplyForTablet(prop: string) {
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const _stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
29
|
+
|
|
30
|
+
return _stackColumnsAt === "tablet" ? prop : "inherit";
|
|
30
31
|
},
|
|
31
32
|
get columnsCssVars() {
|
|
32
33
|
const flexDir =
|
|
@@ -68,29 +69,34 @@ export default function Columns(props) {
|
|
|
68
69
|
style={state.columnsCssVars}
|
|
69
70
|
>
|
|
70
71
|
<For each={props.columns}>
|
|
71
|
-
{(column,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
72
|
+
{(column, _index) => {
|
|
73
|
+
const index = _index();
|
|
74
|
+
return (
|
|
75
|
+
<div
|
|
76
|
+
class={css({
|
|
77
|
+
flexGrow: "1",
|
|
78
|
+
"@media (max-width: 999px)": {
|
|
79
|
+
width: "var(--column-width-tablet) !important",
|
|
80
|
+
marginLeft: "var(--column-margin-left-tablet) !important",
|
|
81
|
+
},
|
|
82
|
+
"@media (max-width: 639px)": {
|
|
83
|
+
width: "var(--column-width) !important",
|
|
84
|
+
marginLeft: "var(--column-margin-left) !important",
|
|
85
|
+
},
|
|
86
|
+
})}
|
|
87
|
+
style={{
|
|
88
|
+
width: state.getColumnCssWidth(index),
|
|
89
|
+
"margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
|
|
90
|
+
...state.columnCssVars,
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<RenderBlocks blocks={column.blocks}></RenderBlocks>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}}
|
|
93
97
|
</For>
|
|
94
98
|
</div>
|
|
95
99
|
);
|
|
96
100
|
}
|
|
101
|
+
|
|
102
|
+
export default Columns;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Columns",
|
|
3
|
+
builtIn: true,
|
|
4
|
+
inputs: [
|
|
5
|
+
{
|
|
6
|
+
name: "columns",
|
|
7
|
+
type: "array",
|
|
8
|
+
broadcast: true,
|
|
9
|
+
subFields: [
|
|
10
|
+
{
|
|
11
|
+
name: "blocks",
|
|
12
|
+
type: "array",
|
|
13
|
+
hideFromUI: true,
|
|
14
|
+
defaultValue: [
|
|
15
|
+
{
|
|
16
|
+
"@type": "@builder.io/sdk:Element",
|
|
17
|
+
responsiveStyles: {
|
|
18
|
+
large: {
|
|
19
|
+
display: "flex",
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
alignItems: "stretch",
|
|
22
|
+
flexShrink: "0",
|
|
23
|
+
position: "relative",
|
|
24
|
+
marginTop: "30px",
|
|
25
|
+
textAlign: "center",
|
|
26
|
+
lineHeight: "normal",
|
|
27
|
+
height: "auto",
|
|
28
|
+
minHeight: "20px",
|
|
29
|
+
minWidth: "20px",
|
|
30
|
+
overflow: "hidden"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
component: {
|
|
34
|
+
name: "Image",
|
|
35
|
+
options: {
|
|
36
|
+
image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
37
|
+
backgroundPosition: "center",
|
|
38
|
+
backgroundSize: "cover",
|
|
39
|
+
aspectRatio: 0.7004048582995948
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"@type": "@builder.io/sdk:Element",
|
|
45
|
+
responsiveStyles: {
|
|
46
|
+
large: {
|
|
47
|
+
display: "flex",
|
|
48
|
+
flexDirection: "column",
|
|
49
|
+
alignItems: "stretch",
|
|
50
|
+
flexShrink: "0",
|
|
51
|
+
position: "relative",
|
|
52
|
+
marginTop: "30px",
|
|
53
|
+
textAlign: "center",
|
|
54
|
+
lineHeight: "normal",
|
|
55
|
+
height: "auto"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
component: {
|
|
59
|
+
name: "Text",
|
|
60
|
+
options: {
|
|
61
|
+
text: "<p>Enter some text...</p>"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "width",
|
|
69
|
+
type: "number",
|
|
70
|
+
hideFromUI: true,
|
|
71
|
+
helperText: "Width %, e.g. set to 50 to fill half of the space"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "link",
|
|
75
|
+
type: "url",
|
|
76
|
+
helperText: "Optionally set a url that clicking this column will link to"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
defaultValue: [
|
|
80
|
+
{
|
|
81
|
+
blocks: [
|
|
82
|
+
{
|
|
83
|
+
"@type": "@builder.io/sdk:Element",
|
|
84
|
+
responsiveStyles: {
|
|
85
|
+
large: {
|
|
86
|
+
display: "flex",
|
|
87
|
+
flexDirection: "column",
|
|
88
|
+
alignItems: "stretch",
|
|
89
|
+
flexShrink: "0",
|
|
90
|
+
position: "relative",
|
|
91
|
+
marginTop: "30px",
|
|
92
|
+
textAlign: "center",
|
|
93
|
+
lineHeight: "normal",
|
|
94
|
+
height: "auto",
|
|
95
|
+
minHeight: "20px",
|
|
96
|
+
minWidth: "20px",
|
|
97
|
+
overflow: "hidden"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
component: {
|
|
101
|
+
name: "Image",
|
|
102
|
+
options: {
|
|
103
|
+
image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
104
|
+
backgroundPosition: "center",
|
|
105
|
+
backgroundSize: "cover",
|
|
106
|
+
aspectRatio: 0.7004048582995948
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"@type": "@builder.io/sdk:Element",
|
|
112
|
+
responsiveStyles: {
|
|
113
|
+
large: {
|
|
114
|
+
display: "flex",
|
|
115
|
+
flexDirection: "column",
|
|
116
|
+
alignItems: "stretch",
|
|
117
|
+
flexShrink: "0",
|
|
118
|
+
position: "relative",
|
|
119
|
+
marginTop: "30px",
|
|
120
|
+
textAlign: "center",
|
|
121
|
+
lineHeight: "normal",
|
|
122
|
+
height: "auto"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
component: {
|
|
126
|
+
name: "Text",
|
|
127
|
+
options: {
|
|
128
|
+
text: "<p>Enter some text...</p>"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
blocks: [
|
|
136
|
+
{
|
|
137
|
+
"@type": "@builder.io/sdk:Element",
|
|
138
|
+
responsiveStyles: {
|
|
139
|
+
large: {
|
|
140
|
+
display: "flex",
|
|
141
|
+
flexDirection: "column",
|
|
142
|
+
alignItems: "stretch",
|
|
143
|
+
flexShrink: "0",
|
|
144
|
+
position: "relative",
|
|
145
|
+
marginTop: "30px",
|
|
146
|
+
textAlign: "center",
|
|
147
|
+
lineHeight: "normal",
|
|
148
|
+
height: "auto",
|
|
149
|
+
minHeight: "20px",
|
|
150
|
+
minWidth: "20px",
|
|
151
|
+
overflow: "hidden"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
component: {
|
|
155
|
+
name: "Image",
|
|
156
|
+
options: {
|
|
157
|
+
image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
158
|
+
backgroundPosition: "center",
|
|
159
|
+
backgroundSize: "cover",
|
|
160
|
+
aspectRatio: 0.7004048582995948
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"@type": "@builder.io/sdk:Element",
|
|
166
|
+
responsiveStyles: {
|
|
167
|
+
large: {
|
|
168
|
+
display: "flex",
|
|
169
|
+
flexDirection: "column",
|
|
170
|
+
alignItems: "stretch",
|
|
171
|
+
flexShrink: "0",
|
|
172
|
+
position: "relative",
|
|
173
|
+
marginTop: "30px",
|
|
174
|
+
textAlign: "center",
|
|
175
|
+
lineHeight: "normal",
|
|
176
|
+
height: "auto"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
component: {
|
|
180
|
+
name: "Text",
|
|
181
|
+
options: {
|
|
182
|
+
text: "<p>Enter some text...</p>"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
onChange: " function clearWidths() { columns.forEach(col => { col.delete('width'); }); } const columns = options.get('columns') as Array<Map<String, any>>; if (Array.isArray(columns)) { const containsColumnWithWidth = !!columns.find(col => col.get('width')); if (containsColumnWithWidth) { const containsColumnWithoutWidth = !!columns.find(col => !col.get('width')); if (containsColumnWithoutWidth) { clearWidths(); } else { const sumWidths = columns.reduce((memo, col) => { return memo + col.get('width'); }, 0); const widthsDontAddUp = sumWidths !== 100; if (widthsDontAddUp) { clearWidths(); } } } } "
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "space",
|
|
193
|
+
type: "number",
|
|
194
|
+
defaultValue: 20,
|
|
195
|
+
helperText: "Size of gap between columns",
|
|
196
|
+
advanced: true
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "stackColumnsAt",
|
|
200
|
+
type: "string",
|
|
201
|
+
defaultValue: "tablet",
|
|
202
|
+
helperText: "Convert horizontal columns to vertical at what device size",
|
|
203
|
+
enum: ["tablet", "mobile", "never"],
|
|
204
|
+
advanced: true
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "reverseColumnsWhenStacked",
|
|
208
|
+
type: "boolean",
|
|
209
|
+
defaultValue: false,
|
|
210
|
+
helperText: "When stacking columns for mobile devices, reverse the ordering",
|
|
211
|
+
advanced: true
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
};
|
|
215
|
+
export {
|
|
216
|
+
componentInfo
|
|
217
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
+
import component from "./columns";
|
|
3
|
+
import { componentInfo } from "./component-info.js";
|
|
4
|
+
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
+
export {
|
|
6
|
+
stdin_default as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Custom Code",
|
|
3
|
+
static: true,
|
|
4
|
+
builtIn: true,
|
|
5
|
+
requiredPermissions: ["editCode"],
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "code",
|
|
9
|
+
type: "html",
|
|
10
|
+
required: true,
|
|
11
|
+
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
12
|
+
code: true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "replaceNodes",
|
|
16
|
+
type: "boolean",
|
|
17
|
+
helperText: "Preserve server rendered dom nodes",
|
|
18
|
+
advanced: true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "scriptsClientOnly",
|
|
22
|
+
type: "boolean",
|
|
23
|
+
defaultValue: false,
|
|
24
|
+
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
25
|
+
advanced: true
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
componentInfo
|
|
31
|
+
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { template as _$template } from "solid-js/web";
|
|
2
|
-
import { effect as _$effect } from "solid-js/web";
|
|
3
|
-
|
|
4
|
-
const _tmpl$ = /*#__PURE__*/_$template(`<div></div>`, 2);
|
|
5
|
-
|
|
6
1
|
import { createMutable } from "solid-js/store";
|
|
7
|
-
|
|
2
|
+
|
|
3
|
+
function CustomCode(props) {
|
|
8
4
|
const state = createMutable({
|
|
9
5
|
scriptsInserted: [],
|
|
10
6
|
scriptsRun: [],
|
|
@@ -49,24 +45,7 @@ export default function CustomCode(props) {
|
|
|
49
45
|
onMount(() => {
|
|
50
46
|
state.findAndRunScripts();
|
|
51
47
|
});
|
|
52
|
-
return (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
elem(_el$);
|
|
56
|
-
|
|
57
|
-
_$effect(_p$ => {
|
|
58
|
-
const _v$ = "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""),
|
|
59
|
-
_v$2 = props.code;
|
|
60
|
-
|
|
61
|
-
_v$ !== _p$._v$ && (_el$.className = _p$._v$ = _v$);
|
|
62
|
-
_v$2 !== _p$._v$2 && (_el$.innerHTML = _p$._v$2 = _v$2);
|
|
63
|
-
return _p$;
|
|
64
|
-
}, {
|
|
65
|
-
_v$: undefined,
|
|
66
|
-
_v$2: undefined
|
|
67
|
-
});
|
|
48
|
+
return <div class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")} ref={elem} innerHTML={props.code}></div>;
|
|
49
|
+
}
|
|
68
50
|
|
|
69
|
-
|
|
70
|
-
})();
|
|
71
|
-
}import { registerComponent } from '../functions/register-component';
|
|
72
|
-
registerComponent(CustomCode, {name:'Custom Code',static:true,builtIn:true,requiredPermissions:['editCode'],inputs:[{name:'code',type:'html',required:true,defaultValue:'<p>Hello there, I am custom HTML code!</p>',code:true},{name:'replaceNodes',type:'boolean',helperText:'Preserve server rendered dom nodes',advanced:true},{name:'scriptsClientOnly',type:'boolean',defaultValue:false,helperText:'Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads',advanced:true}]});
|
|
51
|
+
export default CustomCode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMutable } from "solid-js/store";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function CustomCode(props) {
|
|
4
4
|
const state = createMutable({
|
|
5
5
|
scriptsInserted: [],
|
|
6
6
|
scriptsRun: [],
|
|
@@ -63,3 +63,5 @@ export default function CustomCode(props) {
|
|
|
63
63
|
></div>
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
export default CustomCode;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
+
import { componentInfo } from "./component-info.js";
|
|
3
|
+
import component from "./custom-code";
|
|
4
|
+
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
+
export {
|
|
6
|
+
stdin_default as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Embed",
|
|
3
|
+
static: true,
|
|
4
|
+
builtIn: true,
|
|
5
|
+
inputs: [
|
|
6
|
+
{
|
|
7
|
+
name: "url",
|
|
8
|
+
type: "url",
|
|
9
|
+
required: true,
|
|
10
|
+
defaultValue: "",
|
|
11
|
+
helperText: "e.g. enter a youtube url, google map, etc",
|
|
12
|
+
onChange: " const url = options.get('url'); if (url) { options.set('content', 'Loading...'); // TODO: get this out of here! const apiKey = 'ae0e60e78201a3f2b0de4b'; return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`) .then(res => res.json()) .then(data => { if (options.get('url') === url) { if (data.html) { options.set('content', data.html); } else { options.set('content', 'Invalid url, please try another'); } } }) .catch(err => { options.set( 'content', 'There was an error embedding this URL, please try again or another URL' ); }); } else { options.delete('content'); } "
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "content",
|
|
16
|
+
type: "html",
|
|
17
|
+
defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
|
|
18
|
+
hideFromUI: true
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
componentInfo
|
|
24
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createMutable } from "solid-js/store";
|
|
2
|
+
|
|
3
|
+
function Embed(props) {
|
|
4
|
+
const state = createMutable({
|
|
5
|
+
scriptsInserted: [],
|
|
6
|
+
scriptsRun: [],
|
|
7
|
+
|
|
8
|
+
findAndRunScripts() {
|
|
9
|
+
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
10
|
+
if (elem && typeof window !== "undefined") {
|
|
11
|
+
/** @type {HTMLScriptElement[]} */
|
|
12
|
+
const scripts = elem.getElementsByTagName("script");
|
|
13
|
+
|
|
14
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
15
|
+
const script = scripts[i];
|
|
16
|
+
|
|
17
|
+
if (script.src) {
|
|
18
|
+
if (state.scriptsInserted.includes(script.src)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
state.scriptsInserted.push(script.src);
|
|
23
|
+
const newScript = document.createElement("script");
|
|
24
|
+
newScript.async = true;
|
|
25
|
+
newScript.src = script.src;
|
|
26
|
+
document.head.appendChild(newScript);
|
|
27
|
+
} else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
|
|
28
|
+
if (state.scriptsRun.includes(script.innerText)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
state.scriptsRun.push(script.innerText);
|
|
34
|
+
new Function(script.innerText)();
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.warn("`Embed`: Error running script:", error);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
});
|
|
44
|
+
const elem = useRef();
|
|
45
|
+
onMount(() => {
|
|
46
|
+
state.findAndRunScripts();
|
|
47
|
+
});
|
|
48
|
+
return <div ref={elem} innerHTML={props.content}></div>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default Embed;
|