@builder.io/sdk-svelte 0.0.1-0 → 0.0.1-3
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 +15 -4
- package/src/blocks/{button.svelte → button/button.svelte} +29 -18
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/button/index.js +7 -0
- package/src/blocks/{columns.svelte → columns/columns.svelte} +21 -13
- package/src/blocks/columns/component-info.js +217 -0
- package/src/blocks/columns/index.js +7 -0
- package/src/blocks/custom-code/component-info.js +31 -0
- package/src/blocks/custom-code/custom-code.svelte +64 -0
- package/src/blocks/custom-code/index.js +7 -0
- package/src/blocks/embed/component-info.js +24 -0
- package/src/blocks/embed/embed.svelte +63 -0
- package/src/blocks/embed/index.js +7 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/{form.svelte → form/form.svelte} +49 -16
- package/src/blocks/form/index.js +7 -0
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/{fragment.svelte → fragment/fragment.svelte} +5 -2
- package/src/blocks/fragment/index.js +7 -0
- package/src/blocks/image/component-info.js +104 -0
- package/src/blocks/{image.svelte → image/image.svelte} +27 -9
- package/src/blocks/image/index.js +7 -0
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/{img.svelte → img/img.svelte} +5 -2
- package/src/blocks/img/index.js +7 -0
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/input/index.js +7 -0
- package/src/blocks/{input.svelte → input/input.svelte} +5 -2
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/raw-text/index.js +7 -0
- package/src/blocks/{raw-text.svelte → raw-text/raw-text.svelte} +4 -1
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/section/index.js +7 -0
- package/src/blocks/{section.svelte → section/section.svelte} +4 -1
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/select/index.js +7 -0
- package/src/blocks/{select.svelte → select/select.svelte} +10 -3
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/submit-button/index.js +7 -0
- package/src/blocks/{submit-button.svelte → submit-button/submit-button.svelte} +4 -1
- package/src/blocks/symbol/component-info.js +42 -0
- package/src/blocks/symbol/index.js +7 -0
- package/src/blocks/symbol/symbol.svelte +54 -0
- package/src/blocks/text/component-info.js +24 -0
- package/src/blocks/text/index.js +7 -0
- package/src/blocks/{text.svelte → text/text.svelte} +4 -1
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/textarea/index.js +7 -0
- package/src/blocks/{textarea.svelte → textarea/textarea.svelte} +4 -1
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/video/index.js +7 -0
- package/src/blocks/{video.svelte → video/video.svelte} +4 -1
- package/src/components/error-boundary.svelte +4 -1
- package/src/components/render-block/block-styles.svelte +51 -0
- package/src/components/{render-block.svelte → render-block/render-block.svelte} +60 -18
- package/src/components/render-blocks.svelte +18 -6
- package/src/components/render-content/components/render-styles.svelte +8 -13
- package/src/components/render-content/render-content.svelte +186 -174
- package/src/components/render-inlined-styles.svelte +49 -0
- package/src/constants/device-sizes.js +4 -11
- package/src/constants/target.js +3 -10
- package/src/context/builder.context.js +6 -31
- package/src/functions/evaluate.js +8 -31
- package/src/functions/event-handler-name.js +3 -10
- package/src/functions/get-block-actions.js +6 -29
- package/src/functions/get-block-component-options.js +3 -9
- package/src/functions/get-block-properties.js +3 -9
- package/src/functions/get-block-styles.js +6 -27
- package/src/functions/get-block-tag.js +3 -10
- package/src/functions/get-builder-search-params/fn.test.js +3 -21
- package/src/functions/get-builder-search-params/index.js +4 -11
- package/src/functions/get-content/fn.test.js +3 -21
- package/src/functions/get-content/index.js +8 -28
- package/src/functions/get-fetch.js +31 -32
- package/src/functions/get-global-this.js +3 -10
- package/src/functions/get-processed-block.js +9 -30
- package/src/functions/get-processed-block.test.js +2 -20
- package/src/functions/if-target.js +5 -28
- package/src/functions/is-browser.js +3 -10
- package/src/functions/is-editing.js +5 -28
- package/src/functions/is-iframe.js +5 -28
- package/src/functions/is-previewing.js +7 -30
- package/src/functions/macro-eval.js +3 -10
- package/src/functions/on-change.js +4 -11
- package/src/functions/on-change.test.js +4 -22
- package/src/functions/previewing-model-name.js +5 -28
- package/src/functions/register-component.js +6 -27
- package/src/functions/register.js +5 -28
- package/src/functions/set-editor-settings.js +5 -28
- package/src/functions/set.js +3 -10
- package/src/functions/set.test.js +4 -22
- package/src/functions/track.js +8 -31
- package/src/functions/transform-block.js +3 -10
- package/src/index-helpers/blocks-exports.js +19 -42
- package/src/index-helpers/top-of-file.js +3 -10
- package/src/index.js +10 -32
- package/src/scripts/init-editing.js +72 -81
- package/src/types/builder-block.js +0 -3
- package/src/types/builder-content.js +0 -3
- package/src/types/deep-partial.js +0 -3
- package/src/types/targets.js +0 -3
- package/src/types/typescript.js +0 -3
- package/src/blocks/custom-code.svelte +0 -63
- package/src/blocks/embed.svelte +0 -62
- package/src/blocks/symbol.svelte +0 -55
- package/src/components/block-styles.svelte +0 -23
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Video",
|
|
3
|
+
canHaveChildren: true,
|
|
4
|
+
builtIn: true,
|
|
5
|
+
defaultStyles: {
|
|
6
|
+
minHeight: "20px",
|
|
7
|
+
minWidth: "20px"
|
|
8
|
+
},
|
|
9
|
+
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",
|
|
10
|
+
inputs: [
|
|
11
|
+
{
|
|
12
|
+
name: "video",
|
|
13
|
+
type: "file",
|
|
14
|
+
allowedFileTypes: ["mp4"],
|
|
15
|
+
bubble: true,
|
|
16
|
+
defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "posterImage",
|
|
21
|
+
type: "file",
|
|
22
|
+
allowedFileTypes: ["jpeg", "png"],
|
|
23
|
+
helperText: "Image to show before the video plays"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "autoPlay",
|
|
27
|
+
type: "boolean",
|
|
28
|
+
defaultValue: true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "controls",
|
|
32
|
+
type: "boolean",
|
|
33
|
+
defaultValue: false
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "muted",
|
|
37
|
+
type: "boolean",
|
|
38
|
+
defaultValue: true
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "loop",
|
|
42
|
+
type: "boolean",
|
|
43
|
+
defaultValue: true
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "playsInline",
|
|
47
|
+
type: "boolean",
|
|
48
|
+
defaultValue: true
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "fit",
|
|
52
|
+
type: "text",
|
|
53
|
+
defaultValue: "cover",
|
|
54
|
+
enum: ["contain", "cover", "fill", "auto"]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "fitContent",
|
|
58
|
+
type: "boolean",
|
|
59
|
+
helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
|
|
60
|
+
defaultValue: true,
|
|
61
|
+
advanced: true
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "position",
|
|
65
|
+
type: "text",
|
|
66
|
+
defaultValue: "center",
|
|
67
|
+
enum: [
|
|
68
|
+
"center",
|
|
69
|
+
"top",
|
|
70
|
+
"left",
|
|
71
|
+
"right",
|
|
72
|
+
"bottom",
|
|
73
|
+
"top left",
|
|
74
|
+
"top right",
|
|
75
|
+
"bottom left",
|
|
76
|
+
"bottom right"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "height",
|
|
81
|
+
type: "number",
|
|
82
|
+
advanced: true
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "width",
|
|
86
|
+
type: "number",
|
|
87
|
+
advanced: true
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "aspectRatio",
|
|
91
|
+
type: "number",
|
|
92
|
+
advanced: true,
|
|
93
|
+
defaultValue: 0.7004048582995948
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "lazyLoad",
|
|
97
|
+
type: "boolean",
|
|
98
|
+
helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
|
|
99
|
+
defaultValue: true,
|
|
100
|
+
advanced: true
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
};
|
|
104
|
+
export {
|
|
105
|
+
componentInfo
|
|
106
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
+
import { componentInfo } from "./component-info.js";
|
|
3
|
+
import component from "./video.svelte";
|
|
4
|
+
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
+
export {
|
|
6
|
+
stdin_default as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import RenderInlinedStyles, { } from '../render-inlined-styles.svelte';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export let block;
|
|
14
|
+
|
|
15
|
+
function camelToKebabCase(string) {
|
|
16
|
+
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
$: css = () => {
|
|
19
|
+
// TODO: media queries
|
|
20
|
+
const styleObject = block.responsiveStyles?.large;
|
|
21
|
+
|
|
22
|
+
if (!styleObject) {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let str = `.${block.id} {`;
|
|
27
|
+
|
|
28
|
+
for (const key in styleObject) {
|
|
29
|
+
const value = styleObject[key];
|
|
30
|
+
|
|
31
|
+
if (typeof value === 'string') {
|
|
32
|
+
str += `${camelToKebabCase(key)}: ${value};`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
str += '}';
|
|
37
|
+
return str;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<RenderInlinedStyles styles={css()} ></RenderInlinedStyles>
|
|
@@ -3,22 +3,24 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import { getProcessedBlock } from '
|
|
14
|
-
import
|
|
6
|
+
import { TARGET } from '../../constants/target.js';
|
|
7
|
+
import BuilderContext, { } from '../../context/builder.context';
|
|
8
|
+
import { getBlockActions } from '../../functions/get-block-actions.js';
|
|
9
|
+
import { getBlockComponentOptions } from '../../functions/get-block-component-options.js';
|
|
10
|
+
import { getBlockProperties } from '../../functions/get-block-properties.js';
|
|
11
|
+
import { getBlockStyles } from '../../functions/get-block-styles.js';
|
|
12
|
+
import { getBlockTag } from '../../functions/get-block-tag.js';
|
|
13
|
+
import { getProcessedBlock } from '../../functions/get-processed-block.js';
|
|
14
|
+
import { components } from '../../functions/register-component.js';
|
|
15
|
+
import BlockStyles, { } from './block-styles.svelte';
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
import { getContext, setContext } from "svelte";
|
|
18
20
|
|
|
19
21
|
|
|
20
22
|
export let block;
|
|
21
|
-
|
|
23
|
+
|
|
22
24
|
|
|
23
25
|
$: component = () => {
|
|
24
26
|
const componentName = useBlock().component?.name;
|
|
@@ -27,7 +29,7 @@ if (!componentName) {
|
|
|
27
29
|
return null;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
const ref = components[
|
|
32
|
+
const ref = components[componentName];
|
|
31
33
|
|
|
32
34
|
if (componentName && !ref) {
|
|
33
35
|
// TODO: Public doc page with more info about this message
|
|
@@ -89,6 +91,8 @@ $: noCompRefChildren = () => {
|
|
|
89
91
|
return componentRef() ? [] : children();
|
|
90
92
|
};
|
|
91
93
|
|
|
94
|
+
let builderContext = getContext(BuilderContext.key);
|
|
95
|
+
|
|
92
96
|
|
|
93
97
|
|
|
94
98
|
|
|
@@ -100,22 +104,60 @@ return componentRef() ? [] : children();
|
|
|
100
104
|
|
|
101
105
|
|
|
102
106
|
|
|
107
|
+
|
|
103
108
|
{#if !componentInfo?.()?.noWrap }
|
|
109
|
+
|
|
104
110
|
|
|
105
|
-
<
|
|
111
|
+
<svelte:element {...propertiesAndActions()} style={css()} this={tagName()} >
|
|
106
112
|
|
|
113
|
+
|
|
114
|
+
{#if TARGET === 'vue' || TARGET === 'svelte' }
|
|
115
|
+
|
|
116
|
+
|
|
107
117
|
<BlockStyles block={useBlock()} ></BlockStyles>
|
|
108
118
|
|
|
109
119
|
|
|
110
|
-
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
{/if}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
{#if componentRef() }
|
|
127
|
+
<svelte:component {...componentOptions()} builderBlock={useBlock()} this={componentRef()} >
|
|
111
128
|
|
|
112
|
-
{#each children() as child }<RenderBlock block={child} ></RenderBlock>{/each}
|
|
113
129
|
|
|
114
|
-
|
|
130
|
+
{#each children() as child, index }
|
|
131
|
+
<svelte:self block={child} ></svelte:self>
|
|
132
|
+
{/each}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
</svelte:component>
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
{/if}
|
|
115
139
|
|
|
116
140
|
|
|
117
|
-
{#each noCompRefChildren() as child }<RenderBlock block={child} ></RenderBlock>{/each}
|
|
118
141
|
|
|
119
|
-
|
|
142
|
+
{#each noCompRefChildren() as child, index }
|
|
143
|
+
<svelte:self block={child} ></svelte:self>
|
|
144
|
+
{/each}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
</svelte:element>
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
{:else}
|
|
153
|
+
<svelte:component {...componentOptions()} attributes={propertiesAndActions()} builderBlock={useBlock()} style={css()} this={componentRef()} >
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
{#each children() as child, index }
|
|
157
|
+
<svelte:self block={child} ></svelte:self>
|
|
158
|
+
{/each}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
</svelte:component>
|
|
120
162
|
|
|
121
|
-
|
|
163
|
+
{/if}
|
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import { isEditing } from '../functions/is-editing';
|
|
7
|
-
import RenderBlock, { } from './render-block.
|
|
6
|
+
import { isEditing } from '../functions/is-editing.js';
|
|
7
|
+
import RenderBlock, { } from './render-block/render-block.svelte';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
export let blocks;
|
|
14
15
|
export let parent;
|
|
15
16
|
export let path;
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
function onClick() {
|
|
18
19
|
if (isEditing() && !blocks?.length) {
|
|
19
20
|
window.parent?.postMessage({
|
|
@@ -42,6 +43,8 @@ return 'builder-blocks' + (!blocks?.length ? ' no-blocks' : '');
|
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
|
|
46
|
+
|
|
47
|
+
|
|
45
48
|
|
|
46
49
|
|
|
47
50
|
|
|
@@ -50,15 +53,24 @@ return 'builder-blocks' + (!blocks?.length ? ' no-blocks' : '');
|
|
|
50
53
|
|
|
51
54
|
</script>
|
|
52
55
|
|
|
53
|
-
<div
|
|
56
|
+
<div builder-path={path} builder-parent-id={parent} dataSet={{
|
|
54
57
|
class: className()
|
|
55
58
|
}} on:click="{event => onClick()}" on:mouseenter="{event => onMouseEnter()}" class={className()} >
|
|
56
59
|
|
|
60
|
+
|
|
57
61
|
{#if blocks }
|
|
62
|
+
|
|
58
63
|
|
|
59
|
-
{#each blocks as block }<RenderBlock key={block.id} block={block} ></RenderBlock>{/each}
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
{#each blocks as block, index }
|
|
66
|
+
<RenderBlock key={block.id} block={block} ></RenderBlock>
|
|
67
|
+
{/each}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
{/if}
|
|
62
74
|
|
|
63
75
|
</div>
|
|
64
76
|
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import RenderInlinedStyles, { } from '../../render-inlined-styles.svelte';
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
export let cssCode;
|
|
13
14
|
export let customFonts;
|
|
14
|
-
|
|
15
|
+
|
|
15
16
|
function getCssFromFont(font) {
|
|
16
17
|
// TODO: compute what font sizes are used and only load those.......
|
|
17
18
|
const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
|
|
@@ -61,11 +62,11 @@ function getFontCss({
|
|
|
61
62
|
customFonts
|
|
62
63
|
}) {
|
|
63
64
|
// TODO: flag for this
|
|
64
|
-
// if (!
|
|
65
|
+
// if (!builder.allowCustomFonts) {
|
|
65
66
|
// return '';
|
|
66
67
|
// }
|
|
67
68
|
// TODO: separate internal data from external
|
|
68
|
-
return customFonts?.map(font =>
|
|
69
|
+
return customFonts?.map(font => getCssFromFont(font))?.join(' ') || '';
|
|
69
70
|
}
|
|
70
71
|
$: injectedStyles = () => {
|
|
71
72
|
return `
|
|
@@ -75,21 +76,15 @@ ${getFontCss({
|
|
|
75
76
|
})}`;
|
|
76
77
|
};
|
|
77
78
|
|
|
78
|
-
$: injectedStyleScript = () => {
|
|
79
|
-
return `<style>${injectedStyles()}</style>`;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
79
|
|
|
83
|
-
|
|
80
|
+
|
|
84
81
|
|
|
85
82
|
|
|
86
83
|
|
|
87
84
|
|
|
88
85
|
|
|
89
|
-
</script>
|
|
90
86
|
|
|
91
|
-
{#if TARGET === 'svelte' }
|
|
92
87
|
|
|
93
|
-
|
|
88
|
+
</script>
|
|
94
89
|
|
|
95
|
-
{
|
|
90
|
+
<RenderInlinedStyles styles={injectedStyles()} ></RenderInlinedStyles>
|