@builder.io/sdk-svelte 1.0.36 → 1.1.0
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/lib/browser/blocks/accordion/component-info.js +7 -1
- package/lib/browser/blocks/button/component-info.js +7 -1
- package/lib/browser/blocks/columns/component-info.js +7 -1
- package/lib/browser/blocks/custom-code/component-info.js +6 -0
- package/lib/browser/blocks/embed/component-info.js +6 -0
- package/lib/browser/blocks/form/form/component-info.js +7 -1
- package/lib/browser/blocks/form/input/component-info.js +6 -0
- package/lib/browser/blocks/form/select/component-info.js +6 -0
- package/lib/browser/blocks/form/submit-button/component-info.js +6 -0
- package/lib/browser/blocks/form/textarea/component-info.js +6 -0
- package/lib/browser/blocks/fragment/component-info.js +6 -0
- package/lib/browser/blocks/image/component-info.js +7 -1
- package/lib/browser/blocks/img/component-info.js +6 -0
- package/lib/browser/blocks/raw-text/component-info.js +6 -0
- package/lib/browser/blocks/section/component-info.js +6 -0
- package/lib/browser/blocks/slot/component-info.js +7 -1
- package/lib/browser/blocks/symbol/component-info.js +7 -1
- package/lib/browser/blocks/tabs/component-info.js +7 -1
- package/lib/browser/blocks/text/component-info.js +7 -0
- package/lib/browser/blocks/video/component-info.js +7 -1
- package/lib/browser/components/block/block.helpers.d.ts +8 -8
- package/lib/browser/components/block/block.helpers.js +39 -12
- package/lib/browser/components/content-variants/content-variants.svelte +2 -1
- package/lib/browser/components/content-variants/inlined-fns.d.ts +1 -1
- package/lib/browser/components/content-variants/inlined-fns.js +1 -1
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/evaluate/choose-eval.js +4 -0
- package/lib/browser/types/components.d.ts +31 -0
- package/lib/edge/blocks/accordion/component-info.js +7 -1
- package/lib/edge/blocks/button/component-info.js +7 -1
- package/lib/edge/blocks/columns/component-info.js +7 -1
- package/lib/edge/blocks/custom-code/component-info.js +6 -0
- package/lib/edge/blocks/embed/component-info.js +6 -0
- package/lib/edge/blocks/form/form/component-info.js +7 -1
- package/lib/edge/blocks/form/input/component-info.js +6 -0
- package/lib/edge/blocks/form/select/component-info.js +6 -0
- package/lib/edge/blocks/form/submit-button/component-info.js +6 -0
- package/lib/edge/blocks/form/textarea/component-info.js +6 -0
- package/lib/edge/blocks/fragment/component-info.js +6 -0
- package/lib/edge/blocks/image/component-info.js +7 -1
- package/lib/edge/blocks/img/component-info.js +6 -0
- package/lib/edge/blocks/raw-text/component-info.js +6 -0
- package/lib/edge/blocks/section/component-info.js +6 -0
- package/lib/edge/blocks/slot/component-info.js +7 -1
- package/lib/edge/blocks/symbol/component-info.js +7 -1
- package/lib/edge/blocks/tabs/component-info.js +7 -1
- package/lib/edge/blocks/text/component-info.js +7 -0
- package/lib/edge/blocks/video/component-info.js +7 -1
- package/lib/edge/components/block/block.helpers.d.ts +8 -8
- package/lib/edge/components/block/block.helpers.js +39 -12
- package/lib/edge/components/content-variants/content-variants.svelte +2 -1
- package/lib/edge/components/content-variants/inlined-fns.d.ts +1 -1
- package/lib/edge/components/content-variants/inlined-fns.js +1 -1
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/evaluate/choose-eval.js +4 -0
- package/lib/edge/types/components.d.ts +31 -0
- package/lib/node/blocks/accordion/component-info.js +7 -1
- package/lib/node/blocks/button/component-info.js +7 -1
- package/lib/node/blocks/columns/component-info.js +7 -1
- package/lib/node/blocks/custom-code/component-info.js +6 -0
- package/lib/node/blocks/embed/component-info.js +6 -0
- package/lib/node/blocks/form/form/component-info.js +7 -1
- package/lib/node/blocks/form/input/component-info.js +6 -0
- package/lib/node/blocks/form/select/component-info.js +6 -0
- package/lib/node/blocks/form/submit-button/component-info.js +6 -0
- package/lib/node/blocks/form/textarea/component-info.js +6 -0
- package/lib/node/blocks/fragment/component-info.js +6 -0
- package/lib/node/blocks/image/component-info.js +7 -1
- package/lib/node/blocks/img/component-info.js +6 -0
- package/lib/node/blocks/raw-text/component-info.js +6 -0
- package/lib/node/blocks/section/component-info.js +6 -0
- package/lib/node/blocks/slot/component-info.js +7 -1
- package/lib/node/blocks/symbol/component-info.js +7 -1
- package/lib/node/blocks/tabs/component-info.js +7 -1
- package/lib/node/blocks/text/component-info.js +7 -0
- package/lib/node/blocks/video/component-info.js +7 -1
- package/lib/node/components/block/block.helpers.d.ts +8 -8
- package/lib/node/components/block/block.helpers.js +39 -12
- package/lib/node/components/content-variants/content-variants.svelte +2 -1
- package/lib/node/components/content-variants/inlined-fns.d.ts +1 -1
- package/lib/node/components/content-variants/inlined-fns.js +1 -1
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/evaluate/choose-eval.js +4 -0
- package/lib/node/types/components.d.ts +31 -0
- package/package.json +1 -1
- package/src/blocks/accordion/component-info.ts +7 -1
- package/src/blocks/button/component-info.ts +7 -1
- package/src/blocks/columns/component-info.ts +7 -1
- package/src/blocks/custom-code/component-info.ts +6 -0
- package/src/blocks/embed/component-info.ts +6 -0
- package/src/blocks/form/form/component-info.ts +7 -1
- package/src/blocks/form/input/component-info.ts +6 -0
- package/src/blocks/form/select/component-info.ts +6 -0
- package/src/blocks/form/submit-button/component-info.ts +6 -0
- package/src/blocks/form/textarea/component-info.ts +6 -0
- package/src/blocks/fragment/component-info.ts +6 -0
- package/src/blocks/image/component-info.ts +7 -1
- package/src/blocks/img/component-info.ts +6 -0
- package/src/blocks/raw-text/component-info.ts +6 -0
- package/src/blocks/section/component-info.ts +6 -0
- package/src/blocks/slot/component-info.ts +7 -1
- package/src/blocks/symbol/component-info.ts +7 -1
- package/src/blocks/tabs/component-info.ts +7 -1
- package/src/blocks/text/component-info.ts +7 -0
- package/src/blocks/video/component-info.ts +7 -1
- package/src/components/block/block.helpers.ts +32 -12
- package/src/components/content-variants/content-variants.svelte +3 -1
- package/src/components/content-variants/inlined-fns.ts +1 -1
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/evaluate/choose-eval.ts +4 -0
- package/src/types/components.ts +35 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
|
-
<script>import { onMount } from "svelte";
|
|
3
|
+
<script>import { afterUpdate, onMount } from "svelte";
|
|
4
4
|
import { TARGET } from "../../constants/target";
|
|
5
5
|
import { handleABTestingSync } from "../../helpers/ab-tests";
|
|
6
6
|
import { getDefaultCanTrack } from "../../helpers/canTrack";
|
|
@@ -57,6 +57,7 @@ onMount(() => {
|
|
|
57
57
|
*/
|
|
58
58
|
shouldRenderVariants = false;
|
|
59
59
|
});
|
|
60
|
+
afterUpdate(() => { });
|
|
60
61
|
</script>
|
|
61
62
|
|
|
62
63
|
{#if !isNestedRender && TARGET !== "reactNative"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* For more information on how this works,
|
|
11
|
-
* see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/
|
|
11
|
+
* see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/docs/SSR_AB_TEST.md)
|
|
12
12
|
*/
|
|
13
13
|
export declare const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
|
|
14
14
|
export declare const UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* For more information on how this works,
|
|
11
|
-
* see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/
|
|
11
|
+
* see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/docs/SSR_AB_TEST.md)
|
|
12
12
|
*/
|
|
13
13
|
export const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
|
|
14
14
|
export const UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0
|
|
1
|
+
export declare const SDK_VERSION = "1.1.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0
|
|
1
|
+
export const SDK_VERSION = "1.1.0";
|
|
@@ -105,6 +105,37 @@ export interface ComponentInfo {
|
|
|
105
105
|
*/
|
|
106
106
|
requiredPermissions?: Array<Permission>;
|
|
107
107
|
hidden?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Whether or not the component should receive SDK-related props.
|
|
110
|
+
*/
|
|
111
|
+
shouldReceiveBuilderProps?: {
|
|
112
|
+
/**
|
|
113
|
+
* Whether or not the component should receive the `builderBlock` prop, containing the current Builder block being rendered.
|
|
114
|
+
*
|
|
115
|
+
* Defaults to `true`.
|
|
116
|
+
*/
|
|
117
|
+
builderBlock?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Whether or not the component should receive the `builderContext` prop, containing the current context.
|
|
120
|
+
* The Builder Context contains a lot of data relevant to the current `Content` render.
|
|
121
|
+
* You can see more information [here](https://github.com/BuilderIO/builder/blob/main/packages/sdks/src/context/types.ts).
|
|
122
|
+
*
|
|
123
|
+
* Defaults to `true`.
|
|
124
|
+
*/
|
|
125
|
+
builderContext?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Whether or not the component should receive the `builderComponents` array, containing the all registered components (custom and built-in).
|
|
128
|
+
*
|
|
129
|
+
* Defaults to `false`.
|
|
130
|
+
*/
|
|
131
|
+
builderComponents?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Whether or not the component should receive the `builderLinkComponent` prop, containing the custom link component provided to `Content`.
|
|
134
|
+
*
|
|
135
|
+
* Defaults to `false`.
|
|
136
|
+
*/
|
|
137
|
+
builderLinkComponent?: boolean;
|
|
138
|
+
};
|
|
108
139
|
}
|
|
109
140
|
type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create';
|
|
110
141
|
export {};
|
package/package.json
CHANGED
|
@@ -120,5 +120,11 @@ export const componentInfo: ComponentInfo = {
|
|
|
120
120
|
options.set('items', []);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
}]
|
|
123
|
+
}],
|
|
124
|
+
shouldReceiveBuilderProps: {
|
|
125
|
+
builderBlock: true,
|
|
126
|
+
builderContext: true,
|
|
127
|
+
builderComponents: true,
|
|
128
|
+
builderLinkComponent: true
|
|
129
|
+
}
|
|
124
130
|
}
|
|
@@ -31,5 +31,11 @@ export const componentInfo: ComponentInfo = {
|
|
|
31
31
|
friendlyName: 'Open link in new tab'
|
|
32
32
|
}],
|
|
33
33
|
static: true,
|
|
34
|
-
noWrap: true
|
|
34
|
+
noWrap: true,
|
|
35
|
+
shouldReceiveBuilderProps: {
|
|
36
|
+
builderBlock: false,
|
|
37
|
+
builderContext: false,
|
|
38
|
+
builderComponents: false,
|
|
39
|
+
builderLinkComponent: true
|
|
40
|
+
}
|
|
35
41
|
}
|
|
@@ -215,5 +215,11 @@ export const componentInfo: ComponentInfo = {
|
|
|
215
215
|
defaultValue: false,
|
|
216
216
|
helperText: 'When stacking columns for mobile devices, reverse the ordering',
|
|
217
217
|
advanced: true
|
|
218
|
-
}]
|
|
218
|
+
}],
|
|
219
|
+
shouldReceiveBuilderProps: {
|
|
220
|
+
builderBlock: true,
|
|
221
|
+
builderContext: true,
|
|
222
|
+
builderComponents: true,
|
|
223
|
+
builderLinkComponent: true
|
|
224
|
+
}
|
|
219
225
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../../types/components';
|
|
2
2
|
export const componentInfo: ComponentInfo = {
|
|
3
|
+
shouldReceiveBuilderProps: {
|
|
4
|
+
builderBlock: false,
|
|
5
|
+
builderContext: false,
|
|
6
|
+
builderComponents: false,
|
|
7
|
+
builderLinkComponent: false
|
|
8
|
+
},
|
|
3
9
|
name: 'Custom Code',
|
|
4
10
|
static: true,
|
|
5
11
|
requiredPermissions: ['editCode'],
|
|
@@ -3,6 +3,12 @@ import type { ComponentInfo } from '../../types/components';
|
|
|
3
3
|
// Provided by the web app as a local variable in onChange functions
|
|
4
4
|
declare const _iframelyApiKey: string;
|
|
5
5
|
export const componentInfo: ComponentInfo = {
|
|
6
|
+
shouldReceiveBuilderProps: {
|
|
7
|
+
builderBlock: false,
|
|
8
|
+
builderContext: false,
|
|
9
|
+
builderComponents: false,
|
|
10
|
+
builderLinkComponent: false
|
|
11
|
+
},
|
|
6
12
|
name: 'Embed',
|
|
7
13
|
static: true,
|
|
8
14
|
inputs: [{
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../../../types/components';
|
|
2
2
|
export const componentInfo: ComponentInfo = {
|
|
3
|
+
shouldReceiveBuilderProps: {
|
|
4
|
+
builderBlock: false,
|
|
5
|
+
builderContext: false,
|
|
6
|
+
builderComponents: false,
|
|
7
|
+
builderLinkComponent: false
|
|
8
|
+
},
|
|
3
9
|
name: 'Form:Input',
|
|
4
10
|
image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fad6f37889d9e40bbbbc72cdb5875d6ca',
|
|
5
11
|
inputs: [{
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../../../types/components';
|
|
2
2
|
export const componentInfo: ComponentInfo = {
|
|
3
|
+
shouldReceiveBuilderProps: {
|
|
4
|
+
builderBlock: false,
|
|
5
|
+
builderContext: false,
|
|
6
|
+
builderComponents: false,
|
|
7
|
+
builderLinkComponent: false
|
|
8
|
+
},
|
|
3
9
|
name: 'Form:Select',
|
|
4
10
|
image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F83acca093fb24aaf94dee136e9a4b045',
|
|
5
11
|
defaultStyles: {
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../../../types/components';
|
|
2
2
|
export const componentInfo: ComponentInfo = {
|
|
3
|
+
shouldReceiveBuilderProps: {
|
|
4
|
+
builderBlock: false,
|
|
5
|
+
builderContext: false,
|
|
6
|
+
builderComponents: false,
|
|
7
|
+
builderLinkComponent: false
|
|
8
|
+
},
|
|
3
9
|
name: 'Form:SubmitButton',
|
|
4
10
|
image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fdf2820ffed1f4349a94c40b3221f5b98',
|
|
5
11
|
defaultStyles: {
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../../../types/components';
|
|
2
2
|
export const componentInfo: ComponentInfo = {
|
|
3
|
+
shouldReceiveBuilderProps: {
|
|
4
|
+
builderBlock: false,
|
|
5
|
+
builderContext: false,
|
|
6
|
+
builderComponents: false,
|
|
7
|
+
builderLinkComponent: false
|
|
8
|
+
},
|
|
3
9
|
name: 'Form:TextArea',
|
|
4
10
|
image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3',
|
|
5
11
|
inputs: [{
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../../types/components';
|
|
2
2
|
export const componentInfo: ComponentInfo = {
|
|
3
|
+
shouldReceiveBuilderProps: {
|
|
4
|
+
builderBlock: false,
|
|
5
|
+
builderContext: false,
|
|
6
|
+
builderComponents: false,
|
|
7
|
+
builderLinkComponent: false
|
|
8
|
+
},
|
|
3
9
|
name: 'Fragment',
|
|
4
10
|
static: true,
|
|
5
11
|
hidden: true,
|
|
@@ -125,5 +125,11 @@ export const componentInfo: ComponentInfo = {
|
|
|
125
125
|
helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
|
|
126
126
|
advanced: true,
|
|
127
127
|
defaultValue: 0.7041
|
|
128
|
-
}]
|
|
128
|
+
}],
|
|
129
|
+
shouldReceiveBuilderProps: {
|
|
130
|
+
builderBlock: true,
|
|
131
|
+
builderContext: false,
|
|
132
|
+
builderComponents: false,
|
|
133
|
+
builderLinkComponent: false
|
|
134
|
+
}
|
|
129
135
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../../types/components';
|
|
2
2
|
export const componentInfo: ComponentInfo = {
|
|
3
|
+
shouldReceiveBuilderProps: {
|
|
4
|
+
builderBlock: false,
|
|
5
|
+
builderContext: false,
|
|
6
|
+
builderComponents: false,
|
|
7
|
+
builderLinkComponent: false
|
|
8
|
+
},
|
|
3
9
|
// friendlyName?
|
|
4
10
|
name: 'Raw:Img',
|
|
5
11
|
hideFromInsertMenu: true,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../../types/components';
|
|
2
2
|
export const componentInfo: ComponentInfo = {
|
|
3
|
+
shouldReceiveBuilderProps: {
|
|
4
|
+
builderBlock: false,
|
|
5
|
+
builderContext: false,
|
|
6
|
+
builderComponents: false,
|
|
7
|
+
builderLinkComponent: false
|
|
8
|
+
},
|
|
3
9
|
name: 'Builder:RawText',
|
|
4
10
|
hideFromInsertMenu: true,
|
|
5
11
|
inputs: [{
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../../types/components';
|
|
2
2
|
export const componentInfo: ComponentInfo = {
|
|
3
|
+
shouldReceiveBuilderProps: {
|
|
4
|
+
builderBlock: false,
|
|
5
|
+
builderContext: false,
|
|
6
|
+
builderComponents: false,
|
|
7
|
+
builderLinkComponent: false
|
|
8
|
+
},
|
|
3
9
|
name: 'Core:Section',
|
|
4
10
|
static: true,
|
|
5
11
|
image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a',
|
|
@@ -11,5 +11,11 @@ export const componentInfo: ComponentInfo = {
|
|
|
11
11
|
type: 'string',
|
|
12
12
|
required: true,
|
|
13
13
|
defaultValue: 'children'
|
|
14
|
-
}]
|
|
14
|
+
}],
|
|
15
|
+
shouldReceiveBuilderProps: {
|
|
16
|
+
builderBlock: false,
|
|
17
|
+
builderContext: true,
|
|
18
|
+
builderComponents: false,
|
|
19
|
+
builderLinkComponent: false
|
|
20
|
+
}
|
|
15
21
|
}
|
|
@@ -31,5 +31,11 @@ export const componentInfo: ComponentInfo = {
|
|
|
31
31
|
name: 'useChildren',
|
|
32
32
|
hideFromUI: true,
|
|
33
33
|
type: 'boolean'
|
|
34
|
-
}]
|
|
34
|
+
}],
|
|
35
|
+
shouldReceiveBuilderProps: {
|
|
36
|
+
builderBlock: true,
|
|
37
|
+
builderContext: true,
|
|
38
|
+
builderComponents: true,
|
|
39
|
+
builderLinkComponent: true
|
|
40
|
+
}
|
|
35
41
|
}
|
|
@@ -135,5 +135,11 @@ export const componentInfo: ComponentInfo = {
|
|
|
135
135
|
label: 'Right',
|
|
136
136
|
value: 'flex-end'
|
|
137
137
|
}]
|
|
138
|
-
}]
|
|
138
|
+
}],
|
|
139
|
+
shouldReceiveBuilderProps: {
|
|
140
|
+
builderBlock: true,
|
|
141
|
+
builderContext: true,
|
|
142
|
+
builderComponents: true,
|
|
143
|
+
builderLinkComponent: true
|
|
144
|
+
}
|
|
139
145
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { TARGET } from '../../constants/target';
|
|
1
2
|
import type { ComponentInfo } from '../../types/components';
|
|
2
3
|
export const componentInfo: ComponentInfo = {
|
|
4
|
+
shouldReceiveBuilderProps: {
|
|
5
|
+
builderBlock: TARGET === 'reactNative' ? true : false,
|
|
6
|
+
builderContext: false,
|
|
7
|
+
builderComponents: false,
|
|
8
|
+
builderLinkComponent: false
|
|
9
|
+
},
|
|
3
10
|
name: 'Text',
|
|
4
11
|
static: true,
|
|
5
12
|
isRSC: true,
|
|
@@ -79,5 +79,11 @@ export const componentInfo: ComponentInfo = {
|
|
|
79
79
|
helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
|
|
80
80
|
defaultValue: true,
|
|
81
81
|
advanced: true
|
|
82
|
-
}]
|
|
82
|
+
}],
|
|
83
|
+
shouldReceiveBuilderProps: {
|
|
84
|
+
builderBlock: true,
|
|
85
|
+
builderContext: false,
|
|
86
|
+
builderComponents: false,
|
|
87
|
+
builderLinkComponent: false
|
|
88
|
+
}
|
|
83
89
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Writable } from "svelte/store";
|
|
2
|
-
import { TARGET } from '../../constants/target';
|
|
3
2
|
import type { BuilderContextInterface, RegisteredComponent, RegisteredComponents } from '../../context/types';
|
|
4
3
|
import { evaluate } from '../../functions/evaluate/index';
|
|
5
4
|
import { extractTextStyles } from '../../functions/extract-text-styles';
|
|
6
5
|
import { getProcessedBlock } from '../../functions/get-processed-block';
|
|
7
6
|
import { getStyle } from '../../functions/get-style';
|
|
7
|
+
import type { ComponentInfo } from '../../server-index';
|
|
8
8
|
import type { BuilderBlock } from '../../types/builder-block';
|
|
9
9
|
import type { RepeatData } from './types';
|
|
10
10
|
export const getComponent = ({
|
|
@@ -100,26 +100,46 @@ export const getInheritedStyles = ({
|
|
|
100
100
|
}
|
|
101
101
|
return extractTextStyles(style);
|
|
102
102
|
};
|
|
103
|
+
const applyDefaults = (shouldReceiveBuilderProps: ComponentInfo['shouldReceiveBuilderProps']) => {
|
|
104
|
+
return {
|
|
105
|
+
// once we bump to a major version, toggle this to `false`.
|
|
106
|
+
builderBlock: true,
|
|
107
|
+
// once we bump to a major version, toggle this to `false`.
|
|
108
|
+
builderContext: true,
|
|
109
|
+
builderComponents: false,
|
|
110
|
+
builderLinkComponent: false,
|
|
111
|
+
...shouldReceiveBuilderProps
|
|
112
|
+
};
|
|
113
|
+
};
|
|
103
114
|
export const provideLinkComponent = (block: RegisteredComponent | null | undefined, linkComponent: any) => {
|
|
104
|
-
|
|
115
|
+
if (!block) return {};
|
|
116
|
+
const shouldReceiveProp = applyDefaults(block.shouldReceiveBuilderProps).builderLinkComponent;
|
|
117
|
+
if (!shouldReceiveProp) return {};
|
|
118
|
+
return {
|
|
105
119
|
builderLinkComponent: linkComponent
|
|
106
|
-
}
|
|
120
|
+
};
|
|
107
121
|
};
|
|
108
122
|
export const provideRegisteredComponents = (block: RegisteredComponent | null | undefined, registeredComponents: RegisteredComponents) => {
|
|
109
|
-
|
|
123
|
+
if (!block) return {};
|
|
124
|
+
const shouldReceiveProp = applyDefaults(block.shouldReceiveBuilderProps).builderComponents;
|
|
125
|
+
if (!shouldReceiveProp) return {};
|
|
126
|
+
return {
|
|
110
127
|
builderComponents: registeredComponents
|
|
111
|
-
}
|
|
128
|
+
};
|
|
112
129
|
};
|
|
113
130
|
export const provideBuilderBlock = (block: RegisteredComponent | null | undefined, builderBlock: BuilderBlock) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return
|
|
131
|
+
if (!block) return {};
|
|
132
|
+
const shouldReceiveProp = applyDefaults(block.shouldReceiveBuilderProps).builderBlock;
|
|
133
|
+
if (!shouldReceiveProp) return {};
|
|
134
|
+
return {
|
|
118
135
|
builderBlock
|
|
119
|
-
}
|
|
136
|
+
};
|
|
120
137
|
};
|
|
121
138
|
export const provideBuilderContext = (block: RegisteredComponent | null | undefined, context: Writable<BuilderContextInterface>) => {
|
|
122
|
-
|
|
139
|
+
if (!block) return {};
|
|
140
|
+
const shouldReceiveProp = applyDefaults(block.shouldReceiveBuilderProps).builderContext;
|
|
141
|
+
if (!shouldReceiveProp) return {};
|
|
142
|
+
return {
|
|
123
143
|
builderContext: context
|
|
124
|
-
}
|
|
144
|
+
};
|
|
125
145
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
10
|
<script lang="ts">
|
|
11
|
-
import { onMount } from "svelte";
|
|
11
|
+
import { afterUpdate, onMount } from "svelte";
|
|
12
12
|
|
|
13
13
|
import { TARGET } from "../../constants/target";
|
|
14
14
|
import { handleABTestingSync } from "../../helpers/ab-tests";
|
|
@@ -84,6 +84,8 @@
|
|
|
84
84
|
*/
|
|
85
85
|
shouldRenderVariants = false;
|
|
86
86
|
});
|
|
87
|
+
|
|
88
|
+
afterUpdate(() => {});
|
|
87
89
|
</script>
|
|
88
90
|
|
|
89
91
|
{#if !isNestedRender && TARGET !== "reactNative"}
|
|
@@ -15,7 +15,7 @@ type VariantData = {
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* For more information on how this works,
|
|
18
|
-
* see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/
|
|
18
|
+
* see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/docs/SSR_AB_TEST.md)
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
export const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0
|
|
1
|
+
export const SDK_VERSION = "1.1.0"
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* THIS FILE IS EXPECTED TO EXIST WITH THIS EXACT NAME BY SUBSEQUENT BUNDLE STEPS THAT TRANSFORM IT.
|
|
3
|
+
* DO NOT RENAME THIS FILE.
|
|
4
|
+
*/
|
|
1
5
|
import { isBrowser } from '../is-browser';
|
|
2
6
|
import { runInBrowser } from './browser-runtime/browser';
|
|
3
7
|
import type { ExecutorArgs } from './helpers';
|
package/src/types/components.ts
CHANGED
|
@@ -115,5 +115,40 @@ export interface ComponentInfo {
|
|
|
115
115
|
|
|
116
116
|
// TO-DO: is this used?
|
|
117
117
|
hidden?: boolean;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Whether or not the component should receive SDK-related props.
|
|
121
|
+
*/
|
|
122
|
+
shouldReceiveBuilderProps?: {
|
|
123
|
+
/**
|
|
124
|
+
* Whether or not the component should receive the `builderBlock` prop, containing the current Builder block being rendered.
|
|
125
|
+
*
|
|
126
|
+
* Defaults to `true`.
|
|
127
|
+
*/
|
|
128
|
+
builderBlock?: boolean;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Whether or not the component should receive the `builderContext` prop, containing the current context.
|
|
132
|
+
* The Builder Context contains a lot of data relevant to the current `Content` render.
|
|
133
|
+
* You can see more information [here](https://github.com/BuilderIO/builder/blob/main/packages/sdks/src/context/types.ts).
|
|
134
|
+
*
|
|
135
|
+
* Defaults to `true`.
|
|
136
|
+
*/
|
|
137
|
+
builderContext?: boolean;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Whether or not the component should receive the `builderComponents` array, containing the all registered components (custom and built-in).
|
|
141
|
+
*
|
|
142
|
+
* Defaults to `false`.
|
|
143
|
+
*/
|
|
144
|
+
builderComponents?: boolean;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Whether or not the component should receive the `builderLinkComponent` prop, containing the custom link component provided to `Content`.
|
|
148
|
+
*
|
|
149
|
+
* Defaults to `false`.
|
|
150
|
+
*/
|
|
151
|
+
builderLinkComponent?: boolean;
|
|
152
|
+
};
|
|
118
153
|
}
|
|
119
154
|
type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create'
|