@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
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import { template as _$template } from "solid-js/web";
|
|
2
|
-
import { insert as _$insert } from "solid-js/web";
|
|
3
|
-
import { createComponent as _$createComponent } from "solid-js/web";
|
|
4
|
-
import { setAttribute as _$setAttribute } from "solid-js/web";
|
|
5
|
-
import { effect as _$effect } from "solid-js/web";
|
|
6
|
-
import { memo as _$memo } from "solid-js/web";
|
|
7
|
-
|
|
8
|
-
const _tmpl$ = /*#__PURE__*/_$template(`<source type="image/webp">`, 1),
|
|
9
|
-
_tmpl$2 = /*#__PURE__*/_$template(`<div> </div>`, 2),
|
|
10
|
-
_tmpl$3 = /*#__PURE__*/_$template(`<div></div>`, 2),
|
|
11
|
-
_tmpl$4 = /*#__PURE__*/_$template(`<div><picture><img loading="lazy"></picture></div>`, 5);
|
|
12
|
-
|
|
13
1
|
import { Show } from "solid-js";
|
|
14
2
|
import { createMutable } from "solid-js/store";
|
|
15
3
|
import { css } from "solid-styled-components";
|
|
16
|
-
|
|
4
|
+
|
|
5
|
+
function Image(props) {
|
|
17
6
|
const state = createMutable({
|
|
18
7
|
updateQueryParam: function updateQueryParam(uri = "", key, value) {
|
|
19
8
|
const re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
|
|
@@ -76,97 +65,11 @@ export default function Image(props) {
|
|
|
76
65
|
return props.srcset || state.getSrcSet(props.image) || "";
|
|
77
66
|
}
|
|
78
67
|
});
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
_$insert(_el$2, _$createComponent(Show, {
|
|
85
|
-
get when() {
|
|
86
|
-
return _$memo(() => !!!props.noWebp, true)() && state.useSrcSet().includes("builder.io");
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
get children() {
|
|
90
|
-
const _el$4 = _tmpl$.cloneNode(true);
|
|
91
|
-
|
|
92
|
-
_$effect(() => _$setAttribute(_el$4, "srcset", state.useSrcSet().replace(/\?/g, "?format=webp&")));
|
|
93
|
-
|
|
94
|
-
return _el$4;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
}), null);
|
|
98
|
-
|
|
99
|
-
_$insert(_el$, _$createComponent(Show, {
|
|
100
|
-
get when() {
|
|
101
|
-
return props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length);
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
get children() {
|
|
105
|
-
const _el$5 = _tmpl$2.cloneNode(true);
|
|
106
|
-
|
|
107
|
-
_$effect(_p$ => {
|
|
108
|
-
const _v$ = css({
|
|
109
|
-
width: "100%",
|
|
110
|
-
pointerEvents: "none",
|
|
111
|
-
fontSize: "0"
|
|
112
|
-
}),
|
|
113
|
-
_v$2 = props.aspectRatio * 100 + "%";
|
|
114
|
-
|
|
115
|
-
_v$ !== _p$._v$ && (_el$5.className = _p$._v$ = _v$);
|
|
116
|
-
_v$2 !== _p$._v$2 && _el$5.style.setProperty("padding-top", _p$._v$2 = _v$2);
|
|
117
|
-
return _p$;
|
|
118
|
-
}, {
|
|
119
|
-
_v$: undefined,
|
|
120
|
-
_v$2: undefined
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
return _el$5;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
}), null);
|
|
127
|
-
|
|
128
|
-
_$insert(_el$, _$createComponent(Show, {
|
|
129
|
-
get when() {
|
|
130
|
-
return props.builderBlock?.children?.length && props.fitContent;
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
get children() {
|
|
134
|
-
return props.children;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
}), null);
|
|
138
|
-
|
|
139
|
-
_$insert(_el$, _$createComponent(Show, {
|
|
140
|
-
get when() {
|
|
141
|
-
return !props.fitContent;
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
get children() {
|
|
145
|
-
const _el$6 = _tmpl$3.cloneNode(true);
|
|
146
|
-
|
|
147
|
-
_$insert(_el$6, () => props.children);
|
|
148
|
-
|
|
149
|
-
_$effect(() => _el$6.className = css({
|
|
150
|
-
display: "flex",
|
|
151
|
-
flexDirection: "column",
|
|
152
|
-
alignItems: "stretch",
|
|
153
|
-
position: "absolute",
|
|
154
|
-
top: "0",
|
|
155
|
-
left: "0",
|
|
156
|
-
width: "100%",
|
|
157
|
-
height: "100%"
|
|
158
|
-
}));
|
|
159
|
-
|
|
160
|
-
return _el$6;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
}), null);
|
|
164
|
-
|
|
165
|
-
_$effect(_p$ => {
|
|
166
|
-
const _v$3 = css({
|
|
167
|
-
position: "relative"
|
|
168
|
-
}),
|
|
169
|
-
_v$4 = "builder-image" + (props.class ? " " + props.class : "") + " " + css({
|
|
68
|
+
return <div class={css({
|
|
69
|
+
position: "relative"
|
|
70
|
+
})}>
|
|
71
|
+
<picture>
|
|
72
|
+
<img class={"builder-image" + (props.class ? " " + props.class : "") + " " + css({
|
|
170
73
|
opacity: "1",
|
|
171
74
|
transition: "opacity 0.2s ease-in-out",
|
|
172
75
|
position: "absolute",
|
|
@@ -174,38 +77,44 @@ export default function Image(props) {
|
|
|
174
77
|
width: "100%",
|
|
175
78
|
top: "0px",
|
|
176
79
|
left: "0px"
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
80
|
+
})} loading="lazy" alt={props.altText} aria-role={props.altText ? "presentation" : undefined} style={{
|
|
81
|
+
"object-position": props.backgroundSize || "center",
|
|
82
|
+
"object-fit": props.backgroundSize || "cover"
|
|
83
|
+
}} src={props.image} srcset={props.srcset || state.getSrcSet(props.image)} sizes={props.sizes} />
|
|
84
|
+
<Show when={!props.noWebp && state.useSrcSet().includes("builder.io")}>
|
|
85
|
+
<source type="image/webp" srcSet={state.useSrcSet().replace(/\?/g, "?format=webp&")} />
|
|
86
|
+
</Show>
|
|
87
|
+
</picture>
|
|
88
|
+
<Show when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}>
|
|
89
|
+
<div class={css({
|
|
90
|
+
width: "100%",
|
|
91
|
+
pointerEvents: "none",
|
|
92
|
+
fontSize: "0"
|
|
93
|
+
})} style={{
|
|
94
|
+
"padding-top": props.aspectRatio * 100 + "%"
|
|
95
|
+
}}>
|
|
96
|
+
{" "}
|
|
97
|
+
</div>
|
|
98
|
+
</Show>
|
|
99
|
+
<Show when={props.builderBlock?.children?.length && props.fitContent}>
|
|
100
|
+
{props.children}
|
|
101
|
+
</Show>
|
|
102
|
+
<Show when={!props.fitContent}>
|
|
103
|
+
<div class={css({
|
|
104
|
+
display: "flex",
|
|
105
|
+
flexDirection: "column",
|
|
106
|
+
alignItems: "stretch",
|
|
107
|
+
position: "absolute",
|
|
108
|
+
top: "0",
|
|
109
|
+
left: "0",
|
|
110
|
+
width: "100%",
|
|
111
|
+
height: "100%"
|
|
112
|
+
})}>
|
|
113
|
+
{props.children}
|
|
114
|
+
</div>
|
|
115
|
+
</Show>
|
|
116
|
+
</div>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export default Image;import { registerComponent } from '../functions/register-component';
|
|
211
120
|
registerComponent(Image, {name:'Image',static:true,builtIn:true,image:'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4',defaultStyles:{position:'relative',minHeight:'20px',minWidth:'20px',overflow:'hidden'},canHaveChildren:true,inputs:[{name:'image',type:'file',bubble:true,allowedFileTypes:['jpeg','jpg','png','svg'],required:true,defaultValue:'https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',onChange:" const DEFAULT_ASPECT_RATIO = 0.7041; options.delete('srcset'); options.delete('noWebp'); function loadImage(url, timeout) { return new Promise((resolve, reject) => { const img = document.createElement('img'); let loaded = false; img.onload = () => { loaded = true; resolve(img); }; img.addEventListener('error', event => { console.warn('Image load failed', event.error); reject(event.error); }); img.src = url; setTimeout(() => { if (!loaded) { reject(new Error('Image load timed out')); } }, timeout); }); } function round(num) { return Math.round(num * 1000) / 1000; } const value = options.get('image'); const aspectRatio = options.get('aspectRatio'); // For SVG images - don't render as webp, keep them as SVG fetch(value) .then(res => res.blob()) .then(blob => { if (blob.type.includes('svg')) { options.set('noWebp', true); } }); if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) { return loadImage(value).then(img => { const possiblyUpdatedAspectRatio = options.get('aspectRatio'); if ( options.get('image') === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO) ) { if (img.width && img.height) { options.set('aspectRatio', round(img.height / img.width)); options.set('height', img.height); options.set('width', img.width); } } }); }"},{name:'backgroundSize',type:'text',defaultValue:'cover',enum:[{label:'contain',value:'contain',helperText:'The image should never get cropped'},{label:'cover',value:'cover',helperText:"The image should fill it's box, cropping when needed"}]},{name:'backgroundPosition',type:'text',defaultValue:'center',enum:['center','top','left','right','bottom','top left','top right','bottom left','bottom right']},{name:'altText',type:'string',helperText:'Text to display when the user has images off'},{name:'height',type:'number',hideFromUI:true},{name:'width',type:'number',hideFromUI:true},{name:'sizes',type:'string',hideFromUI:true},{name:'srcset',type:'string',hideFromUI:true},{name:'lazy',type:'boolean',defaultValue:true,hideFromUI:true},{name:'fitContent',type:'boolean',helperText:"When child blocks are provided, fit to them instead of using the image's aspect ratio",defaultValue:true},{name:'aspectRatio',type:'number',helperText:"This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",advanced:true,defaultValue:0.7041}]});
|
|
@@ -3,7 +3,7 @@ import { Show } from "solid-js";
|
|
|
3
3
|
import { createMutable } from "solid-js/store";
|
|
4
4
|
import { css } from "solid-styled-components";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
function Image(props) {
|
|
7
7
|
const state = createMutable({
|
|
8
8
|
updateQueryParam: function updateQueryParam(uri = "", key, value) {
|
|
9
9
|
const re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
|
|
@@ -167,3 +167,5 @@ export default function Image(props) {
|
|
|
167
167
|
</div>
|
|
168
168
|
);
|
|
169
169
|
}
|
|
170
|
+
|
|
171
|
+
export default Image;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isEditing } from "../functions/is-editing";
|
|
2
|
+
|
|
3
|
+
function ImgComponent(props) {
|
|
4
|
+
return <img {...props.attributes} style={{
|
|
5
|
+
"object-fit": props.backgroundSize || "cover",
|
|
6
|
+
"object-position": props.backgroundPosition || "center"
|
|
7
|
+
}} key={isEditing() && props.imgSrc || "default-key"} alt={props.altText} src={props.imgSrc} />;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default ImgComponent;import { registerComponent } from '../functions/register-component';
|
|
11
|
+
registerComponent(ImgComponent, {name:'Raw:Img',hideFromInsertMenu:true,builtIn:true,image:'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4',inputs:[{name:'image',bubble:true,type:'file',allowedFileTypes:['jpeg','jpg','png','svg'],required:true}],noWrap:true,static:true});
|
package/src/blocks/img.lite.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isEditing } from "../functions/is-editing";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function ImgComponent(props) {
|
|
4
4
|
return (
|
|
5
5
|
<img
|
|
6
6
|
{...props.attributes}
|
|
@@ -14,3 +14,5 @@ export default function ImgComponent(props) {
|
|
|
14
14
|
/>
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
export default ImgComponent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { isEditing } from "../functions/is-editing";
|
|
2
|
+
|
|
3
|
+
function FormInputComponent(props) {
|
|
4
|
+
return <input {...props.attributes} key={isEditing() && props.defaultValue ? props.defaultValue : "default-key"} placeholder={props.placeholder} type={props.type} name={props.name} value={props.value} defaultValue={props.defaultValue} required={props.required} />;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default FormInputComponent;import { registerComponent } from '../functions/register-component';
|
|
8
|
+
registerComponent(FormInputComponent, {name:'Form:Input',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fad6f37889d9e40bbbbc72cdb5875d6ca',inputs:[{name:'type',type:'text',enum:['text','number','email','url','checkbox','radio','range','date','datetime-local','search','tel','time','file','month','week','password','color','hidden'],defaultValue:'text'},{name:'name',type:'string',required:true,helperText:'Every input in a form needs a unique name describing what it takes, e.g. "email"'},{name:'placeholder',type:'string',defaultValue:'Hello there',helperText:'Text to display when there is no value'},{name:'defaultValue',type:'string'},{name:'value',type:'string',advanced:true},{name:'required',type:'boolean',helperText:'Is this input required to be filled out to submit a form',defaultValue:false}],noWrap:true,static:true,defaultStyles:{paddingTop:'10px',paddingBottom:'10px',paddingLeft:'10px',paddingRight:'10px',borderRadius:'3px',borderWidth:'1px',borderStyle:'solid',borderColor:'#ccc'}});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isEditing } from "../functions/is-editing";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function FormInputComponent(props) {
|
|
4
4
|
return (
|
|
5
5
|
<input
|
|
6
6
|
{...props.attributes}
|
|
@@ -16,3 +16,5 @@ export default function FormInputComponent(props) {
|
|
|
16
16
|
/>
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
export default FormInputComponent;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
function RawText(props) {
|
|
2
|
+
return <span class={props.attributes?.class || props.attributes?.className} innerHTML={props.text || ""}></span>;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export default RawText;import { registerComponent } from '../functions/register-component';
|
|
6
|
+
registerComponent(RawText, {name:'Builder:RawText',hideFromInsertMenu:true,builtIn:true,inputs:[{name:'text',bubble:true,type:'longText',required:true}]});
|
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export default
|
|
10
|
-
return (() => {
|
|
11
|
-
const _el$ = _tmpl$.cloneNode(true);
|
|
12
|
-
|
|
13
|
-
_$spread(_el$, () => props.attributes, false, true);
|
|
14
|
-
|
|
15
|
-
_$insert(_el$, () => props.children);
|
|
16
|
-
|
|
17
|
-
_$effect(_$p => _$style(_el$, props.maxWidth && typeof props.maxWidth === "number" ? {
|
|
18
|
-
"max-width": props.maxWidth
|
|
19
|
-
} : undefined, _$p));
|
|
20
|
-
|
|
21
|
-
return _el$;
|
|
22
|
-
})();
|
|
23
|
-
}import { registerComponent } from '../functions/register-component';
|
|
1
|
+
function SectionComponent(props) {
|
|
2
|
+
return <section {...props.attributes} style={props.maxWidth && typeof props.maxWidth === "number" ? {
|
|
3
|
+
"max-width": props.maxWidth
|
|
4
|
+
} : undefined}>
|
|
5
|
+
{props.children}
|
|
6
|
+
</section>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default SectionComponent;import { registerComponent } from '../functions/register-component';
|
|
24
10
|
registerComponent(SectionComponent, {name:'Core:Section',static:true,builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a',inputs:[{name:'maxWidth',type:'number',defaultValue:1200},{name:'lazyLoad',type:'boolean',defaultValue:false,advanced:true,description:'Only render this section when in view'}],defaultStyles:{paddingLeft:'20px',paddingRight:'20px',paddingTop:'50px',paddingBottom:'50px',marginTop:'0px',width:'100vw',marginLeft:'calc(50% - 50vw)'},canHaveChildren:true,defaultChildren:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{textAlign:'center'}},component:{name:'Text',options:{text:"<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"}}}]});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function SectionComponent(props) {
|
|
2
2
|
return (
|
|
3
3
|
<section
|
|
4
4
|
{...props.attributes}
|
|
@@ -14,3 +14,5 @@ export default function SectionComponent(props) {
|
|
|
14
14
|
</section>
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
export default SectionComponent;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { For } from "solid-js";
|
|
2
|
+
import { isEditing } from "../functions/is-editing";
|
|
3
|
+
|
|
4
|
+
function SelectComponent(props) {
|
|
5
|
+
return <select {...props.attributes} value={props.value} key={isEditing() && props.defaultValue ? props.defaultValue : "default-key"} defaultValue={props.defaultValue} name={props.name}>
|
|
6
|
+
<For each={props.options}>
|
|
7
|
+
{(option, _index) => {
|
|
8
|
+
const index = _index();
|
|
9
|
+
|
|
10
|
+
return <option value={option.value}>{option.name || option.value}</option>;
|
|
11
|
+
}}
|
|
12
|
+
</For>
|
|
13
|
+
</select>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default SelectComponent;import { registerComponent } from '../functions/register-component';
|
|
17
|
+
registerComponent(SelectComponent, {name:'Form:Select',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F83acca093fb24aaf94dee136e9a4b045',defaultStyles:{alignSelf:'flex-start'},inputs:[{name:'options',type:'list',required:true,subFields:[{name:'value',type:'text',required:true},{name:'name',type:'text'}],defaultValue:[{value:'option 1'},{value:'option 2'}]},{name:'name',type:'string',required:true,helperText:'Every select in a form needs a unique name describing what it gets, e.g. "email"'},{name:'defaultValue',type:'string'},{name:'value',type:'string',advanced:true},{name:'required',type:'boolean',defaultValue:false}],static:true,noWrap:true});
|
|
@@ -2,7 +2,7 @@ import { For } from "solid-js";
|
|
|
2
2
|
|
|
3
3
|
import { isEditing } from "../functions/is-editing";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
function SelectComponent(props) {
|
|
6
6
|
return (
|
|
7
7
|
<select
|
|
8
8
|
{...props.attributes}
|
|
@@ -14,10 +14,15 @@ export default function SelectComponent(props) {
|
|
|
14
14
|
name={props.name}
|
|
15
15
|
>
|
|
16
16
|
<For each={props.options}>
|
|
17
|
-
{(option,
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
{(option, _index) => {
|
|
18
|
+
const index = _index();
|
|
19
|
+
return (
|
|
20
|
+
<option value={option.value}>{option.name || option.value}</option>
|
|
21
|
+
);
|
|
22
|
+
}}
|
|
20
23
|
</For>
|
|
21
24
|
</select>
|
|
22
25
|
);
|
|
23
26
|
}
|
|
27
|
+
|
|
28
|
+
export default SelectComponent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function SubmitButton(props) {
|
|
2
|
+
return <button {...props.attributes} type="submit">
|
|
3
|
+
{props.text}
|
|
4
|
+
</button>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default SubmitButton;import { registerComponent } from '../functions/register-component';
|
|
8
|
+
registerComponent(SubmitButton, {name:'Form:SubmitButton',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fdf2820ffed1f4349a94c40b3221f5b98',defaultStyles:{appearance:'none',paddingTop:'15px',paddingBottom:'15px',paddingLeft:'25px',paddingRight:'25px',backgroundColor:'#3898EC',color:'white',borderRadius:'4px',cursor:'pointer'},inputs:[{name:'text',type:'text',defaultValue:'Click me'}],static:true,noWrap:true});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createMutable } from "solid-js/store";
|
|
2
|
+
import RenderContent from "../components/render-content/render-content";
|
|
3
|
+
import BuilderContext from "../context/builder.context";
|
|
4
|
+
|
|
5
|
+
function Symbol(props) {
|
|
6
|
+
const state = createMutable({
|
|
7
|
+
className: "builder-symbol",
|
|
8
|
+
content: null
|
|
9
|
+
});
|
|
10
|
+
const builderContext = useContext(BuilderContext);
|
|
11
|
+
onMount(() => {
|
|
12
|
+
state.content = props.symbol?.content;
|
|
13
|
+
});
|
|
14
|
+
return <div class={state.className} {...props.attributes} dataSet={{
|
|
15
|
+
class: state.className
|
|
16
|
+
}}>
|
|
17
|
+
<RenderContent apiKey={builderContext.apiKey} context={builderContext.context} data={{ ...props.symbol?.data,
|
|
18
|
+
...builderContext.state,
|
|
19
|
+
...props.symbol?.state.content?.data?.state
|
|
20
|
+
}} model={props.symbol?.model} content={state.content}></RenderContent>
|
|
21
|
+
</div>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default Symbol;import { registerComponent } from '../functions/register-component';
|
|
25
|
+
registerComponent(Symbol, {name:'Symbol',noWrap:true,static:true,inputs:[{name:'symbol',type:'uiSymbol'},{name:'dataOnly',helperText:"Make this a data symbol that doesn't display any UI",type:'boolean',defaultValue:false,advanced:true,hideFromUI:true},{name:'inheritState',helperText:'Inherit the parent component state and data',type:'boolean',defaultValue:false,advanced:true},{name:'renderToLiquid',helperText:'Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting',type:'boolean',defaultValue:false,advanced:true,hideFromUI:true},{name:'useChildren',hideFromUI:true,type:'boolean'}]});
|
|
@@ -4,7 +4,7 @@ import RenderContent from "../components/render-content/render-content.lite";
|
|
|
4
4
|
import BuilderContext from "../context/builder.context";
|
|
5
5
|
import { getContent } from "../functions/get-content";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function Symbol(props) {
|
|
8
8
|
const state = createMutable({ className: "builder-symbol", content: null });
|
|
9
9
|
|
|
10
10
|
const builderContext = useContext(BuilderContext);
|
|
@@ -35,3 +35,5 @@ export default function Symbol(props) {
|
|
|
35
35
|
</div>
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
export default Symbol;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
function Text(props) {
|
|
2
|
+
return <div innerHTML={props.text}></div>;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export default Text;import { registerComponent } from '../functions/register-component';
|
|
6
|
+
registerComponent(Text, {name:'Text',static:true,builtIn:true,image:'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929',inputs:[{name:'text',type:'html',required:true,autoFocus:true,bubble:true,defaultValue:'Enter some text...'}],defaultStyles:{lineHeight:'normal',height:'auto',textAlign:'center'}});
|
package/src/blocks/text.lite.tsx
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
function Textarea(props) {
|
|
2
|
+
return <textarea {...props.attributes} placeholder={props.placeholder} name={props.name} value={props.value} defaultValue={props.defaultValue}></textarea>;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export default Textarea;import { registerComponent } from '../functions/register-component';
|
|
6
|
+
registerComponent(Textarea, {name:'Form:TextArea',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3',inputs:[{advanced:true,name:'value',type:'string'},{name:'name',type:'string',required:true,helperText:'Every input in a form needs a unique name describing what it gets, e.g. "email"'},{name:'defaultValue',type:'string'},{name:'placeholder',type:'string',defaultValue:'Hello there'},{name:'required',type:'boolean',defaultValue:false}],defaultStyles:{paddingTop:'10px',paddingBottom:'10px',paddingLeft:'10px',paddingRight:'10px',borderRadius:'3px',borderWidth:'1px',borderStyle:'solid',borderColor:'#ccc'},static:true,noWrap:true});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function Video(props) {
|
|
2
|
+
return <video {...props.attributes} preload="none" style={{
|
|
3
|
+
width: "100%",
|
|
4
|
+
height: "100%",
|
|
5
|
+
...props.attributes?.style,
|
|
6
|
+
"object-fit": props.fit,
|
|
7
|
+
"object-position": props.position,
|
|
8
|
+
// Hack to get object fit to work as expected and
|
|
9
|
+
// not have the video overflow
|
|
10
|
+
"border-radius": 1
|
|
11
|
+
}} key={props.video || "no-src"} poster={props.posterImage} autoPlay={props.autoPlay} muted={props.muted} controls={props.controls} loop={props.loop}></video>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default Video;import { registerComponent } from '../functions/register-component';
|
|
15
|
+
registerComponent(Video, {name:'Video',canHaveChildren:true,builtIn:true,defaultStyles:{minHeight:'20px',minWidth:'20px'},image:'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb',inputs:[{name:'video',type:'file',allowedFileTypes:['mp4'],bubble:true,defaultValue:'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f',required:true},{name:'posterImage',type:'file',allowedFileTypes:['jpeg','png'],helperText:'Image to show before the video plays'},{name:'autoPlay',type:'boolean',defaultValue:true},{name:'controls',type:'boolean',defaultValue:false},{name:'muted',type:'boolean',defaultValue:true},{name:'loop',type:'boolean',defaultValue:true},{name:'playsInline',type:'boolean',defaultValue:true},{name:'fit',type:'text',defaultValue:'cover',enum:['contain','cover','fill','auto']},{name:'fitContent',type:'boolean',helperText:'When child blocks are provided, fit to them instead of using the aspect ratio',defaultValue:true,advanced:true},{name:'position',type:'text',defaultValue:'center',enum:['center','top','left','right','bottom','top left','top right','bottom left','bottom right']},{name:'height',type:'number',advanced:true},{name:'width',type:'number',advanced:true},{name:'aspectRatio',type:'number',advanced:true,defaultValue:0.7004048582995948},{name:'lazyLoad',type:'boolean',helperText:'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',defaultValue:true,advanced:true}]});
|