@builder.io/sdk-svelte 0.0.6 → 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/--package.json +3 -3
- package/package/blocks/button/button.svelte +35 -3
- package/package/blocks/columns/columns.svelte +1 -2
- package/package/blocks/columns/component-info.js +2 -2
- package/package/blocks/embed/component-info.js +2 -2
- package/package/blocks/form/form.svelte +29 -1
- package/package/blocks/image/component-info.js +2 -2
- package/package/blocks/img/img.svelte +29 -1
- package/package/blocks/input/input.svelte +29 -1
- package/package/blocks/section/section.svelte +30 -2
- package/package/blocks/select/select.svelte +29 -1
- package/package/blocks/submit-button/submit-button.svelte +33 -2
- package/package/blocks/symbol/symbol.svelte +33 -8
- package/package/blocks/textarea/textarea.svelte +36 -2
- package/package/blocks/util.d.ts +4 -1
- package/package/blocks/util.js +13 -4
- package/package/blocks/video/video.svelte +30 -2
- package/package/components/render-block/block-styles.svelte +5 -3
- package/package/components/render-block/render-block.svelte +36 -15
- package/package/components/render-block/render-component.svelte +1 -2
- package/package/components/render-content/builder-editing.svelte +4 -0
- package/package/components/render-content/builder-editing.svelte.d.ts +14 -0
- package/package/components/render-content/render-content.svelte +6 -5
- package/package/components/render-inlined-styles.svelte +3 -3
- package/package/constants/device-sizes.d.ts +12 -1
- package/package/constants/device-sizes.js +27 -1
- package/package/functions/evaluate.d.ts +2 -1
- package/package/functions/evaluate.js +8 -5
- package/package/functions/event-handler-name.js +1 -4
- package/package/functions/get-block-actions-handler.d.ts +5 -2
- package/package/functions/get-block-actions-handler.js +7 -8
- package/package/functions/get-block-actions.js +2 -2
- package/package/functions/get-builder-search-params/index.d.ts +1 -1
- package/package/functions/get-content/index.js +5 -2
- package/package/functions/get-content/types.d.ts +4 -0
- package/package/functions/register-component.js +1 -13
- package/package/functions/track.d.ts +6 -1
- package/package/functions/track.js +4 -0
- package/package/index.d.ts +3 -1
- package/package/index.js +1 -1
- package/package/scripts/init-editing.js +6 -0
- package/package/types/builder-content.d.ts +7 -0
- package/package.json +2 -2
- package/src/blocks/button/button.svelte +41 -2
- package/src/blocks/columns/columns.svelte +1 -2
- package/src/blocks/columns/component-info.ts +2 -2
- package/src/blocks/embed/component-info.ts +2 -2
- package/src/blocks/form/form.svelte +36 -1
- package/src/blocks/image/component-info.ts +2 -2
- package/src/blocks/img/img.svelte +36 -1
- package/src/blocks/input/input.svelte +36 -1
- package/src/blocks/section/section.svelte +36 -1
- package/src/blocks/select/select.svelte +36 -1
- package/src/blocks/submit-button/submit-button.svelte +39 -1
- package/src/blocks/symbol/symbol.svelte +40 -8
- package/src/blocks/textarea/textarea.svelte +42 -1
- package/src/blocks/util.ts +18 -6
- package/src/blocks/video/video.svelte +36 -1
- package/src/components/render-block/block-styles.svelte +16 -3
- package/src/components/render-block/render-block.svelte +41 -15
- package/src/components/render-block/render-component.svelte +1 -2
- package/src/components/render-content/builder-editing.svelte +4 -0
- package/src/components/render-content/render-content.svelte +8 -5
- package/src/components/render-inlined-styles.svelte +3 -3
- package/src/constants/device-sizes.ts +39 -2
- package/src/functions/evaluate.ts +11 -6
- package/src/functions/event-handler-name.ts +1 -6
- package/src/functions/get-block-actions-handler.ts +10 -9
- package/src/functions/get-block-actions.ts +2 -2
- package/src/functions/get-builder-search-params/index.ts +1 -1
- package/src/functions/get-content/index.ts +6 -1
- package/src/functions/get-content/types.ts +5 -0
- package/src/functions/register-component.ts +1 -18
- package/src/functions/track.ts +13 -1
- package/src/index.ts +3 -1
- package/src/scripts/init-editing.ts +6 -0
- package/src/types/builder-content.ts +7 -0
- package/package/functions/mark-mutable.d.ts +0 -2
- package/package/functions/mark-mutable.js +0 -6
- package/src/functions/mark-mutable.ts +0 -7
|
@@ -64,6 +64,40 @@
|
|
|
64
64
|
import BuilderBlocks from "../../components/render-blocks.svelte";
|
|
65
65
|
import { isEditing } from "../../functions/is-editing.js";
|
|
66
66
|
|
|
67
|
+
const isEvent = (attr) => attr.startsWith("on:");
|
|
68
|
+
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
69
|
+
|
|
70
|
+
const filterAttrs = (attrs, filter) => {
|
|
71
|
+
const validAttr = {};
|
|
72
|
+
Object.keys(attrs).forEach((attr) => {
|
|
73
|
+
if (filter(attr)) {
|
|
74
|
+
validAttr[attr] = attrs[attr];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return validAttr;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const setAttrs = (node, attrs) => {
|
|
81
|
+
const attrKeys = Object.keys(attrs);
|
|
82
|
+
|
|
83
|
+
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
84
|
+
const teardown = (attr) =>
|
|
85
|
+
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
86
|
+
|
|
87
|
+
attrKeys.map(setup);
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
update(attrs) {
|
|
91
|
+
const attrKeys = Object.keys(attrs);
|
|
92
|
+
attrKeys.map(teardown);
|
|
93
|
+
attrKeys.map(setup);
|
|
94
|
+
},
|
|
95
|
+
destroy() {
|
|
96
|
+
attrKeys.map(teardown);
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
67
101
|
export let previewState: FormProps["previewState"];
|
|
68
102
|
export let sendWithJs: FormProps["sendWithJs"];
|
|
69
103
|
export let sendSubmissionsTo: FormProps["sendSubmissionsTo"];
|
|
@@ -288,7 +322,6 @@
|
|
|
288
322
|
</script>
|
|
289
323
|
|
|
290
324
|
<form
|
|
291
|
-
{...attributes}
|
|
292
325
|
{validate}
|
|
293
326
|
bind:this={formRef}
|
|
294
327
|
action={!sendWithJs && action}
|
|
@@ -297,6 +330,8 @@
|
|
|
297
330
|
on:submit={(event) => {
|
|
298
331
|
onSubmit(event);
|
|
299
332
|
}}
|
|
333
|
+
{...filterAttrs(attributes, isNonEvent)}
|
|
334
|
+
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
300
335
|
>
|
|
301
336
|
{#if builderBlock && builderBlock.children}
|
|
302
337
|
{#each builderBlock?.children as block}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../../types/components';
|
|
2
|
-
import {
|
|
2
|
+
import { serializeFn } from '../util.js';
|
|
3
3
|
|
|
4
4
|
export const componentInfo: ComponentInfo = {
|
|
5
5
|
name: 'Image',
|
|
@@ -23,7 +23,7 @@ export const componentInfo: ComponentInfo = {
|
|
|
23
23
|
required: true,
|
|
24
24
|
defaultValue:
|
|
25
25
|
'https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
|
|
26
|
-
onChange:
|
|
26
|
+
onChange: serializeFn((options: Map<string, any>) => {
|
|
27
27
|
const DEFAULT_ASPECT_RATIO = 0.7041;
|
|
28
28
|
options.delete('srcset');
|
|
29
29
|
options.delete('noWebp');
|
|
@@ -21,6 +21,40 @@
|
|
|
21
21
|
<script lang="ts">
|
|
22
22
|
import { isEditing } from "../../functions/is-editing.js";
|
|
23
23
|
|
|
24
|
+
const isEvent = (attr) => attr.startsWith("on:");
|
|
25
|
+
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
26
|
+
|
|
27
|
+
const filterAttrs = (attrs, filter) => {
|
|
28
|
+
const validAttr = {};
|
|
29
|
+
Object.keys(attrs).forEach((attr) => {
|
|
30
|
+
if (filter(attr)) {
|
|
31
|
+
validAttr[attr] = attrs[attr];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return validAttr;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const setAttrs = (node, attrs) => {
|
|
38
|
+
const attrKeys = Object.keys(attrs);
|
|
39
|
+
|
|
40
|
+
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
41
|
+
const teardown = (attr) =>
|
|
42
|
+
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
43
|
+
|
|
44
|
+
attrKeys.map(setup);
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
update(attrs) {
|
|
48
|
+
const attrKeys = Object.keys(attrs);
|
|
49
|
+
attrKeys.map(teardown);
|
|
50
|
+
attrKeys.map(setup);
|
|
51
|
+
},
|
|
52
|
+
destroy() {
|
|
53
|
+
attrKeys.map(teardown);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
24
58
|
export let backgroundSize: ImgProps["backgroundSize"];
|
|
25
59
|
export let backgroundPosition: ImgProps["backgroundPosition"];
|
|
26
60
|
export let imgSrc: ImgProps["imgSrc"];
|
|
@@ -40,7 +74,6 @@
|
|
|
40
74
|
</script>
|
|
41
75
|
|
|
42
76
|
<img
|
|
43
|
-
{...attributes}
|
|
44
77
|
use:mitosis_styling={{
|
|
45
78
|
objectFit: backgroundSize || "cover",
|
|
46
79
|
objectPosition: backgroundPosition || "center",
|
|
@@ -48,4 +81,6 @@
|
|
|
48
81
|
key={(isEditing() && imgSrc) || "default-key"}
|
|
49
82
|
alt={altText}
|
|
50
83
|
src={imgSrc || image}
|
|
84
|
+
{...filterAttrs(attributes, isNonEvent)}
|
|
85
|
+
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
51
86
|
/>
|
|
@@ -13,6 +13,40 @@
|
|
|
13
13
|
<script lang="ts">
|
|
14
14
|
import { isEditing } from "../../functions/is-editing.js";
|
|
15
15
|
|
|
16
|
+
const isEvent = (attr) => attr.startsWith("on:");
|
|
17
|
+
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
18
|
+
|
|
19
|
+
const filterAttrs = (attrs, filter) => {
|
|
20
|
+
const validAttr = {};
|
|
21
|
+
Object.keys(attrs).forEach((attr) => {
|
|
22
|
+
if (filter(attr)) {
|
|
23
|
+
validAttr[attr] = attrs[attr];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return validAttr;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const setAttrs = (node, attrs) => {
|
|
30
|
+
const attrKeys = Object.keys(attrs);
|
|
31
|
+
|
|
32
|
+
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
33
|
+
const teardown = (attr) =>
|
|
34
|
+
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
35
|
+
|
|
36
|
+
attrKeys.map(setup);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
update(attrs) {
|
|
40
|
+
const attrKeys = Object.keys(attrs);
|
|
41
|
+
attrKeys.map(teardown);
|
|
42
|
+
attrKeys.map(setup);
|
|
43
|
+
},
|
|
44
|
+
destroy() {
|
|
45
|
+
attrKeys.map(teardown);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
16
50
|
export let attributes: FormInputProps["attributes"];
|
|
17
51
|
export let defaultValue: FormInputProps["defaultValue"];
|
|
18
52
|
export let placeholder: FormInputProps["placeholder"];
|
|
@@ -23,7 +57,7 @@
|
|
|
23
57
|
</script>
|
|
24
58
|
|
|
25
59
|
<input
|
|
26
|
-
{...attributes}
|
|
60
|
+
{...filterAttrs(attributes, isNonEvent)}
|
|
27
61
|
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
28
62
|
{placeholder}
|
|
29
63
|
{type}
|
|
@@ -31,4 +65,5 @@
|
|
|
31
65
|
{value}
|
|
32
66
|
{defaultValue}
|
|
33
67
|
{required}
|
|
68
|
+
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
34
69
|
/>
|
|
@@ -8,6 +8,40 @@
|
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
10
|
<script lang="ts">
|
|
11
|
+
const isEvent = (attr) => attr.startsWith("on:");
|
|
12
|
+
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
13
|
+
|
|
14
|
+
const filterAttrs = (attrs, filter) => {
|
|
15
|
+
const validAttr = {};
|
|
16
|
+
Object.keys(attrs).forEach((attr) => {
|
|
17
|
+
if (filter(attr)) {
|
|
18
|
+
validAttr[attr] = attrs[attr];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return validAttr;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const setAttrs = (node, attrs) => {
|
|
25
|
+
const attrKeys = Object.keys(attrs);
|
|
26
|
+
|
|
27
|
+
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
28
|
+
const teardown = (attr) =>
|
|
29
|
+
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
30
|
+
|
|
31
|
+
attrKeys.map(setup);
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
update(attrs) {
|
|
35
|
+
const attrKeys = Object.keys(attrs);
|
|
36
|
+
attrKeys.map(teardown);
|
|
37
|
+
attrKeys.map(setup);
|
|
38
|
+
},
|
|
39
|
+
destroy() {
|
|
40
|
+
attrKeys.map(teardown);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
11
45
|
export let attributes: SectionProps["attributes"];
|
|
12
46
|
export let maxWidth: SectionProps["maxWidth"];
|
|
13
47
|
|
|
@@ -23,12 +57,13 @@
|
|
|
23
57
|
</script>
|
|
24
58
|
|
|
25
59
|
<section
|
|
26
|
-
{...attributes}
|
|
27
60
|
use:mitosis_styling={maxWidth && typeof maxWidth === "number"
|
|
28
61
|
? {
|
|
29
62
|
maxWidth: maxWidth,
|
|
30
63
|
}
|
|
31
64
|
: undefined}
|
|
65
|
+
{...filterAttrs(attributes, isNonEvent)}
|
|
66
|
+
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
32
67
|
>
|
|
33
68
|
<slot />
|
|
34
69
|
</section>
|
|
@@ -14,6 +14,40 @@
|
|
|
14
14
|
<script lang="ts">
|
|
15
15
|
import { isEditing } from "../../functions/is-editing.js";
|
|
16
16
|
|
|
17
|
+
const isEvent = (attr) => attr.startsWith("on:");
|
|
18
|
+
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
19
|
+
|
|
20
|
+
const filterAttrs = (attrs, filter) => {
|
|
21
|
+
const validAttr = {};
|
|
22
|
+
Object.keys(attrs).forEach((attr) => {
|
|
23
|
+
if (filter(attr)) {
|
|
24
|
+
validAttr[attr] = attrs[attr];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return validAttr;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const setAttrs = (node, attrs) => {
|
|
31
|
+
const attrKeys = Object.keys(attrs);
|
|
32
|
+
|
|
33
|
+
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
34
|
+
const teardown = (attr) =>
|
|
35
|
+
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
36
|
+
|
|
37
|
+
attrKeys.map(setup);
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
update(attrs) {
|
|
41
|
+
const attrKeys = Object.keys(attrs);
|
|
42
|
+
attrKeys.map(teardown);
|
|
43
|
+
attrKeys.map(setup);
|
|
44
|
+
},
|
|
45
|
+
destroy() {
|
|
46
|
+
attrKeys.map(teardown);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
17
51
|
export let attributes: FormSelectProps["attributes"];
|
|
18
52
|
export let value: FormSelectProps["value"];
|
|
19
53
|
export let defaultValue: FormSelectProps["defaultValue"];
|
|
@@ -22,11 +56,12 @@
|
|
|
22
56
|
</script>
|
|
23
57
|
|
|
24
58
|
<select
|
|
25
|
-
{...attributes}
|
|
59
|
+
{...filterAttrs(attributes, isNonEvent)}
|
|
26
60
|
{value}
|
|
27
61
|
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
28
62
|
{defaultValue}
|
|
29
63
|
{name}
|
|
64
|
+
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
30
65
|
>
|
|
31
66
|
{#each options as option}
|
|
32
67
|
<option value={option.value}>{option.name || option.value}</option>
|
|
@@ -6,10 +6,48 @@
|
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<script lang="ts">
|
|
9
|
+
const isEvent = (attr) => attr.startsWith("on:");
|
|
10
|
+
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
11
|
+
|
|
12
|
+
const filterAttrs = (attrs, filter) => {
|
|
13
|
+
const validAttr = {};
|
|
14
|
+
Object.keys(attrs).forEach((attr) => {
|
|
15
|
+
if (filter(attr)) {
|
|
16
|
+
validAttr[attr] = attrs[attr];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return validAttr;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const setAttrs = (node, attrs) => {
|
|
23
|
+
const attrKeys = Object.keys(attrs);
|
|
24
|
+
|
|
25
|
+
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
26
|
+
const teardown = (attr) =>
|
|
27
|
+
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
28
|
+
|
|
29
|
+
attrKeys.map(setup);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
update(attrs) {
|
|
33
|
+
const attrKeys = Object.keys(attrs);
|
|
34
|
+
attrKeys.map(teardown);
|
|
35
|
+
attrKeys.map(setup);
|
|
36
|
+
},
|
|
37
|
+
destroy() {
|
|
38
|
+
attrKeys.map(teardown);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
9
43
|
export let attributes: ButtonProps["attributes"];
|
|
10
44
|
export let text: ButtonProps["text"];
|
|
11
45
|
</script>
|
|
12
46
|
|
|
13
|
-
<button
|
|
47
|
+
<button
|
|
48
|
+
type="submit"
|
|
49
|
+
{...filterAttrs(attributes, isNonEvent)}
|
|
50
|
+
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
51
|
+
>
|
|
14
52
|
{text}
|
|
15
53
|
</button>
|
|
@@ -30,7 +30,40 @@
|
|
|
30
30
|
import RenderContent from "../../components/render-content/render-content.svelte";
|
|
31
31
|
import BuilderContext from "../../context/builder.context.js";
|
|
32
32
|
import { getContent } from "../../functions/get-content/index.js";
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
const isEvent = (attr) => attr.startsWith("on:");
|
|
35
|
+
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
36
|
+
|
|
37
|
+
const filterAttrs = (attrs, filter) => {
|
|
38
|
+
const validAttr = {};
|
|
39
|
+
Object.keys(attrs).forEach((attr) => {
|
|
40
|
+
if (filter(attr)) {
|
|
41
|
+
validAttr[attr] = attrs[attr];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return validAttr;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const setAttrs = (node, attrs) => {
|
|
48
|
+
const attrKeys = Object.keys(attrs);
|
|
49
|
+
|
|
50
|
+
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
51
|
+
const teardown = (attr) =>
|
|
52
|
+
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
53
|
+
|
|
54
|
+
attrKeys.map(setup);
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
update(attrs) {
|
|
58
|
+
const attrKeys = Object.keys(attrs);
|
|
59
|
+
attrKeys.map(teardown);
|
|
60
|
+
attrKeys.map(setup);
|
|
61
|
+
},
|
|
62
|
+
destroy() {
|
|
63
|
+
attrKeys.map(teardown);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
};
|
|
34
67
|
|
|
35
68
|
export let symbol: SymbolProps["symbol"];
|
|
36
69
|
export let attributes: SymbolProps["attributes"];
|
|
@@ -77,24 +110,23 @@
|
|
|
77
110
|
</script>
|
|
78
111
|
|
|
79
112
|
<div
|
|
80
|
-
{...attributes}
|
|
113
|
+
{...filterAttrs(attributes, isNonEvent)}
|
|
81
114
|
dataSet={{
|
|
82
115
|
class: className,
|
|
83
116
|
}}
|
|
84
117
|
class={className}
|
|
118
|
+
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
85
119
|
>
|
|
86
120
|
<RenderContent
|
|
87
121
|
apiKey={builderContext.apiKey}
|
|
88
122
|
context={builderContext.context}
|
|
89
|
-
customComponents={
|
|
90
|
-
|
|
91
|
-
)}
|
|
92
|
-
data={markMutable({
|
|
123
|
+
customComponents={Object.values(builderContext.registeredComponents)}
|
|
124
|
+
data={{
|
|
93
125
|
...symbol?.data,
|
|
94
126
|
...builderContext.state,
|
|
95
127
|
...symbol?.content?.data?.state,
|
|
96
|
-
}
|
|
128
|
+
}}
|
|
97
129
|
model={symbol?.model}
|
|
98
|
-
content={
|
|
130
|
+
content={contentToUse()}
|
|
99
131
|
/>
|
|
100
132
|
</div>
|
|
@@ -9,6 +9,40 @@
|
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
11
|
<script lang="ts">
|
|
12
|
+
const isEvent = (attr) => attr.startsWith("on:");
|
|
13
|
+
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
14
|
+
|
|
15
|
+
const filterAttrs = (attrs, filter) => {
|
|
16
|
+
const validAttr = {};
|
|
17
|
+
Object.keys(attrs).forEach((attr) => {
|
|
18
|
+
if (filter(attr)) {
|
|
19
|
+
validAttr[attr] = attrs[attr];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return validAttr;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const setAttrs = (node, attrs) => {
|
|
26
|
+
const attrKeys = Object.keys(attrs);
|
|
27
|
+
|
|
28
|
+
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
29
|
+
const teardown = (attr) =>
|
|
30
|
+
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
31
|
+
|
|
32
|
+
attrKeys.map(setup);
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
update(attrs) {
|
|
36
|
+
const attrKeys = Object.keys(attrs);
|
|
37
|
+
attrKeys.map(teardown);
|
|
38
|
+
attrKeys.map(setup);
|
|
39
|
+
},
|
|
40
|
+
destroy() {
|
|
41
|
+
attrKeys.map(teardown);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
12
46
|
export let attributes: TextareaProps["attributes"];
|
|
13
47
|
export let placeholder: TextareaProps["placeholder"];
|
|
14
48
|
export let name: TextareaProps["name"];
|
|
@@ -16,4 +50,11 @@
|
|
|
16
50
|
export let defaultValue: TextareaProps["defaultValue"];
|
|
17
51
|
</script>
|
|
18
52
|
|
|
19
|
-
<textarea
|
|
53
|
+
<textarea
|
|
54
|
+
{...filterAttrs(attributes, isNonEvent)}
|
|
55
|
+
{placeholder}
|
|
56
|
+
{name}
|
|
57
|
+
{value}
|
|
58
|
+
{defaultValue}
|
|
59
|
+
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
60
|
+
/>
|
package/src/blocks/util.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Input attributes that are functions must be converted to strings before being serialized to JSON.
|
|
3
|
+
*/
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
5
|
+
export const serializeFn = (fnValue: Function) => {
|
|
6
|
+
const fnStr = fnValue.toString().trim();
|
|
7
|
+
|
|
8
|
+
// we need to account for a few different fn syntaxes:
|
|
9
|
+
// 1. `function name(args) => {code}`
|
|
10
|
+
// 2. `name(args) => {code}`
|
|
11
|
+
// 3. `(args) => {}`
|
|
12
|
+
const appendFunction =
|
|
13
|
+
!fnStr.startsWith('function') && !fnStr.startsWith('(');
|
|
14
|
+
|
|
15
|
+
return `return (${
|
|
16
|
+
appendFunction ? 'function ' : ''
|
|
17
|
+
}${fnStr}).apply(this, arguments)`;
|
|
18
|
+
};
|
|
@@ -27,6 +27,40 @@
|
|
|
27
27
|
</script>
|
|
28
28
|
|
|
29
29
|
<script lang="ts">
|
|
30
|
+
const isEvent = (attr) => attr.startsWith("on:");
|
|
31
|
+
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
32
|
+
|
|
33
|
+
const filterAttrs = (attrs, filter) => {
|
|
34
|
+
const validAttr = {};
|
|
35
|
+
Object.keys(attrs).forEach((attr) => {
|
|
36
|
+
if (filter(attr)) {
|
|
37
|
+
validAttr[attr] = attrs[attr];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return validAttr;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const setAttrs = (node, attrs) => {
|
|
44
|
+
const attrKeys = Object.keys(attrs);
|
|
45
|
+
|
|
46
|
+
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
47
|
+
const teardown = (attr) =>
|
|
48
|
+
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
49
|
+
|
|
50
|
+
attrKeys.map(setup);
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
update(attrs) {
|
|
54
|
+
const attrKeys = Object.keys(attrs);
|
|
55
|
+
attrKeys.map(teardown);
|
|
56
|
+
attrKeys.map(setup);
|
|
57
|
+
},
|
|
58
|
+
destroy() {
|
|
59
|
+
attrKeys.map(teardown);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
30
64
|
export let autoPlay: VideoProps["autoPlay"];
|
|
31
65
|
export let muted: VideoProps["muted"];
|
|
32
66
|
export let controls: VideoProps["controls"];
|
|
@@ -86,7 +120,6 @@
|
|
|
86
120
|
</script>
|
|
87
121
|
|
|
88
122
|
<video
|
|
89
|
-
{...spreadProps()}
|
|
90
123
|
use:mitosis_styling={{
|
|
91
124
|
width: "100%",
|
|
92
125
|
height: "100%",
|
|
@@ -97,6 +130,8 @@
|
|
|
97
130
|
// not have the video overflow
|
|
98
131
|
borderRadius: 1,
|
|
99
132
|
}}
|
|
133
|
+
{...filterAttrs(spreadProps(), isNonEvent)}
|
|
100
134
|
src={video || "no-src"}
|
|
101
135
|
poster={posterImage}
|
|
136
|
+
use:setAttrs={filterAttrs(spreadProps(), isEvent)}
|
|
102
137
|
/>
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
<script lang="ts">
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
getMaxWidthQueryForSize,
|
|
15
|
+
getSizesForBreakpoints,
|
|
16
|
+
} from "../../constants/device-sizes.js";
|
|
14
17
|
import { TARGET } from "../../constants/target.js";
|
|
15
18
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
16
19
|
import { createCssClass } from "../../helpers/css.js";
|
|
@@ -29,6 +32,10 @@
|
|
|
29
32
|
};
|
|
30
33
|
$: css = () => {
|
|
31
34
|
const styles = useBlock().responsiveStyles;
|
|
35
|
+
const content = context.content;
|
|
36
|
+
const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(
|
|
37
|
+
content?.meta?.breakpoints || {}
|
|
38
|
+
);
|
|
32
39
|
const largeStyles = styles?.large;
|
|
33
40
|
const mediumStyles = styles?.medium;
|
|
34
41
|
const smallStyles = styles?.small;
|
|
@@ -43,14 +50,20 @@
|
|
|
43
50
|
? createCssClass({
|
|
44
51
|
className,
|
|
45
52
|
styles: mediumStyles,
|
|
46
|
-
mediaQuery: getMaxWidthQueryForSize(
|
|
53
|
+
mediaQuery: getMaxWidthQueryForSize(
|
|
54
|
+
"medium",
|
|
55
|
+
sizesWithUpdatedBreakpoints
|
|
56
|
+
),
|
|
47
57
|
})
|
|
48
58
|
: "";
|
|
49
59
|
const smallStylesClass = smallStyles
|
|
50
60
|
? createCssClass({
|
|
51
61
|
className,
|
|
52
62
|
styles: smallStyles,
|
|
53
|
-
mediaQuery: getMaxWidthQueryForSize(
|
|
63
|
+
mediaQuery: getMaxWidthQueryForSize(
|
|
64
|
+
"small",
|
|
65
|
+
sizesWithUpdatedBreakpoints
|
|
66
|
+
),
|
|
54
67
|
})
|
|
55
68
|
: "";
|
|
56
69
|
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|