@builder.io/sdk-svelte 0.0.3 → 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 +160 -0
- package/package/blocks/BaseText.svelte +19 -0
- package/package/blocks/BaseText.svelte.d.ts +19 -0
- package/package/blocks/columns/columns.svelte +13 -4
- package/package/blocks/columns/columns.svelte.d.ts +1 -1
- package/package/blocks/custom-code/custom-code.svelte +1 -1
- package/package/blocks/embed/embed.svelte +2 -0
- package/package/blocks/form/form.svelte +7 -5
- package/package/blocks/image/image.svelte +48 -46
- package/package/blocks/image/image.svelte.d.ts +1 -1
- package/package/blocks/img/img.svelte +7 -2
- package/package/blocks/section/section.svelte +7 -2
- package/package/blocks/symbol/symbol.svelte +13 -13
- package/package/blocks/symbol/symbol.svelte.d.ts +3 -3
- package/package/blocks/video/video.svelte +14 -3
- package/package/components/render-block/block-styles.svelte +24 -19
- package/package/components/render-block/block-styles.svelte.d.ts +2 -2
- package/package/components/render-block/render-block.svelte +81 -58
- package/package/components/render-block/render-block.svelte.d.ts +2 -2
- package/package/components/render-block/render-component-with-context.svelte +32 -0
- package/package/components/render-block/render-component-with-context.svelte.d.ts +19 -0
- package/package/components/render-block/render-component.svelte +1 -3
- package/package/components/render-block/render-component.svelte.d.ts +2 -2
- package/package/components/render-block/render-repeated-block.svelte +3 -0
- package/package/components/render-block/types.d.ts +2 -2
- package/package/components/render-block/types.js +1 -2
- package/package/components/render-blocks.svelte +12 -1
- package/package/components/render-blocks.svelte.d.ts +3 -1
- package/package/components/render-content/components/render-styles.svelte +2 -1
- package/package/components/render-content/render-content.svelte +24 -8
- package/package/components/render-content/render-content.svelte.d.ts +2 -2
- package/package/constants/builder-registered-components.js +3 -0
- package/package/context/builder.context.d.ts +1 -0
- package/package/context/builder.context.js +1 -0
- package/package/context/types.d.ts +4 -3
- package/package/context/types.js +1 -3
- package/package/functions/extract-text-styles.d.ts +4 -0
- package/package/functions/extract-text-styles.js +34 -0
- package/package/functions/fast-clone.d.ts +4 -0
- package/package/functions/fast-clone.js +4 -0
- package/package/functions/get-block-actions-handler.d.ts +5 -0
- package/package/functions/get-block-actions-handler.js +9 -0
- package/package/functions/get-block-actions.d.ts +1 -1
- package/package/functions/get-block-actions.js +2 -8
- package/package/functions/get-block-component-options.d.ts +1 -1
- package/package/functions/get-block-component-options.js +0 -1
- package/package/functions/get-block-properties.d.ts +1 -1
- package/package/functions/get-block-properties.js +0 -1
- package/package/functions/get-block-tag.d.ts +1 -1
- package/package/functions/get-block-tag.js +0 -1
- package/package/functions/get-content/ab-testing.d.ts +5 -3
- package/package/functions/get-content/ab-testing.js +75 -37
- package/package/functions/get-content/index.d.ts +1 -1
- package/package/functions/get-content/index.js +4 -5
- package/package/functions/get-content/types.d.ts +7 -2
- package/package/functions/get-processed-block.d.ts +1 -1
- package/package/functions/get-processed-block.js +5 -4
- package/package/functions/get-processed-block.test.js +0 -1
- package/package/functions/get-react-native-block-styles.d.ts +6 -0
- package/package/functions/get-react-native-block-styles.js +16 -0
- package/package/functions/register-component.d.ts +2 -2
- package/package/functions/register-component.js +1 -5
- package/package/functions/register.d.ts +2 -2
- package/package/functions/register.js +0 -2
- package/package/functions/sanitize-react-native-block-styles.d.ts +3 -0
- package/package/functions/sanitize-react-native-block-styles.js +53 -0
- package/package/functions/track.d.ts +1 -1
- package/package/functions/track.js +5 -6
- package/package/functions/transform-block.d.ts +1 -1
- package/package/functions/transform-block.js +0 -1
- package/package/helpers/ab-tests.d.ts +8 -0
- package/package/helpers/ab-tests.js +5 -0
- package/package/helpers/cookie.d.ts +9 -3
- package/package/helpers/cookie.js +8 -3
- package/package/helpers/css.d.ts +5 -1
- package/package/helpers/css.js +14 -1
- package/package/helpers/localStorage.d.ts +3 -4
- package/package/helpers/sessionId.d.ts +3 -4
- package/package/helpers/sessionId.js +5 -3
- package/package/helpers/visitorId.d.ts +3 -5
- package/package/scripts/init-editing.js +42 -38
- package/package/types/builder-content.d.ts +1 -1
- package/package/types/builder-content.js +1 -1
- package/package/types/targets.d.ts +1 -1
- package/package/types/typescript.d.ts +1 -0
- package/package.json +10 -4
- package/src/blocks/BaseText.svelte +27 -0
- package/{package/blocks/button/button.lite.tsx → src/blocks/button/button.svelte} +0 -0
- package/src/blocks/button/component-info.ts +42 -0
- package/{package/blocks/columns/columns.lite.tsx → src/blocks/columns/columns.svelte} +26 -17
- package/src/blocks/columns/component-info.ts +254 -0
- package/src/blocks/custom-code/component-info.ts +31 -0
- package/{package/blocks/custom-code/custom-code.lite.tsx → src/blocks/custom-code/custom-code.svelte} +1 -5
- package/src/blocks/embed/component-info.ts +53 -0
- package/{package/blocks/embed/embed.lite.tsx → src/blocks/embed/embed.svelte} +1 -2
- package/src/blocks/embed/helpers.ts +8 -0
- package/src/blocks/form/component-info.ts +282 -0
- package/{package/blocks/form/form.lite.tsx → src/blocks/form/form.svelte} +12 -31
- package/src/blocks/fragment/component-info.ts +10 -0
- package/{package/blocks/fragment/fragment.lite.tsx → src/blocks/fragment/fragment.svelte} +0 -0
- package/src/blocks/image/component-info.ts +170 -0
- package/src/blocks/image/image.helpers.ts +75 -0
- package/{package/blocks/image/image.lite.tsx → src/blocks/image/image.svelte} +47 -50
- package/src/blocks/img/component-info.ts +21 -0
- package/{package/blocks/img/img.lite.tsx → src/blocks/img/img.svelte} +6 -3
- package/src/blocks/input/component-info.ts +78 -0
- package/{package/blocks/input/input.lite.tsx → src/blocks/input/input.svelte} +0 -0
- package/src/blocks/raw-text/component-info.ts +15 -0
- package/{package/blocks/raw-text/raw-text.lite.tsx → src/blocks/raw-text/raw-text.svelte} +2 -1
- package/src/blocks/section/component-info.ts +50 -0
- package/{package/blocks/section/section.lite.tsx → src/blocks/section/section.svelte} +6 -2
- package/src/blocks/select/component-info.ts +61 -0
- package/{package/blocks/select/select.lite.tsx → src/blocks/select/select.svelte} +0 -0
- package/src/blocks/submit-button/component-info.ts +32 -0
- package/{package/blocks/submit-button/submit-button.lite.tsx → src/blocks/submit-button/submit-button.svelte} +0 -0
- package/src/blocks/symbol/component-info.ts +43 -0
- package/{package/blocks/symbol/symbol.lite.tsx → src/blocks/symbol/symbol.svelte} +23 -15
- package/src/blocks/text/component-info.ts +24 -0
- package/{package/blocks/text/text.lite.tsx → src/blocks/text/text.svelte} +0 -0
- package/src/blocks/textarea/component-info.ts +48 -0
- package/{package/blocks/textarea/textarea.lite.tsx → src/blocks/textarea/textarea.svelte} +0 -0
- package/src/blocks/util.ts +6 -0
- package/src/blocks/video/component-info.ts +109 -0
- package/{package/blocks/video/video.lite.tsx → src/blocks/video/video.svelte} +13 -3
- package/{package/components/render-block/block-styles.lite.tsx → src/components/render-block/block-styles.svelte} +28 -26
- package/src/components/render-block/render-block.helpers.ts +27 -0
- package/{package/components/render-block/render-block.lite.tsx → src/components/render-block/render-block.svelte} +93 -81
- package/src/components/render-block/render-component-with-context.svelte +38 -0
- package/{package/components/render-block/render-component.lite.tsx → src/components/render-block/render-component.svelte} +5 -3
- package/{package/components/render-block/render-repeated-block.lite.tsx → src/components/render-block/render-repeated-block.svelte} +4 -0
- package/src/components/render-block/types.ts +7 -0
- package/{package/components/render-blocks.lite.tsx → src/components/render-blocks.svelte} +15 -2
- package/{package/components/render-content/components/render-styles.lite.tsx → src/components/render-content/components/render-styles.svelte} +2 -8
- package/src/components/render-content/index.ts +1 -0
- package/{package/components/render-content/render-content.lite.tsx → src/components/render-content/render-content.svelte} +34 -36
- package/{package/components/render-inlined-styles.lite.tsx → src/components/render-inlined-styles.svelte} +0 -1
- 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
- package/package/blocks/button/button.lite.d.ts +0 -0
- package/package/blocks/columns/columns.lite.d.ts +0 -0
- package/package/blocks/custom-code/custom-code.lite.d.ts +0 -0
- package/package/blocks/embed/embed.lite.d.ts +0 -0
- package/package/blocks/form/form.lite.d.ts +0 -0
- package/package/blocks/fragment/fragment.lite.d.ts +0 -0
- package/package/blocks/image/image.lite.d.ts +0 -0
- package/package/blocks/img/img.lite.d.ts +0 -0
- package/package/blocks/input/input.lite.d.ts +0 -0
- package/package/blocks/raw-text/raw-text.lite.d.ts +0 -0
- package/package/blocks/section/section.lite.d.ts +0 -0
- package/package/blocks/select/select.lite.d.ts +0 -0
- package/package/blocks/submit-button/submit-button.lite.d.ts +0 -0
- package/package/blocks/symbol/symbol.lite.d.ts +0 -0
- package/package/blocks/text/text.lite.d.ts +0 -0
- package/package/blocks/textarea/textarea.lite.d.ts +0 -0
- package/package/blocks/video/video.lite.d.ts +0 -0
- package/package/components/render-block/block-styles.lite.d.ts +0 -0
- package/package/components/render-block/render-block.lite.d.ts +0 -0
- package/package/components/render-block/render-component.lite.d.ts +0 -0
- package/package/components/render-block/render-repeated-block.lite.d.ts +0 -0
- package/package/components/render-blocks.lite.d.ts +0 -0
- package/package/components/render-content/components/render-styles.lite.d.ts +0 -0
- package/package/components/render-content/render-content.lite.d.ts +0 -0
- package/package/components/render-inlined-styles.lite.d.ts +0 -0
- package/package/functions/convert-style-object.d.ts +0 -1
- package/package/functions/convert-style-object.js +0 -3
- package/package/functions/get-block-styles.d.ts +0 -2
- package/package/functions/get-block-styles.js +0 -21
- package/package/functions/sanitize-styles.d.ts +0 -4
- package/package/functions/sanitize-styles.js +0 -6
|
@@ -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
|
+
};
|
|
File without changes
|
|
@@ -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
|
+
};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
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
|
+
|
|
2
8
|
export interface SymbolInfo {
|
|
3
9
|
model?: string;
|
|
4
10
|
entry?: string;
|
|
@@ -19,30 +25,28 @@
|
|
|
19
25
|
</script>
|
|
20
26
|
|
|
21
27
|
<script lang="ts">
|
|
22
|
-
import { afterUpdate, getContext,
|
|
28
|
+
import { afterUpdate, getContext, setContext } from "svelte";
|
|
23
29
|
|
|
24
30
|
import RenderContent from "../../components/render-content/render-content.svelte";
|
|
25
31
|
import BuilderContext from "../../context/builder.context.js";
|
|
26
32
|
import { getContent } from "../../functions/get-content/index.js";
|
|
27
|
-
import { BuilderContent } from "../../types/builder-content.js";
|
|
28
|
-
import { Nullable } from "../../types/typescript.js";
|
|
29
|
-
import { BuilderBlock } from "../../types/builder-block.js";
|
|
30
33
|
import { markMutable } from "../../functions/mark-mutable";
|
|
31
34
|
|
|
32
|
-
export let attributes: SymbolProps["attributes"];
|
|
33
35
|
export let symbol: SymbolProps["symbol"];
|
|
36
|
+
export let attributes: SymbolProps["attributes"];
|
|
34
37
|
|
|
35
38
|
let builderContext = getContext(BuilderContext.key);
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
$: contentToUse = () => {
|
|
41
|
+
return symbol?.content || fetchedContent;
|
|
42
|
+
};
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
44
|
+
let className = "builder-symbol";
|
|
45
|
+
let fetchedContent = null;
|
|
43
46
|
|
|
44
47
|
function onUpdateFn_0() {
|
|
45
48
|
const symbolToUse = symbol;
|
|
49
|
+
|
|
46
50
|
/**
|
|
47
51
|
* If:
|
|
48
52
|
* - we have a symbol prop
|
|
@@ -52,8 +56,12 @@
|
|
|
52
56
|
*
|
|
53
57
|
* then we want to re-fetch the symbol content.
|
|
54
58
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
if (
|
|
60
|
+
symbolToUse &&
|
|
61
|
+
!symbolToUse.content &&
|
|
62
|
+
!fetchedContent &&
|
|
63
|
+
symbolToUse.model
|
|
64
|
+
) {
|
|
57
65
|
getContent({
|
|
58
66
|
model: symbolToUse.model,
|
|
59
67
|
apiKey: builderContext.apiKey,
|
|
@@ -61,11 +69,11 @@
|
|
|
61
69
|
id: symbolToUse.entry,
|
|
62
70
|
},
|
|
63
71
|
}).then((response) => {
|
|
64
|
-
|
|
72
|
+
fetchedContent = response;
|
|
65
73
|
});
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
|
-
$: onUpdateFn_0(...[symbol,
|
|
76
|
+
$: onUpdateFn_0(...[symbol, fetchedContent]);
|
|
69
77
|
</script>
|
|
70
78
|
|
|
71
79
|
<div
|
|
@@ -87,6 +95,6 @@
|
|
|
87
95
|
...symbol?.content?.data?.state,
|
|
88
96
|
})}
|
|
89
97
|
model={symbol?.model}
|
|
90
|
-
content={markMutable(
|
|
98
|
+
content={markMutable(contentToUse())}
|
|
91
99
|
/>
|
|
92
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
|
+
};
|
|
File without changes
|
|
@@ -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
|
+
};
|
|
File without changes
|
|
@@ -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
|
+
};
|
|
@@ -39,8 +39,12 @@
|
|
|
39
39
|
export let posterImage: VideoProps["posterImage"];
|
|
40
40
|
|
|
41
41
|
function mitosis_styling(node, vars) {
|
|
42
|
-
Object.entries(vars).forEach(([p, v]) => {
|
|
43
|
-
|
|
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
|
+
}
|
|
44
48
|
});
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -73,10 +77,16 @@
|
|
|
73
77
|
: {}),
|
|
74
78
|
};
|
|
75
79
|
};
|
|
80
|
+
$: spreadProps = () => {
|
|
81
|
+
return {
|
|
82
|
+
...attributes,
|
|
83
|
+
...videoProps(),
|
|
84
|
+
};
|
|
85
|
+
};
|
|
76
86
|
</script>
|
|
77
87
|
|
|
78
88
|
<video
|
|
79
|
-
{...
|
|
89
|
+
{...spreadProps()}
|
|
80
90
|
use:mitosis_styling={{
|
|
81
91
|
width: "100%",
|
|
82
92
|
height: "100%",
|
|
@@ -1,4 +1,8 @@
|
|
|
1
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
|
+
|
|
2
6
|
export type BlockStylesProps = {
|
|
3
7
|
block: BuilderBlock;
|
|
4
8
|
context: BuilderContextInterface;
|
|
@@ -8,10 +12,8 @@
|
|
|
8
12
|
<script lang="ts">
|
|
9
13
|
import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
|
|
10
14
|
import { TARGET } from "../../constants/target.js";
|
|
11
|
-
import { BuilderContextInterface } from "../../context/types.js";
|
|
12
15
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
13
|
-
import {
|
|
14
|
-
import { BuilderBlock } from "../../types/builder-block.js";
|
|
16
|
+
import { createCssClass } from "../../helpers/css.js";
|
|
15
17
|
import RenderInlinedStyles from "../render-inlined-styles.svelte";
|
|
16
18
|
|
|
17
19
|
export let block: BlockStylesProps["block"];
|
|
@@ -25,36 +27,36 @@
|
|
|
25
27
|
shouldEvaluateBindings: true,
|
|
26
28
|
});
|
|
27
29
|
};
|
|
28
|
-
|
|
29
30
|
$: css = () => {
|
|
30
31
|
const styles = useBlock().responsiveStyles;
|
|
31
32
|
const largeStyles = styles?.large;
|
|
32
33
|
const mediumStyles = styles?.medium;
|
|
33
34
|
const smallStyles = styles?.small;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
: ""
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
: ""
|
|
53
|
-
|
|
54
|
-
|
|
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(" ");
|
|
55
57
|
};
|
|
56
58
|
</script>
|
|
57
59
|
|
|
58
|
-
{#if TARGET
|
|
60
|
+
{#if TARGET !== "reactNative" && css()}
|
|
59
61
|
<RenderInlinedStyles styles={css()} />
|
|
60
62
|
{/if}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
|
|
3
|
+
*/
|
|
4
|
+
const EMPTY_HTML_ELEMENTS = [
|
|
5
|
+
'area',
|
|
6
|
+
'base',
|
|
7
|
+
'br',
|
|
8
|
+
'col',
|
|
9
|
+
'embed',
|
|
10
|
+
'hr',
|
|
11
|
+
'img',
|
|
12
|
+
'input',
|
|
13
|
+
'keygen',
|
|
14
|
+
'link',
|
|
15
|
+
'meta',
|
|
16
|
+
'param',
|
|
17
|
+
'source',
|
|
18
|
+
'track',
|
|
19
|
+
'wbr',
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export const isEmptyHtmlElement = (tagName: unknown) => {
|
|
23
|
+
return (
|
|
24
|
+
typeof tagName === 'string' &&
|
|
25
|
+
EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase())
|
|
26
|
+
);
|
|
27
|
+
};
|