@builder.io/sdk-svelte 0.0.1-3 → 0.0.1-32
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 +19 -0
- package/package.json +8 -1
- package/src/blocks/button/button.svelte +35 -48
- package/src/blocks/columns/columns.svelte +137 -103
- package/src/blocks/columns/component-info.js +26 -1
- package/src/blocks/custom-code/custom-code.svelte +58 -53
- package/src/blocks/embed/component-info.js +21 -1
- package/src/blocks/embed/embed.svelte +45 -57
- package/src/blocks/embed/helpers.js +9 -0
- package/src/blocks/form/form.svelte +313 -296
- package/src/blocks/fragment/fragment.svelte +9 -25
- package/src/blocks/image/component-info.js +48 -1
- package/src/blocks/image/image.helpers.js +48 -0
- package/src/blocks/image/image.svelte +146 -117
- package/src/blocks/img/img.svelte +48 -36
- package/src/blocks/input/input.svelte +30 -31
- package/src/blocks/raw-text/raw-text.svelte +12 -26
- package/src/blocks/section/section.svelte +30 -36
- package/src/blocks/select/select.svelte +30 -37
- package/src/blocks/submit-button/submit-button.svelte +12 -30
- package/src/blocks/symbol/component-info.js +1 -0
- package/src/blocks/symbol/symbol.svelte +88 -53
- package/src/blocks/text/text.svelte +8 -25
- package/src/blocks/textarea/textarea.svelte +16 -29
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/video.svelte +88 -41
- package/src/components/render-block/block-styles.svelte +58 -51
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.svelte +204 -160
- package/src/components/render-block/render-component.svelte +30 -0
- package/src/components/render-block/render-repeated-block.svelte +45 -0
- package/src/components/render-block/types.js +0 -0
- package/src/components/render-blocks.svelte +88 -80
- package/src/components/render-content/components/render-styles.svelte +59 -63
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.svelte +316 -207
- package/src/components/render-inlined-styles.svelte +26 -48
- package/src/constants/builder-registered-components.js +51 -0
- package/src/constants/device-sizes.js +3 -21
- package/src/context/builder.context.js +7 -1
- package/src/functions/camel-to-kebab-case.js +4 -0
- package/src/functions/convert-style-object.js +6 -0
- package/src/functions/get-block-component-options.js +6 -1
- package/src/functions/get-block-styles.js +7 -4
- package/src/functions/get-builder-search-params/index.js +12 -1
- package/src/functions/get-content/ab-testing.js +38 -0
- package/src/functions/get-content/fn.test.js +1 -1
- package/src/functions/get-content/index.js +16 -58
- package/src/functions/get-content/types.js +0 -0
- package/src/functions/get-fetch.js +2 -2
- package/src/functions/get-processed-block.js +19 -8
- package/src/functions/get-processed-block.test.js +2 -1
- package/src/functions/register-component.js +45 -26
- package/src/functions/sanitize-styles.js +5 -0
- package/src/functions/track.js +71 -2
- package/src/helpers/cookie.js +59 -0
- package/src/helpers/css.js +12 -0
- package/src/helpers/flatten.js +34 -0
- package/src/helpers/localStorage.js +34 -0
- package/src/helpers/nullable.js +4 -0
- package/src/helpers/sessionId.js +26 -0
- package/src/helpers/time.js +5 -0
- package/src/helpers/url.js +10 -0
- package/src/helpers/url.test.js +15 -0
- package/src/helpers/uuid.js +13 -0
- package/src/helpers/visitorId.js +33 -0
- package/src/index-helpers/blocks-exports.js +10 -8
- package/src/scripts/init-editing.js +4 -5
- package/src/types/can-track.js +0 -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/components/error-boundary.svelte +0 -26
- package/src/functions/macro-eval.js +0 -5
- package/src/functions/previewing-model-name.js +0 -11
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { markSerializable } from "../util";
|
|
1
2
|
const componentInfo = {
|
|
2
3
|
name: "Image",
|
|
3
4
|
static: true,
|
|
@@ -18,7 +19,53 @@ const componentInfo = {
|
|
|
18
19
|
allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
|
|
19
20
|
required: true,
|
|
20
21
|
defaultValue: "https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
21
|
-
onChange:
|
|
22
|
+
onChange: markSerializable((options) => {
|
|
23
|
+
const DEFAULT_ASPECT_RATIO = 0.7041;
|
|
24
|
+
options.delete("srcset");
|
|
25
|
+
options.delete("noWebp");
|
|
26
|
+
function loadImage(url, timeout = 6e4) {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
const img = document.createElement("img");
|
|
29
|
+
let loaded = false;
|
|
30
|
+
img.onload = () => {
|
|
31
|
+
loaded = true;
|
|
32
|
+
resolve(img);
|
|
33
|
+
};
|
|
34
|
+
img.addEventListener("error", (event) => {
|
|
35
|
+
console.warn("Image load failed", event.error);
|
|
36
|
+
reject(event.error);
|
|
37
|
+
});
|
|
38
|
+
img.src = url;
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
if (!loaded) {
|
|
41
|
+
reject(new Error("Image load timed out"));
|
|
42
|
+
}
|
|
43
|
+
}, timeout);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function round(num) {
|
|
47
|
+
return Math.round(num * 1e3) / 1e3;
|
|
48
|
+
}
|
|
49
|
+
const value = options.get("image");
|
|
50
|
+
const aspectRatio = options.get("aspectRatio");
|
|
51
|
+
fetch(value).then((res) => res.blob()).then((blob) => {
|
|
52
|
+
if (blob.type.includes("svg")) {
|
|
53
|
+
options.set("noWebp", true);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) {
|
|
57
|
+
return loadImage(value).then((img) => {
|
|
58
|
+
const possiblyUpdatedAspectRatio = options.get("aspectRatio");
|
|
59
|
+
if (options.get("image") === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
|
|
60
|
+
if (img.width && img.height) {
|
|
61
|
+
options.set("aspectRatio", round(img.height / img.width));
|
|
62
|
+
options.set("height", img.height);
|
|
63
|
+
options.set("width", img.width);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
})
|
|
22
69
|
},
|
|
23
70
|
{
|
|
24
71
|
name: "backgroundSize",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function removeProtocol(path) {
|
|
2
|
+
return path.replace(/http(s)?:/, "");
|
|
3
|
+
}
|
|
4
|
+
function updateQueryParam(uri = "", key, value) {
|
|
5
|
+
const re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
|
|
6
|
+
const separator = uri.indexOf("?") !== -1 ? "&" : "?";
|
|
7
|
+
if (uri.match(re)) {
|
|
8
|
+
return uri.replace(re, "$1" + key + "=" + encodeURIComponent(value) + "$2");
|
|
9
|
+
}
|
|
10
|
+
return uri + separator + key + "=" + encodeURIComponent(value);
|
|
11
|
+
}
|
|
12
|
+
function getShopifyImageUrl(src, size) {
|
|
13
|
+
if (!src || !(src == null ? void 0 : src.match(/cdn\.shopify\.com/)) || !size) {
|
|
14
|
+
return src;
|
|
15
|
+
}
|
|
16
|
+
if (size === "master") {
|
|
17
|
+
return removeProtocol(src);
|
|
18
|
+
}
|
|
19
|
+
const match = src.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
|
|
20
|
+
if (match) {
|
|
21
|
+
const prefix = src.split(match[0]);
|
|
22
|
+
const suffix = match[3];
|
|
23
|
+
const useSize = size.match("x") ? size : `${size}x`;
|
|
24
|
+
return removeProtocol(`${prefix[0]}_${useSize}${suffix}`);
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
function getSrcSet(url) {
|
|
29
|
+
if (!url) {
|
|
30
|
+
return url;
|
|
31
|
+
}
|
|
32
|
+
const sizes = [100, 200, 400, 800, 1200, 1600, 2e3];
|
|
33
|
+
if (url.match(/builder\.io/)) {
|
|
34
|
+
let srcUrl = url;
|
|
35
|
+
const widthInSrc = Number(url.split("?width=")[1]);
|
|
36
|
+
if (!isNaN(widthInSrc)) {
|
|
37
|
+
srcUrl = `${srcUrl} ${widthInSrc}w`;
|
|
38
|
+
}
|
|
39
|
+
return sizes.filter((size) => size !== widthInSrc).map((size) => `${updateQueryParam(url, "width", size)} ${size}w`).concat([srcUrl]).join(", ");
|
|
40
|
+
}
|
|
41
|
+
if (url.match(/cdn\.shopify\.com/)) {
|
|
42
|
+
return sizes.map((size) => [getShopifyImageUrl(url, `${size}x${size}`), size]).filter(([sizeUrl]) => !!sizeUrl).map(([sizeUrl, size]) => `${sizeUrl} ${size}w`).concat([url]).join(", ");
|
|
43
|
+
}
|
|
44
|
+
return url;
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
getSrcSet
|
|
48
|
+
};
|
|
@@ -1,117 +1,146 @@
|
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface ImageProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
image: string;
|
|
5
|
+
sizes?: string;
|
|
6
|
+
lazy?: boolean;
|
|
7
|
+
height?: number;
|
|
8
|
+
width?: number;
|
|
9
|
+
altText?: string;
|
|
10
|
+
backgroundSize?: string;
|
|
11
|
+
backgroundPosition?: string;
|
|
12
|
+
srcset?: string;
|
|
13
|
+
aspectRatio?: number;
|
|
14
|
+
children?: JSX.Element;
|
|
15
|
+
fitContent?: boolean;
|
|
16
|
+
builderBlock?: BuilderBlock;
|
|
17
|
+
noWebp?: boolean;
|
|
18
|
+
src?: string;
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { getSrcSet } from "./image.helpers";
|
|
24
|
+
|
|
25
|
+
export let image: ImageProps["image"];
|
|
26
|
+
export let src: ImageProps["src"];
|
|
27
|
+
export let srcset: ImageProps["srcset"];
|
|
28
|
+
export let noWebp: ImageProps["noWebp"];
|
|
29
|
+
export let altText: ImageProps["altText"];
|
|
30
|
+
export let backgroundSize: ImageProps["backgroundSize"];
|
|
31
|
+
export let className: ImageProps["className"];
|
|
32
|
+
export let sizes: ImageProps["sizes"];
|
|
33
|
+
export let aspectRatio: ImageProps["aspectRatio"];
|
|
34
|
+
export let fitContent: ImageProps["fitContent"];
|
|
35
|
+
export let builderBlock: ImageProps["builderBlock"];
|
|
36
|
+
|
|
37
|
+
function mitosis_styling(node, vars) {
|
|
38
|
+
Object.entries(vars).forEach(([p, v]) => {
|
|
39
|
+
node.style[p] = v;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
$: srcSetToUse = () => {
|
|
44
|
+
const imageToUse = image || src;
|
|
45
|
+
const url = imageToUse;
|
|
46
|
+
|
|
47
|
+
if (
|
|
48
|
+
!url || // We can auto add srcset for cdn.builder.io and shopify
|
|
49
|
+
// images, otherwise you can supply this prop manually
|
|
50
|
+
!(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/))
|
|
51
|
+
) {
|
|
52
|
+
return srcset;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (srcset && image?.includes("builder.io/api/v1/image")) {
|
|
56
|
+
if (!srcset.includes(image.split("?")[0])) {
|
|
57
|
+
console.debug("Removed given srcset");
|
|
58
|
+
return getSrcSet(url);
|
|
59
|
+
}
|
|
60
|
+
} else if (image && !srcset) {
|
|
61
|
+
return getSrcSet(url);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return getSrcSet(url);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
$: webpSrcSet = () => {
|
|
68
|
+
if (srcSetToUse?.()?.match(/builder\.io/) && !noWebp) {
|
|
69
|
+
return srcSetToUse().replace(/\?/g, "?format=webp&");
|
|
70
|
+
} else {
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<div class="div">
|
|
77
|
+
<picture>
|
|
78
|
+
{#if webpSrcSet()}
|
|
79
|
+
<source type="image/webp" srcset={webpSrcSet()} />
|
|
80
|
+
{/if}
|
|
81
|
+
<img
|
|
82
|
+
use:mitosis_styling={{
|
|
83
|
+
objectPosition: backgroundSize || "center",
|
|
84
|
+
objectFit: backgroundSize || "cover",
|
|
85
|
+
}}
|
|
86
|
+
loading="lazy"
|
|
87
|
+
alt={altText}
|
|
88
|
+
role={altText ? "presentation" : undefined}
|
|
89
|
+
class={"builder-image" + (className ? " " + className : "") + " img"}
|
|
90
|
+
src={image}
|
|
91
|
+
srcset={srcSetToUse()}
|
|
92
|
+
{sizes}
|
|
93
|
+
/>
|
|
94
|
+
<source srcset={srcSetToUse()} />
|
|
95
|
+
</picture>
|
|
96
|
+
|
|
97
|
+
{#if aspectRatio && !(fitContent && builderBlock?.children?.length)}
|
|
98
|
+
<div
|
|
99
|
+
use:mitosis_styling={{
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
101
|
+
paddingTop: aspectRatio * 100 + "%",
|
|
102
|
+
}}
|
|
103
|
+
class="builder-image-sizer div-2"
|
|
104
|
+
/>
|
|
105
|
+
{/if}
|
|
106
|
+
|
|
107
|
+
{#if builderBlock?.children?.length && fitContent}
|
|
108
|
+
<slot />
|
|
109
|
+
{/if}
|
|
110
|
+
|
|
111
|
+
{#if !fitContent}
|
|
112
|
+
<div class="div-3">
|
|
113
|
+
<slot />
|
|
114
|
+
</div>
|
|
115
|
+
{/if}
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
<style>
|
|
119
|
+
.div {
|
|
120
|
+
position: relative;
|
|
121
|
+
}
|
|
122
|
+
.img {
|
|
123
|
+
opacity: 1;
|
|
124
|
+
transition: opacity 0.2s ease-in-out;
|
|
125
|
+
position: absolute;
|
|
126
|
+
height: 100%;
|
|
127
|
+
width: 100%;
|
|
128
|
+
top: 0px;
|
|
129
|
+
left: 0px;
|
|
130
|
+
}
|
|
131
|
+
.div-2 {
|
|
132
|
+
width: 100%;
|
|
133
|
+
pointer-events: none;
|
|
134
|
+
font-size: 0;
|
|
135
|
+
}
|
|
136
|
+
.div-3 {
|
|
137
|
+
display: flex;
|
|
138
|
+
flex-direction: column;
|
|
139
|
+
align-items: stretch;
|
|
140
|
+
position: absolute;
|
|
141
|
+
top: 0;
|
|
142
|
+
left: 0;
|
|
143
|
+
width: 100%;
|
|
144
|
+
height: 100%;
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -1,36 +1,48 @@
|
|
|
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
|
-
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface ImgProps {
|
|
3
|
+
attributes?: any;
|
|
4
|
+
imgSrc?: string; // TODO(misko): I think this is unused
|
|
5
|
+
|
|
6
|
+
image?: string;
|
|
7
|
+
altText?: string;
|
|
8
|
+
backgroundSize?: "cover" | "contain";
|
|
9
|
+
backgroundPosition?:
|
|
10
|
+
| "center"
|
|
11
|
+
| "top"
|
|
12
|
+
| "left"
|
|
13
|
+
| "right"
|
|
14
|
+
| "bottom"
|
|
15
|
+
| "top left"
|
|
16
|
+
| "top right"
|
|
17
|
+
| "bottom left"
|
|
18
|
+
| "bottom right";
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
24
|
+
|
|
25
|
+
export let backgroundSize: ImgProps["backgroundSize"];
|
|
26
|
+
export let backgroundPosition: ImgProps["backgroundPosition"];
|
|
27
|
+
export let imgSrc: ImgProps["imgSrc"];
|
|
28
|
+
export let altText: ImgProps["altText"];
|
|
29
|
+
export let image: ImgProps["image"];
|
|
30
|
+
export let attributes: ImgProps["attributes"];
|
|
31
|
+
|
|
32
|
+
function mitosis_styling(node, vars) {
|
|
33
|
+
Object.entries(vars).forEach(([p, v]) => {
|
|
34
|
+
node.style[p] = v;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<img
|
|
40
|
+
{...attributes}
|
|
41
|
+
use:mitosis_styling={{
|
|
42
|
+
objectFit: backgroundSize || "cover",
|
|
43
|
+
objectPosition: backgroundPosition || "center",
|
|
44
|
+
}}
|
|
45
|
+
key={(isEditing() && imgSrc) || "default-key"}
|
|
46
|
+
alt={altText}
|
|
47
|
+
src={imgSrc || image}
|
|
48
|
+
/>
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
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
|
-
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface FormInputProps {
|
|
3
|
+
type?: string;
|
|
4
|
+
attributes?: any;
|
|
5
|
+
name?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
defaultValue?: string;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
29
12
|
|
|
30
|
-
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
31
15
|
|
|
32
|
-
|
|
16
|
+
export let attributes: FormInputProps["attributes"];
|
|
17
|
+
export let defaultValue: FormInputProps["defaultValue"];
|
|
18
|
+
export let placeholder: FormInputProps["placeholder"];
|
|
19
|
+
export let type: FormInputProps["type"];
|
|
20
|
+
export let name: FormInputProps["name"];
|
|
21
|
+
export let value: FormInputProps["value"];
|
|
22
|
+
export let required: FormInputProps["required"];
|
|
33
23
|
</script>
|
|
34
24
|
|
|
35
|
-
<input
|
|
25
|
+
<input
|
|
26
|
+
{...attributes}
|
|
27
|
+
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
28
|
+
{placeholder}
|
|
29
|
+
{type}
|
|
30
|
+
{name}
|
|
31
|
+
{value}
|
|
32
|
+
{defaultValue}
|
|
33
|
+
{required}
|
|
34
|
+
/>
|
|
@@ -1,29 +1,15 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export let attributes;
|
|
13
|
-
export let text;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface RawTextProps {
|
|
3
|
+
attributes?: any;
|
|
4
|
+
text?: string; // builderBlock?: any;
|
|
5
|
+
}
|
|
6
|
+
</script>
|
|
25
7
|
|
|
26
|
-
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
export let attributes: RawTextProps["attributes"];
|
|
10
|
+
export let text: RawTextProps["text"];
|
|
27
11
|
</script>
|
|
28
12
|
|
|
29
|
-
<span
|
|
13
|
+
<span class={attributes?.class || attributes?.className}
|
|
14
|
+
>{@html text || ""}</span
|
|
15
|
+
>
|
|
@@ -1,36 +1,30 @@
|
|
|
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
|
-
maxWidth: maxWidth
|
|
32
|
-
} : undefined} >
|
|
33
|
-
|
|
34
|
-
<slot></slot>
|
|
35
|
-
|
|
36
|
-
</section>
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface SectionProps {
|
|
3
|
+
maxWidth?: number;
|
|
4
|
+
attributes?: any;
|
|
5
|
+
children?: any;
|
|
6
|
+
builderBlock?: any;
|
|
7
|
+
}
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
export let attributes: SectionProps["attributes"];
|
|
12
|
+
export let maxWidth: SectionProps["maxWidth"];
|
|
13
|
+
|
|
14
|
+
function mitosis_styling(node, vars) {
|
|
15
|
+
Object.entries(vars).forEach(([p, v]) => {
|
|
16
|
+
node.style[p] = v;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<section
|
|
22
|
+
{...attributes}
|
|
23
|
+
use:mitosis_styling={maxWidth && typeof maxWidth === "number"
|
|
24
|
+
? {
|
|
25
|
+
maxWidth: maxWidth,
|
|
26
|
+
}
|
|
27
|
+
: undefined}
|
|
28
|
+
>
|
|
29
|
+
<slot />
|
|
30
|
+
</section>
|