@builder.io/sdk-svelte 0.0.4 → 0.0.5
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 -2
- package/package.json +3 -2
- package/src/blocks/BaseText.svelte +27 -0
- package/src/blocks/button/button.svelte +36 -0
- package/src/blocks/button/component-info.ts +42 -0
- package/src/blocks/columns/columns.svelte +148 -0
- package/src/blocks/columns/component-info.ts +254 -0
- package/src/blocks/custom-code/component-info.ts +31 -0
- package/src/blocks/custom-code/custom-code.svelte +66 -0
- package/src/blocks/embed/component-info.ts +53 -0
- package/src/blocks/embed/embed.svelte +51 -0
- package/src/blocks/embed/helpers.ts +8 -0
- package/src/blocks/form/component-info.ts +282 -0
- package/src/blocks/form/form.svelte +332 -0
- package/src/blocks/fragment/component-info.ts +10 -0
- package/src/blocks/fragment/fragment.svelte +12 -0
- package/src/blocks/image/component-info.ts +170 -0
- package/src/blocks/image/image.helpers.ts +75 -0
- package/src/blocks/image/image.svelte +145 -0
- package/src/blocks/img/component-info.ts +21 -0
- package/src/blocks/img/img.svelte +51 -0
- package/src/blocks/input/component-info.ts +78 -0
- package/src/blocks/input/input.svelte +34 -0
- package/src/blocks/raw-text/component-info.ts +15 -0
- package/src/blocks/raw-text/raw-text.svelte +16 -0
- package/src/blocks/section/component-info.ts +50 -0
- package/src/blocks/section/section.svelte +34 -0
- package/src/blocks/select/component-info.ts +61 -0
- package/src/blocks/select/select.svelte +34 -0
- package/src/blocks/submit-button/component-info.ts +32 -0
- package/src/blocks/submit-button/submit-button.svelte +15 -0
- package/src/blocks/symbol/component-info.ts +43 -0
- package/src/blocks/symbol/symbol.svelte +100 -0
- package/src/blocks/text/component-info.ts +24 -0
- package/src/blocks/text/text.svelte +11 -0
- package/src/blocks/textarea/component-info.ts +48 -0
- package/src/blocks/textarea/textarea.svelte +19 -0
- package/src/blocks/util.ts +6 -0
- package/src/blocks/video/component-info.ts +109 -0
- package/src/blocks/video/video.svelte +102 -0
- package/src/components/render-block/block-styles.svelte +62 -0
- package/src/components/render-block/render-block.helpers.ts +27 -0
- package/src/components/render-block/render-block.svelte +228 -0
- package/src/components/render-block/render-component-with-context.svelte +38 -0
- package/src/components/render-block/render-component.svelte +35 -0
- package/src/components/render-block/render-repeated-block.svelte +53 -0
- package/src/components/render-block/types.ts +7 -0
- package/src/components/render-blocks.svelte +104 -0
- package/src/components/render-content/components/render-styles.svelte +80 -0
- package/src/components/render-content/index.ts +1 -0
- package/src/components/render-content/render-content.svelte +354 -0
- package/src/components/render-inlined-styles.svelte +26 -0
- package/src/constants/builder-registered-components.ts +42 -0
- package/src/constants/device-sizes.ts +28 -0
- package/src/constants/target.ts +2 -0
- package/src/context/builder.context.ts +13 -0
- package/src/context/types.ts +23 -0
- package/src/functions/camel-to-kebab-case.ts +2 -0
- package/src/functions/evaluate.ts +52 -0
- package/src/functions/event-handler-name.ts +6 -0
- package/src/functions/extract-text-styles.ts +39 -0
- package/src/functions/fast-clone.ts +5 -0
- package/src/functions/get-block-actions-handler.ts +19 -0
- package/src/functions/get-block-actions.ts +25 -0
- package/src/functions/get-block-component-options.ts +12 -0
- package/src/functions/get-block-properties.ts +11 -0
- package/src/functions/get-block-tag.ts +7 -0
- package/src/functions/get-builder-search-params/fn.test.ts +19 -0
- package/src/functions/get-builder-search-params/index.ts +48 -0
- package/src/functions/get-content/ab-testing.ts +132 -0
- package/src/functions/get-content/fn.test.ts +35 -0
- package/src/functions/get-content/index.ts +77 -0
- package/src/functions/get-content/types.ts +36 -0
- package/src/functions/get-fetch.ts +14 -0
- package/src/functions/get-global-this.ts +15 -0
- package/src/functions/get-processed-block.test.ts +33 -0
- package/src/functions/get-processed-block.ts +54 -0
- package/src/functions/get-react-native-block-styles.ts +30 -0
- package/src/functions/if-target.ts +20 -0
- package/src/functions/is-browser.ts +3 -0
- package/src/functions/is-editing.ts +7 -0
- package/src/functions/is-iframe.ts +5 -0
- package/src/functions/is-previewing.ts +14 -0
- package/src/functions/mark-mutable.ts +7 -0
- package/src/functions/on-change.test.ts +23 -0
- package/src/functions/on-change.ts +29 -0
- package/src/functions/register-component.ts +67 -0
- package/src/functions/register.ts +46 -0
- package/src/functions/sanitize-react-native-block-styles.ts +65 -0
- package/src/functions/set-editor-settings.ts +16 -0
- package/src/functions/set.test.ts +19 -0
- package/src/functions/set.ts +26 -0
- package/src/functions/track.ts +90 -0
- package/src/functions/transform-block.ts +6 -0
- package/src/helpers/ab-tests.ts +22 -0
- package/src/helpers/cookie.ts +102 -0
- package/src/helpers/css.ts +33 -0
- package/src/helpers/flatten.ts +24 -0
- package/src/helpers/localStorage.ts +38 -0
- package/src/helpers/nullable.ts +4 -0
- package/src/helpers/sessionId.ts +34 -0
- package/src/helpers/time.ts +4 -0
- package/src/helpers/url.test.ts +16 -0
- package/src/helpers/url.ts +12 -0
- package/src/helpers/uuid.ts +17 -0
- package/src/helpers/visitorId.ts +38 -0
- package/src/index-helpers/blocks-exports.ts +10 -0
- package/src/index-helpers/top-of-file.ts +4 -0
- package/src/index.ts +12 -0
- package/src/scripts/init-editing.ts +102 -0
- package/src/types/builder-block.ts +58 -0
- package/src/types/builder-content.ts +39 -0
- package/src/types/can-track.ts +3 -0
- package/src/types/components.ts +188 -0
- package/src/types/deep-partial.ts +7 -0
- package/src/types/element.ts +60 -0
- package/src/types/targets.ts +6 -0
- package/src/types/typescript.ts +7 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
|
|
3
|
+
export const componentInfo: ComponentInfo = {
|
|
4
|
+
name: 'Form:Select',
|
|
5
|
+
builtIn: true,
|
|
6
|
+
image:
|
|
7
|
+
'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F83acca093fb24aaf94dee136e9a4b045',
|
|
8
|
+
defaultStyles: {
|
|
9
|
+
alignSelf: 'flex-start',
|
|
10
|
+
},
|
|
11
|
+
inputs: [
|
|
12
|
+
{
|
|
13
|
+
name: 'options',
|
|
14
|
+
type: 'list',
|
|
15
|
+
required: true,
|
|
16
|
+
subFields: [
|
|
17
|
+
{
|
|
18
|
+
name: 'value',
|
|
19
|
+
type: 'text',
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'name',
|
|
24
|
+
type: 'text',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
defaultValue: [
|
|
28
|
+
{
|
|
29
|
+
value: 'option 1',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
value: 'option 2',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'name',
|
|
38
|
+
type: 'string',
|
|
39
|
+
required: true,
|
|
40
|
+
helperText:
|
|
41
|
+
'Every select in a form needs a unique name describing what it gets, e.g. "email"',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'defaultValue',
|
|
45
|
+
type: 'string',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'value',
|
|
49
|
+
type: 'string',
|
|
50
|
+
advanced: true,
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
{
|
|
54
|
+
name: 'required',
|
|
55
|
+
type: 'boolean',
|
|
56
|
+
defaultValue: false,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
static: true,
|
|
60
|
+
noWrap: true,
|
|
61
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface FormSelectProps {
|
|
3
|
+
options?: {
|
|
4
|
+
name?: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}[];
|
|
7
|
+
attributes?: any;
|
|
8
|
+
name?: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
16
|
+
|
|
17
|
+
export let attributes: FormSelectProps["attributes"];
|
|
18
|
+
export let value: FormSelectProps["value"];
|
|
19
|
+
export let defaultValue: FormSelectProps["defaultValue"];
|
|
20
|
+
export let name: FormSelectProps["name"];
|
|
21
|
+
export let options: FormSelectProps["options"];
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<select
|
|
25
|
+
{...attributes}
|
|
26
|
+
{value}
|
|
27
|
+
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
28
|
+
{defaultValue}
|
|
29
|
+
{name}
|
|
30
|
+
>
|
|
31
|
+
{#each options as option}
|
|
32
|
+
<option value={option.value}>{option.name || option.value}</option>
|
|
33
|
+
{/each}
|
|
34
|
+
</select>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
|
|
3
|
+
export const componentInfo: ComponentInfo = {
|
|
4
|
+
name: 'Form:SubmitButton',
|
|
5
|
+
builtIn: true,
|
|
6
|
+
image:
|
|
7
|
+
'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fdf2820ffed1f4349a94c40b3221f5b98',
|
|
8
|
+
defaultStyles: {
|
|
9
|
+
appearance: 'none',
|
|
10
|
+
paddingTop: '15px',
|
|
11
|
+
paddingBottom: '15px',
|
|
12
|
+
paddingLeft: '25px',
|
|
13
|
+
paddingRight: '25px',
|
|
14
|
+
backgroundColor: '#3898EC',
|
|
15
|
+
color: 'white',
|
|
16
|
+
borderRadius: '4px',
|
|
17
|
+
cursor: 'pointer',
|
|
18
|
+
},
|
|
19
|
+
inputs: [
|
|
20
|
+
{
|
|
21
|
+
name: 'text',
|
|
22
|
+
type: 'text',
|
|
23
|
+
defaultValue: 'Click me',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
static: true,
|
|
27
|
+
noWrap: true,
|
|
28
|
+
// TODO: optional children? maybe as optional form input
|
|
29
|
+
// that only shows if advanced setting is flipped
|
|
30
|
+
// TODO: defaultChildren
|
|
31
|
+
// canHaveChildren: true,
|
|
32
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface ButtonProps {
|
|
3
|
+
attributes?: any;
|
|
4
|
+
text?: string;
|
|
5
|
+
}
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
export let attributes: ButtonProps["attributes"];
|
|
10
|
+
export let text: ButtonProps["text"];
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<button {...attributes} type="submit">
|
|
14
|
+
{text}
|
|
15
|
+
</button>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
|
|
3
|
+
export const componentInfo: ComponentInfo = {
|
|
4
|
+
name: 'Symbol',
|
|
5
|
+
noWrap: true,
|
|
6
|
+
static: true,
|
|
7
|
+
builtIn: true,
|
|
8
|
+
inputs: [
|
|
9
|
+
{
|
|
10
|
+
name: 'symbol',
|
|
11
|
+
type: 'uiSymbol',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'dataOnly',
|
|
15
|
+
helperText: "Make this a data symbol that doesn't display any UI",
|
|
16
|
+
type: 'boolean',
|
|
17
|
+
defaultValue: false,
|
|
18
|
+
advanced: true,
|
|
19
|
+
hideFromUI: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'inheritState',
|
|
23
|
+
helperText: 'Inherit the parent component state and data',
|
|
24
|
+
type: 'boolean',
|
|
25
|
+
defaultValue: false,
|
|
26
|
+
advanced: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'renderToLiquid',
|
|
30
|
+
helperText:
|
|
31
|
+
'Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting',
|
|
32
|
+
type: 'boolean',
|
|
33
|
+
defaultValue: false,
|
|
34
|
+
advanced: true,
|
|
35
|
+
hideFromUI: true,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'useChildren',
|
|
39
|
+
hideFromUI: true,
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
import type { BuilderContent } from "../../types/builder-content.js";
|
|
3
|
+
|
|
4
|
+
import type { Nullable } from "../../types/typescript.js";
|
|
5
|
+
|
|
6
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
7
|
+
|
|
8
|
+
export interface SymbolInfo {
|
|
9
|
+
model?: string;
|
|
10
|
+
entry?: string;
|
|
11
|
+
data?: any;
|
|
12
|
+
content?: BuilderContent;
|
|
13
|
+
inline?: boolean;
|
|
14
|
+
dynamic?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SymbolProps {
|
|
18
|
+
symbol?: SymbolInfo;
|
|
19
|
+
dataOnly?: boolean;
|
|
20
|
+
dynamic?: boolean;
|
|
21
|
+
builderBlock?: BuilderBlock;
|
|
22
|
+
attributes?: any;
|
|
23
|
+
inheritState?: boolean;
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script lang="ts">
|
|
28
|
+
import { afterUpdate, getContext, setContext } from "svelte";
|
|
29
|
+
|
|
30
|
+
import RenderContent from "../../components/render-content/render-content.svelte";
|
|
31
|
+
import BuilderContext from "../../context/builder.context.js";
|
|
32
|
+
import { getContent } from "../../functions/get-content/index.js";
|
|
33
|
+
import { markMutable } from "../../functions/mark-mutable";
|
|
34
|
+
|
|
35
|
+
export let symbol: SymbolProps["symbol"];
|
|
36
|
+
export let attributes: SymbolProps["attributes"];
|
|
37
|
+
|
|
38
|
+
let builderContext = getContext(BuilderContext.key);
|
|
39
|
+
|
|
40
|
+
$: contentToUse = () => {
|
|
41
|
+
return symbol?.content || fetchedContent;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
let className = "builder-symbol";
|
|
45
|
+
let fetchedContent = null;
|
|
46
|
+
|
|
47
|
+
function onUpdateFn_0() {
|
|
48
|
+
const symbolToUse = symbol;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* If:
|
|
52
|
+
* - we have a symbol prop
|
|
53
|
+
* - yet it does not have any content
|
|
54
|
+
* - and we have not already stored content from before
|
|
55
|
+
* - and it has a model name
|
|
56
|
+
*
|
|
57
|
+
* then we want to re-fetch the symbol content.
|
|
58
|
+
*/
|
|
59
|
+
if (
|
|
60
|
+
symbolToUse &&
|
|
61
|
+
!symbolToUse.content &&
|
|
62
|
+
!fetchedContent &&
|
|
63
|
+
symbolToUse.model
|
|
64
|
+
) {
|
|
65
|
+
getContent({
|
|
66
|
+
model: symbolToUse.model,
|
|
67
|
+
apiKey: builderContext.apiKey,
|
|
68
|
+
query: {
|
|
69
|
+
id: symbolToUse.entry,
|
|
70
|
+
},
|
|
71
|
+
}).then((response) => {
|
|
72
|
+
fetchedContent = response;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
$: onUpdateFn_0(...[symbol, fetchedContent]);
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<div
|
|
80
|
+
{...attributes}
|
|
81
|
+
dataSet={{
|
|
82
|
+
class: className,
|
|
83
|
+
}}
|
|
84
|
+
class={className}
|
|
85
|
+
>
|
|
86
|
+
<RenderContent
|
|
87
|
+
apiKey={builderContext.apiKey}
|
|
88
|
+
context={builderContext.context}
|
|
89
|
+
customComponents={markMutable(
|
|
90
|
+
Object.values(builderContext.registeredComponents)
|
|
91
|
+
)}
|
|
92
|
+
data={markMutable({
|
|
93
|
+
...symbol?.data,
|
|
94
|
+
...builderContext.state,
|
|
95
|
+
...symbol?.content?.data?.state,
|
|
96
|
+
})}
|
|
97
|
+
model={symbol?.model}
|
|
98
|
+
content={markMutable(contentToUse())}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
|
|
3
|
+
export const componentInfo: ComponentInfo = {
|
|
4
|
+
name: 'Text',
|
|
5
|
+
static: true,
|
|
6
|
+
builtIn: true,
|
|
7
|
+
image:
|
|
8
|
+
'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929',
|
|
9
|
+
inputs: [
|
|
10
|
+
{
|
|
11
|
+
name: 'text',
|
|
12
|
+
type: 'html',
|
|
13
|
+
required: true,
|
|
14
|
+
autoFocus: true,
|
|
15
|
+
bubble: true,
|
|
16
|
+
defaultValue: 'Enter some text...',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
defaultStyles: {
|
|
20
|
+
lineHeight: 'normal',
|
|
21
|
+
height: 'auto',
|
|
22
|
+
textAlign: 'center',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
|
|
3
|
+
export const componentInfo: ComponentInfo = {
|
|
4
|
+
name: 'Form:TextArea',
|
|
5
|
+
builtIn: true,
|
|
6
|
+
image:
|
|
7
|
+
'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3',
|
|
8
|
+
inputs: [
|
|
9
|
+
{
|
|
10
|
+
advanced: true,
|
|
11
|
+
name: 'value',
|
|
12
|
+
type: 'string',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'name',
|
|
16
|
+
type: 'string',
|
|
17
|
+
required: true,
|
|
18
|
+
helperText:
|
|
19
|
+
'Every input in a form needs a unique name describing what it gets, e.g. "email"',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'defaultValue',
|
|
23
|
+
type: 'string',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'placeholder',
|
|
27
|
+
type: 'string',
|
|
28
|
+
defaultValue: 'Hello there',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'required',
|
|
32
|
+
type: 'boolean',
|
|
33
|
+
defaultValue: false,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
defaultStyles: {
|
|
37
|
+
paddingTop: '10px',
|
|
38
|
+
paddingBottom: '10px',
|
|
39
|
+
paddingLeft: '10px',
|
|
40
|
+
paddingRight: '10px',
|
|
41
|
+
borderRadius: '3px',
|
|
42
|
+
borderWidth: '1px',
|
|
43
|
+
borderStyle: 'solid',
|
|
44
|
+
borderColor: '#ccc',
|
|
45
|
+
},
|
|
46
|
+
static: true,
|
|
47
|
+
noWrap: true,
|
|
48
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface TextareaProps {
|
|
3
|
+
attributes?: any;
|
|
4
|
+
name?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
}
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
export let attributes: TextareaProps["attributes"];
|
|
13
|
+
export let placeholder: TextareaProps["placeholder"];
|
|
14
|
+
export let name: TextareaProps["name"];
|
|
15
|
+
export let value: TextareaProps["value"];
|
|
16
|
+
export let defaultValue: TextareaProps["defaultValue"];
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<textarea {...attributes} {placeholder} {name} {value} {defaultValue} />
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
|
|
3
|
+
export const componentInfo: ComponentInfo = {
|
|
4
|
+
name: 'Video',
|
|
5
|
+
canHaveChildren: true,
|
|
6
|
+
builtIn: true,
|
|
7
|
+
defaultStyles: {
|
|
8
|
+
minHeight: '20px',
|
|
9
|
+
minWidth: '20px',
|
|
10
|
+
},
|
|
11
|
+
image:
|
|
12
|
+
'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',
|
|
13
|
+
inputs: [
|
|
14
|
+
{
|
|
15
|
+
name: 'video',
|
|
16
|
+
type: 'file',
|
|
17
|
+
allowedFileTypes: ['mp4'],
|
|
18
|
+
bubble: true,
|
|
19
|
+
defaultValue:
|
|
20
|
+
'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f',
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'posterImage',
|
|
25
|
+
type: 'file',
|
|
26
|
+
allowedFileTypes: ['jpeg', 'png'],
|
|
27
|
+
helperText: 'Image to show before the video plays',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'autoPlay',
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
defaultValue: true,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'controls',
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
defaultValue: false,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'muted',
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
defaultValue: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'loop',
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
defaultValue: true,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'playsInline',
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
defaultValue: true,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'fit',
|
|
56
|
+
type: 'text',
|
|
57
|
+
defaultValue: 'cover',
|
|
58
|
+
enum: ['contain', 'cover', 'fill', 'auto'],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'fitContent',
|
|
62
|
+
type: 'boolean',
|
|
63
|
+
helperText:
|
|
64
|
+
'When child blocks are provided, fit to them instead of using the aspect ratio',
|
|
65
|
+
defaultValue: true,
|
|
66
|
+
advanced: true,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'position',
|
|
70
|
+
type: 'text',
|
|
71
|
+
defaultValue: 'center',
|
|
72
|
+
enum: [
|
|
73
|
+
'center',
|
|
74
|
+
'top',
|
|
75
|
+
'left',
|
|
76
|
+
'right',
|
|
77
|
+
'bottom',
|
|
78
|
+
'top left',
|
|
79
|
+
'top right',
|
|
80
|
+
'bottom left',
|
|
81
|
+
'bottom right',
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'height',
|
|
86
|
+
type: 'number',
|
|
87
|
+
advanced: true,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'width',
|
|
91
|
+
type: 'number',
|
|
92
|
+
advanced: true,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'aspectRatio',
|
|
96
|
+
type: 'number',
|
|
97
|
+
advanced: true,
|
|
98
|
+
defaultValue: 0.7004048582995948,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'lazyLoad',
|
|
102
|
+
type: 'boolean',
|
|
103
|
+
helperText:
|
|
104
|
+
'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
|
|
105
|
+
defaultValue: true,
|
|
106
|
+
advanced: true,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface VideoProps {
|
|
3
|
+
attributes?: any;
|
|
4
|
+
video?: string;
|
|
5
|
+
autoPlay?: boolean;
|
|
6
|
+
controls?: boolean;
|
|
7
|
+
muted?: boolean;
|
|
8
|
+
loop?: boolean;
|
|
9
|
+
playsInline?: boolean;
|
|
10
|
+
aspectRatio?: number;
|
|
11
|
+
width?: number;
|
|
12
|
+
height?: number;
|
|
13
|
+
fit?: "contain" | "cover" | "fill";
|
|
14
|
+
position?:
|
|
15
|
+
| "center"
|
|
16
|
+
| "top"
|
|
17
|
+
| "left"
|
|
18
|
+
| "right"
|
|
19
|
+
| "bottom"
|
|
20
|
+
| "top left"
|
|
21
|
+
| "top right"
|
|
22
|
+
| "bottom left"
|
|
23
|
+
| "bottom right";
|
|
24
|
+
posterImage?: string;
|
|
25
|
+
lazyLoad?: boolean;
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
export let autoPlay: VideoProps["autoPlay"];
|
|
31
|
+
export let muted: VideoProps["muted"];
|
|
32
|
+
export let controls: VideoProps["controls"];
|
|
33
|
+
export let loop: VideoProps["loop"];
|
|
34
|
+
export let playsInline: VideoProps["playsInline"];
|
|
35
|
+
export let attributes: VideoProps["attributes"];
|
|
36
|
+
export let fit: VideoProps["fit"];
|
|
37
|
+
export let position: VideoProps["position"];
|
|
38
|
+
export let video: VideoProps["video"];
|
|
39
|
+
export let posterImage: VideoProps["posterImage"];
|
|
40
|
+
|
|
41
|
+
function mitosis_styling(node, vars) {
|
|
42
|
+
Object.entries(vars || {}).forEach(([p, v]) => {
|
|
43
|
+
if (p.startsWith("--")) {
|
|
44
|
+
node.style.setProperty(p, v);
|
|
45
|
+
} else {
|
|
46
|
+
node.style[p] = v;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
$: videoProps = () => {
|
|
52
|
+
return {
|
|
53
|
+
...(autoPlay === true
|
|
54
|
+
? {
|
|
55
|
+
autoPlay: true,
|
|
56
|
+
}
|
|
57
|
+
: {}),
|
|
58
|
+
...(muted === true
|
|
59
|
+
? {
|
|
60
|
+
muted: true,
|
|
61
|
+
}
|
|
62
|
+
: {}),
|
|
63
|
+
...(controls === true
|
|
64
|
+
? {
|
|
65
|
+
controls: true,
|
|
66
|
+
}
|
|
67
|
+
: {}),
|
|
68
|
+
...(loop === true
|
|
69
|
+
? {
|
|
70
|
+
loop: true,
|
|
71
|
+
}
|
|
72
|
+
: {}),
|
|
73
|
+
...(playsInline === true
|
|
74
|
+
? {
|
|
75
|
+
playsInline: true,
|
|
76
|
+
}
|
|
77
|
+
: {}),
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
$: spreadProps = () => {
|
|
81
|
+
return {
|
|
82
|
+
...attributes,
|
|
83
|
+
...videoProps(),
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<video
|
|
89
|
+
{...spreadProps()}
|
|
90
|
+
use:mitosis_styling={{
|
|
91
|
+
width: "100%",
|
|
92
|
+
height: "100%",
|
|
93
|
+
...attributes?.style,
|
|
94
|
+
objectFit: fit,
|
|
95
|
+
objectPosition: position,
|
|
96
|
+
// Hack to get object fit to work as expected and
|
|
97
|
+
// not have the video overflow
|
|
98
|
+
borderRadius: 1,
|
|
99
|
+
}}
|
|
100
|
+
src={video || "no-src"}
|
|
101
|
+
poster={posterImage}
|
|
102
|
+
/>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
import type { BuilderContextInterface } from "../../context/types.js";
|
|
3
|
+
|
|
4
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
5
|
+
|
|
6
|
+
export type BlockStylesProps = {
|
|
7
|
+
block: BuilderBlock;
|
|
8
|
+
context: BuilderContextInterface;
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
|
|
14
|
+
import { TARGET } from "../../constants/target.js";
|
|
15
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
16
|
+
import { createCssClass } from "../../helpers/css.js";
|
|
17
|
+
import RenderInlinedStyles from "../render-inlined-styles.svelte";
|
|
18
|
+
|
|
19
|
+
export let block: BlockStylesProps["block"];
|
|
20
|
+
export let context: BlockStylesProps["context"];
|
|
21
|
+
|
|
22
|
+
$: useBlock = () => {
|
|
23
|
+
return getProcessedBlock({
|
|
24
|
+
block: block,
|
|
25
|
+
state: context.state,
|
|
26
|
+
context: context.context,
|
|
27
|
+
shouldEvaluateBindings: true,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
$: css = () => {
|
|
31
|
+
const styles = useBlock().responsiveStyles;
|
|
32
|
+
const largeStyles = styles?.large;
|
|
33
|
+
const mediumStyles = styles?.medium;
|
|
34
|
+
const smallStyles = styles?.small;
|
|
35
|
+
const className = useBlock().id;
|
|
36
|
+
const largeStylesClass = largeStyles
|
|
37
|
+
? createCssClass({
|
|
38
|
+
className,
|
|
39
|
+
styles: largeStyles,
|
|
40
|
+
})
|
|
41
|
+
: "";
|
|
42
|
+
const mediumStylesClass = mediumStyles
|
|
43
|
+
? createCssClass({
|
|
44
|
+
className,
|
|
45
|
+
styles: mediumStyles,
|
|
46
|
+
mediaQuery: getMaxWidthQueryForSize("medium"),
|
|
47
|
+
})
|
|
48
|
+
: "";
|
|
49
|
+
const smallStylesClass = smallStyles
|
|
50
|
+
? createCssClass({
|
|
51
|
+
className,
|
|
52
|
+
styles: smallStyles,
|
|
53
|
+
mediaQuery: getMaxWidthQueryForSize("small"),
|
|
54
|
+
})
|
|
55
|
+
: "";
|
|
56
|
+
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
57
|
+
};
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
{#if TARGET !== "reactNative" && css()}
|
|
61
|
+
<RenderInlinedStyles styles={css()} />
|
|
62
|
+
{/if}
|