@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
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
<script>import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
|
|
4
4
|
import { TARGET } from "../../constants/target.js";
|
|
5
|
-
import "../../context/types.js";
|
|
6
5
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
7
|
-
import {
|
|
8
|
-
import "../../types/builder-block.js";
|
|
6
|
+
import { createCssClass } from "../../helpers/css.js";
|
|
9
7
|
import RenderInlinedStyles from "../render-inlined-styles.svelte";
|
|
10
8
|
export let block;
|
|
11
9
|
export let context;
|
|
@@ -22,24 +20,31 @@ $: css = () => {
|
|
|
22
20
|
const largeStyles = styles?.large;
|
|
23
21
|
const mediumStyles = styles?.medium;
|
|
24
22
|
const smallStyles = styles?.small;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
?
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
: ""
|
|
39
|
-
|
|
23
|
+
const className = useBlock().id;
|
|
24
|
+
const largeStylesClass = largeStyles
|
|
25
|
+
? createCssClass({
|
|
26
|
+
className,
|
|
27
|
+
styles: largeStyles,
|
|
28
|
+
})
|
|
29
|
+
: "";
|
|
30
|
+
const mediumStylesClass = mediumStyles
|
|
31
|
+
? createCssClass({
|
|
32
|
+
className,
|
|
33
|
+
styles: mediumStyles,
|
|
34
|
+
mediaQuery: getMaxWidthQueryForSize("medium"),
|
|
35
|
+
})
|
|
36
|
+
: "";
|
|
37
|
+
const smallStylesClass = smallStyles
|
|
38
|
+
? createCssClass({
|
|
39
|
+
className,
|
|
40
|
+
styles: smallStyles,
|
|
41
|
+
mediaQuery: getMaxWidthQueryForSize("small"),
|
|
42
|
+
})
|
|
43
|
+
: "";
|
|
44
|
+
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
40
45
|
};
|
|
41
46
|
</script>
|
|
42
47
|
|
|
43
|
-
{#if TARGET
|
|
48
|
+
{#if TARGET !== "reactNative" && css()}
|
|
44
49
|
<RenderInlinedStyles styles={css()} />
|
|
45
50
|
{/if}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { BuilderContextInterface } from "../../context/types.js";
|
|
3
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
2
4
|
export declare type BlockStylesProps = {
|
|
3
5
|
block: BuilderBlock;
|
|
4
6
|
context: BuilderContextInterface;
|
|
5
7
|
};
|
|
6
|
-
import { BuilderContextInterface } from "../../context/types.js";
|
|
7
|
-
import { BuilderBlock } from "../../types/builder-block.js";
|
|
8
8
|
declare const __propDef: {
|
|
9
9
|
props: {
|
|
10
10
|
block: BlockStylesProps["block"];
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
|
-
<script>import "../../
|
|
4
|
-
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
3
|
+
<script>import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
5
4
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
6
5
|
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
7
|
-
import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
8
6
|
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
9
7
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
10
|
-
import "../../types/builder-block.js";
|
|
11
|
-
import "../../types/typescript.js";
|
|
12
8
|
import { evaluate } from "../../functions/evaluate.js";
|
|
13
9
|
import BlockStyles from "./block-styles.svelte";
|
|
14
10
|
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
15
|
-
import RenderComponent from "./render-component.svelte";
|
|
16
|
-
import "./types.js";
|
|
17
11
|
import RenderRepeatedBlock from "./render-repeated-block.svelte";
|
|
12
|
+
import { TARGET } from "../../constants/target.js";
|
|
13
|
+
import { extractTextStyles } from "../../functions/extract-text-styles.js";
|
|
14
|
+
import RenderComponentWithContext from "./render-component-with-context.svelte";
|
|
15
|
+
import RenderComponent from "./render-component.svelte";
|
|
16
|
+
import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
|
|
18
17
|
export let block;
|
|
19
18
|
export let context;
|
|
20
19
|
$: component = () => {
|
|
@@ -39,18 +38,6 @@ $: component = () => {
|
|
|
39
38
|
return ref;
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
|
-
$: componentInfo = () => {
|
|
43
|
-
if (component()) {
|
|
44
|
-
const { component: _, ...info } = component();
|
|
45
|
-
return info;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
$: componentRef = () => {
|
|
52
|
-
return component?.()?.component;
|
|
53
|
-
};
|
|
54
41
|
$: tagName = () => {
|
|
55
42
|
return getBlockTag(useBlock());
|
|
56
43
|
};
|
|
@@ -72,39 +59,43 @@ $: attributes = () => {
|
|
|
72
59
|
state: context.state,
|
|
73
60
|
context: context.context,
|
|
74
61
|
}),
|
|
75
|
-
|
|
62
|
+
...(TARGET === "reactNative"
|
|
63
|
+
? {
|
|
64
|
+
style: getReactNativeBlockStyles({
|
|
65
|
+
block: useBlock(),
|
|
66
|
+
context: context,
|
|
67
|
+
}),
|
|
68
|
+
}
|
|
69
|
+
: {}),
|
|
76
70
|
};
|
|
77
71
|
};
|
|
78
72
|
$: shouldWrap = () => {
|
|
79
|
-
return !
|
|
80
|
-
};
|
|
81
|
-
$: componentOptions = () => {
|
|
82
|
-
return {
|
|
83
|
-
...getBlockComponentOptions(useBlock()),
|
|
84
|
-
/**
|
|
85
|
-
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
86
|
-
* they are provided to the component itself directly.
|
|
87
|
-
*/
|
|
88
|
-
...(shouldWrap()
|
|
89
|
-
? {}
|
|
90
|
-
: {
|
|
91
|
-
attributes: attributes(),
|
|
92
|
-
}),
|
|
93
|
-
};
|
|
73
|
+
return !component?.()?.noWrap;
|
|
94
74
|
};
|
|
95
75
|
$: renderComponentProps = () => {
|
|
96
76
|
return {
|
|
97
77
|
blockChildren: children(),
|
|
98
|
-
componentRef:
|
|
99
|
-
componentOptions:
|
|
100
|
-
|
|
78
|
+
componentRef: component?.()?.component,
|
|
79
|
+
componentOptions: {
|
|
80
|
+
...getBlockComponentOptions(useBlock()),
|
|
81
|
+
/**
|
|
82
|
+
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
83
|
+
* they are provided to the component itself directly.
|
|
84
|
+
*/
|
|
85
|
+
...(shouldWrap()
|
|
86
|
+
? {}
|
|
87
|
+
: {
|
|
88
|
+
attributes: attributes(),
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
context: childrenContext(),
|
|
101
92
|
};
|
|
102
93
|
};
|
|
103
94
|
$: children = () => {
|
|
104
95
|
// TO-DO: When should `canHaveChildren` dictate rendering?
|
|
105
96
|
// This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
|
|
106
97
|
// but still receive and need to render children.
|
|
107
|
-
// return componentInfo?.
|
|
98
|
+
// return componentInfo?.canHaveChildren ? useBlock().children : [];
|
|
108
99
|
return useBlock().children ?? [];
|
|
109
100
|
};
|
|
110
101
|
$: childrenWithoutParentComponent = () => {
|
|
@@ -114,7 +105,7 @@ $: childrenWithoutParentComponent = () => {
|
|
|
114
105
|
* NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
|
|
115
106
|
* blocks, and the children will be repeated within those blocks.
|
|
116
107
|
*/
|
|
117
|
-
const shouldRenderChildrenOutsideRef = !
|
|
108
|
+
const shouldRenderChildrenOutsideRef = !component?.()?.component && !repeatItemData();
|
|
118
109
|
return shouldRenderChildrenOutsideRef ? children() : [];
|
|
119
110
|
};
|
|
120
111
|
$: repeatItemData = () => {
|
|
@@ -151,35 +142,67 @@ $: repeatItemData = () => {
|
|
|
151
142
|
}));
|
|
152
143
|
return repeatArray;
|
|
153
144
|
};
|
|
145
|
+
$: inheritedTextStyles = () => {
|
|
146
|
+
if (TARGET !== "reactNative") {
|
|
147
|
+
return {};
|
|
148
|
+
}
|
|
149
|
+
const styles = getReactNativeBlockStyles({
|
|
150
|
+
block: useBlock(),
|
|
151
|
+
context: context,
|
|
152
|
+
});
|
|
153
|
+
return extractTextStyles(styles);
|
|
154
|
+
};
|
|
155
|
+
$: childrenContext = () => {
|
|
156
|
+
return {
|
|
157
|
+
apiKey: context.apiKey,
|
|
158
|
+
state: context.state,
|
|
159
|
+
content: context.content,
|
|
160
|
+
context: context.context,
|
|
161
|
+
registeredComponents: context.registeredComponents,
|
|
162
|
+
inheritedStyles: inheritedTextStyles(),
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
$: renderComponentTag = () => {
|
|
166
|
+
if (TARGET === "reactNative") {
|
|
167
|
+
return RenderComponentWithContext;
|
|
168
|
+
}
|
|
169
|
+
else if (TARGET === "vue3") {
|
|
170
|
+
// vue3 expects a string for the component tag
|
|
171
|
+
return "RenderComponent";
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
return RenderComponent;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
154
177
|
</script>
|
|
155
178
|
|
|
156
179
|
{#if shouldWrap()}
|
|
157
|
-
{#if
|
|
158
|
-
<svelte:element this={tagName()} {...attributes()}
|
|
159
|
-
|
|
160
|
-
{#each repeatItemData() as data, index (index)}
|
|
161
|
-
<RenderRepeatedBlock
|
|
162
|
-
repeatContext={data.context}
|
|
163
|
-
block={data.block}
|
|
164
|
-
/>
|
|
165
|
-
{/each}
|
|
166
|
-
{/if}
|
|
180
|
+
{#if isEmptyHtmlElement(tagName())}
|
|
181
|
+
<svelte:element this={tagName()} {...attributes()} />
|
|
182
|
+
{/if}
|
|
167
183
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
{
|
|
184
|
+
{#if !isEmptyHtmlElement(tagName()) && repeatItemData()}
|
|
185
|
+
{#each repeatItemData() as data, index (index)}
|
|
186
|
+
<RenderRepeatedBlock repeatContext={data.context} block={data.block} />
|
|
187
|
+
{/each}
|
|
188
|
+
{/if}
|
|
189
|
+
|
|
190
|
+
{#if !isEmptyHtmlElement(tagName()) && !repeatItemData()}
|
|
191
|
+
<svelte:element this={tagName()} {...attributes()}>
|
|
192
|
+
<svelte:component
|
|
193
|
+
this={renderComponentTag()}
|
|
194
|
+
{...renderComponentProps()}
|
|
195
|
+
/>
|
|
171
196
|
|
|
172
197
|
{#each childrenWithoutParentComponent() as child ("render-block-" + child.id)}
|
|
173
|
-
<svelte:self block={child} {
|
|
198
|
+
<svelte:self block={child} context={childrenContext()} />
|
|
174
199
|
{/each}
|
|
175
200
|
|
|
176
201
|
{#each childrenWithoutParentComponent() as child ("block-style-" + child.id)}
|
|
177
|
-
<BlockStyles block={child} {
|
|
202
|
+
<BlockStyles block={child} context={childrenContext()} />
|
|
178
203
|
{/each}
|
|
179
204
|
</svelte:element>
|
|
180
|
-
{:else}
|
|
181
|
-
<svelte:element this={tagName()} {...attributes()} />
|
|
182
205
|
{/if}
|
|
183
206
|
{:else}
|
|
184
|
-
<
|
|
207
|
+
<svelte:component this={renderComponentTag()} {...renderComponentProps()} />
|
|
185
208
|
{/if}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { BuilderContextInterface } from "../../context/types.js";
|
|
3
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
2
4
|
export declare type RenderBlockProps = {
|
|
3
5
|
block: BuilderBlock;
|
|
4
6
|
context: BuilderContextInterface;
|
|
5
7
|
};
|
|
6
|
-
import { BuilderContextInterface } from "../../context/types.js";
|
|
7
|
-
import { BuilderBlock } from "../../types/builder-block.js";
|
|
8
8
|
declare const __propDef: {
|
|
9
9
|
props: {
|
|
10
10
|
block: RenderBlockProps["block"];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>import { setContext } from "svelte";
|
|
4
|
+
import BuilderContext from "../../context/builder.context.js";
|
|
5
|
+
import RenderComponent from "./render-component.svelte";
|
|
6
|
+
export let componentRef;
|
|
7
|
+
export let componentOptions;
|
|
8
|
+
export let blockChildren;
|
|
9
|
+
export let context;
|
|
10
|
+
setContext(BuilderContext.key, {
|
|
11
|
+
get content() {
|
|
12
|
+
return context.content;
|
|
13
|
+
},
|
|
14
|
+
get state() {
|
|
15
|
+
return context.state;
|
|
16
|
+
},
|
|
17
|
+
get context() {
|
|
18
|
+
return context.context;
|
|
19
|
+
},
|
|
20
|
+
get apiKey() {
|
|
21
|
+
return context.apiKey;
|
|
22
|
+
},
|
|
23
|
+
get registeredComponents() {
|
|
24
|
+
return context.registeredComponents;
|
|
25
|
+
},
|
|
26
|
+
get inheritedStyles() {
|
|
27
|
+
return context.inheritedStyles;
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<RenderComponent {componentRef} {componentOptions} {blockChildren} {context} />
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
componentRef: RenderComponentProps;
|
|
5
|
+
componentOptions: RenderComponentProps;
|
|
6
|
+
blockChildren: RenderComponentProps;
|
|
7
|
+
context: RenderComponentProps;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export declare type RenderComponentWithContextProps = typeof __propDef.props;
|
|
15
|
+
export declare type RenderComponentWithContextEvents = typeof __propDef.events;
|
|
16
|
+
export declare type RenderComponentWithContextSlots = typeof __propDef.slots;
|
|
17
|
+
export default class RenderComponentWithContext extends SvelteComponentTyped<RenderComponentWithContextProps, RenderComponentWithContextEvents, RenderComponentWithContextSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
|
-
<script>import "
|
|
4
|
-
import BlockStyles from "./block-styles.svelte";
|
|
3
|
+
<script>import BlockStyles from "./block-styles.svelte";
|
|
5
4
|
import RenderBlock from "./render-block.svelte";
|
|
6
|
-
import "../../context/types.js";
|
|
7
5
|
import { markPropsMutable } from "../../functions/mark-mutable.js";
|
|
8
6
|
export let componentRef;
|
|
9
7
|
export let componentOptions;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
3
|
+
import type { BuilderContextInterface } from "../../context/types.js";
|
|
2
4
|
export interface RenderComponentProps {
|
|
3
5
|
componentRef: any;
|
|
4
6
|
componentOptions: any;
|
|
5
7
|
blockChildren: BuilderBlock[];
|
|
6
8
|
context: BuilderContextInterface;
|
|
7
9
|
}
|
|
8
|
-
import { BuilderBlock } from "../../types/builder-block.js";
|
|
9
|
-
import { BuilderContextInterface } from "../../context/types.js";
|
|
10
10
|
declare const __propDef: {
|
|
11
11
|
props: {
|
|
12
12
|
componentRef: RenderComponentProps["componentRef"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BuilderContextInterface } from '../../context/types.js';
|
|
2
|
-
import { BuilderBlock } from '../../types/builder-block.js';
|
|
1
|
+
import type { BuilderContextInterface } from '../../context/types.js';
|
|
2
|
+
import type { BuilderBlock } from '../../types/builder-block.js';
|
|
3
3
|
export interface RepeatData {
|
|
4
4
|
block: BuilderBlock;
|
|
5
5
|
context: BuilderContextInterface;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import '../../types/builder-block.js';
|
|
1
|
+
export {};
|
|
@@ -3,12 +3,22 @@
|
|
|
3
3
|
<script>import { getContext } from "svelte";
|
|
4
4
|
import BuilderContext from "../context/builder.context.js";
|
|
5
5
|
import { isEditing } from "../functions/is-editing.js";
|
|
6
|
-
import "../types/builder-block.js";
|
|
7
6
|
import BlockStyles from "./render-block/block-styles.svelte";
|
|
8
7
|
import RenderBlock from "./render-block/render-block.svelte";
|
|
9
8
|
export let blocks;
|
|
10
9
|
export let parent;
|
|
11
10
|
export let path;
|
|
11
|
+
export let styleProp;
|
|
12
|
+
function mitosis_styling(node, vars) {
|
|
13
|
+
Object.entries(vars || {}).forEach(([p, v]) => {
|
|
14
|
+
if (p.startsWith("--")) {
|
|
15
|
+
node.style.setProperty(p, v);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
node.style[p] = v;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
12
22
|
let builderContext = getContext(BuilderContext.key);
|
|
13
23
|
function onClick() {
|
|
14
24
|
if (isEditing() && !blocks?.length) {
|
|
@@ -38,6 +48,7 @@ $: className = () => {
|
|
|
38
48
|
</script>
|
|
39
49
|
|
|
40
50
|
<div
|
|
51
|
+
use:mitosis_styling={styleProp}
|
|
41
52
|
class={className() + " div"}
|
|
42
53
|
builder-path={path}
|
|
43
54
|
builder-parent-id={parent}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { BuilderBlock } from "../types/builder-block.js";
|
|
2
3
|
export declare type RenderBlockProps = {
|
|
3
4
|
blocks?: BuilderBlock[];
|
|
4
5
|
parent?: string;
|
|
5
6
|
path?: string;
|
|
7
|
+
styleProp?: Record<string, any>;
|
|
6
8
|
};
|
|
7
|
-
import { BuilderBlock } from "../types/builder-block.js";
|
|
8
9
|
declare const __propDef: {
|
|
9
10
|
props: {
|
|
10
11
|
blocks: RenderBlockProps["blocks"];
|
|
11
12
|
parent: RenderBlockProps["parent"];
|
|
12
13
|
path: RenderBlockProps["path"];
|
|
14
|
+
styleProp: RenderBlockProps["styleProp"];
|
|
13
15
|
};
|
|
14
16
|
events: {
|
|
15
17
|
[evt: string]: CustomEvent<any>;
|
|
@@ -25,7 +25,8 @@ function getCssFromFont(font) {
|
|
|
25
25
|
const isNumber = String(Number(weight)) === weight;
|
|
26
26
|
if (!isNumber) {
|
|
27
27
|
continue;
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
|
+
// TODO: maybe limit number loaded
|
|
29
30
|
const weightUrl = font.files[weight];
|
|
30
31
|
if (weightUrl && weightUrl !== url) {
|
|
31
32
|
str += `
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
5
5
|
import { TARGET } from "../../constants/target.js";
|
|
6
6
|
import BuilderContext from "../../context/builder.context.js";
|
|
7
|
-
import "../../context/types.js";
|
|
8
7
|
import { evaluate } from "../../functions/evaluate.js";
|
|
9
8
|
import { getContent } from "../../functions/get-content/index.js";
|
|
10
9
|
import { getFetch } from "../../functions/get-fetch.js";
|
|
@@ -13,7 +12,6 @@ import { isEditing } from "../../functions/is-editing.js";
|
|
|
13
12
|
import { isPreviewing } from "../../functions/is-previewing.js";
|
|
14
13
|
import { components, createRegisterComponentMessage, } from "../../functions/register-component.js";
|
|
15
14
|
import { track } from "../../functions/track.js";
|
|
16
|
-
import "../../types/builder-content.js";
|
|
17
15
|
import RenderBlocks from "../render-blocks.svelte";
|
|
18
16
|
import RenderContentStyles from "./components/render-styles.svelte";
|
|
19
17
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../scripts/init-editing.js";
|
|
@@ -99,7 +97,10 @@ function handleRequest({ url, key }) {
|
|
|
99
97
|
.then((fetch) => fetch(url))
|
|
100
98
|
.then((response) => response.json())
|
|
101
99
|
.then((json) => {
|
|
102
|
-
const newOverrideState = {
|
|
100
|
+
const newOverrideState = {
|
|
101
|
+
...overrideState,
|
|
102
|
+
[key]: json,
|
|
103
|
+
};
|
|
103
104
|
overrideState = newOverrideState;
|
|
104
105
|
})
|
|
105
106
|
.catch((err) => {
|
|
@@ -137,7 +138,11 @@ $: useContent = () => {
|
|
|
137
138
|
const mergedContent = {
|
|
138
139
|
...content,
|
|
139
140
|
...overrideContent,
|
|
140
|
-
data: {
|
|
141
|
+
data: {
|
|
142
|
+
...content?.data,
|
|
143
|
+
...data,
|
|
144
|
+
...overrideContent?.data,
|
|
145
|
+
},
|
|
141
146
|
};
|
|
142
147
|
return mergedContent;
|
|
143
148
|
};
|
|
@@ -145,7 +150,11 @@ $: canTrackToUse = () => {
|
|
|
145
150
|
return canTrack || true;
|
|
146
151
|
};
|
|
147
152
|
$: contentState = () => {
|
|
148
|
-
return {
|
|
153
|
+
return {
|
|
154
|
+
...content?.data?.state,
|
|
155
|
+
...data,
|
|
156
|
+
...overrideState,
|
|
157
|
+
};
|
|
149
158
|
};
|
|
150
159
|
$: contextContext = () => {
|
|
151
160
|
return context || {};
|
|
@@ -153,6 +162,7 @@ $: contextContext = () => {
|
|
|
153
162
|
$: allRegisteredComponents = () => {
|
|
154
163
|
const allComponentsArray = [
|
|
155
164
|
...getDefaultRegisteredComponents(),
|
|
165
|
+
// While this `components` object is deprecated, we must maintain support for it.
|
|
156
166
|
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
157
167
|
// existing usage.
|
|
158
168
|
// This is why we spread `components` after the default Builder.io components, but before the `customComponents`,
|
|
@@ -160,7 +170,10 @@ $: allRegisteredComponents = () => {
|
|
|
160
170
|
...components,
|
|
161
171
|
...(customComponents || []),
|
|
162
172
|
];
|
|
163
|
-
const allComponents = allComponentsArray.reduce((acc, curr) => ({
|
|
173
|
+
const allComponents = allComponentsArray.reduce((acc, curr) => ({
|
|
174
|
+
...acc,
|
|
175
|
+
[curr.name]: curr,
|
|
176
|
+
}), {});
|
|
164
177
|
return allComponents;
|
|
165
178
|
};
|
|
166
179
|
$: httpReqsData = () => {
|
|
@@ -179,7 +192,8 @@ let overrideState = {};
|
|
|
179
192
|
onMount(() => {
|
|
180
193
|
if (isBrowser()) {
|
|
181
194
|
if (isEditing()) {
|
|
182
|
-
forceReRenderCount = forceReRenderCount + 1;
|
|
195
|
+
forceReRenderCount = forceReRenderCount + 1;
|
|
196
|
+
// QWIK-REPLACE: _useMutableProps
|
|
183
197
|
registerInsertMenu();
|
|
184
198
|
setupBrowserForEditing();
|
|
185
199
|
Object.values(allRegisteredComponents()).forEach((registeredComponent) => {
|
|
@@ -196,7 +210,8 @@ onMount(() => {
|
|
|
196
210
|
contentId: useContent?.()?.id,
|
|
197
211
|
orgId: apiKey,
|
|
198
212
|
});
|
|
199
|
-
}
|
|
213
|
+
}
|
|
214
|
+
// override normal content in preview mode
|
|
200
215
|
if (isPreviewing()) {
|
|
201
216
|
const searchParams = new URL(location.href).searchParams;
|
|
202
217
|
if (model && searchParams.get("builder.preview") === model) {
|
|
@@ -245,6 +260,7 @@ onDestroy(() => {
|
|
|
245
260
|
onClick(event);
|
|
246
261
|
}}
|
|
247
262
|
builder-content-id={useContent?.()?.id}
|
|
263
|
+
builder-model={model}
|
|
248
264
|
>
|
|
249
265
|
{#if shouldRenderContentStyles()}
|
|
250
266
|
<RenderContentStyles
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { BuilderRenderContext, RegisteredComponent } from "../../context/types.js";
|
|
3
|
+
import type { BuilderContent } from "../../types/builder-content.js";
|
|
2
4
|
import type { Nullable } from "../../types/typescript.js";
|
|
3
5
|
export declare type RenderContentProps = {
|
|
4
6
|
content?: Nullable<BuilderContent>;
|
|
@@ -11,8 +13,6 @@ export declare type RenderContentProps = {
|
|
|
11
13
|
customComponents?: RegisteredComponent[];
|
|
12
14
|
canTrack?: boolean;
|
|
13
15
|
};
|
|
14
|
-
import { BuilderRenderContext, RegisteredComponent } from "../../context/types.js";
|
|
15
|
-
import { BuilderContent } from "../../types/builder-content.js";
|
|
16
16
|
declare const __propDef: {
|
|
17
17
|
props: {
|
|
18
18
|
content: RenderContentProps["content"];
|
|
@@ -18,6 +18,8 @@ import { componentInfo as embedComponentInfo } from '../blocks/embed/component-i
|
|
|
18
18
|
import { default as embed } from '../blocks/embed/embed.svelte';
|
|
19
19
|
import { default as Img } from '../blocks/img/img.svelte';
|
|
20
20
|
import { componentInfo as imgComponentInfo } from '../blocks/img/component-info.js';
|
|
21
|
+
import { default as customCode } from '../blocks/custom-code/custom-code.svelte';
|
|
22
|
+
import { componentInfo as customCodeInfo } from '../blocks/custom-code/component-info.js';
|
|
21
23
|
/**
|
|
22
24
|
* Returns a list of all registered components.
|
|
23
25
|
* NOTE: This needs to be a function to work around ESM circular dependencies.
|
|
@@ -33,4 +35,5 @@ export const getDefaultRegisteredComponents = () => [
|
|
|
33
35
|
{ component: Section, ...sectionComponentInfo },
|
|
34
36
|
{ component: Fragment, ...fragmentComponentInfo },
|
|
35
37
|
{ component: embed, ...embedComponentInfo },
|
|
38
|
+
{ component: customCode, ...customCodeInfo },
|
|
36
39
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BuilderContent } from '../types/builder-content.js';
|
|
2
|
-
import { ComponentInfo } from '../types/components.js';
|
|
3
|
-
import { Dictionary, Nullable } from '../types/typescript.js';
|
|
1
|
+
import type { BuilderContent } from '../types/builder-content.js';
|
|
2
|
+
import type { ComponentInfo } from '../types/components.js';
|
|
3
|
+
import type { Dictionary, Nullable } from '../types/typescript.js';
|
|
4
4
|
export declare type RegisteredComponent = ComponentInfo & {
|
|
5
5
|
component: any;
|
|
6
6
|
};
|
|
@@ -13,4 +13,5 @@ export interface BuilderContextInterface {
|
|
|
13
13
|
state: BuilderRenderState;
|
|
14
14
|
apiKey: string | null;
|
|
15
15
|
registeredComponents: RegisteredComponents;
|
|
16
|
+
inheritedStyles: Record<string, unknown>;
|
|
16
17
|
}
|
package/package/context/types.js
CHANGED