@builder.io/sdk-solid 0.0.8-1 → 0.0.8-12
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/README.md +5 -1
- package/package.json +11 -7
- package/src/blocks/button/button.jsx +1 -1
- package/src/blocks/button/button.lite.tsx +4 -1
- package/src/blocks/columns/columns.jsx +4 -4
- package/src/blocks/columns/columns.lite.tsx +31 -24
- package/src/blocks/custom-code/custom-code.jsx +1 -1
- package/src/blocks/custom-code/custom-code.lite.tsx +2 -1
- package/src/blocks/embed/embed.jsx +2 -2
- package/src/blocks/embed/embed.lite.tsx +3 -2
- package/src/blocks/form/form.jsx +3 -3
- package/src/blocks/form/form.lite.tsx +10 -7
- package/src/blocks/image/image.jsx +3 -3
- package/src/blocks/image/image.lite.tsx +10 -7
- package/src/blocks/symbol/component-info.js +1 -0
- package/src/blocks/symbol/symbol.jsx +3 -2
- package/src/blocks/symbol/symbol.lite.tsx +4 -2
- package/src/blocks/text/text.jsx +1 -1
- package/src/blocks/text/text.lite.tsx +1 -1
- package/src/components/render-block/block-styles.jsx +19 -4
- package/src/components/render-block/block-styles.lite.tsx +22 -4
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.jsx +49 -32
- package/src/components/render-block/render-block.lite.tsx +75 -38
- package/src/components/render-block/render-component.jsx +27 -0
- package/src/components/render-block/render-component.lite.tsx +38 -0
- package/src/components/render-blocks.jsx +12 -2
- package/src/components/render-blocks.lite.tsx +21 -2
- package/src/components/render-content/components/render-styles.jsx +1 -1
- package/src/components/render-content/components/render-styles.lite.tsx +1 -1
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.jsx +34 -9
- package/src/components/render-content/render-content.lite.tsx +47 -17
- package/src/components/render-inlined-styles.jsx +2 -1
- package/src/components/render-inlined-styles.lite.tsx +4 -1
- package/src/constants/builder-registered-components.js +45 -0
- package/src/context/builder.context.js +2 -1
- package/src/functions/fast-clone.js +4 -0
- package/src/functions/get-block-component-options.js +6 -1
- package/src/functions/get-block-styles.js +2 -2
- package/src/functions/register-component.js +30 -13
- package/src/index-helpers/blocks-exports.js +11 -9
- package/src/solid-index.jsx +5 -0
- package/src/types/components.js +0 -0
- package/src/types/element.js +0 -0
- package/src/blocks/button/index.js +0 -7
- package/src/blocks/columns/index.js +0 -7
- package/src/blocks/custom-code/index.js +0 -7
- package/src/blocks/embed/index.js +0 -7
- package/src/blocks/form/index.js +0 -7
- package/src/blocks/fragment/index.js +0 -7
- package/src/blocks/image/index.js +0 -7
- package/src/blocks/img/index.js +0 -7
- package/src/blocks/input/index.js +0 -7
- package/src/blocks/raw-text/index.js +0 -7
- package/src/blocks/section/index.js +0 -7
- package/src/blocks/select/index.js +0 -7
- package/src/blocks/submit-button/index.js +0 -7
- package/src/blocks/symbol/index.js +0 -7
- package/src/blocks/text/index.js +0 -7
- package/src/blocks/textarea/index.js +0 -7
- package/src/blocks/video/index.js +0 -7
- package/src/functions/macro-eval.js +0 -5
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-solid",
|
|
3
|
-
"version": "0.0.8-
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.0.8-12",
|
|
5
4
|
"description": "",
|
|
6
|
-
"
|
|
7
|
-
"main": "src/index.
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/solid-index.jsx",
|
|
7
|
+
"module": "./src/solid-index.jsx",
|
|
8
8
|
"exports": {
|
|
9
|
-
".": "./src/index.
|
|
9
|
+
".": "./src/solid-index.jsx"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"node-fetch": "^2.6.7",
|
|
15
16
|
"solid-styled-components": "^0.27.6"
|
|
16
17
|
},
|
|
17
18
|
"peerDependencies": {
|
|
18
|
-
"solid-js": "^1.3
|
|
19
|
+
"solid-js": "^1.4.3"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
|
-
"solid
|
|
22
|
+
"babel-preset-solid": "^1.3.17",
|
|
23
|
+
"solid-js": "^1.4.3",
|
|
24
|
+
"vite": "^2.9.8",
|
|
25
|
+
"vite-plugin-solid": "^2.2.6"
|
|
22
26
|
}
|
|
23
27
|
}
|
|
@@ -2,7 +2,7 @@ import { Show } from "solid-js";
|
|
|
2
2
|
|
|
3
3
|
function Button(props) {
|
|
4
4
|
return <>
|
|
5
|
-
<Show when={props.link}>
|
|
5
|
+
<Show fallback={<span {...props.attributes}>{props.text}</span>} when={props.link}>
|
|
6
6
|
<a {...props.attributes} role="button" href={props.link} target={props.openLinkInNewTab ? "_blank" : undefined}>
|
|
7
7
|
{props.text}
|
|
8
8
|
</a>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { For } from "solid-js";
|
|
2
2
|
import { createMutable } from "solid-js/store";
|
|
3
3
|
import { css } from "solid-styled-components";
|
|
4
|
-
import RenderBlocks from "../../components/render-blocks";
|
|
4
|
+
import RenderBlocks from "../../components/render-blocks.jsx";
|
|
5
5
|
|
|
6
6
|
function Columns(props) {
|
|
7
7
|
const state = createMutable({
|
|
@@ -51,7 +51,7 @@ function Columns(props) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
});
|
|
54
|
-
return <div class={css({
|
|
54
|
+
return <div class={"builder-columns " + css({
|
|
55
55
|
display: "flex",
|
|
56
56
|
alignItems: "stretch",
|
|
57
57
|
lineHeight: "normal",
|
|
@@ -66,7 +66,7 @@ function Columns(props) {
|
|
|
66
66
|
{(column, _index) => {
|
|
67
67
|
const index = _index();
|
|
68
68
|
|
|
69
|
-
return <div class={css({
|
|
69
|
+
return <div class={"builder-column " + css({
|
|
70
70
|
flexGrow: "1",
|
|
71
71
|
"@media (max-width: 999px)": {
|
|
72
72
|
width: "var(--column-width-tablet) !important",
|
|
@@ -80,7 +80,7 @@ function Columns(props) {
|
|
|
80
80
|
width: state.getColumnCssWidth(index),
|
|
81
81
|
"margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
|
|
82
82
|
...state.columnCssVars
|
|
83
|
-
}}>
|
|
83
|
+
}} key={index}>
|
|
84
84
|
<RenderBlocks blocks={column.blocks}></RenderBlocks>
|
|
85
85
|
</div>;
|
|
86
86
|
}}
|
|
@@ -3,7 +3,7 @@ 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 "../../components/render-blocks.
|
|
6
|
+
import RenderBlocks from "../../components/render-blocks.jsx";
|
|
7
7
|
|
|
8
8
|
function Columns(props) {
|
|
9
9
|
const state = createMutable({
|
|
@@ -24,7 +24,7 @@ function Columns(props) {
|
|
|
24
24
|
(gutterSize * (columns.length - 1)) / columns.length;
|
|
25
25
|
return `calc(${this.getWidth(index)}% - ${subtractWidth}px)`;
|
|
26
26
|
},
|
|
27
|
-
maybeApplyForTablet(prop:
|
|
27
|
+
maybeApplyForTablet(prop: JSX.CSSProperties["flexDirection"]) {
|
|
28
28
|
const _stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
29
29
|
|
|
30
30
|
return _stackColumnsAt === "tablet" ? prop : "inherit";
|
|
@@ -55,17 +55,20 @@ function Columns(props) {
|
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
57
|
<div
|
|
58
|
-
class={
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
class={
|
|
59
|
+
"builder-columns " +
|
|
60
|
+
css({
|
|
61
|
+
display: "flex",
|
|
62
|
+
alignItems: "stretch",
|
|
63
|
+
lineHeight: "normal",
|
|
64
|
+
"@media (max-width: 999px)": {
|
|
65
|
+
flexDirection: "var(--flex-dir-tablet)",
|
|
66
|
+
},
|
|
67
|
+
"@media (max-width: 639px)": {
|
|
68
|
+
flexDirection: "var(--flex-dir)",
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
}
|
|
69
72
|
style={state.columnsCssVars}
|
|
70
73
|
>
|
|
71
74
|
<For each={props.columns}>
|
|
@@ -73,22 +76,26 @@ function Columns(props) {
|
|
|
73
76
|
const index = _index();
|
|
74
77
|
return (
|
|
75
78
|
<div
|
|
76
|
-
class={
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
class={
|
|
80
|
+
"builder-column " +
|
|
81
|
+
css({
|
|
82
|
+
flexGrow: "1",
|
|
83
|
+
"@media (max-width: 999px)": {
|
|
84
|
+
width: "var(--column-width-tablet) !important",
|
|
85
|
+
marginLeft: "var(--column-margin-left-tablet) !important",
|
|
86
|
+
},
|
|
87
|
+
"@media (max-width: 639px)": {
|
|
88
|
+
width: "var(--column-width) !important",
|
|
89
|
+
marginLeft: "var(--column-margin-left) !important",
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
}
|
|
87
93
|
style={{
|
|
88
94
|
width: state.getColumnCssWidth(index),
|
|
89
95
|
"margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
|
|
90
96
|
...state.columnCssVars,
|
|
91
97
|
}}
|
|
98
|
+
key={index}
|
|
92
99
|
>
|
|
93
100
|
<RenderBlocks blocks={column.blocks}></RenderBlocks>
|
|
94
101
|
</div>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { onMount, useRef } from "solid-js";
|
|
1
2
|
import { createMutable } from "solid-js/store";
|
|
2
3
|
|
|
3
4
|
function CustomCode(props) {
|
|
@@ -8,7 +9,6 @@ function CustomCode(props) {
|
|
|
8
9
|
findAndRunScripts() {
|
|
9
10
|
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
10
11
|
if (elem && typeof window !== "undefined") {
|
|
11
|
-
/** @type {HTMLScriptElement[]} */
|
|
12
12
|
const scripts = elem.getElementsByTagName("script");
|
|
13
13
|
|
|
14
14
|
for (let i = 0; i < scripts.length; i++) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { onMount, useRef } from "solid-js";
|
|
2
|
+
|
|
1
3
|
import { createMutable } from "solid-js/store";
|
|
2
4
|
|
|
3
5
|
function CustomCode(props) {
|
|
@@ -7,7 +9,6 @@ function CustomCode(props) {
|
|
|
7
9
|
findAndRunScripts() {
|
|
8
10
|
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
9
11
|
if (elem && typeof window !== "undefined") {
|
|
10
|
-
/** @type {HTMLScriptElement[]} */
|
|
11
12
|
const scripts = elem.getElementsByTagName("script");
|
|
12
13
|
|
|
13
14
|
for (let i = 0; i < scripts.length; i++) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { onMount, useRef } from "solid-js";
|
|
1
2
|
import { createMutable } from "solid-js/store";
|
|
2
3
|
|
|
3
4
|
function Embed(props) {
|
|
@@ -8,7 +9,6 @@ function Embed(props) {
|
|
|
8
9
|
findAndRunScripts() {
|
|
9
10
|
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
10
11
|
if (elem && typeof window !== "undefined") {
|
|
11
|
-
/** @type {HTMLScriptElement[]} */
|
|
12
12
|
const scripts = elem.getElementsByTagName("script");
|
|
13
13
|
|
|
14
14
|
for (let i = 0; i < scripts.length; i++) {
|
|
@@ -45,7 +45,7 @@ function Embed(props) {
|
|
|
45
45
|
onMount(() => {
|
|
46
46
|
state.findAndRunScripts();
|
|
47
47
|
});
|
|
48
|
-
return <div ref={elem} innerHTML={props.content}></div>;
|
|
48
|
+
return <div class="builder-embed" ref={elem} innerHTML={props.content}></div>;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export default Embed;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { onMount, useRef } from "solid-js";
|
|
2
|
+
|
|
1
3
|
import { createMutable } from "solid-js/store";
|
|
2
4
|
|
|
3
5
|
function Embed(props) {
|
|
@@ -7,7 +9,6 @@ function Embed(props) {
|
|
|
7
9
|
findAndRunScripts() {
|
|
8
10
|
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
9
11
|
if (elem && typeof window !== "undefined") {
|
|
10
|
-
/** @type {HTMLScriptElement[]} */
|
|
11
12
|
const scripts = elem.getElementsByTagName("script");
|
|
12
13
|
|
|
13
14
|
for (let i = 0; i < scripts.length; i++) {
|
|
@@ -53,7 +54,7 @@ function Embed(props) {
|
|
|
53
54
|
state.findAndRunScripts();
|
|
54
55
|
});
|
|
55
56
|
|
|
56
|
-
return <div ref={elem} innerHTML={props.content}></div>;
|
|
57
|
+
return <div class="builder-embed" ref={elem} innerHTML={props.content}></div>;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
export default Embed;
|
package/src/blocks/form/form.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Show, For } from "solid-js";
|
|
1
|
+
import { Show, For, useRef } from "solid-js";
|
|
2
2
|
import { createMutable } from "solid-js/store";
|
|
3
3
|
import { css } from "solid-styled-components";
|
|
4
|
-
import RenderBlock from "../../components/render-block/render-block";
|
|
4
|
+
import RenderBlock from "../../components/render-block/render-block.jsx";
|
|
5
5
|
import { isEditing } from "../../functions/is-editing.js";
|
|
6
6
|
|
|
7
7
|
function FormComponent(props) {
|
|
@@ -236,7 +236,7 @@ function FormComponent(props) {
|
|
|
236
236
|
<BuilderBlocks dataPath="sendingMessage" blocks={props.sendingMessage}></BuilderBlocks>
|
|
237
237
|
</Show>
|
|
238
238
|
<Show when={state.submissionState === "error" && state.responseData}>
|
|
239
|
-
<pre class={css({
|
|
239
|
+
<pre class={"builder-form-error-text " + css({
|
|
240
240
|
padding: "10px",
|
|
241
241
|
color: "red",
|
|
242
242
|
textAlign: "center"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Show, For } from "solid-js";
|
|
1
|
+
import { Show, For, useRef } from "solid-js";
|
|
2
2
|
|
|
3
3
|
import { createMutable } from "solid-js/store";
|
|
4
4
|
import { css } from "solid-styled-components";
|
|
5
5
|
|
|
6
|
-
import RenderBlock from "../../components/render-block/render-block.
|
|
6
|
+
import RenderBlock from "../../components/render-block/render-block.jsx";
|
|
7
7
|
import { isEditing } from "../../functions/is-editing.js";
|
|
8
8
|
|
|
9
9
|
function FormComponent(props) {
|
|
@@ -271,11 +271,14 @@ function FormComponent(props) {
|
|
|
271
271
|
</Show>
|
|
272
272
|
<Show when={state.submissionState === "error" && state.responseData}>
|
|
273
273
|
<pre
|
|
274
|
-
class={
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
274
|
+
class={
|
|
275
|
+
"builder-form-error-text " +
|
|
276
|
+
css({
|
|
277
|
+
padding: "10px",
|
|
278
|
+
color: "red",
|
|
279
|
+
textAlign: "center",
|
|
280
|
+
})
|
|
281
|
+
}
|
|
279
282
|
>
|
|
280
283
|
{JSON.stringify(state.responseData, null, 2)}
|
|
281
284
|
</pre>
|
|
@@ -14,14 +14,14 @@ function Image(props) {
|
|
|
14
14
|
width: "100%",
|
|
15
15
|
top: "0px",
|
|
16
16
|
left: "0px"
|
|
17
|
-
})} loading="lazy" alt={props.altText}
|
|
17
|
+
})} loading="lazy" alt={props.altText} role={props.altText ? "presentation" : undefined} style={{
|
|
18
18
|
"object-position": props.backgroundSize || "center",
|
|
19
19
|
"object-fit": props.backgroundSize || "cover"
|
|
20
20
|
}} src={props.image} srcset={props.srcset} sizes={props.sizes} />
|
|
21
|
-
<source
|
|
21
|
+
<source srcset={props.srcset} />
|
|
22
22
|
</picture>
|
|
23
23
|
<Show when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}>
|
|
24
|
-
<div class={css({
|
|
24
|
+
<div class={"builder-image-sizer " + css({
|
|
25
25
|
width: "100%",
|
|
26
26
|
pointerEvents: "none",
|
|
27
27
|
fontSize: "0"
|
|
@@ -27,7 +27,7 @@ function Image(props) {
|
|
|
27
27
|
}
|
|
28
28
|
loading="lazy"
|
|
29
29
|
alt={props.altText}
|
|
30
|
-
|
|
30
|
+
role={props.altText ? "presentation" : undefined}
|
|
31
31
|
style={{
|
|
32
32
|
"object-position": props.backgroundSize || "center",
|
|
33
33
|
"object-fit": props.backgroundSize || "cover",
|
|
@@ -36,7 +36,7 @@ function Image(props) {
|
|
|
36
36
|
srcset={props.srcset}
|
|
37
37
|
sizes={props.sizes}
|
|
38
38
|
/>
|
|
39
|
-
<source
|
|
39
|
+
<source srcset={props.srcset} />
|
|
40
40
|
</picture>
|
|
41
41
|
<Show
|
|
42
42
|
when={
|
|
@@ -45,11 +45,14 @@ function Image(props) {
|
|
|
45
45
|
}
|
|
46
46
|
>
|
|
47
47
|
<div
|
|
48
|
-
class={
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
class={
|
|
49
|
+
"builder-image-sizer " +
|
|
50
|
+
css({
|
|
51
|
+
width: "100%",
|
|
52
|
+
pointerEvents: "none",
|
|
53
|
+
fontSize: "0",
|
|
54
|
+
})
|
|
55
|
+
}
|
|
53
56
|
style={{
|
|
54
57
|
"padding-top": props.aspectRatio * 100 + "%",
|
|
55
58
|
}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { useContext, onMount } from "solid-js";
|
|
1
2
|
import { createMutable } from "solid-js/store";
|
|
2
|
-
import RenderContent from "../../components/render-content/render-content";
|
|
3
|
+
import RenderContent from "../../components/render-content/render-content.jsx";
|
|
3
4
|
import BuilderContext from "../../context/builder.context";
|
|
4
5
|
|
|
5
6
|
function Symbol(props) {
|
|
@@ -16,7 +17,7 @@ function Symbol(props) {
|
|
|
16
17
|
}}>
|
|
17
18
|
<RenderContent apiKey={builderContext.apiKey} context={builderContext.context} data={{ ...props.symbol?.data,
|
|
18
19
|
...builderContext.state,
|
|
19
|
-
...props.symbol?.
|
|
20
|
+
...props.symbol?.content?.data?.state
|
|
20
21
|
}} model={props.symbol?.model} content={state.content}></RenderContent>
|
|
21
22
|
</div>;
|
|
22
23
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { useContext, onMount } from "solid-js";
|
|
2
|
+
|
|
1
3
|
import { createMutable } from "solid-js/store";
|
|
2
4
|
|
|
3
|
-
import RenderContent from "../../components/render-content/render-content.
|
|
5
|
+
import RenderContent from "../../components/render-content/render-content.jsx";
|
|
4
6
|
import BuilderContext from "../../context/builder.context";
|
|
5
7
|
import { getContent } from "../../functions/get-content/index.js";
|
|
6
8
|
|
|
@@ -27,7 +29,7 @@ function Symbol(props) {
|
|
|
27
29
|
data={{
|
|
28
30
|
...props.symbol?.data,
|
|
29
31
|
...builderContext.state,
|
|
30
|
-
...props.symbol?.
|
|
32
|
+
...props.symbol?.content?.data?.state,
|
|
31
33
|
}}
|
|
32
34
|
model={props.symbol?.model}
|
|
33
35
|
content={state.content}
|
package/src/blocks/text/text.jsx
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
|
+
import { useContext, Show } from "solid-js";
|
|
1
2
|
import { createMutable } from "solid-js/store";
|
|
2
|
-
import
|
|
3
|
+
import { TARGET } from "../../constants/target.js";
|
|
4
|
+
import BuilderContext from "../../context/builder.context";
|
|
5
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
6
|
+
import RenderInlinedStyles from "../render-inlined-styles.jsx";
|
|
3
7
|
|
|
4
8
|
function BlockStyles(props) {
|
|
5
9
|
const state = createMutable({
|
|
10
|
+
get useBlock() {
|
|
11
|
+
return getProcessedBlock({
|
|
12
|
+
block: props.block,
|
|
13
|
+
state: builderContext.state,
|
|
14
|
+
context: builderContext.context
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
|
|
6
18
|
camelToKebabCase(string) {
|
|
7
19
|
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
8
20
|
},
|
|
9
21
|
|
|
10
22
|
get css() {
|
|
11
23
|
// TODO: media queries
|
|
12
|
-
const styleObject =
|
|
24
|
+
const styleObject = state.useBlock.responsiveStyles?.large;
|
|
13
25
|
|
|
14
26
|
if (!styleObject) {
|
|
15
27
|
return "";
|
|
16
28
|
}
|
|
17
29
|
|
|
18
|
-
let str = `.${
|
|
30
|
+
let str = `.${state.useBlock.id} {`;
|
|
19
31
|
|
|
20
32
|
for (const key in styleObject) {
|
|
21
33
|
const value = styleObject[key];
|
|
@@ -30,7 +42,10 @@ function BlockStyles(props) {
|
|
|
30
42
|
}
|
|
31
43
|
|
|
32
44
|
});
|
|
33
|
-
|
|
45
|
+
const builderContext = useContext(BuilderContext);
|
|
46
|
+
return <Show when={TARGET === "vue" || TARGET === "svelte"}>
|
|
47
|
+
<RenderInlinedStyles styles={state.css}></RenderInlinedStyles>
|
|
48
|
+
</Show>;
|
|
34
49
|
}
|
|
35
50
|
|
|
36
51
|
export default BlockStyles;
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
import { useContext, Show } from "solid-js";
|
|
2
|
+
|
|
1
3
|
import { createMutable } from "solid-js/store";
|
|
2
4
|
|
|
3
|
-
import
|
|
5
|
+
import { TARGET } from "../../constants/target.js";
|
|
6
|
+
import BuilderContext from "../../context/builder.context";
|
|
7
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
8
|
+
import RenderInlinedStyles from "../render-inlined-styles.jsx";
|
|
4
9
|
|
|
5
10
|
function BlockStyles(props) {
|
|
6
11
|
const state = createMutable({
|
|
12
|
+
get useBlock() {
|
|
13
|
+
return getProcessedBlock({
|
|
14
|
+
block: props.block,
|
|
15
|
+
state: builderContext.state,
|
|
16
|
+
context: builderContext.context,
|
|
17
|
+
});
|
|
18
|
+
},
|
|
7
19
|
camelToKebabCase(string: string) {
|
|
8
20
|
return string
|
|
9
21
|
.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2")
|
|
@@ -11,13 +23,13 @@ function BlockStyles(props) {
|
|
|
11
23
|
},
|
|
12
24
|
get css() {
|
|
13
25
|
// TODO: media queries
|
|
14
|
-
const styleObject =
|
|
26
|
+
const styleObject = state.useBlock.responsiveStyles?.large;
|
|
15
27
|
|
|
16
28
|
if (!styleObject) {
|
|
17
29
|
return "";
|
|
18
30
|
}
|
|
19
31
|
|
|
20
|
-
let str = `.${
|
|
32
|
+
let str = `.${state.useBlock.id} {`;
|
|
21
33
|
|
|
22
34
|
for (const key in styleObject) {
|
|
23
35
|
const value = styleObject[key];
|
|
@@ -32,7 +44,13 @@ function BlockStyles(props) {
|
|
|
32
44
|
},
|
|
33
45
|
});
|
|
34
46
|
|
|
35
|
-
|
|
47
|
+
const builderContext = useContext(BuilderContext);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Show when={TARGET === "vue" || TARGET === "svelte"}>
|
|
51
|
+
<RenderInlinedStyles styles={state.css}></RenderInlinedStyles>
|
|
52
|
+
</Show>
|
|
53
|
+
);
|
|
36
54
|
}
|
|
37
55
|
|
|
38
56
|
export default BlockStyles;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const EMPTY_HTML_ELEMENTS = [
|
|
2
|
+
"area",
|
|
3
|
+
"base",
|
|
4
|
+
"br",
|
|
5
|
+
"col",
|
|
6
|
+
"embed",
|
|
7
|
+
"hr",
|
|
8
|
+
"img",
|
|
9
|
+
"input",
|
|
10
|
+
"keygen",
|
|
11
|
+
"link",
|
|
12
|
+
"meta",
|
|
13
|
+
"param",
|
|
14
|
+
"source",
|
|
15
|
+
"track",
|
|
16
|
+
"wbr"
|
|
17
|
+
];
|
|
18
|
+
const isEmptyHtmlElement = (tagName) => {
|
|
19
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
isEmptyHtmlElement
|
|
23
|
+
};
|