@builder.io/sdk-solid 4.0.8 → 4.0.10
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 +14 -2
- package/lib/browser/dev.js +418 -297
- package/lib/browser/dev.jsx +342 -273
- package/lib/browser/index.js +417 -297
- package/lib/browser/index.jsx +341 -273
- package/lib/edge/dev.js +418 -297
- package/lib/edge/dev.jsx +342 -273
- package/lib/edge/index.js +417 -297
- package/lib/edge/index.jsx +341 -273
- package/lib/node/dev.js +418 -297
- package/lib/node/dev.jsx +342 -273
- package/lib/node/index.js +417 -297
- package/lib/node/index.jsx +341 -273
- package/package.json +1 -1
package/lib/node/dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { delegateEvents, createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, use, Dynamic
|
|
1
|
+
import { delegateEvents, createComponent, memo, spread, mergeProps, insert, effect, setAttribute, className, style, template, use, Dynamic } from 'solid-js/web';
|
|
2
2
|
import { createContext, useContext, Show, For, createMemo, onMount, createSignal, createEffect, on } from 'solid-js';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
|
|
@@ -1837,7 +1837,7 @@ function Block(props) {
|
|
|
1837
1837
|
});
|
|
1838
1838
|
}
|
|
1839
1839
|
var block_default = Block;
|
|
1840
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1840
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-450facf4 {
|
|
1841
1841
|
display: flex;
|
|
1842
1842
|
flex-direction: column;
|
|
1843
1843
|
align-items: stretch;
|
|
@@ -1886,7 +1886,7 @@ function BlocksWrapper(props) {
|
|
|
1886
1886
|
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1887
1887
|
return [createComponent(Dynamic, mergeProps({
|
|
1888
1888
|
get ["class"]() {
|
|
1889
|
-
return className() + " dynamic-
|
|
1889
|
+
return className() + " dynamic-450facf4";
|
|
1890
1890
|
},
|
|
1891
1891
|
ref(r$) {
|
|
1892
1892
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1933,17 +1933,17 @@ function Blocks(props) {
|
|
|
1933
1933
|
get styleProp() {
|
|
1934
1934
|
return props.styleProp;
|
|
1935
1935
|
},
|
|
1936
|
+
get BlocksWrapperProps() {
|
|
1937
|
+
return props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1938
|
+
},
|
|
1936
1939
|
get classNameProp() {
|
|
1937
1940
|
return props.className;
|
|
1938
1941
|
},
|
|
1939
1942
|
get BlocksWrapper() {
|
|
1940
1943
|
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
1941
1944
|
},
|
|
1942
|
-
get BlocksWrapperProps() {
|
|
1943
|
-
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1944
|
-
},
|
|
1945
1945
|
get children() {
|
|
1946
|
-
return createComponent(Show, {
|
|
1946
|
+
return [memo(() => props.children), createComponent(Show, {
|
|
1947
1947
|
get when() {
|
|
1948
1948
|
return props.blocks;
|
|
1949
1949
|
},
|
|
@@ -1972,7 +1972,7 @@ function Blocks(props) {
|
|
|
1972
1972
|
}
|
|
1973
1973
|
});
|
|
1974
1974
|
}
|
|
1975
|
-
});
|
|
1975
|
+
})];
|
|
1976
1976
|
}
|
|
1977
1977
|
});
|
|
1978
1978
|
}
|
|
@@ -2397,6 +2397,166 @@ function SectionComponent(props) {
|
|
|
2397
2397
|
}
|
|
2398
2398
|
var section_default = SectionComponent;
|
|
2399
2399
|
|
|
2400
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
2401
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
2402
|
+
function isString(val) {
|
|
2403
|
+
return typeof val === "string";
|
|
2404
|
+
}
|
|
2405
|
+
function isNumber(val) {
|
|
2406
|
+
return typeof val === "number";
|
|
2407
|
+
}
|
|
2408
|
+
function objectMatchesQuery(userattr, query2) {
|
|
2409
|
+
const result = (() => {
|
|
2410
|
+
const property = query2.property;
|
|
2411
|
+
const operator = query2.operator;
|
|
2412
|
+
let testValue = query2.value;
|
|
2413
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
2414
|
+
testValue = query2.value.slice(0, -1);
|
|
2415
|
+
}
|
|
2416
|
+
if (!(property && operator)) {
|
|
2417
|
+
return true;
|
|
2418
|
+
}
|
|
2419
|
+
if (Array.isArray(testValue)) {
|
|
2420
|
+
if (operator === "isNot") {
|
|
2421
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
2422
|
+
property,
|
|
2423
|
+
operator,
|
|
2424
|
+
value: val
|
|
2425
|
+
}));
|
|
2426
|
+
}
|
|
2427
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
2428
|
+
property,
|
|
2429
|
+
operator,
|
|
2430
|
+
value: val
|
|
2431
|
+
}));
|
|
2432
|
+
}
|
|
2433
|
+
const value = userattr[property];
|
|
2434
|
+
if (Array.isArray(value)) {
|
|
2435
|
+
return value.includes(testValue);
|
|
2436
|
+
}
|
|
2437
|
+
switch (operator) {
|
|
2438
|
+
case "is":
|
|
2439
|
+
return value === testValue;
|
|
2440
|
+
case "isNot":
|
|
2441
|
+
return value !== testValue;
|
|
2442
|
+
case "contains":
|
|
2443
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
2444
|
+
case "startsWith":
|
|
2445
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
2446
|
+
case "endsWith":
|
|
2447
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
2448
|
+
case "greaterThan":
|
|
2449
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
2450
|
+
case "lessThan":
|
|
2451
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
2452
|
+
case "greaterThanOrEqualTo":
|
|
2453
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
2454
|
+
case "lessThanOrEqualTo":
|
|
2455
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
2456
|
+
default:
|
|
2457
|
+
return false;
|
|
2458
|
+
}
|
|
2459
|
+
})();
|
|
2460
|
+
return result;
|
|
2461
|
+
}
|
|
2462
|
+
const item = {
|
|
2463
|
+
query,
|
|
2464
|
+
startDate,
|
|
2465
|
+
endDate
|
|
2466
|
+
};
|
|
2467
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
2468
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
2469
|
+
return false;
|
|
2470
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
2471
|
+
return false;
|
|
2472
|
+
}
|
|
2473
|
+
if (!item.query || !item.query.length) {
|
|
2474
|
+
return true;
|
|
2475
|
+
}
|
|
2476
|
+
return item.query.every((filter) => {
|
|
2477
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
2478
|
+
});
|
|
2479
|
+
}
|
|
2480
|
+
var PERSONALIZATION_SCRIPT = "function getPersonalizedVariant(variants, blockId, isHydrationTarget, locale) {\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 attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');\n if (locale) {\n attributes.locale = locale;\n }\n const winningVariantIndex = variants?.findIndex(function (variant) {\n return window.filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);\n });\n const parentDiv = document.currentScript?.parentElement;\n const variantId = parentDiv?.getAttribute('data-variant-id');\n const isDefaultVariant = variantId === `${blockId}-default`;\n const isWinningVariant = winningVariantIndex !== -1 && variantId === `${blockId}-${winningVariantIndex}` || winningVariantIndex === -1 && isDefaultVariant;\n if (isWinningVariant && !isDefaultVariant) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultVariant) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n const itsStyleEl = parentDiv?.previousElementSibling;\n if (itsStyleEl) {\n itsStyleEl.remove();\n }\n parentDiv?.remove();\n }\n const thisScript = document.currentScript;\n if (thisScript) {\n thisScript.remove();\n }\n }\n}";
|
|
2481
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT = "function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {\n function isString(val) {\n return typeof val === 'string';\n }\n function isNumber(val) {\n return typeof val === 'number';\n }\n function objectMatchesQuery(userattr, query) {\n const result = (() => {\n const property = query.property;\n const operator = query.operator;\n let testValue = query.value;\n if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {\n testValue = query.value.slice(0, -1);\n }\n if (!(property && operator)) {\n return true;\n }\n if (Array.isArray(testValue)) {\n if (operator === 'isNot') {\n return testValue.every(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n return !!testValue.find(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n const value = userattr[property];\n if (Array.isArray(value)) {\n return value.includes(testValue);\n }\n switch (operator) {\n case 'is':\n return value === testValue;\n case 'isNot':\n return value !== testValue;\n case 'contains':\n return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));\n case 'startsWith':\n return isString(value) && value.startsWith(String(testValue));\n case 'endsWith':\n return isString(value) && value.endsWith(String(testValue));\n case 'greaterThan':\n return isNumber(value) && isNumber(testValue) && value > testValue;\n case 'lessThan':\n return isNumber(value) && isNumber(testValue) && value < testValue;\n case 'greaterThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value >= testValue;\n case 'lessThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value <= testValue;\n default:\n return false;\n }\n })();\n return result;\n }\n const item = {\n query,\n startDate,\n endDate\n };\n const now = userAttributes.date && new Date(userAttributes.date) || new Date();\n if (item.startDate && new Date(item.startDate) > now) {\n return false;\n } else if (item.endDate && new Date(item.endDate) < now) {\n return false;\n }\n if (!item.query || !item.query.length) {\n return true;\n }\n return item.query.every(filter => {\n return objectMatchesQuery(userAttributes, filter);\n });\n}";
|
|
2482
|
+
var UPDATE_VISIBILITY_STYLES_SCRIPT = "function updateVisibilityStylesScript(variants, blockId, isHydrationTarget, locale) {\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 visibilityStylesEl = document.currentScript?.previousElementSibling;\n if (!visibilityStylesEl) {\n return;\n }\n if (isHydrationTarget) {\n visibilityStylesEl.remove();\n const currentScript = document.currentScript;\n if (currentScript) {\n currentScript.remove();\n }\n } else {\n const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');\n if (locale) {\n attributes.locale = locale;\n }\n const winningVariantIndex = variants?.findIndex(function (variant) {\n return window.filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);\n });\n if (winningVariantIndex !== -1) {\n let newStyleStr = variants?.map((_, index) => {\n if (index === winningVariantIndex) return '';\n return `div[data-variant-id=\"${blockId}-${index}\"] { display: none !important; } `;\n }).join('') || '';\n newStyleStr += `div[data-variant-id=\"${blockId}-default\"] { display: none !important; } `;\n visibilityStylesEl.innerHTML = newStyleStr;\n }\n }\n}";
|
|
2483
|
+
|
|
2484
|
+
// src/blocks/personalization-container/helpers.ts
|
|
2485
|
+
var DEFAULT_INDEX = "default";
|
|
2486
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
2487
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
2488
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
2489
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte", "qwik"];
|
|
2490
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte", "qwik"];
|
|
2491
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
2492
|
+
const hasVariants = variants && variants.length > 0;
|
|
2493
|
+
if (TARGET === "reactNative")
|
|
2494
|
+
return false;
|
|
2495
|
+
if (!hasVariants)
|
|
2496
|
+
return false;
|
|
2497
|
+
if (!canTrack)
|
|
2498
|
+
return false;
|
|
2499
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
2500
|
+
return true;
|
|
2501
|
+
if (isBrowser())
|
|
2502
|
+
return false;
|
|
2503
|
+
return true;
|
|
2504
|
+
}
|
|
2505
|
+
function getBlocksToRender({
|
|
2506
|
+
variants,
|
|
2507
|
+
previewingIndex,
|
|
2508
|
+
isHydrated,
|
|
2509
|
+
filteredVariants,
|
|
2510
|
+
fallbackBlocks
|
|
2511
|
+
}) {
|
|
2512
|
+
const fallback = {
|
|
2513
|
+
blocks: fallbackBlocks ?? [],
|
|
2514
|
+
path: "this.children",
|
|
2515
|
+
index: DEFAULT_INDEX
|
|
2516
|
+
};
|
|
2517
|
+
if (isHydrated && isEditing()) {
|
|
2518
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
2519
|
+
const variant = variants?.[previewingIndex];
|
|
2520
|
+
if (variant) {
|
|
2521
|
+
return {
|
|
2522
|
+
blocks: variant.blocks,
|
|
2523
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
2524
|
+
index: previewingIndex
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
return fallback;
|
|
2529
|
+
}
|
|
2530
|
+
if (isBrowser()) {
|
|
2531
|
+
const winningVariant = filteredVariants?.[0];
|
|
2532
|
+
if (winningVariant && variants) {
|
|
2533
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
2534
|
+
if (variantIndex !== -1) {
|
|
2535
|
+
return {
|
|
2536
|
+
blocks: winningVariant.blocks,
|
|
2537
|
+
path: `variants.${variantIndex}.blocks`,
|
|
2538
|
+
index: variantIndex
|
|
2539
|
+
};
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
return fallback;
|
|
2544
|
+
}
|
|
2545
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
2546
|
+
return `
|
|
2547
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
2548
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
2549
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
2550
|
+
`;
|
|
2551
|
+
};
|
|
2552
|
+
var isHydrationTarget = TARGET === "react";
|
|
2553
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
2554
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2555
|
+
};
|
|
2556
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
2557
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2558
|
+
};
|
|
2559
|
+
|
|
2400
2560
|
// src/helpers/url.ts
|
|
2401
2561
|
var getTopLevelDomain = (host) => {
|
|
2402
2562
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -2585,6 +2745,11 @@ var handleABTesting = async ({
|
|
|
2585
2745
|
};
|
|
2586
2746
|
};
|
|
2587
2747
|
|
|
2748
|
+
// src/helpers/no-serialize-wrapper.ts
|
|
2749
|
+
function noSerializeWrapper(fn) {
|
|
2750
|
+
return fn;
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2588
2753
|
// src/helpers/user-attributes.ts
|
|
2589
2754
|
var USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
2590
2755
|
function createUserAttributesService() {
|
|
@@ -2615,18 +2780,32 @@ function createUserAttributesService() {
|
|
|
2615
2780
|
canTrack
|
|
2616
2781
|
}) || "{}");
|
|
2617
2782
|
},
|
|
2618
|
-
subscribeOnUserAttributesChange(callback
|
|
2783
|
+
subscribeOnUserAttributesChange(callback, {
|
|
2784
|
+
fireImmediately
|
|
2785
|
+
} = {}) {
|
|
2619
2786
|
subscribers.add(callback);
|
|
2620
|
-
|
|
2787
|
+
if (fireImmediately) {
|
|
2788
|
+
callback(this.getUserAttributes());
|
|
2789
|
+
}
|
|
2790
|
+
return noSerializeWrapper(function() {
|
|
2621
2791
|
subscribers.delete(callback);
|
|
2622
|
-
};
|
|
2792
|
+
});
|
|
2623
2793
|
},
|
|
2624
2794
|
setCanTrack(value) {
|
|
2625
2795
|
canTrack = value;
|
|
2626
2796
|
}
|
|
2627
2797
|
};
|
|
2628
2798
|
}
|
|
2629
|
-
var
|
|
2799
|
+
var _userAttributesService;
|
|
2800
|
+
if (isBrowser() && TARGET === "qwik") {
|
|
2801
|
+
if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__) {
|
|
2802
|
+
window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
|
|
2803
|
+
}
|
|
2804
|
+
_userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
|
|
2805
|
+
} else {
|
|
2806
|
+
_userAttributesService = createUserAttributesService();
|
|
2807
|
+
}
|
|
2808
|
+
var userAttributesService = _userAttributesService;
|
|
2630
2809
|
var setClientUserAttributes = (attributes) => {
|
|
2631
2810
|
userAttributesService.setUserAttributes(attributes);
|
|
2632
2811
|
};
|
|
@@ -3376,7 +3555,8 @@ var componentInfo6 = {
|
|
|
3376
3555
|
name: "PersonalizationContainer",
|
|
3377
3556
|
shouldReceiveBuilderProps: {
|
|
3378
3557
|
builderBlock: true,
|
|
3379
|
-
builderContext: true
|
|
3558
|
+
builderContext: true,
|
|
3559
|
+
builderComponents: true
|
|
3380
3560
|
},
|
|
3381
3561
|
noWrap: true,
|
|
3382
3562
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -3438,208 +3618,22 @@ function isPreviewing(_search) {
|
|
|
3438
3618
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
3439
3619
|
}
|
|
3440
3620
|
|
|
3441
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
3442
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
3443
|
-
function isString(val) {
|
|
3444
|
-
return typeof val === "string";
|
|
3445
|
-
}
|
|
3446
|
-
function isNumber(val) {
|
|
3447
|
-
return typeof val === "number";
|
|
3448
|
-
}
|
|
3449
|
-
function objectMatchesQuery(userattr, query2) {
|
|
3450
|
-
const result = (() => {
|
|
3451
|
-
const property = query2.property;
|
|
3452
|
-
const operator = query2.operator;
|
|
3453
|
-
let testValue = query2.value;
|
|
3454
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
3455
|
-
testValue = query2.value.slice(0, -1);
|
|
3456
|
-
}
|
|
3457
|
-
if (!(property && operator)) {
|
|
3458
|
-
return true;
|
|
3459
|
-
}
|
|
3460
|
-
if (Array.isArray(testValue)) {
|
|
3461
|
-
if (operator === "isNot") {
|
|
3462
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
3463
|
-
property,
|
|
3464
|
-
operator,
|
|
3465
|
-
value: val
|
|
3466
|
-
}));
|
|
3467
|
-
}
|
|
3468
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
3469
|
-
property,
|
|
3470
|
-
operator,
|
|
3471
|
-
value: val
|
|
3472
|
-
}));
|
|
3473
|
-
}
|
|
3474
|
-
const value = userattr[property];
|
|
3475
|
-
if (Array.isArray(value)) {
|
|
3476
|
-
return value.includes(testValue);
|
|
3477
|
-
}
|
|
3478
|
-
switch (operator) {
|
|
3479
|
-
case "is":
|
|
3480
|
-
return value === testValue;
|
|
3481
|
-
case "isNot":
|
|
3482
|
-
return value !== testValue;
|
|
3483
|
-
case "contains":
|
|
3484
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
3485
|
-
case "startsWith":
|
|
3486
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
3487
|
-
case "endsWith":
|
|
3488
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
3489
|
-
case "greaterThan":
|
|
3490
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
3491
|
-
case "lessThan":
|
|
3492
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
3493
|
-
case "greaterThanOrEqualTo":
|
|
3494
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
3495
|
-
case "lessThanOrEqualTo":
|
|
3496
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
3497
|
-
default:
|
|
3498
|
-
return false;
|
|
3499
|
-
}
|
|
3500
|
-
})();
|
|
3501
|
-
return result;
|
|
3502
|
-
}
|
|
3503
|
-
const item = {
|
|
3504
|
-
query,
|
|
3505
|
-
startDate,
|
|
3506
|
-
endDate
|
|
3507
|
-
};
|
|
3508
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
3509
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
3510
|
-
return false;
|
|
3511
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
3512
|
-
return false;
|
|
3513
|
-
}
|
|
3514
|
-
if (!item.query || !item.query.length) {
|
|
3515
|
-
return true;
|
|
3516
|
-
}
|
|
3517
|
-
return item.query.every((filter) => {
|
|
3518
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
3519
|
-
});
|
|
3520
|
-
}
|
|
3521
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
3522
|
-
if (!navigator.cookieEnabled) {
|
|
3523
|
-
return;
|
|
3524
|
-
}
|
|
3525
|
-
function getCookie(name) {
|
|
3526
|
-
const nameEQ = name + '=';
|
|
3527
|
-
const ca = document.cookie.split(';');
|
|
3528
|
-
for (let i = 0; i < ca.length; i++) {
|
|
3529
|
-
let c = ca[i];
|
|
3530
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
3531
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
3532
|
-
}
|
|
3533
|
-
return null;
|
|
3534
|
-
}
|
|
3535
|
-
function removeVariants() {
|
|
3536
|
-
variants?.forEach(function (_, index) {
|
|
3537
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
3538
|
-
});
|
|
3539
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
3540
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
3541
|
-
}
|
|
3542
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
3543
|
-
if (locale) {
|
|
3544
|
-
attributes.locale = locale;
|
|
3545
|
-
}
|
|
3546
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
3547
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
3548
|
-
});
|
|
3549
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
3550
|
-
if (isDebug) {
|
|
3551
|
-
console.debug('PersonalizationContainer', {
|
|
3552
|
-
attributes,
|
|
3553
|
-
variants,
|
|
3554
|
-
winningVariantIndex
|
|
3555
|
-
});
|
|
3556
|
-
}
|
|
3557
|
-
if (winningVariantIndex !== -1) {
|
|
3558
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
3559
|
-
if (winningVariant) {
|
|
3560
|
-
const parentNode = winningVariant.parentNode;
|
|
3561
|
-
if (parentNode) {
|
|
3562
|
-
const newParent = parentNode.cloneNode(false);
|
|
3563
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
3564
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
3565
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
3566
|
-
}
|
|
3567
|
-
if (isDebug) {
|
|
3568
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
3569
|
-
}
|
|
3570
|
-
}
|
|
3571
|
-
} else if (variants && variants.length > 0) {
|
|
3572
|
-
removeVariants();
|
|
3573
|
-
}
|
|
3574
|
-
}`;
|
|
3575
|
-
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT = "function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {\n function isString(val) {\n return typeof val === 'string';\n }\n function isNumber(val) {\n return typeof val === 'number';\n }\n function objectMatchesQuery(userattr, query) {\n const result = (() => {\n const property = query.property;\n const operator = query.operator;\n let testValue = query.value;\n if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {\n testValue = query.value.slice(0, -1);\n }\n if (!(property && operator)) {\n return true;\n }\n if (Array.isArray(testValue)) {\n if (operator === 'isNot') {\n return testValue.every(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n return !!testValue.find(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n const value = userattr[property];\n if (Array.isArray(value)) {\n return value.includes(testValue);\n }\n switch (operator) {\n case 'is':\n return value === testValue;\n case 'isNot':\n return value !== testValue;\n case 'contains':\n return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));\n case 'startsWith':\n return isString(value) && value.startsWith(String(testValue));\n case 'endsWith':\n return isString(value) && value.endsWith(String(testValue));\n case 'greaterThan':\n return isNumber(value) && isNumber(testValue) && value > testValue;\n case 'lessThan':\n return isNumber(value) && isNumber(testValue) && value < testValue;\n case 'greaterThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value >= testValue;\n case 'lessThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value <= testValue;\n default:\n return false;\n }\n })();\n return result;\n }\n const item = {\n query,\n startDate,\n endDate\n };\n const now = userAttributes.date && new Date(userAttributes.date) || new Date();\n if (item.startDate && new Date(item.startDate) > now) {\n return false;\n } else if (item.endDate && new Date(item.endDate) < now) {\n return false;\n }\n if (!item.query || !item.query.length) {\n return true;\n }\n return item.query.every(filter => {\n return objectMatchesQuery(userAttributes, filter);\n });\n}";
|
|
3576
|
-
|
|
3577
|
-
// src/blocks/personalization-container/helpers.ts
|
|
3578
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
3579
|
-
const hasVariants = variants && variants.length > 0;
|
|
3580
|
-
if (TARGET === "reactNative")
|
|
3581
|
-
return false;
|
|
3582
|
-
if (!hasVariants)
|
|
3583
|
-
return false;
|
|
3584
|
-
if (!canTrack)
|
|
3585
|
-
return false;
|
|
3586
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
3587
|
-
return true;
|
|
3588
|
-
if (isBrowser())
|
|
3589
|
-
return false;
|
|
3590
|
-
return true;
|
|
3591
|
-
}
|
|
3592
|
-
function getBlocksToRender({
|
|
3593
|
-
variants,
|
|
3594
|
-
previewingIndex,
|
|
3595
|
-
isHydrated,
|
|
3596
|
-
filteredVariants,
|
|
3597
|
-
fallbackBlocks
|
|
3598
|
-
}) {
|
|
3599
|
-
const fallback = {
|
|
3600
|
-
blocks: fallbackBlocks ?? [],
|
|
3601
|
-
path: "this.children"
|
|
3602
|
-
};
|
|
3603
|
-
if (isHydrated && isEditing()) {
|
|
3604
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
3605
|
-
const variant = variants[previewingIndex];
|
|
3606
|
-
return {
|
|
3607
|
-
blocks: variant.blocks,
|
|
3608
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
3609
|
-
};
|
|
3610
|
-
}
|
|
3611
|
-
return fallback;
|
|
3612
|
-
}
|
|
3613
|
-
if (isBrowser()) {
|
|
3614
|
-
const winningVariant = filteredVariants?.[0];
|
|
3615
|
-
if (winningVariant) {
|
|
3616
|
-
return {
|
|
3617
|
-
blocks: winningVariant.blocks,
|
|
3618
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
3619
|
-
};
|
|
3620
|
-
}
|
|
3621
|
-
}
|
|
3622
|
-
return fallback;
|
|
3623
|
-
}
|
|
3624
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
3625
|
-
return `
|
|
3626
|
-
(function() {
|
|
3627
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
3628
|
-
${PERSONALIZATION_SCRIPT}
|
|
3629
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
3630
|
-
})();
|
|
3631
|
-
`;
|
|
3632
|
-
};
|
|
3633
|
-
|
|
3634
3621
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
3635
3622
|
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
3636
|
-
var _tmpl$25 = /* @__PURE__ */ template(`<template>`);
|
|
3637
3623
|
function PersonalizationContainer(props) {
|
|
3638
3624
|
const [userAttributes, setUserAttributes] = createSignal(userAttributesService.getUserAttributes());
|
|
3639
3625
|
const [scriptStr, setScriptStr] = createSignal(getPersonalizationScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3626
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal(getUpdateVisibilityStylesScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3640
3627
|
const [unsubscribers, setUnsubscribers] = createSignal([]);
|
|
3641
3628
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRenderVariants(props.variants, getDefaultCanTrack(props.builderContext?.canTrack)));
|
|
3642
|
-
const [
|
|
3629
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal(false);
|
|
3630
|
+
const attrs = createMemo(() => {
|
|
3631
|
+
return {
|
|
3632
|
+
...props.attributes,
|
|
3633
|
+
...{},
|
|
3634
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
3635
|
+
};
|
|
3636
|
+
});
|
|
3643
3637
|
const filteredVariants = createMemo(() => {
|
|
3644
3638
|
return (props.variants || []).filter((variant) => {
|
|
3645
3639
|
return filterWithCustomTargeting({
|
|
@@ -3654,26 +3648,28 @@ function PersonalizationContainer(props) {
|
|
|
3654
3648
|
return getBlocksToRender({
|
|
3655
3649
|
variants: props.variants,
|
|
3656
3650
|
fallbackBlocks: props.builderBlock?.children,
|
|
3657
|
-
isHydrated:
|
|
3651
|
+
isHydrated: shouldResetVariants(),
|
|
3658
3652
|
filteredVariants: filteredVariants(),
|
|
3659
3653
|
previewingIndex: props.previewingIndex
|
|
3660
3654
|
});
|
|
3661
3655
|
});
|
|
3662
3656
|
const hideVariantsStyleString = createMemo(() => {
|
|
3663
|
-
return (props.variants || []).map((_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `).join("");
|
|
3657
|
+
return (props.variants || []).map((_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `).join("");
|
|
3664
3658
|
});
|
|
3665
3659
|
let rootRef;
|
|
3666
3660
|
onMount(() => {
|
|
3667
|
-
|
|
3668
|
-
const unsub = userAttributesService.subscribeOnUserAttributesChange((
|
|
3669
|
-
setUserAttributes(
|
|
3661
|
+
setShouldResetVariants(true);
|
|
3662
|
+
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
3663
|
+
setUserAttributes(attrs2);
|
|
3664
|
+
}, {
|
|
3665
|
+
fireImmediately: TARGET === "qwik"
|
|
3670
3666
|
});
|
|
3671
3667
|
if (!(isEditing() || isPreviewing())) {
|
|
3672
3668
|
const variant = filteredVariants()[0];
|
|
3673
3669
|
if (rootRef) {
|
|
3674
3670
|
rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
|
|
3675
3671
|
detail: {
|
|
3676
|
-
variant: variant ||
|
|
3672
|
+
variant: variant || DEFAULT_INDEX,
|
|
3677
3673
|
content: props.builderContext?.content
|
|
3678
3674
|
},
|
|
3679
3675
|
bubbles: true
|
|
@@ -3683,7 +3679,7 @@ function PersonalizationContainer(props) {
|
|
|
3683
3679
|
if (entry.isIntersecting && rootRef) {
|
|
3684
3680
|
rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
|
|
3685
3681
|
detail: {
|
|
3686
|
-
variant: variant ||
|
|
3682
|
+
variant: variant || DEFAULT_INDEX,
|
|
3687
3683
|
content: props.builderContext?.content
|
|
3688
3684
|
},
|
|
3689
3685
|
bubbles: true
|
|
@@ -3700,70 +3696,158 @@ function PersonalizationContainer(props) {
|
|
|
3700
3696
|
const _el$ = _tmpl$9();
|
|
3701
3697
|
const _ref$ = rootRef;
|
|
3702
3698
|
typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
|
|
3703
|
-
spread(_el$, mergeProps(
|
|
3704
|
-
get ["class"]() {
|
|
3705
|
-
return `builder-personalization-container ${props.attributes?.className || ""}`;
|
|
3706
|
-
}
|
|
3707
|
-
}, () => props.attributes), false, true);
|
|
3699
|
+
spread(_el$, mergeProps(attrs), false, true);
|
|
3708
3700
|
insert(_el$, createComponent(Show, {
|
|
3709
3701
|
get when() {
|
|
3710
|
-
return
|
|
3702
|
+
return memo(() => !!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3711
3703
|
},
|
|
3712
3704
|
get children() {
|
|
3713
|
-
return
|
|
3714
|
-
get
|
|
3715
|
-
return
|
|
3705
|
+
return createComponent(blocks_default, {
|
|
3706
|
+
get blocks() {
|
|
3707
|
+
return blocksToRender().blocks;
|
|
3716
3708
|
},
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
return (() => {
|
|
3720
|
-
const _el$2 = _tmpl$25();
|
|
3721
|
-
setAttribute(_el$2, "key", index);
|
|
3722
|
-
insert(_el$2, createComponent(blocks_default, {
|
|
3723
|
-
get blocks() {
|
|
3724
|
-
return variant.blocks;
|
|
3725
|
-
},
|
|
3726
|
-
get parent() {
|
|
3727
|
-
return props.builderBlock?.id;
|
|
3728
|
-
},
|
|
3729
|
-
path: `component.options.variants.${index}.blocks`
|
|
3730
|
-
}));
|
|
3731
|
-
effect(() => setAttribute(_el$2, "data-variant-id", `${props.builderBlock?.id}-${index}`));
|
|
3732
|
-
return _el$2;
|
|
3733
|
-
})();
|
|
3734
|
-
}
|
|
3735
|
-
}), createComponent(inlined_styles_default, {
|
|
3736
|
-
get nonce() {
|
|
3737
|
-
return props.builderContext?.nonce || "";
|
|
3709
|
+
get parent() {
|
|
3710
|
+
return props.builderBlock?.id;
|
|
3738
3711
|
},
|
|
3739
|
-
get
|
|
3740
|
-
return
|
|
3712
|
+
get path() {
|
|
3713
|
+
return blocksToRender().path;
|
|
3741
3714
|
},
|
|
3742
|
-
get
|
|
3743
|
-
return
|
|
3744
|
-
}
|
|
3745
|
-
}), createComponent(inlined_script_default, {
|
|
3746
|
-
get nonce() {
|
|
3747
|
-
return props.builderContext?.nonce || "";
|
|
3715
|
+
get context() {
|
|
3716
|
+
return props.builderContext;
|
|
3748
3717
|
},
|
|
3749
|
-
get
|
|
3750
|
-
return
|
|
3718
|
+
get registeredComponents() {
|
|
3719
|
+
return props.builderComponents;
|
|
3751
3720
|
},
|
|
3752
|
-
get
|
|
3753
|
-
return
|
|
3721
|
+
get BlocksWrapperProps() {
|
|
3722
|
+
return {
|
|
3723
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3724
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3725
|
+
};
|
|
3754
3726
|
}
|
|
3755
|
-
})
|
|
3727
|
+
});
|
|
3756
3728
|
}
|
|
3757
3729
|
}), null);
|
|
3758
|
-
insert(_el$, createComponent(
|
|
3759
|
-
get
|
|
3760
|
-
return
|
|
3761
|
-
},
|
|
3762
|
-
get parent() {
|
|
3763
|
-
return props.builderBlock?.id;
|
|
3730
|
+
insert(_el$, createComponent(Show, {
|
|
3731
|
+
get when() {
|
|
3732
|
+
return memo(() => !!!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3764
3733
|
},
|
|
3765
|
-
get
|
|
3766
|
-
return
|
|
3734
|
+
get children() {
|
|
3735
|
+
return [createComponent(Show, {
|
|
3736
|
+
get when() {
|
|
3737
|
+
return shouldRenderVariants();
|
|
3738
|
+
},
|
|
3739
|
+
get children() {
|
|
3740
|
+
return [createComponent(inlined_styles_default, {
|
|
3741
|
+
get nonce() {
|
|
3742
|
+
return props.builderContext?.nonce || "";
|
|
3743
|
+
},
|
|
3744
|
+
get styles() {
|
|
3745
|
+
return hideVariantsStyleString();
|
|
3746
|
+
},
|
|
3747
|
+
get id() {
|
|
3748
|
+
return `variants-styles-${props.builderBlock?.id}`;
|
|
3749
|
+
}
|
|
3750
|
+
}), createComponent(inlined_script_default, {
|
|
3751
|
+
get nonce() {
|
|
3752
|
+
return props.builderContext?.nonce || "";
|
|
3753
|
+
},
|
|
3754
|
+
get scriptStr() {
|
|
3755
|
+
return updateVisibilityStylesScript();
|
|
3756
|
+
},
|
|
3757
|
+
get id() {
|
|
3758
|
+
return `variants-visibility-script-${props.builderBlock?.id}`;
|
|
3759
|
+
}
|
|
3760
|
+
}), createComponent(For, {
|
|
3761
|
+
get each() {
|
|
3762
|
+
return props.variants;
|
|
3763
|
+
},
|
|
3764
|
+
children: (variant, _index) => {
|
|
3765
|
+
const index = _index();
|
|
3766
|
+
return createComponent(blocks_default, {
|
|
3767
|
+
get key() {
|
|
3768
|
+
return `${props.builderBlock?.id}-${index}`;
|
|
3769
|
+
},
|
|
3770
|
+
get BlocksWrapperProps() {
|
|
3771
|
+
return {
|
|
3772
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3773
|
+
"aria-hidden": true,
|
|
3774
|
+
hidden: true,
|
|
3775
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
3776
|
+
};
|
|
3777
|
+
},
|
|
3778
|
+
get blocks() {
|
|
3779
|
+
return variant.blocks;
|
|
3780
|
+
},
|
|
3781
|
+
get parent() {
|
|
3782
|
+
return props.builderBlock?.id;
|
|
3783
|
+
},
|
|
3784
|
+
path: `component.options.variants.${index}.blocks`,
|
|
3785
|
+
get context() {
|
|
3786
|
+
return props.builderContext;
|
|
3787
|
+
},
|
|
3788
|
+
get registeredComponents() {
|
|
3789
|
+
return props.builderComponents;
|
|
3790
|
+
},
|
|
3791
|
+
get children() {
|
|
3792
|
+
return createComponent(inlined_script_default, {
|
|
3793
|
+
get nonce() {
|
|
3794
|
+
return props.builderContext?.nonce || "";
|
|
3795
|
+
},
|
|
3796
|
+
get scriptStr() {
|
|
3797
|
+
return scriptStr();
|
|
3798
|
+
},
|
|
3799
|
+
get id() {
|
|
3800
|
+
return `variants-script-${props.builderBlock?.id}-${index}`;
|
|
3801
|
+
}
|
|
3802
|
+
});
|
|
3803
|
+
}
|
|
3804
|
+
});
|
|
3805
|
+
}
|
|
3806
|
+
})];
|
|
3807
|
+
}
|
|
3808
|
+
}), createComponent(blocks_default, {
|
|
3809
|
+
get blocks() {
|
|
3810
|
+
return blocksToRender().blocks;
|
|
3811
|
+
},
|
|
3812
|
+
get parent() {
|
|
3813
|
+
return props.builderBlock?.id;
|
|
3814
|
+
},
|
|
3815
|
+
get path() {
|
|
3816
|
+
return blocksToRender().path;
|
|
3817
|
+
},
|
|
3818
|
+
get context() {
|
|
3819
|
+
return props.builderContext;
|
|
3820
|
+
},
|
|
3821
|
+
get registeredComponents() {
|
|
3822
|
+
return props.builderComponents;
|
|
3823
|
+
},
|
|
3824
|
+
get BlocksWrapperProps() {
|
|
3825
|
+
return {
|
|
3826
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3827
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3828
|
+
};
|
|
3829
|
+
},
|
|
3830
|
+
get children() {
|
|
3831
|
+
return createComponent(Show, {
|
|
3832
|
+
get when() {
|
|
3833
|
+
return shouldRenderVariants();
|
|
3834
|
+
},
|
|
3835
|
+
get children() {
|
|
3836
|
+
return createComponent(inlined_script_default, {
|
|
3837
|
+
get nonce() {
|
|
3838
|
+
return props.builderContext?.nonce || "";
|
|
3839
|
+
},
|
|
3840
|
+
get scriptStr() {
|
|
3841
|
+
return scriptStr();
|
|
3842
|
+
},
|
|
3843
|
+
get id() {
|
|
3844
|
+
return `variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`;
|
|
3845
|
+
}
|
|
3846
|
+
});
|
|
3847
|
+
}
|
|
3848
|
+
});
|
|
3849
|
+
}
|
|
3850
|
+
})];
|
|
3767
3851
|
}
|
|
3768
3852
|
}), null);
|
|
3769
3853
|
return _el$;
|
|
@@ -4050,7 +4134,7 @@ var componentInfo10 = {
|
|
|
4050
4134
|
}
|
|
4051
4135
|
};
|
|
4052
4136
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
4053
|
-
var _tmpl$
|
|
4137
|
+
var _tmpl$25 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
|
|
4054
4138
|
var _tmpl$33 = /* @__PURE__ */ template(`<span>`);
|
|
4055
4139
|
function Tabs(props) {
|
|
4056
4140
|
const [activeTab, setActiveTab] = createSignal(props.defaultActiveTab ? props.defaultActiveTab - 1 : 0);
|
|
@@ -4065,7 +4149,7 @@ function Tabs(props) {
|
|
|
4065
4149
|
}
|
|
4066
4150
|
}
|
|
4067
4151
|
return (() => {
|
|
4068
|
-
const _el$ = _tmpl$
|
|
4152
|
+
const _el$ = _tmpl$25(), _el$2 = _el$.firstChild;
|
|
4069
4153
|
_el$2.style.setProperty("display", "flex");
|
|
4070
4154
|
_el$2.style.setProperty("flex-direction", "row");
|
|
4071
4155
|
_el$2.style.setProperty("overflow", "auto");
|
|
@@ -4596,9 +4680,9 @@ function logFetch(url) {
|
|
|
4596
4680
|
}
|
|
4597
4681
|
|
|
4598
4682
|
// src/blocks/form/form/form.tsx
|
|
4599
|
-
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-
|
|
4600
|
-
var _tmpl$
|
|
4601
|
-
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-
|
|
4683
|
+
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-7430044e">`);
|
|
4684
|
+
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
4685
|
+
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-7430044e {
|
|
4602
4686
|
padding: 10px;
|
|
4603
4687
|
color: red;
|
|
4604
4688
|
text-align: center;
|
|
@@ -4710,6 +4794,15 @@ function FormComponent(props) {
|
|
|
4710
4794
|
}
|
|
4711
4795
|
}
|
|
4712
4796
|
setFormState("sending");
|
|
4797
|
+
if (props.sendSubmissionsTo === "email" && (props.sendSubmissionsToEmail === "your@email.com" || !props.sendSubmissionsToEmail)) {
|
|
4798
|
+
const message = "SubmissionsToEmail is required when sendSubmissionsTo is set to email";
|
|
4799
|
+
console.error(message);
|
|
4800
|
+
setFormState("error");
|
|
4801
|
+
mergeNewRootState({
|
|
4802
|
+
formErrorMessage: message
|
|
4803
|
+
});
|
|
4804
|
+
return;
|
|
4805
|
+
}
|
|
4713
4806
|
const formUrl = `${getEnv() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${props.builderContext.apiKey}&to=${btoa(props.sendSubmissionsToEmail || "")}&name=${encodeURIComponent(props.name || "")}`;
|
|
4714
4807
|
const url = props.sendSubmissionsTo === "email" ? formUrl : props.action;
|
|
4715
4808
|
logFetch(url);
|
|
@@ -4725,17 +4818,30 @@ function FormComponent(props) {
|
|
|
4725
4818
|
} else {
|
|
4726
4819
|
body2 = await res.text();
|
|
4727
4820
|
}
|
|
4728
|
-
if (!res.ok
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4821
|
+
if (!res.ok) {
|
|
4822
|
+
const submitErrorEvent = new CustomEvent("submit:error", {
|
|
4823
|
+
detail: {
|
|
4824
|
+
error: body2,
|
|
4825
|
+
status: res.status
|
|
4733
4826
|
}
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4827
|
+
});
|
|
4828
|
+
if (formRef?.nativeElement) {
|
|
4829
|
+
formRef?.nativeElement.dispatchEvent(submitErrorEvent);
|
|
4830
|
+
if (submitErrorEvent.defaultPrevented) {
|
|
4831
|
+
return;
|
|
4832
|
+
}
|
|
4833
|
+
}
|
|
4834
|
+
setResponseData(body2);
|
|
4835
|
+
setFormState("error");
|
|
4836
|
+
let message = props.errorMessagePath ? get(body2, props.errorMessagePath) : body2.message || body2.error || body2;
|
|
4837
|
+
if (typeof message !== "string") {
|
|
4838
|
+
message = JSON.stringify(message);
|
|
4738
4839
|
}
|
|
4840
|
+
setFormErrorMessage(message);
|
|
4841
|
+
mergeNewRootState({
|
|
4842
|
+
formErrorMessage: message
|
|
4843
|
+
});
|
|
4844
|
+
return;
|
|
4739
4845
|
}
|
|
4740
4846
|
setResponseData(body2);
|
|
4741
4847
|
setFormState(res.ok ? "success" : "error");
|
|
@@ -4790,7 +4896,7 @@ function FormComponent(props) {
|
|
|
4790
4896
|
}
|
|
4791
4897
|
let formRef;
|
|
4792
4898
|
return [(() => {
|
|
4793
|
-
const _el$ = _tmpl$
|
|
4899
|
+
const _el$ = _tmpl$26();
|
|
4794
4900
|
_el$.addEventListener("submit", (event) => onSubmit(event));
|
|
4795
4901
|
const _ref$ = formRef;
|
|
4796
4902
|
typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
|
|
@@ -5002,7 +5108,7 @@ var componentInfo16 = {
|
|
|
5002
5108
|
noWrap: true
|
|
5003
5109
|
};
|
|
5004
5110
|
var _tmpl$17 = /* @__PURE__ */ template(`<select>`);
|
|
5005
|
-
var _tmpl$
|
|
5111
|
+
var _tmpl$27 = /* @__PURE__ */ template(`<option>`);
|
|
5006
5112
|
function SelectComponent(props) {
|
|
5007
5113
|
return (() => {
|
|
5008
5114
|
const _el$ = _tmpl$17();
|
|
@@ -5030,7 +5136,7 @@ function SelectComponent(props) {
|
|
|
5030
5136
|
children: (option, _index) => {
|
|
5031
5137
|
const index = _index();
|
|
5032
5138
|
return (() => {
|
|
5033
|
-
const _el$2 = _tmpl$
|
|
5139
|
+
const _el$2 = _tmpl$27();
|
|
5034
5140
|
insert(_el$2, () => option.name || option.value);
|
|
5035
5141
|
effect(() => setAttribute(_el$2, "key", `${option.name}-${index}`));
|
|
5036
5142
|
effect(() => _el$2.value = option.value);
|
|
@@ -5274,7 +5380,7 @@ var componentInfo20 = {
|
|
|
5274
5380
|
}
|
|
5275
5381
|
};
|
|
5276
5382
|
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
5277
|
-
var _tmpl$
|
|
5383
|
+
var _tmpl$28 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
5278
5384
|
function Video(props) {
|
|
5279
5385
|
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
5280
5386
|
const videoProps = createMemo(() => {
|
|
@@ -5330,7 +5436,7 @@ function Video(props) {
|
|
|
5330
5436
|
}
|
|
5331
5437
|
});
|
|
5332
5438
|
return (() => {
|
|
5333
|
-
const _el$ = _tmpl$
|
|
5439
|
+
const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
5334
5440
|
_el$.style.setProperty("position", "relative");
|
|
5335
5441
|
const _ref$ = videoRef;
|
|
5336
5442
|
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
@@ -5467,7 +5573,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
5467
5573
|
}, {
|
|
5468
5574
|
component: text_default,
|
|
5469
5575
|
...componentInfo11
|
|
5470
|
-
}, ...TARGET
|
|
5576
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
5471
5577
|
component: personalization_container_default,
|
|
5472
5578
|
...componentInfo6
|
|
5473
5579
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -5504,7 +5610,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
5504
5610
|
|
|
5505
5611
|
// src/components/content-variants/helpers.ts
|
|
5506
5612
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
5507
|
-
var
|
|
5613
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
5508
5614
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
5509
5615
|
...variant,
|
|
5510
5616
|
testVariationId: variant.id,
|
|
@@ -5529,20 +5635,20 @@ var checkShouldRenderVariants2 = ({
|
|
|
5529
5635
|
};
|
|
5530
5636
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
5531
5637
|
var isAngularSDK = TARGET === "angular";
|
|
5532
|
-
var
|
|
5638
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
5533
5639
|
var getInitVariantsFnsScriptString = () => `
|
|
5534
5640
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
5535
|
-
window.${
|
|
5641
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
5536
5642
|
`;
|
|
5537
5643
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
5538
5644
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
5539
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
5645
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
5540
5646
|
)`;
|
|
5541
5647
|
var getUpdateVariantVisibilityScript = ({
|
|
5542
5648
|
contentId,
|
|
5543
5649
|
variationId
|
|
5544
|
-
}) => `window.${
|
|
5545
|
-
"${variationId}", "${contentId}", ${
|
|
5650
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
5651
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
5546
5652
|
)`;
|
|
5547
5653
|
|
|
5548
5654
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -5551,7 +5657,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5551
5657
|
}
|
|
5552
5658
|
|
|
5553
5659
|
// src/constants/sdk-version.ts
|
|
5554
|
-
var SDK_VERSION = "4.0.
|
|
5660
|
+
var SDK_VERSION = "4.0.10";
|
|
5555
5661
|
|
|
5556
5662
|
// src/helpers/sdk-headers.ts
|
|
5557
5663
|
var getSdkHeaders = () => ({
|
|
@@ -6974,7 +7080,7 @@ function ContentVariants(props) {
|
|
|
6974
7080
|
return !props.isNestedRender && TARGET !== "reactNative";
|
|
6975
7081
|
},
|
|
6976
7082
|
get children() {
|
|
6977
|
-
return createComponent(inlined_script_default, {
|
|
7083
|
+
return [createComponent(inlined_script_default, {
|
|
6978
7084
|
id: "builderio-init-variants-fns",
|
|
6979
7085
|
get scriptStr() {
|
|
6980
7086
|
return getInitVariantsFnsScriptString();
|
|
@@ -6982,7 +7088,22 @@ function ContentVariants(props) {
|
|
|
6982
7088
|
get nonce() {
|
|
6983
7089
|
return props.nonce || "";
|
|
6984
7090
|
}
|
|
6985
|
-
})
|
|
7091
|
+
}), createComponent(Show, {
|
|
7092
|
+
get when() {
|
|
7093
|
+
return SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET);
|
|
7094
|
+
},
|
|
7095
|
+
get children() {
|
|
7096
|
+
return createComponent(inlined_script_default, {
|
|
7097
|
+
id: "builderio-init-personalization-variants-fns",
|
|
7098
|
+
get nonce() {
|
|
7099
|
+
return props.nonce || "";
|
|
7100
|
+
},
|
|
7101
|
+
get scriptStr() {
|
|
7102
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
7103
|
+
}
|
|
7104
|
+
});
|
|
7105
|
+
}
|
|
7106
|
+
})];
|
|
6986
7107
|
}
|
|
6987
7108
|
}), createComponent(Show, {
|
|
6988
7109
|
get when() {
|
|
@@ -7170,7 +7291,7 @@ var fetchSymbolContent = async ({
|
|
|
7170
7291
|
};
|
|
7171
7292
|
|
|
7172
7293
|
// src/blocks/symbol/symbol.tsx
|
|
7173
|
-
var _tmpl$
|
|
7294
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
7174
7295
|
function Symbol(props) {
|
|
7175
7296
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
7176
7297
|
const [symbolEntry, setSymbolEntry] = createSignal(props.symbol?.entry);
|
|
@@ -7204,7 +7325,7 @@ function Symbol(props) {
|
|
|
7204
7325
|
}
|
|
7205
7326
|
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
7206
7327
|
return (() => {
|
|
7207
|
-
const _el$ = _tmpl$
|
|
7328
|
+
const _el$ = _tmpl$29();
|
|
7208
7329
|
spread(_el$, mergeProps({
|
|
7209
7330
|
get ["class"]() {
|
|
7210
7331
|
return className();
|