@builder.io/sdk-svelte 0.0.1-19 → 0.0.1-21
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 +1 -1
- package/src/blocks/button/button.svelte +17 -48
- package/src/blocks/columns/columns.svelte +110 -102
- package/src/blocks/custom-code/custom-code.svelte +59 -61
- package/src/blocks/embed/embed.svelte +50 -57
- package/src/blocks/form/form.svelte +264 -294
- package/src/blocks/fragment/fragment.svelte +1 -26
- package/src/blocks/image/image.svelte +85 -117
- package/src/blocks/img/img.svelte +22 -32
- package/src/blocks/input/input.svelte +17 -30
- package/src/blocks/raw-text/raw-text.svelte +4 -26
- package/src/blocks/section/section.svelte +20 -36
- package/src/blocks/select/select.svelte +16 -36
- package/src/blocks/submit-button/submit-button.svelte +4 -30
- package/src/blocks/symbol/symbol.svelte +64 -52
- package/src/blocks/text/text.svelte +1 -25
- package/src/blocks/textarea/textarea.svelte +5 -29
- package/src/blocks/video/video.svelte +35 -43
- package/src/components/render-block/block-styles.svelte +49 -59
- package/src/components/render-block/render-block.svelte +197 -167
- package/src/components/render-block/render-component.svelte +13 -51
- package/src/components/render-block/render-repeated-block.svelte +29 -0
- package/src/components/render-blocks.svelte +74 -98
- package/src/components/render-content/components/render-styles.svelte +42 -62
- package/src/components/render-content/render-content.svelte +257 -231
- package/src/components/render-inlined-styles.svelte +15 -45
- package/src/context/builder.context.js +7 -1
- package/src/functions/convert-style-object.js +6 -0
- package/src/functions/get-block-styles.js +6 -3
- package/src/functions/get-processed-block.js +15 -8
- package/src/functions/get-processed-block.test.js +2 -1
- package/src/functions/sanitize-styles.js +5 -0
|
@@ -1,118 +1,86 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
</div>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
{/if}
|
|
94
|
-
|
|
95
|
-
</div>
|
|
96
|
-
|
|
97
|
-
<style>
|
|
98
|
-
.div {
|
|
99
|
-
position: relative; }.img {
|
|
100
|
-
opacity: 1;
|
|
101
|
-
transition: opacity 0.2s ease-in-out;
|
|
102
|
-
position: absolute;
|
|
103
|
-
height: 100%;
|
|
104
|
-
width: 100%;
|
|
105
|
-
top: 0px;
|
|
106
|
-
left: 0px; }.div-2 {
|
|
107
|
-
width: 100%;
|
|
108
|
-
pointer-events: none;
|
|
109
|
-
font-size: 0; }.div-3 {
|
|
110
|
-
display: flex;
|
|
111
|
-
flex-direction: column;
|
|
112
|
-
align-items: stretch;
|
|
113
|
-
position: absolute;
|
|
114
|
-
top: 0;
|
|
115
|
-
left: 0;
|
|
116
|
-
width: 100%;
|
|
117
|
-
height: 100%; }
|
|
118
|
-
</style>
|
|
2
|
+
export let altText;
|
|
3
|
+
export let backgroundSize;
|
|
4
|
+
export let className;
|
|
5
|
+
export let image;
|
|
6
|
+
export let srcset;
|
|
7
|
+
export let sizes;
|
|
8
|
+
export let aspectRatio;
|
|
9
|
+
export let fitContent;
|
|
10
|
+
export let builderBlock;
|
|
11
|
+
|
|
12
|
+
function mitosis_styling(node, vars) {
|
|
13
|
+
Object.entries(vars).forEach(([p, v]) => {
|
|
14
|
+
node.style[p] = v;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class="div">
|
|
20
|
+
<picture>
|
|
21
|
+
<img
|
|
22
|
+
use:mitosis_styling={{
|
|
23
|
+
objectPosition: backgroundSize || "center",
|
|
24
|
+
objectFit: backgroundSize || "cover",
|
|
25
|
+
}}
|
|
26
|
+
loading="lazy"
|
|
27
|
+
alt={altText}
|
|
28
|
+
role={altText ? "presentation" : undefined}
|
|
29
|
+
class={"builder-image" + (className ? " " + className : "") + "img"}
|
|
30
|
+
src={image}
|
|
31
|
+
{srcset}
|
|
32
|
+
{sizes}
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
<source {srcset} />
|
|
36
|
+
</picture>
|
|
37
|
+
|
|
38
|
+
{#if aspectRatio && !(fitContent && builderBlock?.children?.length)}
|
|
39
|
+
<div
|
|
40
|
+
use:mitosis_styling={{
|
|
41
|
+
paddingTop: aspectRatio * 100 + "%",
|
|
42
|
+
}}
|
|
43
|
+
class="builder-image-sizer div-2"
|
|
44
|
+
/>
|
|
45
|
+
{/if}
|
|
46
|
+
|
|
47
|
+
{#if builderBlock?.children?.length && fitContent}
|
|
48
|
+
<slot />
|
|
49
|
+
{/if}
|
|
50
|
+
|
|
51
|
+
{#if !fitContent}
|
|
52
|
+
<div class="div-3">
|
|
53
|
+
<slot />
|
|
54
|
+
</div>
|
|
55
|
+
{/if}
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<style>
|
|
59
|
+
.div {
|
|
60
|
+
position: relative;
|
|
61
|
+
}
|
|
62
|
+
.img {
|
|
63
|
+
opacity: 1;
|
|
64
|
+
transition: opacity 0.2s ease-in-out;
|
|
65
|
+
position: absolute;
|
|
66
|
+
height: 100%;
|
|
67
|
+
width: 100%;
|
|
68
|
+
top: 0px;
|
|
69
|
+
left: 0px;
|
|
70
|
+
}
|
|
71
|
+
.div-2 {
|
|
72
|
+
width: 100%;
|
|
73
|
+
pointer-events: none;
|
|
74
|
+
font-size: 0;
|
|
75
|
+
}
|
|
76
|
+
.div-3 {
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
align-items: stretch;
|
|
80
|
+
position: absolute;
|
|
81
|
+
top: 0;
|
|
82
|
+
left: 0;
|
|
83
|
+
width: 100%;
|
|
84
|
+
height: 100%;
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { isEditing } from '../../functions/is-editing.js';
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
9
3
|
|
|
10
|
-
|
|
4
|
+
export let backgroundSize;
|
|
5
|
+
export let backgroundPosition;
|
|
6
|
+
export let attributes;
|
|
7
|
+
export let imgSrc;
|
|
8
|
+
export let altText;
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
function mitosis_styling(node, vars) {
|
|
11
|
+
Object.entries(vars).forEach(([p, v]) => {
|
|
12
|
+
node.style[p] = v;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<img {...attributes} style={{
|
|
34
|
-
objectFit: backgroundSize || 'cover',
|
|
35
|
-
objectPosition: backgroundPosition || 'center'
|
|
36
|
-
}} key={isEditing() && imgSrc || 'default-key'} alt={altText} src={imgSrc} />
|
|
17
|
+
<img
|
|
18
|
+
{...attributes}
|
|
19
|
+
use:mitosis_styling={{
|
|
20
|
+
objectFit: backgroundSize || "cover",
|
|
21
|
+
objectPosition: backgroundPosition || "center",
|
|
22
|
+
}}
|
|
23
|
+
key={(isEditing() && imgSrc) || "default-key"}
|
|
24
|
+
alt={altText}
|
|
25
|
+
src={imgSrc}
|
|
26
|
+
/>
|
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { isEditing } from '../../functions/is-editing.js';
|
|
2
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
4
|
export let attributes;
|
|
14
|
-
export let defaultValue;
|
|
15
|
-
export let placeholder;
|
|
16
|
-
export let type;
|
|
17
|
-
export let name;
|
|
18
|
-
export let value;
|
|
19
|
-
export let required;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
5
|
+
export let defaultValue;
|
|
6
|
+
export let placeholder;
|
|
7
|
+
export let type;
|
|
8
|
+
export let name;
|
|
9
|
+
export let value;
|
|
10
|
+
export let required;
|
|
33
11
|
</script>
|
|
34
12
|
|
|
35
|
-
<input
|
|
13
|
+
<input
|
|
14
|
+
{...attributes}
|
|
15
|
+
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
16
|
+
{placeholder}
|
|
17
|
+
{type}
|
|
18
|
+
{name}
|
|
19
|
+
{value}
|
|
20
|
+
{defaultValue}
|
|
21
|
+
{required}
|
|
22
|
+
/>
|
|
@@ -1,30 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
2
|
export let attributes;
|
|
14
|
-
export let text;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
export let text;
|
|
28
4
|
</script>
|
|
29
5
|
|
|
30
|
-
<span
|
|
6
|
+
<span class={attributes?.class || attributes?.className}
|
|
7
|
+
>{@html text || ""}</span
|
|
8
|
+
>
|
|
@@ -1,37 +1,21 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<section {...attributes} style={maxWidth && typeof maxWidth === 'number' ? {
|
|
32
|
-
maxWidth: maxWidth
|
|
33
|
-
} : undefined} >
|
|
34
|
-
|
|
35
|
-
<slot></slot>
|
|
36
|
-
|
|
37
|
-
</section>
|
|
2
|
+
export let attributes;
|
|
3
|
+
export let maxWidth;
|
|
4
|
+
|
|
5
|
+
function mitosis_styling(node, vars) {
|
|
6
|
+
Object.entries(vars).forEach(([p, v]) => {
|
|
7
|
+
node.style[p] = v;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<section
|
|
13
|
+
{...attributes}
|
|
14
|
+
use:mitosis_styling={maxWidth && typeof maxWidth === "number"
|
|
15
|
+
? {
|
|
16
|
+
maxWidth: maxWidth,
|
|
17
|
+
}
|
|
18
|
+
: undefined}
|
|
19
|
+
>
|
|
20
|
+
<slot />
|
|
21
|
+
</section>
|
|
@@ -1,41 +1,21 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { isEditing } from '../../functions/is-editing.js';
|
|
2
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
4
|
export let attributes;
|
|
14
|
-
export let value;
|
|
15
|
-
export let defaultValue;
|
|
16
|
-
export let name;
|
|
17
|
-
export let options;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
5
|
+
export let value;
|
|
6
|
+
export let defaultValue;
|
|
7
|
+
export let name;
|
|
8
|
+
export let options;
|
|
31
9
|
</script>
|
|
32
10
|
|
|
33
|
-
<select
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</
|
|
11
|
+
<select
|
|
12
|
+
{...attributes}
|
|
13
|
+
{value}
|
|
14
|
+
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
15
|
+
{defaultValue}
|
|
16
|
+
{name}
|
|
17
|
+
>
|
|
18
|
+
{#each options as option, undefined}
|
|
19
|
+
<option value={option.value}>{option.name || option.value}</option>
|
|
20
|
+
{/each}
|
|
21
|
+
</select>
|
|
@@ -1,34 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
2
|
export let attributes;
|
|
14
|
-
export let text;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
export let text;
|
|
28
4
|
</script>
|
|
29
5
|
|
|
30
|
-
<button {...attributes} type="submit"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</button>
|
|
6
|
+
<button {...attributes} type="submit">
|
|
7
|
+
{text}
|
|
8
|
+
</button>
|
|
@@ -1,54 +1,66 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
import { afterUpdate } from "svelte";
|
|
4
|
+
|
|
5
|
+
import RenderContent from "../../components/render-content/render-content.svelte";
|
|
6
|
+
import BuilderContext from "../../context/builder.context";
|
|
7
|
+
import { getContent } from "../../functions/get-content/index.js";
|
|
8
|
+
|
|
9
|
+
import { getContext, setContext } from "svelte";
|
|
10
|
+
|
|
11
|
+
export let attributes;
|
|
12
|
+
export let symbol;
|
|
13
|
+
|
|
14
|
+
let builderContext = getContext(BuilderContext.key);
|
|
15
|
+
|
|
16
|
+
let className = "builder-symbol";
|
|
17
|
+
let content = null;
|
|
18
|
+
|
|
19
|
+
onMount(() => {
|
|
20
|
+
content = symbol?.content;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function onUpdateFn_0() {
|
|
24
|
+
const symbolToUse = symbol;
|
|
25
|
+
|
|
26
|
+
if (symbolToUse && !symbolToUse.content && !content && symbolToUse.model) {
|
|
27
|
+
getContent({
|
|
28
|
+
model: symbolToUse.model,
|
|
29
|
+
apiKey: builderContext.apiKey,
|
|
30
|
+
options: {
|
|
31
|
+
entry: symbolToUse.entry,
|
|
32
|
+
},
|
|
33
|
+
}).then((response) => {
|
|
34
|
+
content = response;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
38
|
+
$: onUpdateFn_0(
|
|
39
|
+
...[
|
|
40
|
+
props.symbol?.content,
|
|
41
|
+
props.symbol?.model,
|
|
42
|
+
props.symbol?.entry,
|
|
43
|
+
state.content,
|
|
44
|
+
]
|
|
45
|
+
);
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<div
|
|
49
|
+
{...attributes}
|
|
50
|
+
dataSet={{
|
|
51
|
+
class: className,
|
|
52
|
+
}}
|
|
53
|
+
class={className}
|
|
54
|
+
>
|
|
55
|
+
<RenderContent
|
|
56
|
+
apiKey={builderContext.apiKey}
|
|
57
|
+
context={builderContext.context}
|
|
58
|
+
data={{
|
|
59
|
+
...symbol?.data,
|
|
60
|
+
...builderContext.state,
|
|
61
|
+
...symbol?.content?.data?.state,
|
|
62
|
+
}}
|
|
63
|
+
model={symbol?.model}
|
|
64
|
+
{content}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|