@builder.io/sdk-solid 0.0.5 → 0.0.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 +59 -2
- package/src/blocks/button.jsx +8 -0
- package/src/blocks/button.lite.tsx +3 -1
- package/src/blocks/{columns.js → columns.jsx} +39 -81
- package/src/blocks/columns.lite.tsx +28 -23
- package/src/blocks/{custom-code.js → custom-code.jsx} +5 -25
- package/src/blocks/custom-code.lite.tsx +3 -1
- package/src/blocks/{embed.js → embed.jsx} +5 -15
- package/src/blocks/embed.lite.tsx +3 -1
- package/src/blocks/{form.js → form.jsx} +34 -136
- package/src/blocks/form.lite.tsx +7 -2
- package/src/blocks/fragment.jsx +6 -0
- package/src/blocks/fragment.lite.tsx +3 -1
- package/src/blocks/{image.js → image.jsx} +47 -138
- package/src/blocks/image.lite.tsx +3 -1
- package/src/blocks/img.jsx +11 -0
- package/src/blocks/img.lite.tsx +3 -1
- package/src/blocks/input.jsx +8 -0
- package/src/blocks/input.lite.tsx +3 -1
- package/src/blocks/raw-text.jsx +6 -0
- package/src/blocks/raw-text.lite.tsx +3 -1
- package/src/blocks/{section.js → section.jsx} +9 -23
- package/src/blocks/section.lite.tsx +3 -1
- package/src/blocks/select.jsx +17 -0
- package/src/blocks/select.lite.tsx +9 -4
- package/src/blocks/submit-button.jsx +8 -0
- package/src/blocks/submit-button.lite.tsx +3 -1
- package/src/blocks/symbol.jsx +25 -0
- package/src/blocks/symbol.lite.tsx +3 -1
- package/src/blocks/text.jsx +6 -0
- package/src/blocks/text.lite.tsx +3 -1
- package/src/blocks/textarea.jsx +6 -0
- package/src/blocks/textarea.lite.tsx +3 -1
- package/src/blocks/video.jsx +15 -0
- package/src/blocks/video.lite.tsx +3 -1
- package/src/components/block-styles.jsx +5 -0
- package/src/components/block-styles.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.js → render-block.jsx} +30 -70
- package/src/components/render-block.lite.tsx +11 -3
- package/src/components/render-blocks.jsx +57 -0
- package/src/components/render-blocks.lite.tsx +7 -4
- package/src/components/render-content/components/{render-styles.js → render-styles.jsx} +5 -13
- package/src/components/render-content/components/render-styles.lite.tsx +3 -1
- package/src/components/render-content/{render-content.js → render-content.jsx} +25 -78
- package/src/components/render-content/render-content.lite.tsx +3 -1
- package/src/index.js +11 -11
- package/src/blocks/button.js +0 -32
- package/src/blocks/fragment.js +0 -15
- 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/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/error-boundary.js +0 -3
- package/src/components/render-blocks.js +0 -104
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-solid",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "",
|
|
5
|
-
"
|
|
6
|
+
"module": "src/index.js",
|
|
6
7
|
"dependencies": {
|
|
7
8
|
"solid-styled-components": "^0.27.6"
|
|
8
9
|
},
|
|
@@ -11,5 +12,61 @@
|
|
|
11
12
|
},
|
|
12
13
|
"devDependencies": {
|
|
13
14
|
"solid-js": "^1.3.15"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
"./functions/event-handler": "./functions/event-handler.js",
|
|
18
|
+
"./functions/get-block-actions": "./functions/get-block-actions.js",
|
|
19
|
+
"./functions/get-block-component": "./functions/get-block-component.js",
|
|
20
|
+
"./functions/get-block-properties": "./functions/get-block-properties.js",
|
|
21
|
+
"./functions/get-block-styles": "./functions/get-block-styles.js",
|
|
22
|
+
"./functions/get-block-tag": "./functions/get-block-tag.js",
|
|
23
|
+
"./functions/get-fetch": "./functions/get-fetch.js",
|
|
24
|
+
"./functions/get-global-this": "./functions/get-global-this.js",
|
|
25
|
+
"./functions/get-processed-block": "./functions/get-processed-block.js",
|
|
26
|
+
"./functions/if-target": "./functions/if-target.js",
|
|
27
|
+
"./functions/is-browser": "./functions/is-browser.js",
|
|
28
|
+
"./functions/is-editing": "./functions/is-editing.js",
|
|
29
|
+
"./functions/is-iframe": "./functions/is-iframe.js",
|
|
30
|
+
"./functions/is-previewing": "./functions/is-previewing.js",
|
|
31
|
+
"./functions/macro-eval": "./functions/macro-eval.js",
|
|
32
|
+
"./functions/on-change": "./functions/on-change.js",
|
|
33
|
+
"./functions/previewing-model-name": "./functions/previewing-model-name.js",
|
|
34
|
+
"./functions/register-component": "./functions/register-component.js",
|
|
35
|
+
"./functions/register": "./functions/register.js",
|
|
36
|
+
"./functions/set-editor-settings": "./functions/set-editor-settings.js",
|
|
37
|
+
"./functions/set": "./functions/set.js",
|
|
38
|
+
"./functions/track": "./functions/track.js",
|
|
39
|
+
"./functions/transform-block": "./functions/transform-block.js",
|
|
40
|
+
"./functions/get-content": "./functions/get-content/index.js",
|
|
41
|
+
"./functions/get-builder-search-params": "./functions/get-builder-search-params/index.js",
|
|
42
|
+
"./functions/index-helpers/block-exports": "./functions/index-helpers/block-exports.js",
|
|
43
|
+
"./functions/index-helpers/top-of-file": "./functions/index-helpers/top-of-file.js",
|
|
44
|
+
"./functions/scripts/init-editing": "./functions/scripts/init-editing.js",
|
|
45
|
+
"./constants/device-sizes": "./constants/device-sizes.js",
|
|
46
|
+
"./constants/target": "./constants/target.js",
|
|
47
|
+
"./context/builder.context": "./context/builder.context.js",
|
|
48
|
+
"./components/block-styles": "./components/block-styles.js",
|
|
49
|
+
"./components/error-boundary": "./components/error-boundary.js",
|
|
50
|
+
"./components/render-block": "./components/render-block.js",
|
|
51
|
+
"./components/render-blocks": "./components/render-blocks.js",
|
|
52
|
+
"./components/render-content/render-content": "./components/render-content/render-content.js",
|
|
53
|
+
"./components/render-content/components/render-styles": "./components/components/render-styles/render-content.js",
|
|
54
|
+
"./blocks/button": "./blocks/button.jsx",
|
|
55
|
+
"./blocks/columns": "./blocks/columns.jsx",
|
|
56
|
+
"./blocks/custom-code": "./blocks/custom-code.jsx",
|
|
57
|
+
"./blocks/embed": "./blocks/embed.jsx",
|
|
58
|
+
"./blocks/form": "./blocks/form.jsx",
|
|
59
|
+
"./blocks/fragment": "./blocks/fragment.jsx",
|
|
60
|
+
"./blocks/image": "./blocks/image.jsx",
|
|
61
|
+
"./blocks/img": "./blocks/img.jsx",
|
|
62
|
+
"./blocks/input": "./blocks/input.jsx",
|
|
63
|
+
"./blocks/raw-text": "./blocks/raw-text.jsx",
|
|
64
|
+
"./blocks/section": "./blocks/section.jsx",
|
|
65
|
+
"./blocks/select": "./blocks/select.jsx",
|
|
66
|
+
"./blocks/submit-button": "./blocks/submit-button.jsx",
|
|
67
|
+
"./blocks/symbol": "./blocks/symbol.jsx",
|
|
68
|
+
"./blocks/text": "./blocks/text.jsx",
|
|
69
|
+
"./blocks/textarea": "./blocks/textarea.jsx",
|
|
70
|
+
"./blocks/video": "./blocks/video.jsx"
|
|
14
71
|
}
|
|
15
72
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function Button(props) {
|
|
2
|
+
return <a {...props.attributes} role="button" href={props.link} target={props.openLinkInNewTab ? "_blank" : undefined}>
|
|
3
|
+
{props.text}
|
|
4
|
+
</a>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default Button;import { registerComponent } from '../functions/register-component';
|
|
8
|
+
registerComponent(Button, {name:'Core:Button',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13',defaultStyles:{appearance:'none',paddingTop:'15px',paddingBottom:'15px',paddingLeft:'25px',paddingRight:'25px',backgroundColor:'#000000',color:'white',borderRadius:'4px',textAlign:'center',cursor:'pointer'},inputs:[{name:'text',type:'text',defaultValue:'Click me!',bubble:true},{name:'link',type:'url',bubble:true},{name:'openLinkInNewTab',type:'boolean',defaultValue:false,friendlyName:'Open link in new tab'}],static:true,noWrap:true});
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { template as _$template } from "solid-js/web";
|
|
2
|
-
import { style as _$style } from "solid-js/web";
|
|
3
|
-
import { effect as _$effect } from "solid-js/web";
|
|
4
|
-
import { insert as _$insert } from "solid-js/web";
|
|
5
|
-
import { createComponent as _$createComponent } from "solid-js/web";
|
|
6
|
-
|
|
7
|
-
const _tmpl$ = /*#__PURE__*/_$template(`<div></div>`, 2);
|
|
8
|
-
|
|
9
1
|
import { For } from "solid-js";
|
|
10
2
|
import { createMutable } from "solid-js/store";
|
|
11
3
|
import { css } from "solid-styled-components";
|
|
12
4
|
import RenderBlocks from "../components/render-blocks";
|
|
13
|
-
|
|
5
|
+
|
|
6
|
+
function Columns(props) {
|
|
14
7
|
const state = createMutable({
|
|
15
8
|
getGutterSize() {
|
|
16
9
|
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
@@ -57,77 +50,42 @@ export default function Columns(props) {
|
|
|
57
50
|
}
|
|
58
51
|
|
|
59
52
|
});
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
53
|
+
return <div class={css({
|
|
54
|
+
display: "flex",
|
|
55
|
+
alignItems: "stretch",
|
|
56
|
+
lineHeight: "normal",
|
|
57
|
+
"@media (max-width: 999px)": {
|
|
58
|
+
flexDirection: "var(--flex-dir-tablet)"
|
|
59
|
+
},
|
|
60
|
+
"@media (max-width: 639px)": {
|
|
61
|
+
flexDirection: "var(--flex-dir)"
|
|
62
|
+
}
|
|
63
|
+
})} style={state.columnsCssVars}>
|
|
64
|
+
<For each={props.columns}>
|
|
65
|
+
{(column, _index) => {
|
|
66
|
+
const index = _index();
|
|
67
|
+
|
|
68
|
+
return <div class={css({
|
|
69
|
+
flexGrow: "1",
|
|
70
|
+
"@media (max-width: 999px)": {
|
|
71
|
+
width: "var(--column-width-tablet) !important",
|
|
72
|
+
marginLeft: "var(--column-margin-left-tablet) !important"
|
|
73
|
+
},
|
|
74
|
+
"@media (max-width: 639px)": {
|
|
75
|
+
width: "var(--column-width) !important",
|
|
76
|
+
marginLeft: "var(--column-margin-left) !important"
|
|
74
77
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
}),
|
|
90
|
-
_v$4 = {
|
|
91
|
-
width: state.getColumnCssWidth(index),
|
|
92
|
-
"margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
|
|
93
|
-
...state.columnCssVars
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
_v$3 !== _p$._v$3 && (_el$2.className = _p$._v$3 = _v$3);
|
|
97
|
-
_p$._v$4 = _$style(_el$2, _v$4, _p$._v$4);
|
|
98
|
-
return _p$;
|
|
99
|
-
}, {
|
|
100
|
-
_v$3: undefined,
|
|
101
|
-
_v$4: undefined
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
return _el$2;
|
|
105
|
-
})()
|
|
106
|
-
}));
|
|
107
|
-
|
|
108
|
-
_$effect(_p$ => {
|
|
109
|
-
const _v$ = css({
|
|
110
|
-
display: "flex",
|
|
111
|
-
alignItems: "stretch",
|
|
112
|
-
lineHeight: "normal",
|
|
113
|
-
"@media (max-width: 999px)": {
|
|
114
|
-
flexDirection: "var(--flex-dir-tablet)"
|
|
115
|
-
},
|
|
116
|
-
"@media (max-width: 639px)": {
|
|
117
|
-
flexDirection: "var(--flex-dir)"
|
|
118
|
-
}
|
|
119
|
-
}),
|
|
120
|
-
_v$2 = state.columnsCssVars;
|
|
121
|
-
|
|
122
|
-
_v$ !== _p$._v$ && (_el$.className = _p$._v$ = _v$);
|
|
123
|
-
_p$._v$2 = _$style(_el$, _v$2, _p$._v$2);
|
|
124
|
-
return _p$;
|
|
125
|
-
}, {
|
|
126
|
-
_v$: undefined,
|
|
127
|
-
_v$2: undefined
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
return _el$;
|
|
131
|
-
})();
|
|
132
|
-
}import { registerComponent } from '../functions/register-component';
|
|
78
|
+
})} style={{
|
|
79
|
+
width: state.getColumnCssWidth(index),
|
|
80
|
+
"margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
|
|
81
|
+
...state.columnCssVars
|
|
82
|
+
}}>
|
|
83
|
+
<RenderBlocks blocks={column.blocks}></RenderBlocks>
|
|
84
|
+
</div>;
|
|
85
|
+
}}
|
|
86
|
+
</For>
|
|
87
|
+
</div>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default Columns;import { registerComponent } from '../functions/register-component';
|
|
133
91
|
registerComponent(Columns, {name:'Columns',builtIn:true,inputs:[{name:'columns',type:'array',broadcast:true,subFields:[{name:'blocks',type:'array',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]},{name:'width',type:'number',hideFromUI:true,helperText:'Width %, e.g. set to 50 to fill half of the space'},{name:'link',type:'url',helperText:'Optionally set a url that clicking this column will link to'}],defaultValue:[{blocks:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]},{blocks:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]}],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(); } } } } "},{name:'space',type:'number',defaultValue:20,helperText:'Size of gap between columns',advanced:true},{name:'stackColumnsAt',type:'string',defaultValue:'tablet',helperText:'Convert horizontal columns to vertical at what device size',enum:['tablet','mobile','never'],advanced:true},{name:'reverseColumnsWhenStacked',type:'boolean',defaultValue:false,helperText:'When stacking columns for mobile devices, reverse the ordering',advanced:true}]});
|
|
@@ -5,7 +5,7 @@ import { css } from "solid-styled-components";
|
|
|
5
5
|
|
|
6
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;
|
|
@@ -68,29 +68,34 @@ export default function Columns(props) {
|
|
|
68
68
|
style={state.columnsCssVars}
|
|
69
69
|
>
|
|
70
70
|
<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
|
-
|
|
71
|
+
{(column, _index) => {
|
|
72
|
+
const index = _index();
|
|
73
|
+
return (
|
|
74
|
+
<div
|
|
75
|
+
class={css({
|
|
76
|
+
flexGrow: "1",
|
|
77
|
+
"@media (max-width: 999px)": {
|
|
78
|
+
width: "var(--column-width-tablet) !important",
|
|
79
|
+
marginLeft: "var(--column-margin-left-tablet) !important",
|
|
80
|
+
},
|
|
81
|
+
"@media (max-width: 639px)": {
|
|
82
|
+
width: "var(--column-width) !important",
|
|
83
|
+
marginLeft: "var(--column-margin-left) !important",
|
|
84
|
+
},
|
|
85
|
+
})}
|
|
86
|
+
style={{
|
|
87
|
+
width: state.getColumnCssWidth(index),
|
|
88
|
+
"margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
|
|
89
|
+
...state.columnCssVars,
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<RenderBlocks blocks={column.blocks}></RenderBlocks>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}}
|
|
93
96
|
</For>
|
|
94
97
|
</div>
|
|
95
98
|
);
|
|
96
99
|
}
|
|
100
|
+
|
|
101
|
+
export default Columns;
|
|
@@ -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,8 @@ 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';
|
|
51
|
+
export default CustomCode;import { registerComponent } from '../functions/register-component';
|
|
72
52
|
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}]});
|
|
@@ -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;
|
|
@@ -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 Embed(props) {
|
|
8
4
|
const state = createMutable({
|
|
9
5
|
scriptsInserted: [],
|
|
10
6
|
scriptsRun: [],
|
|
@@ -49,14 +45,8 @@ export default function Embed(props) {
|
|
|
49
45
|
onMount(() => {
|
|
50
46
|
state.findAndRunScripts();
|
|
51
47
|
});
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
elem(_el$);
|
|
56
|
-
|
|
57
|
-
_$effect(() => _el$.innerHTML = props.content);
|
|
48
|
+
return <div ref={elem} innerHTML={props.content}></div>;
|
|
49
|
+
}
|
|
58
50
|
|
|
59
|
-
|
|
60
|
-
})();
|
|
61
|
-
}import { registerComponent } from '../functions/register-component';
|
|
51
|
+
export default Embed;import { registerComponent } from '../functions/register-component';
|
|
62
52
|
registerComponent(Embed, {name:'Embed',static:true,builtIn:true,inputs:[{name:'url',type:'url',required:true,defaultValue:'',helperText:'e.g. enter a youtube url, google map, etc',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'); } "},{name:'content',type:'html',defaultValue:'<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',hideFromUI:true}]});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMutable } from "solid-js/store";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function Embed(props) {
|
|
4
4
|
const state = createMutable({
|
|
5
5
|
scriptsInserted: [],
|
|
6
6
|
scriptsRun: [],
|
|
@@ -55,3 +55,5 @@ export default function Embed(props) {
|
|
|
55
55
|
|
|
56
56
|
return <div ref={elem} innerHTML={props.content}></div>;
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
export default Embed;
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import { template as _$template } from "solid-js/web";
|
|
2
|
-
import { setAttribute as _$setAttribute } from "solid-js/web";
|
|
3
|
-
import { effect as _$effect } from "solid-js/web";
|
|
4
|
-
import { insert as _$insert } from "solid-js/web";
|
|
5
|
-
import { createComponent as _$createComponent } from "solid-js/web";
|
|
6
|
-
import { memo as _$memo } from "solid-js/web";
|
|
7
|
-
import { spread as _$spread } from "solid-js/web";
|
|
8
|
-
|
|
9
|
-
const _tmpl$ = /*#__PURE__*/_$template(`<pre></pre>`, 2),
|
|
10
|
-
_tmpl$2 = /*#__PURE__*/_$template(`<form></form>`, 2);
|
|
11
|
-
|
|
12
1
|
import { Show, For } from "solid-js";
|
|
13
2
|
import { createMutable } from "solid-js/store";
|
|
14
3
|
import { css } from "solid-styled-components";
|
|
15
4
|
import RenderBlock from "../components/render-block";
|
|
16
|
-
|
|
5
|
+
|
|
6
|
+
function FormComponent(props) {
|
|
17
7
|
const state = createMutable({
|
|
18
8
|
state: "unsubmitted",
|
|
19
9
|
responseData: null,
|
|
@@ -228,128 +218,36 @@ export default function FormComponent(props) {
|
|
|
228
218
|
|
|
229
219
|
});
|
|
230
220
|
const formRef = useRef();
|
|
231
|
-
return
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
get children() {
|
|
265
|
-
return _$createComponent(BuilderBlocks, {
|
|
266
|
-
dataPath: "errorMessage",
|
|
267
|
-
|
|
268
|
-
get blocks() {
|
|
269
|
-
return props.errorMessage;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
}), null);
|
|
276
|
-
|
|
277
|
-
_$insert(_el$, _$createComponent(Show, {
|
|
278
|
-
get when() {
|
|
279
|
-
return state.submissionState === "sending";
|
|
280
|
-
},
|
|
281
|
-
|
|
282
|
-
get children() {
|
|
283
|
-
return _$createComponent(BuilderBlocks, {
|
|
284
|
-
dataPath: "sendingMessage",
|
|
285
|
-
|
|
286
|
-
get blocks() {
|
|
287
|
-
return props.sendingMessage;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
}), null);
|
|
294
|
-
|
|
295
|
-
_$insert(_el$, _$createComponent(Show, {
|
|
296
|
-
get when() {
|
|
297
|
-
return state.submissionState === "error" && state.responseData;
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
get children() {
|
|
301
|
-
const _el$2 = _tmpl$.cloneNode(true);
|
|
302
|
-
|
|
303
|
-
_$insert(_el$2, () => JSON.stringify(state.responseData, null, 2));
|
|
304
|
-
|
|
305
|
-
_$effect(() => _el$2.className = css({
|
|
306
|
-
padding: "10px",
|
|
307
|
-
color: "red",
|
|
308
|
-
textAlign: "center"
|
|
309
|
-
}));
|
|
310
|
-
|
|
311
|
-
return _el$2;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
}), null);
|
|
315
|
-
|
|
316
|
-
_$insert(_el$, _$createComponent(Show, {
|
|
317
|
-
get when() {
|
|
318
|
-
return state.submissionState === "success";
|
|
319
|
-
},
|
|
320
|
-
|
|
321
|
-
get children() {
|
|
322
|
-
return _$createComponent(BuilderBlocks, {
|
|
323
|
-
dataPath: "successMessage",
|
|
324
|
-
|
|
325
|
-
get blocks() {
|
|
326
|
-
return props.successMessage;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
}), null);
|
|
333
|
-
|
|
334
|
-
_$effect(_p$ => {
|
|
335
|
-
const _v$ = props.validate,
|
|
336
|
-
_v$2 = !props.sendWithJs && props.action,
|
|
337
|
-
_v$3 = props.method,
|
|
338
|
-
_v$4 = props.name;
|
|
339
|
-
|
|
340
|
-
_v$ !== _p$._v$ && _$setAttribute(_el$, "validate", _p$._v$ = _v$);
|
|
341
|
-
_v$2 !== _p$._v$2 && _$setAttribute(_el$, "action", _p$._v$2 = _v$2);
|
|
342
|
-
_v$3 !== _p$._v$3 && _$setAttribute(_el$, "method", _p$._v$3 = _v$3);
|
|
343
|
-
_v$4 !== _p$._v$4 && _$setAttribute(_el$, "name", _p$._v$4 = _v$4);
|
|
344
|
-
return _p$;
|
|
345
|
-
}, {
|
|
346
|
-
_v$: undefined,
|
|
347
|
-
_v$2: undefined,
|
|
348
|
-
_v$3: undefined,
|
|
349
|
-
_v$4: undefined
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
return _el$;
|
|
353
|
-
})();
|
|
354
|
-
}import { registerComponent } from '../functions/register-component';
|
|
221
|
+
return <form {...props.attributes} validate={props.validate} ref={formRef} action={!props.sendWithJs && props.action} method={props.method} name={props.name} onSubmit={event => state.onSubmit(event)}>
|
|
222
|
+
<Show when={props.builderBlock && props.builderBlock.children}>
|
|
223
|
+
<For each={props.builderBlock?.children}>
|
|
224
|
+
{(block, _index) => {
|
|
225
|
+
const index = _index();
|
|
226
|
+
|
|
227
|
+
return <RenderBlock block={block}></RenderBlock>;
|
|
228
|
+
}}
|
|
229
|
+
</For>
|
|
230
|
+
</Show>
|
|
231
|
+
<Show when={state.submissionState === "error"}>
|
|
232
|
+
<BuilderBlocks dataPath="errorMessage" blocks={props.errorMessage}></BuilderBlocks>
|
|
233
|
+
</Show>
|
|
234
|
+
<Show when={state.submissionState === "sending"}>
|
|
235
|
+
<BuilderBlocks dataPath="sendingMessage" blocks={props.sendingMessage}></BuilderBlocks>
|
|
236
|
+
</Show>
|
|
237
|
+
<Show when={state.submissionState === "error" && state.responseData}>
|
|
238
|
+
<pre class={css({
|
|
239
|
+
padding: "10px",
|
|
240
|
+
color: "red",
|
|
241
|
+
textAlign: "center"
|
|
242
|
+
})}>
|
|
243
|
+
{JSON.stringify(state.responseData, null, 2)}
|
|
244
|
+
</pre>
|
|
245
|
+
</Show>
|
|
246
|
+
<Show when={state.submissionState === "success"}>
|
|
247
|
+
<BuilderBlocks dataPath="successMessage" blocks={props.successMessage}></BuilderBlocks>
|
|
248
|
+
</Show>
|
|
249
|
+
</form>;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export default FormComponent;import { registerComponent } from '../functions/register-component';
|
|
355
253
|
registerComponent(FormComponent, {name:'Form:Form',builtIn:true,defaults:{responsiveStyles:{large:{marginTop:'15px',paddingBottom:'15px'}}},image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fef36d2a846134910b64b88e6d18c5ca5',inputs:[{name:'sendSubmissionsTo',type:'string',enum:[{label:'Send to email',value:'email',helperText:'Send form submissions to the email address of your choosing'},{label:'Custom',value:'custom',helperText:'Handle where the form requests go manually with a little code, e.g. to your own custom backend'}],defaultValue:'email'},{name:'sendSubmissionsToEmail',type:'string',required:true,defaultValue:'your@email.com',showIf:'options.get("sendSubmissionsTo") === "email"'},{name:'sendWithJs',type:'boolean',helperText:'Set to false to use basic html form action',defaultValue:true,showIf:'options.get("sendSubmissionsTo") === "custom"'},{name:'name',type:'string',defaultValue:'My form'},{name:'action',type:'string',helperText:'URL to send the form data to',showIf:'options.get("sendSubmissionsTo") === "custom"'},{name:'contentType',type:'string',defaultValue:'application/json',advanced:true,enum:['application/json','multipart/form-data','application/x-www-form-urlencoded'],showIf:'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'},{name:'method',type:'string',showIf:'options.get("sendSubmissionsTo") === "custom"',defaultValue:'POST',advanced:true},{name:'previewState',type:'string',enum:['unsubmitted','sending','success','error'],defaultValue:'unsubmitted',helperText:'Choose a state to edit, e.g. choose "success" to show what users see on success and edit the message',showIf:'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'},{name:'successUrl',type:'url',helperText:'Optional URL to redirect the user to on form submission success',showIf:'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'},{name:'resetFormOnSubmit',type:'boolean',showIf:"options.get('sendSubmissionsTo') === 'custom' && options.get('sendWithJs') === true",advanced:true},{name:'successMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Thanks!</span>'}}}]},{name:'validate',type:'boolean',defaultValue:true,advanced:true},{name:'errorMessagePath',type:'text',advanced:true,helperText:'Path to where to get the error message from in a JSON response to display to the user, e.g. "error.message" for a response like { "error": { "message": "this username is taken" }}'},{name:'errorMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},bindings:{'component.options.text':'state.formErrorMessage || block.component.options.text'},component:{name:'Text',options:{text:'<span>Form submission error :( Please check your answers and try again</span>'}}}]},{name:'sendingMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Sending...</span>'}}}]},{name:'customHeaders',type:'map',valueType:{type:'string'},advanced:true,showIf:'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'}],noWrap:true,canHaveChildren:true,defaultChildren:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Enter your name</span>'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:Input',options:{name:'name',placeholder:'Jane Doe'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Enter your email</span>'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:Input',options:{name:'email',placeholder:'jane@doe.com'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:SubmitButton',options:{text:'Submit'}}}]});
|
package/src/blocks/form.lite.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { css } from "solid-styled-components";
|
|
|
5
5
|
|
|
6
6
|
import RenderBlock from "../components/render-block.lite";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function FormComponent(props) {
|
|
9
9
|
const state = createMutable({
|
|
10
10
|
state: "unsubmitted",
|
|
11
11
|
responseData: null,
|
|
@@ -250,7 +250,10 @@ export default function FormComponent(props) {
|
|
|
250
250
|
>
|
|
251
251
|
<Show when={props.builderBlock && props.builderBlock.children}>
|
|
252
252
|
<For each={props.builderBlock?.children}>
|
|
253
|
-
{(block,
|
|
253
|
+
{(block, _index) => {
|
|
254
|
+
const index = _index();
|
|
255
|
+
return <RenderBlock block={block}></RenderBlock>;
|
|
256
|
+
}}
|
|
254
257
|
</For>
|
|
255
258
|
</Show>
|
|
256
259
|
<Show when={state.submissionState === "error"}>
|
|
@@ -285,3 +288,5 @@ export default function FormComponent(props) {
|
|
|
285
288
|
</form>
|
|
286
289
|
);
|
|
287
290
|
}
|
|
291
|
+
|
|
292
|
+
export default FormComponent;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
function FragmentComponent(props) {
|
|
2
|
+
return <span>{props.children}</span>;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export default FragmentComponent;import { registerComponent } from '../functions/register-component';
|
|
6
|
+
registerComponent(FragmentComponent, {name:'Fragment',static:true,hidden:true,builtIn:true,canHaveChildren:true,noWrap:true});
|