@builder.io/sdk-solid 0.7.3 → 0.7.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/dist/index.d.ts +4 -4
- package/lib/browser/dev.js +103 -147
- package/lib/browser/dev.jsx +118 -176
- package/lib/browser/index.js +103 -147
- package/lib/browser/index.jsx +118 -176
- package/lib/edge/dev.js +103 -147
- package/lib/edge/dev.jsx +118 -176
- package/lib/edge/index.js +103 -147
- package/lib/edge/index.jsx +118 -176
- package/lib/node/dev.js +103 -147
- package/lib/node/dev.jsx +118 -176
- package/lib/node/index.js +103 -147
- package/lib/node/index.jsx +118 -176
- package/package.json +8 -1
package/lib/browser/index.jsx
CHANGED
|
@@ -876,7 +876,7 @@ function Block(props) {
|
|
|
876
876
|
});
|
|
877
877
|
}
|
|
878
878
|
function processedBlock() {
|
|
879
|
-
return
|
|
879
|
+
return props.block.repeat?.collection ? props.block : getProcessedBlock({
|
|
880
880
|
block: props.block,
|
|
881
881
|
localState: props.context.localState,
|
|
882
882
|
rootState: props.context.rootState,
|
|
@@ -895,6 +895,9 @@ function Block(props) {
|
|
|
895
895
|
if ("show" in processedBlock()) {
|
|
896
896
|
return processedBlock().show;
|
|
897
897
|
}
|
|
898
|
+
if (props.block.repeat?.collection && !repeatItem()?.length) {
|
|
899
|
+
return false;
|
|
900
|
+
}
|
|
898
901
|
return true;
|
|
899
902
|
}
|
|
900
903
|
function childrenWithoutParentComponent() {
|
|
@@ -1367,10 +1370,10 @@ function SectionComponent(props) {
|
|
|
1367
1370
|
var section_default = SectionComponent;
|
|
1368
1371
|
|
|
1369
1372
|
// src/blocks/symbol/symbol.tsx
|
|
1370
|
-
import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as
|
|
1373
|
+
import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as createSignal14 } from "solid-js";
|
|
1371
1374
|
|
|
1372
1375
|
// src/components/content-variants/content-variants.tsx
|
|
1373
|
-
import { Show as
|
|
1376
|
+
import { Show as Show12, For as For5, onMount as onMount3, createSignal as createSignal13 } from "solid-js";
|
|
1374
1377
|
|
|
1375
1378
|
// src/helpers/url.ts
|
|
1376
1379
|
var getTopLevelDomain = (host) => {
|
|
@@ -1564,7 +1567,7 @@ var handleABTesting = async ({
|
|
|
1564
1567
|
var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
|
|
1565
1568
|
|
|
1566
1569
|
// src/components/content/content.tsx
|
|
1567
|
-
import { Show as
|
|
1570
|
+
import { Show as Show11, createSignal as createSignal12 } from "solid-js";
|
|
1568
1571
|
|
|
1569
1572
|
// src/blocks/button/component-info.ts
|
|
1570
1573
|
var componentInfo = {
|
|
@@ -2336,6 +2339,7 @@ var componentInfo11 = {
|
|
|
2336
2339
|
};
|
|
2337
2340
|
|
|
2338
2341
|
// src/blocks/video/video.tsx
|
|
2342
|
+
import { Show as Show9 } from "solid-js";
|
|
2339
2343
|
function Video(props) {
|
|
2340
2344
|
function videoProps() {
|
|
2341
2345
|
return {
|
|
@@ -2358,26 +2362,66 @@ function Video(props) {
|
|
|
2358
2362
|
}
|
|
2359
2363
|
function spreadProps() {
|
|
2360
2364
|
return {
|
|
2361
|
-
...props.attributes,
|
|
2362
2365
|
...videoProps()
|
|
2363
2366
|
};
|
|
2364
2367
|
}
|
|
2365
|
-
return <
|
|
2366
|
-
{...spreadProps()}
|
|
2367
|
-
preload={props.preload || "metadata"}
|
|
2368
|
+
return <div
|
|
2368
2369
|
style={{
|
|
2369
|
-
|
|
2370
|
-
height: "100%",
|
|
2371
|
-
...props.attributes?.style,
|
|
2372
|
-
"object-fit": props.fit,
|
|
2373
|
-
"object-position": props.position,
|
|
2374
|
-
// Hack to get object fit to work as expected and
|
|
2375
|
-
// not have the video overflow
|
|
2376
|
-
"border-radius": 1
|
|
2370
|
+
position: "relative"
|
|
2377
2371
|
}}
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2372
|
+
>
|
|
2373
|
+
<video
|
|
2374
|
+
class="builder-video"
|
|
2375
|
+
{...spreadProps()}
|
|
2376
|
+
preload={props.preload || "metadata"}
|
|
2377
|
+
style={{
|
|
2378
|
+
width: "100%",
|
|
2379
|
+
height: "100%",
|
|
2380
|
+
...props.attributes?.style,
|
|
2381
|
+
"object-fit": props.fit,
|
|
2382
|
+
"object-position": props.position,
|
|
2383
|
+
// Hack to get object fit to work as expected and
|
|
2384
|
+
// not have the video overflow
|
|
2385
|
+
"z-index": 2,
|
|
2386
|
+
"border-radius": "1px",
|
|
2387
|
+
...props.aspectRatio ? {
|
|
2388
|
+
position: "absolute"
|
|
2389
|
+
} : null
|
|
2390
|
+
}}
|
|
2391
|
+
src={props.video || "no-src"}
|
|
2392
|
+
poster={props.posterImage}
|
|
2393
|
+
><Show9 when={!props.lazyLoad}><source type="video/mp4" src={props.video} /></Show9></video>
|
|
2394
|
+
<Show9
|
|
2395
|
+
when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}
|
|
2396
|
+
><div
|
|
2397
|
+
style={{
|
|
2398
|
+
width: "100%",
|
|
2399
|
+
"padding-top": props.aspectRatio * 100 + "%",
|
|
2400
|
+
"pointer-events": "none",
|
|
2401
|
+
"font-size": "0px"
|
|
2402
|
+
}}
|
|
2403
|
+
/></Show9>
|
|
2404
|
+
<Show9 when={props.builderBlock?.children?.length && props.fitContent}><div
|
|
2405
|
+
style={{
|
|
2406
|
+
display: "flex",
|
|
2407
|
+
"flex-direction": "column",
|
|
2408
|
+
"align-items": "stretch"
|
|
2409
|
+
}}
|
|
2410
|
+
>{props.children}</div></Show9>
|
|
2411
|
+
<Show9 when={props.builderBlock?.children?.length && !props.fitContent}><div
|
|
2412
|
+
style={{
|
|
2413
|
+
"pointer-events": "none",
|
|
2414
|
+
display: "flex",
|
|
2415
|
+
"flex-direction": "column",
|
|
2416
|
+
"align-items": "stretch",
|
|
2417
|
+
position: "absolute",
|
|
2418
|
+
top: "0",
|
|
2419
|
+
left: "0",
|
|
2420
|
+
width: "100%",
|
|
2421
|
+
height: "100%"
|
|
2422
|
+
}}
|
|
2423
|
+
>{props.children}</div></Show9>
|
|
2424
|
+
</div>;
|
|
2381
2425
|
}
|
|
2382
2426
|
var video_default = Video;
|
|
2383
2427
|
|
|
@@ -2440,13 +2484,19 @@ var serializeComponentInfo = ({
|
|
|
2440
2484
|
}), {}))
|
|
2441
2485
|
});
|
|
2442
2486
|
|
|
2487
|
+
// src/components/content-variants/inlined-fns.ts
|
|
2488
|
+
var 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}";
|
|
2489
|
+
var 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}";
|
|
2490
|
+
|
|
2443
2491
|
// src/components/content-variants/helpers.ts
|
|
2492
|
+
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
2493
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "builderIoRenderContent";
|
|
2444
2494
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
2445
2495
|
...variant,
|
|
2446
2496
|
testVariationId: variant.id,
|
|
2447
2497
|
id: content?.id
|
|
2448
2498
|
}));
|
|
2449
|
-
var
|
|
2499
|
+
var checkShouldRenderVariants = ({
|
|
2450
2500
|
canTrack,
|
|
2451
2501
|
content
|
|
2452
2502
|
}) => {
|
|
@@ -2457,142 +2507,37 @@ var checkShouldRunVariants = ({
|
|
|
2457
2507
|
return false;
|
|
2458
2508
|
if (!canTrack)
|
|
2459
2509
|
return false;
|
|
2460
|
-
if (TARGET === "vue2" || TARGET === "vue3")
|
|
2510
|
+
if (TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte")
|
|
2461
2511
|
return true;
|
|
2462
2512
|
if (isBrowser())
|
|
2463
2513
|
return false;
|
|
2464
2514
|
return true;
|
|
2465
2515
|
};
|
|
2466
|
-
function bldrAbTest(contentId, variants, isHydrationTarget2) {
|
|
2467
|
-
function getAndSetVariantId2() {
|
|
2468
|
-
function setCookie2(name, value, days) {
|
|
2469
|
-
let expires = "";
|
|
2470
|
-
if (days) {
|
|
2471
|
-
const date = /* @__PURE__ */ new Date();
|
|
2472
|
-
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
2473
|
-
expires = "; expires=" + date.toUTCString();
|
|
2474
|
-
}
|
|
2475
|
-
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
|
|
2476
|
-
}
|
|
2477
|
-
function getCookie2(name) {
|
|
2478
|
-
const nameEQ = name + "=";
|
|
2479
|
-
const ca = document.cookie.split(";");
|
|
2480
|
-
for (let i = 0; i < ca.length; i++) {
|
|
2481
|
-
let c = ca[i];
|
|
2482
|
-
while (c.charAt(0) === " ")
|
|
2483
|
-
c = c.substring(1, c.length);
|
|
2484
|
-
if (c.indexOf(nameEQ) === 0)
|
|
2485
|
-
return c.substring(nameEQ.length, c.length);
|
|
2486
|
-
}
|
|
2487
|
-
return null;
|
|
2488
|
-
}
|
|
2489
|
-
const cookieName = `builder.tests.${contentId}`;
|
|
2490
|
-
const variantInCookie = getCookie2(cookieName);
|
|
2491
|
-
const availableIDs = variants.map((vr) => vr.id).concat(contentId);
|
|
2492
|
-
if (variantInCookie && availableIDs.includes(variantInCookie)) {
|
|
2493
|
-
return variantInCookie;
|
|
2494
|
-
}
|
|
2495
|
-
let n = 0;
|
|
2496
|
-
const random = Math.random();
|
|
2497
|
-
for (let i = 0; i < variants.length; i++) {
|
|
2498
|
-
const variant = variants[i];
|
|
2499
|
-
const testRatio = variant.testRatio;
|
|
2500
|
-
n += testRatio;
|
|
2501
|
-
if (random < n) {
|
|
2502
|
-
setCookie2(cookieName, variant.id);
|
|
2503
|
-
return variant.id;
|
|
2504
|
-
}
|
|
2505
|
-
}
|
|
2506
|
-
setCookie2(cookieName, contentId);
|
|
2507
|
-
return contentId;
|
|
2508
|
-
}
|
|
2509
|
-
const winningVariantId = getAndSetVariantId2();
|
|
2510
|
-
const styleEl = document.currentScript?.previousElementSibling;
|
|
2511
|
-
if (isHydrationTarget2) {
|
|
2512
|
-
styleEl.remove();
|
|
2513
|
-
const thisScriptEl = document.currentScript;
|
|
2514
|
-
thisScriptEl?.remove();
|
|
2515
|
-
} else {
|
|
2516
|
-
const newStyleStr = variants.concat({
|
|
2517
|
-
id: contentId
|
|
2518
|
-
}).filter((variant) => variant.id !== winningVariantId).map((value) => {
|
|
2519
|
-
return `.variant-${value.id} { display: none; }
|
|
2520
|
-
`;
|
|
2521
|
-
}).join("");
|
|
2522
|
-
styleEl.innerHTML = newStyleStr;
|
|
2523
|
-
}
|
|
2524
|
-
}
|
|
2525
|
-
function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
|
|
2526
|
-
if (!navigator.cookieEnabled) {
|
|
2527
|
-
return;
|
|
2528
|
-
}
|
|
2529
|
-
function getCookie2(name) {
|
|
2530
|
-
const nameEQ = name + "=";
|
|
2531
|
-
const ca = document.cookie.split(";");
|
|
2532
|
-
for (let i = 0; i < ca.length; i++) {
|
|
2533
|
-
let c = ca[i];
|
|
2534
|
-
while (c.charAt(0) === " ")
|
|
2535
|
-
c = c.substring(1, c.length);
|
|
2536
|
-
if (c.indexOf(nameEQ) === 0)
|
|
2537
|
-
return c.substring(nameEQ.length, c.length);
|
|
2538
|
-
}
|
|
2539
|
-
return null;
|
|
2540
|
-
}
|
|
2541
|
-
const cookieName = `builder.tests.${defaultContentId}`;
|
|
2542
|
-
const variantId = getCookie2(cookieName);
|
|
2543
|
-
const parentDiv = document.currentScript?.parentElement;
|
|
2544
|
-
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
2545
|
-
if (variantId === variantContentId) {
|
|
2546
|
-
if (variantIsDefaultContent) {
|
|
2547
|
-
return;
|
|
2548
|
-
}
|
|
2549
|
-
parentDiv?.removeAttribute("hidden");
|
|
2550
|
-
parentDiv?.removeAttribute("aria-hidden");
|
|
2551
|
-
} else {
|
|
2552
|
-
if (variantIsDefaultContent) {
|
|
2553
|
-
if (isHydrationTarget2) {
|
|
2554
|
-
parentDiv?.remove();
|
|
2555
|
-
} else {
|
|
2556
|
-
parentDiv?.setAttribute("hidden", "true");
|
|
2557
|
-
parentDiv?.setAttribute("aria-hidden", "true");
|
|
2558
|
-
}
|
|
2559
|
-
}
|
|
2560
|
-
return;
|
|
2561
|
-
}
|
|
2562
|
-
return;
|
|
2563
|
-
}
|
|
2564
2516
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
2565
2517
|
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
2566
|
-
var
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
|
|
2570
|
-
const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
|
|
2571
|
-
return `
|
|
2572
|
-
window.${AB_TEST_FN_NAME} = ${fnStr}
|
|
2573
|
-
window.${CONTENT_FN_NAME} = ${fnStr2}
|
|
2518
|
+
var getScriptString = () => `
|
|
2519
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
2520
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
2574
2521
|
`;
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
var getRenderContentScriptString = ({
|
|
2522
|
+
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
2523
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
2524
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
|
|
2525
|
+
)`;
|
|
2526
|
+
var getUpdateVariantVisibilityScript = ({
|
|
2581
2527
|
contentId,
|
|
2582
2528
|
variationId
|
|
2583
|
-
}) => {
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
};
|
|
2529
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
|
|
2530
|
+
"${variationId}", "${contentId}", ${isHydrationTarget}
|
|
2531
|
+
)`;
|
|
2587
2532
|
|
|
2588
2533
|
// src/components/inlined-script.tsx
|
|
2589
2534
|
function InlinedScript(props) {
|
|
2590
|
-
return <script innerHTML={props.scriptStr} id={props.id} />;
|
|
2535
|
+
return <script innerHTML={props.scriptStr} id={props.id || ""} />;
|
|
2591
2536
|
}
|
|
2592
2537
|
var Inlined_script_default = InlinedScript;
|
|
2593
2538
|
|
|
2594
2539
|
// src/components/content/components/enable-editor.tsx
|
|
2595
|
-
import { Show as
|
|
2540
|
+
import { Show as Show10, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
|
|
2596
2541
|
|
|
2597
2542
|
// src/helpers/preview-lru-cache/get.ts
|
|
2598
2543
|
function getPreviewContent(_searchParams) {
|
|
@@ -3074,7 +3019,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3074
3019
|
};
|
|
3075
3020
|
|
|
3076
3021
|
// src/constants/sdk-version.ts
|
|
3077
|
-
var SDK_VERSION = "0.7.
|
|
3022
|
+
var SDK_VERSION = "0.7.5";
|
|
3078
3023
|
|
|
3079
3024
|
// src/functions/register.ts
|
|
3080
3025
|
var registry = {};
|
|
@@ -3208,11 +3153,11 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3208
3153
|
|
|
3209
3154
|
// src/components/content/components/enable-editor.tsx
|
|
3210
3155
|
function EnableEditor(props) {
|
|
3211
|
-
const [forceReRenderCount, setForceReRenderCount] =
|
|
3212
|
-
const [lastUpdated, setLastUpdated] =
|
|
3213
|
-
const [shouldSendResetCookie, setShouldSendResetCookie] =
|
|
3214
|
-
const [httpReqsData, setHttpReqsData] =
|
|
3215
|
-
const [clicked, setClicked] =
|
|
3156
|
+
const [forceReRenderCount, setForceReRenderCount] = createSignal10(0);
|
|
3157
|
+
const [lastUpdated, setLastUpdated] = createSignal10(0);
|
|
3158
|
+
const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal10(false);
|
|
3159
|
+
const [httpReqsData, setHttpReqsData] = createSignal10({});
|
|
3160
|
+
const [clicked, setClicked] = createSignal10(false);
|
|
3216
3161
|
function mergeNewContent(newContent) {
|
|
3217
3162
|
const newContentValue = {
|
|
3218
3163
|
...props.builderContextSignal.content,
|
|
@@ -3454,8 +3399,8 @@ function EnableEditor(props) {
|
|
|
3454
3399
|
emitStateUpdate();
|
|
3455
3400
|
}
|
|
3456
3401
|
createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
|
|
3457
|
-
return <builder_context_default.Provider value={props.builderContextSignal}><
|
|
3458
|
-
class={props.
|
|
3402
|
+
return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><div
|
|
3403
|
+
class={`variant-${props.content?.testVariationId || props.content?.id}`}
|
|
3459
3404
|
{...{}}
|
|
3460
3405
|
key={forceReRenderCount()}
|
|
3461
3406
|
ref={elementRef}
|
|
@@ -3467,12 +3412,12 @@ function EnableEditor(props) {
|
|
|
3467
3412
|
hidden: true,
|
|
3468
3413
|
"aria-hidden": true
|
|
3469
3414
|
}}
|
|
3470
|
-
>{props.children}</div></
|
|
3415
|
+
>{props.children}</div></Show10></builder_context_default.Provider>;
|
|
3471
3416
|
}
|
|
3472
3417
|
var Enable_editor_default = EnableEditor;
|
|
3473
3418
|
|
|
3474
3419
|
// src/components/content/components/styles.tsx
|
|
3475
|
-
import { createSignal as
|
|
3420
|
+
import { createSignal as createSignal11 } from "solid-js";
|
|
3476
3421
|
|
|
3477
3422
|
// src/components/content/components/styles.helpers.ts
|
|
3478
3423
|
var getCssFromFont = (font) => {
|
|
@@ -3531,7 +3476,7 @@ var getCss = ({
|
|
|
3531
3476
|
|
|
3532
3477
|
// src/components/content/components/styles.tsx
|
|
3533
3478
|
function ContentStyles(props) {
|
|
3534
|
-
const [injectedStyles, setInjectedStyles] =
|
|
3479
|
+
const [injectedStyles, setInjectedStyles] = createSignal11(
|
|
3535
3480
|
`
|
|
3536
3481
|
${getCss({
|
|
3537
3482
|
cssCode: props.cssCode,
|
|
@@ -3566,22 +3511,20 @@ var getContextStateInitialValue = ({
|
|
|
3566
3511
|
locale
|
|
3567
3512
|
}) => {
|
|
3568
3513
|
const defaultValues = {};
|
|
3514
|
+
const initialState = content?.data?.state || {};
|
|
3569
3515
|
content?.data?.inputs?.forEach((input) => {
|
|
3570
|
-
if (input.name && input.defaultValue !== void 0
|
|
3516
|
+
if (input.name && input.defaultValue !== void 0) {
|
|
3571
3517
|
defaultValues[input.name] = input.defaultValue;
|
|
3572
3518
|
}
|
|
3573
3519
|
});
|
|
3574
|
-
|
|
3575
|
-
...
|
|
3520
|
+
return {
|
|
3521
|
+
...defaultValues,
|
|
3522
|
+
...initialState,
|
|
3576
3523
|
...data,
|
|
3577
3524
|
...locale ? {
|
|
3578
3525
|
locale
|
|
3579
3526
|
} : {}
|
|
3580
3527
|
};
|
|
3581
|
-
return {
|
|
3582
|
-
...defaultValues,
|
|
3583
|
-
...stateToUse
|
|
3584
|
-
};
|
|
3585
3528
|
};
|
|
3586
3529
|
var getContentInitialValue = ({
|
|
3587
3530
|
content,
|
|
@@ -3599,15 +3542,15 @@ var getContentInitialValue = ({
|
|
|
3599
3542
|
|
|
3600
3543
|
// src/components/content/content.tsx
|
|
3601
3544
|
function ContentComponent(props) {
|
|
3602
|
-
const [scriptStr, setScriptStr] =
|
|
3603
|
-
|
|
3545
|
+
const [scriptStr, setScriptStr] = createSignal12(
|
|
3546
|
+
getUpdateVariantVisibilityScript({
|
|
3604
3547
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
3605
3548
|
variationId: props.content?.testVariationId,
|
|
3606
3549
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
3607
3550
|
contentId: props.content?.id
|
|
3608
3551
|
})
|
|
3609
3552
|
);
|
|
3610
|
-
const [registeredComponents, setRegisteredComponents] =
|
|
3553
|
+
const [registeredComponents, setRegisteredComponents] = createSignal12(
|
|
3611
3554
|
[
|
|
3612
3555
|
...getDefaultRegisteredComponents(),
|
|
3613
3556
|
// While this `components` object is deprecated, we must maintain support for it.
|
|
@@ -3628,7 +3571,7 @@ function ContentComponent(props) {
|
|
|
3628
3571
|
{}
|
|
3629
3572
|
)
|
|
3630
3573
|
);
|
|
3631
|
-
const [builderContextSignal, setBuilderContextSignal] =
|
|
3574
|
+
const [builderContextSignal, setBuilderContextSignal] = createSignal12({
|
|
3632
3575
|
content: getContentInitialValue({
|
|
3633
3576
|
content: props.content,
|
|
3634
3577
|
data: props.data
|
|
@@ -3680,19 +3623,18 @@ function ContentComponent(props) {
|
|
|
3680
3623
|
locale={props.locale}
|
|
3681
3624
|
includeRefs={props.includeRefs}
|
|
3682
3625
|
enrich={props.enrich}
|
|
3683
|
-
classNameProp={props.classNameProp}
|
|
3684
3626
|
showContent={props.showContent}
|
|
3685
3627
|
builderContextSignal={builderContextSignal()}
|
|
3686
3628
|
{...{
|
|
3687
3629
|
setBuilderContextSignal
|
|
3688
3630
|
}}
|
|
3689
3631
|
>
|
|
3690
|
-
<
|
|
3691
|
-
<
|
|
3632
|
+
<Show11 when={props.isSsrAbTest}><Inlined_script_default scriptStr={scriptStr()} /></Show11>
|
|
3633
|
+
<Show11 when={TARGET !== "reactNative"}><Styles_default
|
|
3692
3634
|
contentId={builderContextSignal().content?.id}
|
|
3693
3635
|
cssCode={builderContextSignal().content?.data?.cssCode}
|
|
3694
3636
|
customFonts={builderContextSignal().content?.data?.customFonts}
|
|
3695
|
-
/></
|
|
3637
|
+
/></Show11>
|
|
3696
3638
|
<Blocks_default
|
|
3697
3639
|
blocks={builderContextSignal().content?.data?.blocks}
|
|
3698
3640
|
context={builderContextSignal()}
|
|
@@ -3704,14 +3646,14 @@ var Content_default = ContentComponent;
|
|
|
3704
3646
|
|
|
3705
3647
|
// src/components/content-variants/content-variants.tsx
|
|
3706
3648
|
function ContentVariants(props) {
|
|
3707
|
-
const [shouldRenderVariants, setShouldRenderVariants] =
|
|
3708
|
-
|
|
3649
|
+
const [shouldRenderVariants, setShouldRenderVariants] = createSignal13(
|
|
3650
|
+
checkShouldRenderVariants({
|
|
3709
3651
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
3710
3652
|
content: props.content
|
|
3711
3653
|
})
|
|
3712
3654
|
);
|
|
3713
|
-
function
|
|
3714
|
-
return
|
|
3655
|
+
function updateCookieAndStylesScriptStr() {
|
|
3656
|
+
return getUpdateCookieAndStylesScript(
|
|
3715
3657
|
getVariants(props.content).map((value) => ({
|
|
3716
3658
|
id: value.testVariationId,
|
|
3717
3659
|
testRatio: value.testRatio
|
|
@@ -3735,20 +3677,21 @@ function ContentVariants(props) {
|
|
|
3735
3677
|
setShouldRenderVariants(false);
|
|
3736
3678
|
});
|
|
3737
3679
|
return <>
|
|
3738
|
-
<
|
|
3739
|
-
<
|
|
3680
|
+
<Show12 when={!props.__isNestedRender && TARGET !== "reactNative"}><Inlined_script_default scriptStr={getScriptString()} /></Show12>
|
|
3681
|
+
<Show12 when={shouldRenderVariants()}>
|
|
3740
3682
|
<Inlined_styles_default
|
|
3741
3683
|
id={`variants-styles-${props.content?.id}`}
|
|
3742
3684
|
styles={hideVariantsStyleString()}
|
|
3743
3685
|
/>
|
|
3744
|
-
<Inlined_script_default
|
|
3686
|
+
<Inlined_script_default
|
|
3687
|
+
scriptStr={updateCookieAndStylesScriptStr()}
|
|
3688
|
+
/>
|
|
3745
3689
|
<For5 each={getVariants(props.content)}>{(variant, _index) => {
|
|
3746
3690
|
const index = _index();
|
|
3747
3691
|
return <Content_default
|
|
3748
3692
|
key={variant.testVariationId}
|
|
3749
3693
|
content={variant}
|
|
3750
3694
|
showContent={false}
|
|
3751
|
-
classNameProp={void 0}
|
|
3752
3695
|
model={props.model}
|
|
3753
3696
|
data={props.data}
|
|
3754
3697
|
context={props.context}
|
|
@@ -3762,11 +3705,10 @@ function ContentVariants(props) {
|
|
|
3762
3705
|
isSsrAbTest={shouldRenderVariants()}
|
|
3763
3706
|
/>;
|
|
3764
3707
|
}}</For5>
|
|
3765
|
-
</
|
|
3708
|
+
</Show12>
|
|
3766
3709
|
<Content_default
|
|
3767
3710
|
{...{}}
|
|
3768
3711
|
content={defaultContent()}
|
|
3769
|
-
classNameProp={`variant-${props.content?.id}`}
|
|
3770
3712
|
showContent={true}
|
|
3771
3713
|
model={props.model}
|
|
3772
3714
|
data={props.data}
|
|
@@ -3810,7 +3752,7 @@ var fetchSymbolContent = async ({
|
|
|
3810
3752
|
|
|
3811
3753
|
// src/blocks/symbol/symbol.tsx
|
|
3812
3754
|
function Symbol(props) {
|
|
3813
|
-
const [contentToUse, setContentToUse] =
|
|
3755
|
+
const [contentToUse, setContentToUse] = createSignal14(props.symbol?.content);
|
|
3814
3756
|
function className() {
|
|
3815
3757
|
return [
|
|
3816
3758
|
...[props.attributes.class],
|