@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/edge/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
|
|
|
4
4
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -4849,7 +4849,7 @@ function Block(props) {
|
|
|
4849
4849
|
});
|
|
4850
4850
|
}
|
|
4851
4851
|
var block_default = Block;
|
|
4852
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
4852
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-450facf4 {
|
|
4853
4853
|
display: flex;
|
|
4854
4854
|
flex-direction: column;
|
|
4855
4855
|
align-items: stretch;
|
|
@@ -4898,7 +4898,7 @@ function BlocksWrapper(props) {
|
|
|
4898
4898
|
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
4899
4899
|
return [createComponent(Dynamic, mergeProps({
|
|
4900
4900
|
get ["class"]() {
|
|
4901
|
-
return className() + " dynamic-
|
|
4901
|
+
return className() + " dynamic-450facf4";
|
|
4902
4902
|
},
|
|
4903
4903
|
ref(r$) {
|
|
4904
4904
|
const _ref$ = blocksWrapperRef;
|
|
@@ -4945,17 +4945,17 @@ function Blocks(props) {
|
|
|
4945
4945
|
get styleProp() {
|
|
4946
4946
|
return props.styleProp;
|
|
4947
4947
|
},
|
|
4948
|
+
get BlocksWrapperProps() {
|
|
4949
|
+
return props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
4950
|
+
},
|
|
4948
4951
|
get classNameProp() {
|
|
4949
4952
|
return props.className;
|
|
4950
4953
|
},
|
|
4951
4954
|
get BlocksWrapper() {
|
|
4952
4955
|
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
4953
4956
|
},
|
|
4954
|
-
get BlocksWrapperProps() {
|
|
4955
|
-
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
4956
|
-
},
|
|
4957
4957
|
get children() {
|
|
4958
|
-
return createComponent(Show, {
|
|
4958
|
+
return [memo(() => props.children), createComponent(Show, {
|
|
4959
4959
|
get when() {
|
|
4960
4960
|
return props.blocks;
|
|
4961
4961
|
},
|
|
@@ -4984,7 +4984,7 @@ function Blocks(props) {
|
|
|
4984
4984
|
}
|
|
4985
4985
|
});
|
|
4986
4986
|
}
|
|
4987
|
-
});
|
|
4987
|
+
})];
|
|
4988
4988
|
}
|
|
4989
4989
|
});
|
|
4990
4990
|
}
|
|
@@ -5409,6 +5409,166 @@ function SectionComponent(props) {
|
|
|
5409
5409
|
}
|
|
5410
5410
|
var section_default = SectionComponent;
|
|
5411
5411
|
|
|
5412
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
5413
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
5414
|
+
function isString(val) {
|
|
5415
|
+
return typeof val === "string";
|
|
5416
|
+
}
|
|
5417
|
+
function isNumber(val) {
|
|
5418
|
+
return typeof val === "number";
|
|
5419
|
+
}
|
|
5420
|
+
function objectMatchesQuery(userattr, query2) {
|
|
5421
|
+
const result = (() => {
|
|
5422
|
+
const property = query2.property;
|
|
5423
|
+
const operator = query2.operator;
|
|
5424
|
+
let testValue = query2.value;
|
|
5425
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
5426
|
+
testValue = query2.value.slice(0, -1);
|
|
5427
|
+
}
|
|
5428
|
+
if (!(property && operator)) {
|
|
5429
|
+
return true;
|
|
5430
|
+
}
|
|
5431
|
+
if (Array.isArray(testValue)) {
|
|
5432
|
+
if (operator === "isNot") {
|
|
5433
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
5434
|
+
property,
|
|
5435
|
+
operator,
|
|
5436
|
+
value: val
|
|
5437
|
+
}));
|
|
5438
|
+
}
|
|
5439
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
5440
|
+
property,
|
|
5441
|
+
operator,
|
|
5442
|
+
value: val
|
|
5443
|
+
}));
|
|
5444
|
+
}
|
|
5445
|
+
const value = userattr[property];
|
|
5446
|
+
if (Array.isArray(value)) {
|
|
5447
|
+
return value.includes(testValue);
|
|
5448
|
+
}
|
|
5449
|
+
switch (operator) {
|
|
5450
|
+
case "is":
|
|
5451
|
+
return value === testValue;
|
|
5452
|
+
case "isNot":
|
|
5453
|
+
return value !== testValue;
|
|
5454
|
+
case "contains":
|
|
5455
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
5456
|
+
case "startsWith":
|
|
5457
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
5458
|
+
case "endsWith":
|
|
5459
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
5460
|
+
case "greaterThan":
|
|
5461
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
5462
|
+
case "lessThan":
|
|
5463
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
5464
|
+
case "greaterThanOrEqualTo":
|
|
5465
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
5466
|
+
case "lessThanOrEqualTo":
|
|
5467
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
5468
|
+
default:
|
|
5469
|
+
return false;
|
|
5470
|
+
}
|
|
5471
|
+
})();
|
|
5472
|
+
return result;
|
|
5473
|
+
}
|
|
5474
|
+
const item = {
|
|
5475
|
+
query,
|
|
5476
|
+
startDate,
|
|
5477
|
+
endDate
|
|
5478
|
+
};
|
|
5479
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
5480
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
5481
|
+
return false;
|
|
5482
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
5483
|
+
return false;
|
|
5484
|
+
}
|
|
5485
|
+
if (!item.query || !item.query.length) {
|
|
5486
|
+
return true;
|
|
5487
|
+
}
|
|
5488
|
+
return item.query.every((filter) => {
|
|
5489
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
5490
|
+
});
|
|
5491
|
+
}
|
|
5492
|
+
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}";
|
|
5493
|
+
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}";
|
|
5494
|
+
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}";
|
|
5495
|
+
|
|
5496
|
+
// src/blocks/personalization-container/helpers.ts
|
|
5497
|
+
var DEFAULT_INDEX = "default";
|
|
5498
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
5499
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
5500
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
5501
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte", "qwik"];
|
|
5502
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte", "qwik"];
|
|
5503
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
5504
|
+
const hasVariants = variants && variants.length > 0;
|
|
5505
|
+
if (TARGET === "reactNative")
|
|
5506
|
+
return false;
|
|
5507
|
+
if (!hasVariants)
|
|
5508
|
+
return false;
|
|
5509
|
+
if (!canTrack)
|
|
5510
|
+
return false;
|
|
5511
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
5512
|
+
return true;
|
|
5513
|
+
if (isBrowser())
|
|
5514
|
+
return false;
|
|
5515
|
+
return true;
|
|
5516
|
+
}
|
|
5517
|
+
function getBlocksToRender({
|
|
5518
|
+
variants,
|
|
5519
|
+
previewingIndex,
|
|
5520
|
+
isHydrated,
|
|
5521
|
+
filteredVariants,
|
|
5522
|
+
fallbackBlocks
|
|
5523
|
+
}) {
|
|
5524
|
+
const fallback = {
|
|
5525
|
+
blocks: fallbackBlocks ?? [],
|
|
5526
|
+
path: "this.children",
|
|
5527
|
+
index: DEFAULT_INDEX
|
|
5528
|
+
};
|
|
5529
|
+
if (isHydrated && isEditing()) {
|
|
5530
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
5531
|
+
const variant = variants?.[previewingIndex];
|
|
5532
|
+
if (variant) {
|
|
5533
|
+
return {
|
|
5534
|
+
blocks: variant.blocks,
|
|
5535
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
5536
|
+
index: previewingIndex
|
|
5537
|
+
};
|
|
5538
|
+
}
|
|
5539
|
+
}
|
|
5540
|
+
return fallback;
|
|
5541
|
+
}
|
|
5542
|
+
if (isBrowser()) {
|
|
5543
|
+
const winningVariant = filteredVariants?.[0];
|
|
5544
|
+
if (winningVariant && variants) {
|
|
5545
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
5546
|
+
if (variantIndex !== -1) {
|
|
5547
|
+
return {
|
|
5548
|
+
blocks: winningVariant.blocks,
|
|
5549
|
+
path: `variants.${variantIndex}.blocks`,
|
|
5550
|
+
index: variantIndex
|
|
5551
|
+
};
|
|
5552
|
+
}
|
|
5553
|
+
}
|
|
5554
|
+
}
|
|
5555
|
+
return fallback;
|
|
5556
|
+
}
|
|
5557
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
5558
|
+
return `
|
|
5559
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
5560
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
5561
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
5562
|
+
`;
|
|
5563
|
+
};
|
|
5564
|
+
var isHydrationTarget = TARGET === "react";
|
|
5565
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
5566
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
5567
|
+
};
|
|
5568
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
5569
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
5570
|
+
};
|
|
5571
|
+
|
|
5412
5572
|
// src/helpers/url.ts
|
|
5413
5573
|
var getTopLevelDomain = (host) => {
|
|
5414
5574
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -5597,6 +5757,11 @@ var handleABTesting = async ({
|
|
|
5597
5757
|
};
|
|
5598
5758
|
};
|
|
5599
5759
|
|
|
5760
|
+
// src/helpers/no-serialize-wrapper.ts
|
|
5761
|
+
function noSerializeWrapper(fn) {
|
|
5762
|
+
return fn;
|
|
5763
|
+
}
|
|
5764
|
+
|
|
5600
5765
|
// src/helpers/user-attributes.ts
|
|
5601
5766
|
var USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
5602
5767
|
function createUserAttributesService() {
|
|
@@ -5627,18 +5792,32 @@ function createUserAttributesService() {
|
|
|
5627
5792
|
canTrack
|
|
5628
5793
|
}) || "{}");
|
|
5629
5794
|
},
|
|
5630
|
-
subscribeOnUserAttributesChange(callback
|
|
5795
|
+
subscribeOnUserAttributesChange(callback, {
|
|
5796
|
+
fireImmediately
|
|
5797
|
+
} = {}) {
|
|
5631
5798
|
subscribers.add(callback);
|
|
5632
|
-
|
|
5799
|
+
if (fireImmediately) {
|
|
5800
|
+
callback(this.getUserAttributes());
|
|
5801
|
+
}
|
|
5802
|
+
return noSerializeWrapper(function() {
|
|
5633
5803
|
subscribers.delete(callback);
|
|
5634
|
-
};
|
|
5804
|
+
});
|
|
5635
5805
|
},
|
|
5636
5806
|
setCanTrack(value) {
|
|
5637
5807
|
canTrack = value;
|
|
5638
5808
|
}
|
|
5639
5809
|
};
|
|
5640
5810
|
}
|
|
5641
|
-
var
|
|
5811
|
+
var _userAttributesService;
|
|
5812
|
+
if (isBrowser() && TARGET === "qwik") {
|
|
5813
|
+
if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__) {
|
|
5814
|
+
window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
|
|
5815
|
+
}
|
|
5816
|
+
_userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
|
|
5817
|
+
} else {
|
|
5818
|
+
_userAttributesService = createUserAttributesService();
|
|
5819
|
+
}
|
|
5820
|
+
var userAttributesService = _userAttributesService;
|
|
5642
5821
|
var setClientUserAttributes = (attributes) => {
|
|
5643
5822
|
userAttributesService.setUserAttributes(attributes);
|
|
5644
5823
|
};
|
|
@@ -6388,7 +6567,8 @@ var componentInfo6 = {
|
|
|
6388
6567
|
name: "PersonalizationContainer",
|
|
6389
6568
|
shouldReceiveBuilderProps: {
|
|
6390
6569
|
builderBlock: true,
|
|
6391
|
-
builderContext: true
|
|
6570
|
+
builderContext: true,
|
|
6571
|
+
builderComponents: true
|
|
6392
6572
|
},
|
|
6393
6573
|
noWrap: true,
|
|
6394
6574
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -6450,208 +6630,22 @@ function isPreviewing(_search) {
|
|
|
6450
6630
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
6451
6631
|
}
|
|
6452
6632
|
|
|
6453
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
6454
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
6455
|
-
function isString(val) {
|
|
6456
|
-
return typeof val === "string";
|
|
6457
|
-
}
|
|
6458
|
-
function isNumber(val) {
|
|
6459
|
-
return typeof val === "number";
|
|
6460
|
-
}
|
|
6461
|
-
function objectMatchesQuery(userattr, query2) {
|
|
6462
|
-
const result = (() => {
|
|
6463
|
-
const property = query2.property;
|
|
6464
|
-
const operator = query2.operator;
|
|
6465
|
-
let testValue = query2.value;
|
|
6466
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
6467
|
-
testValue = query2.value.slice(0, -1);
|
|
6468
|
-
}
|
|
6469
|
-
if (!(property && operator)) {
|
|
6470
|
-
return true;
|
|
6471
|
-
}
|
|
6472
|
-
if (Array.isArray(testValue)) {
|
|
6473
|
-
if (operator === "isNot") {
|
|
6474
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
6475
|
-
property,
|
|
6476
|
-
operator,
|
|
6477
|
-
value: val
|
|
6478
|
-
}));
|
|
6479
|
-
}
|
|
6480
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
6481
|
-
property,
|
|
6482
|
-
operator,
|
|
6483
|
-
value: val
|
|
6484
|
-
}));
|
|
6485
|
-
}
|
|
6486
|
-
const value = userattr[property];
|
|
6487
|
-
if (Array.isArray(value)) {
|
|
6488
|
-
return value.includes(testValue);
|
|
6489
|
-
}
|
|
6490
|
-
switch (operator) {
|
|
6491
|
-
case "is":
|
|
6492
|
-
return value === testValue;
|
|
6493
|
-
case "isNot":
|
|
6494
|
-
return value !== testValue;
|
|
6495
|
-
case "contains":
|
|
6496
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
6497
|
-
case "startsWith":
|
|
6498
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
6499
|
-
case "endsWith":
|
|
6500
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
6501
|
-
case "greaterThan":
|
|
6502
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
6503
|
-
case "lessThan":
|
|
6504
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
6505
|
-
case "greaterThanOrEqualTo":
|
|
6506
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
6507
|
-
case "lessThanOrEqualTo":
|
|
6508
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
6509
|
-
default:
|
|
6510
|
-
return false;
|
|
6511
|
-
}
|
|
6512
|
-
})();
|
|
6513
|
-
return result;
|
|
6514
|
-
}
|
|
6515
|
-
const item = {
|
|
6516
|
-
query,
|
|
6517
|
-
startDate,
|
|
6518
|
-
endDate
|
|
6519
|
-
};
|
|
6520
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
6521
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
6522
|
-
return false;
|
|
6523
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
6524
|
-
return false;
|
|
6525
|
-
}
|
|
6526
|
-
if (!item.query || !item.query.length) {
|
|
6527
|
-
return true;
|
|
6528
|
-
}
|
|
6529
|
-
return item.query.every((filter) => {
|
|
6530
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
6531
|
-
});
|
|
6532
|
-
}
|
|
6533
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
6534
|
-
if (!navigator.cookieEnabled) {
|
|
6535
|
-
return;
|
|
6536
|
-
}
|
|
6537
|
-
function getCookie(name) {
|
|
6538
|
-
const nameEQ = name + '=';
|
|
6539
|
-
const ca = document.cookie.split(';');
|
|
6540
|
-
for (let i = 0; i < ca.length; i++) {
|
|
6541
|
-
let c = ca[i];
|
|
6542
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
6543
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
6544
|
-
}
|
|
6545
|
-
return null;
|
|
6546
|
-
}
|
|
6547
|
-
function removeVariants() {
|
|
6548
|
-
variants?.forEach(function (_, index) {
|
|
6549
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
6550
|
-
});
|
|
6551
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
6552
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
6553
|
-
}
|
|
6554
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
6555
|
-
if (locale) {
|
|
6556
|
-
attributes.locale = locale;
|
|
6557
|
-
}
|
|
6558
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
6559
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
6560
|
-
});
|
|
6561
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
6562
|
-
if (isDebug) {
|
|
6563
|
-
console.debug('PersonalizationContainer', {
|
|
6564
|
-
attributes,
|
|
6565
|
-
variants,
|
|
6566
|
-
winningVariantIndex
|
|
6567
|
-
});
|
|
6568
|
-
}
|
|
6569
|
-
if (winningVariantIndex !== -1) {
|
|
6570
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
6571
|
-
if (winningVariant) {
|
|
6572
|
-
const parentNode = winningVariant.parentNode;
|
|
6573
|
-
if (parentNode) {
|
|
6574
|
-
const newParent = parentNode.cloneNode(false);
|
|
6575
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
6576
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
6577
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
6578
|
-
}
|
|
6579
|
-
if (isDebug) {
|
|
6580
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
6581
|
-
}
|
|
6582
|
-
}
|
|
6583
|
-
} else if (variants && variants.length > 0) {
|
|
6584
|
-
removeVariants();
|
|
6585
|
-
}
|
|
6586
|
-
}`;
|
|
6587
|
-
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}";
|
|
6588
|
-
|
|
6589
|
-
// src/blocks/personalization-container/helpers.ts
|
|
6590
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
6591
|
-
const hasVariants = variants && variants.length > 0;
|
|
6592
|
-
if (TARGET === "reactNative")
|
|
6593
|
-
return false;
|
|
6594
|
-
if (!hasVariants)
|
|
6595
|
-
return false;
|
|
6596
|
-
if (!canTrack)
|
|
6597
|
-
return false;
|
|
6598
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
6599
|
-
return true;
|
|
6600
|
-
if (isBrowser())
|
|
6601
|
-
return false;
|
|
6602
|
-
return true;
|
|
6603
|
-
}
|
|
6604
|
-
function getBlocksToRender({
|
|
6605
|
-
variants,
|
|
6606
|
-
previewingIndex,
|
|
6607
|
-
isHydrated,
|
|
6608
|
-
filteredVariants,
|
|
6609
|
-
fallbackBlocks
|
|
6610
|
-
}) {
|
|
6611
|
-
const fallback = {
|
|
6612
|
-
blocks: fallbackBlocks ?? [],
|
|
6613
|
-
path: "this.children"
|
|
6614
|
-
};
|
|
6615
|
-
if (isHydrated && isEditing()) {
|
|
6616
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
6617
|
-
const variant = variants[previewingIndex];
|
|
6618
|
-
return {
|
|
6619
|
-
blocks: variant.blocks,
|
|
6620
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
6621
|
-
};
|
|
6622
|
-
}
|
|
6623
|
-
return fallback;
|
|
6624
|
-
}
|
|
6625
|
-
if (isBrowser()) {
|
|
6626
|
-
const winningVariant = filteredVariants?.[0];
|
|
6627
|
-
if (winningVariant) {
|
|
6628
|
-
return {
|
|
6629
|
-
blocks: winningVariant.blocks,
|
|
6630
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
6631
|
-
};
|
|
6632
|
-
}
|
|
6633
|
-
}
|
|
6634
|
-
return fallback;
|
|
6635
|
-
}
|
|
6636
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
6637
|
-
return `
|
|
6638
|
-
(function() {
|
|
6639
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
6640
|
-
${PERSONALIZATION_SCRIPT}
|
|
6641
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
6642
|
-
})();
|
|
6643
|
-
`;
|
|
6644
|
-
};
|
|
6645
|
-
|
|
6646
6633
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
6647
6634
|
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
6648
|
-
var _tmpl$25 = /* @__PURE__ */ template(`<template>`);
|
|
6649
6635
|
function PersonalizationContainer(props) {
|
|
6650
6636
|
const [userAttributes, setUserAttributes] = createSignal(userAttributesService.getUserAttributes());
|
|
6651
6637
|
const [scriptStr, setScriptStr] = createSignal(getPersonalizationScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
6638
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal(getUpdateVisibilityStylesScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
6652
6639
|
const [unsubscribers, setUnsubscribers] = createSignal([]);
|
|
6653
6640
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRenderVariants(props.variants, getDefaultCanTrack(props.builderContext?.canTrack)));
|
|
6654
|
-
const [
|
|
6641
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal(false);
|
|
6642
|
+
const attrs = createMemo(() => {
|
|
6643
|
+
return {
|
|
6644
|
+
...props.attributes,
|
|
6645
|
+
...{},
|
|
6646
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
6647
|
+
};
|
|
6648
|
+
});
|
|
6655
6649
|
const filteredVariants = createMemo(() => {
|
|
6656
6650
|
return (props.variants || []).filter((variant) => {
|
|
6657
6651
|
return filterWithCustomTargeting({
|
|
@@ -6666,26 +6660,28 @@ function PersonalizationContainer(props) {
|
|
|
6666
6660
|
return getBlocksToRender({
|
|
6667
6661
|
variants: props.variants,
|
|
6668
6662
|
fallbackBlocks: props.builderBlock?.children,
|
|
6669
|
-
isHydrated:
|
|
6663
|
+
isHydrated: shouldResetVariants(),
|
|
6670
6664
|
filteredVariants: filteredVariants(),
|
|
6671
6665
|
previewingIndex: props.previewingIndex
|
|
6672
6666
|
});
|
|
6673
6667
|
});
|
|
6674
6668
|
const hideVariantsStyleString = createMemo(() => {
|
|
6675
|
-
return (props.variants || []).map((_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `).join("");
|
|
6669
|
+
return (props.variants || []).map((_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `).join("");
|
|
6676
6670
|
});
|
|
6677
6671
|
let rootRef;
|
|
6678
6672
|
onMount(() => {
|
|
6679
|
-
|
|
6680
|
-
const unsub = userAttributesService.subscribeOnUserAttributesChange((
|
|
6681
|
-
setUserAttributes(
|
|
6673
|
+
setShouldResetVariants(true);
|
|
6674
|
+
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
6675
|
+
setUserAttributes(attrs2);
|
|
6676
|
+
}, {
|
|
6677
|
+
fireImmediately: TARGET === "qwik"
|
|
6682
6678
|
});
|
|
6683
6679
|
if (!(isEditing() || isPreviewing())) {
|
|
6684
6680
|
const variant = filteredVariants()[0];
|
|
6685
6681
|
if (rootRef) {
|
|
6686
6682
|
rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
|
|
6687
6683
|
detail: {
|
|
6688
|
-
variant: variant ||
|
|
6684
|
+
variant: variant || DEFAULT_INDEX,
|
|
6689
6685
|
content: props.builderContext?.content
|
|
6690
6686
|
},
|
|
6691
6687
|
bubbles: true
|
|
@@ -6695,7 +6691,7 @@ function PersonalizationContainer(props) {
|
|
|
6695
6691
|
if (entry.isIntersecting && rootRef) {
|
|
6696
6692
|
rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
|
|
6697
6693
|
detail: {
|
|
6698
|
-
variant: variant ||
|
|
6694
|
+
variant: variant || DEFAULT_INDEX,
|
|
6699
6695
|
content: props.builderContext?.content
|
|
6700
6696
|
},
|
|
6701
6697
|
bubbles: true
|
|
@@ -6712,70 +6708,158 @@ function PersonalizationContainer(props) {
|
|
|
6712
6708
|
const _el$ = _tmpl$9();
|
|
6713
6709
|
const _ref$ = rootRef;
|
|
6714
6710
|
typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
|
|
6715
|
-
spread(_el$, mergeProps(
|
|
6716
|
-
get ["class"]() {
|
|
6717
|
-
return `builder-personalization-container ${props.attributes?.className || ""}`;
|
|
6718
|
-
}
|
|
6719
|
-
}, () => props.attributes), false, true);
|
|
6711
|
+
spread(_el$, mergeProps(attrs), false, true);
|
|
6720
6712
|
insert(_el$, createComponent(Show, {
|
|
6721
6713
|
get when() {
|
|
6722
|
-
return
|
|
6714
|
+
return memo(() => !!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
6723
6715
|
},
|
|
6724
6716
|
get children() {
|
|
6725
|
-
return
|
|
6726
|
-
get
|
|
6727
|
-
return
|
|
6717
|
+
return createComponent(blocks_default, {
|
|
6718
|
+
get blocks() {
|
|
6719
|
+
return blocksToRender().blocks;
|
|
6728
6720
|
},
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
return (() => {
|
|
6732
|
-
const _el$2 = _tmpl$25();
|
|
6733
|
-
setAttribute(_el$2, "key", index);
|
|
6734
|
-
insert(_el$2, createComponent(blocks_default, {
|
|
6735
|
-
get blocks() {
|
|
6736
|
-
return variant.blocks;
|
|
6737
|
-
},
|
|
6738
|
-
get parent() {
|
|
6739
|
-
return props.builderBlock?.id;
|
|
6740
|
-
},
|
|
6741
|
-
path: `component.options.variants.${index}.blocks`
|
|
6742
|
-
}));
|
|
6743
|
-
effect(() => setAttribute(_el$2, "data-variant-id", `${props.builderBlock?.id}-${index}`));
|
|
6744
|
-
return _el$2;
|
|
6745
|
-
})();
|
|
6746
|
-
}
|
|
6747
|
-
}), createComponent(inlined_styles_default, {
|
|
6748
|
-
get nonce() {
|
|
6749
|
-
return props.builderContext?.nonce || "";
|
|
6721
|
+
get parent() {
|
|
6722
|
+
return props.builderBlock?.id;
|
|
6750
6723
|
},
|
|
6751
|
-
get
|
|
6752
|
-
return
|
|
6724
|
+
get path() {
|
|
6725
|
+
return blocksToRender().path;
|
|
6753
6726
|
},
|
|
6754
|
-
get
|
|
6755
|
-
return
|
|
6756
|
-
}
|
|
6757
|
-
}), createComponent(inlined_script_default, {
|
|
6758
|
-
get nonce() {
|
|
6759
|
-
return props.builderContext?.nonce || "";
|
|
6727
|
+
get context() {
|
|
6728
|
+
return props.builderContext;
|
|
6760
6729
|
},
|
|
6761
|
-
get
|
|
6762
|
-
return
|
|
6730
|
+
get registeredComponents() {
|
|
6731
|
+
return props.builderComponents;
|
|
6763
6732
|
},
|
|
6764
|
-
get
|
|
6765
|
-
return
|
|
6733
|
+
get BlocksWrapperProps() {
|
|
6734
|
+
return {
|
|
6735
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6736
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
6737
|
+
};
|
|
6766
6738
|
}
|
|
6767
|
-
})
|
|
6739
|
+
});
|
|
6768
6740
|
}
|
|
6769
6741
|
}), null);
|
|
6770
|
-
insert(_el$, createComponent(
|
|
6771
|
-
get
|
|
6772
|
-
return
|
|
6773
|
-
},
|
|
6774
|
-
get parent() {
|
|
6775
|
-
return props.builderBlock?.id;
|
|
6742
|
+
insert(_el$, createComponent(Show, {
|
|
6743
|
+
get when() {
|
|
6744
|
+
return memo(() => !!!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
6776
6745
|
},
|
|
6777
|
-
get
|
|
6778
|
-
return
|
|
6746
|
+
get children() {
|
|
6747
|
+
return [createComponent(Show, {
|
|
6748
|
+
get when() {
|
|
6749
|
+
return shouldRenderVariants();
|
|
6750
|
+
},
|
|
6751
|
+
get children() {
|
|
6752
|
+
return [createComponent(inlined_styles_default, {
|
|
6753
|
+
get nonce() {
|
|
6754
|
+
return props.builderContext?.nonce || "";
|
|
6755
|
+
},
|
|
6756
|
+
get styles() {
|
|
6757
|
+
return hideVariantsStyleString();
|
|
6758
|
+
},
|
|
6759
|
+
get id() {
|
|
6760
|
+
return `variants-styles-${props.builderBlock?.id}`;
|
|
6761
|
+
}
|
|
6762
|
+
}), createComponent(inlined_script_default, {
|
|
6763
|
+
get nonce() {
|
|
6764
|
+
return props.builderContext?.nonce || "";
|
|
6765
|
+
},
|
|
6766
|
+
get scriptStr() {
|
|
6767
|
+
return updateVisibilityStylesScript();
|
|
6768
|
+
},
|
|
6769
|
+
get id() {
|
|
6770
|
+
return `variants-visibility-script-${props.builderBlock?.id}`;
|
|
6771
|
+
}
|
|
6772
|
+
}), createComponent(For, {
|
|
6773
|
+
get each() {
|
|
6774
|
+
return props.variants;
|
|
6775
|
+
},
|
|
6776
|
+
children: (variant, _index) => {
|
|
6777
|
+
const index = _index();
|
|
6778
|
+
return createComponent(blocks_default, {
|
|
6779
|
+
get key() {
|
|
6780
|
+
return `${props.builderBlock?.id}-${index}`;
|
|
6781
|
+
},
|
|
6782
|
+
get BlocksWrapperProps() {
|
|
6783
|
+
return {
|
|
6784
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6785
|
+
"aria-hidden": true,
|
|
6786
|
+
hidden: true,
|
|
6787
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
6788
|
+
};
|
|
6789
|
+
},
|
|
6790
|
+
get blocks() {
|
|
6791
|
+
return variant.blocks;
|
|
6792
|
+
},
|
|
6793
|
+
get parent() {
|
|
6794
|
+
return props.builderBlock?.id;
|
|
6795
|
+
},
|
|
6796
|
+
path: `component.options.variants.${index}.blocks`,
|
|
6797
|
+
get context() {
|
|
6798
|
+
return props.builderContext;
|
|
6799
|
+
},
|
|
6800
|
+
get registeredComponents() {
|
|
6801
|
+
return props.builderComponents;
|
|
6802
|
+
},
|
|
6803
|
+
get children() {
|
|
6804
|
+
return createComponent(inlined_script_default, {
|
|
6805
|
+
get nonce() {
|
|
6806
|
+
return props.builderContext?.nonce || "";
|
|
6807
|
+
},
|
|
6808
|
+
get scriptStr() {
|
|
6809
|
+
return scriptStr();
|
|
6810
|
+
},
|
|
6811
|
+
get id() {
|
|
6812
|
+
return `variants-script-${props.builderBlock?.id}-${index}`;
|
|
6813
|
+
}
|
|
6814
|
+
});
|
|
6815
|
+
}
|
|
6816
|
+
});
|
|
6817
|
+
}
|
|
6818
|
+
})];
|
|
6819
|
+
}
|
|
6820
|
+
}), createComponent(blocks_default, {
|
|
6821
|
+
get blocks() {
|
|
6822
|
+
return blocksToRender().blocks;
|
|
6823
|
+
},
|
|
6824
|
+
get parent() {
|
|
6825
|
+
return props.builderBlock?.id;
|
|
6826
|
+
},
|
|
6827
|
+
get path() {
|
|
6828
|
+
return blocksToRender().path;
|
|
6829
|
+
},
|
|
6830
|
+
get context() {
|
|
6831
|
+
return props.builderContext;
|
|
6832
|
+
},
|
|
6833
|
+
get registeredComponents() {
|
|
6834
|
+
return props.builderComponents;
|
|
6835
|
+
},
|
|
6836
|
+
get BlocksWrapperProps() {
|
|
6837
|
+
return {
|
|
6838
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6839
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
6840
|
+
};
|
|
6841
|
+
},
|
|
6842
|
+
get children() {
|
|
6843
|
+
return createComponent(Show, {
|
|
6844
|
+
get when() {
|
|
6845
|
+
return shouldRenderVariants();
|
|
6846
|
+
},
|
|
6847
|
+
get children() {
|
|
6848
|
+
return createComponent(inlined_script_default, {
|
|
6849
|
+
get nonce() {
|
|
6850
|
+
return props.builderContext?.nonce || "";
|
|
6851
|
+
},
|
|
6852
|
+
get scriptStr() {
|
|
6853
|
+
return scriptStr();
|
|
6854
|
+
},
|
|
6855
|
+
get id() {
|
|
6856
|
+
return `variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`;
|
|
6857
|
+
}
|
|
6858
|
+
});
|
|
6859
|
+
}
|
|
6860
|
+
});
|
|
6861
|
+
}
|
|
6862
|
+
})];
|
|
6779
6863
|
}
|
|
6780
6864
|
}), null);
|
|
6781
6865
|
return _el$;
|
|
@@ -7062,7 +7146,7 @@ var componentInfo10 = {
|
|
|
7062
7146
|
}
|
|
7063
7147
|
};
|
|
7064
7148
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
7065
|
-
var _tmpl$
|
|
7149
|
+
var _tmpl$25 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
|
|
7066
7150
|
var _tmpl$33 = /* @__PURE__ */ template(`<span>`);
|
|
7067
7151
|
function Tabs(props) {
|
|
7068
7152
|
const [activeTab, setActiveTab] = createSignal(props.defaultActiveTab ? props.defaultActiveTab - 1 : 0);
|
|
@@ -7077,7 +7161,7 @@ function Tabs(props) {
|
|
|
7077
7161
|
}
|
|
7078
7162
|
}
|
|
7079
7163
|
return (() => {
|
|
7080
|
-
const _el$ = _tmpl$
|
|
7164
|
+
const _el$ = _tmpl$25(), _el$2 = _el$.firstChild;
|
|
7081
7165
|
_el$2.style.setProperty("display", "flex");
|
|
7082
7166
|
_el$2.style.setProperty("flex-direction", "row");
|
|
7083
7167
|
_el$2.style.setProperty("overflow", "auto");
|
|
@@ -7608,9 +7692,9 @@ function logFetch(url) {
|
|
|
7608
7692
|
}
|
|
7609
7693
|
|
|
7610
7694
|
// src/blocks/form/form/form.tsx
|
|
7611
|
-
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-
|
|
7612
|
-
var _tmpl$
|
|
7613
|
-
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-
|
|
7695
|
+
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-7430044e">`);
|
|
7696
|
+
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
7697
|
+
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-7430044e {
|
|
7614
7698
|
padding: 10px;
|
|
7615
7699
|
color: red;
|
|
7616
7700
|
text-align: center;
|
|
@@ -7722,6 +7806,15 @@ function FormComponent(props) {
|
|
|
7722
7806
|
}
|
|
7723
7807
|
}
|
|
7724
7808
|
setFormState("sending");
|
|
7809
|
+
if (props.sendSubmissionsTo === "email" && (props.sendSubmissionsToEmail === "your@email.com" || !props.sendSubmissionsToEmail)) {
|
|
7810
|
+
const message = "SubmissionsToEmail is required when sendSubmissionsTo is set to email";
|
|
7811
|
+
console.error(message);
|
|
7812
|
+
setFormState("error");
|
|
7813
|
+
mergeNewRootState({
|
|
7814
|
+
formErrorMessage: message
|
|
7815
|
+
});
|
|
7816
|
+
return;
|
|
7817
|
+
}
|
|
7725
7818
|
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 || "")}`;
|
|
7726
7819
|
const url = props.sendSubmissionsTo === "email" ? formUrl : props.action;
|
|
7727
7820
|
logFetch(url);
|
|
@@ -7737,17 +7830,30 @@ function FormComponent(props) {
|
|
|
7737
7830
|
} else {
|
|
7738
7831
|
body2 = await res.text();
|
|
7739
7832
|
}
|
|
7740
|
-
if (!res.ok
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7833
|
+
if (!res.ok) {
|
|
7834
|
+
const submitErrorEvent = new CustomEvent("submit:error", {
|
|
7835
|
+
detail: {
|
|
7836
|
+
error: body2,
|
|
7837
|
+
status: res.status
|
|
7745
7838
|
}
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7839
|
+
});
|
|
7840
|
+
if (formRef?.nativeElement) {
|
|
7841
|
+
formRef?.nativeElement.dispatchEvent(submitErrorEvent);
|
|
7842
|
+
if (submitErrorEvent.defaultPrevented) {
|
|
7843
|
+
return;
|
|
7844
|
+
}
|
|
7845
|
+
}
|
|
7846
|
+
setResponseData(body2);
|
|
7847
|
+
setFormState("error");
|
|
7848
|
+
let message = props.errorMessagePath ? get(body2, props.errorMessagePath) : body2.message || body2.error || body2;
|
|
7849
|
+
if (typeof message !== "string") {
|
|
7850
|
+
message = JSON.stringify(message);
|
|
7750
7851
|
}
|
|
7852
|
+
setFormErrorMessage(message);
|
|
7853
|
+
mergeNewRootState({
|
|
7854
|
+
formErrorMessage: message
|
|
7855
|
+
});
|
|
7856
|
+
return;
|
|
7751
7857
|
}
|
|
7752
7858
|
setResponseData(body2);
|
|
7753
7859
|
setFormState(res.ok ? "success" : "error");
|
|
@@ -7802,7 +7908,7 @@ function FormComponent(props) {
|
|
|
7802
7908
|
}
|
|
7803
7909
|
let formRef;
|
|
7804
7910
|
return [(() => {
|
|
7805
|
-
const _el$ = _tmpl$
|
|
7911
|
+
const _el$ = _tmpl$26();
|
|
7806
7912
|
_el$.addEventListener("submit", (event) => onSubmit(event));
|
|
7807
7913
|
const _ref$ = formRef;
|
|
7808
7914
|
typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
|
|
@@ -8014,7 +8120,7 @@ var componentInfo16 = {
|
|
|
8014
8120
|
noWrap: true
|
|
8015
8121
|
};
|
|
8016
8122
|
var _tmpl$17 = /* @__PURE__ */ template(`<select>`);
|
|
8017
|
-
var _tmpl$
|
|
8123
|
+
var _tmpl$27 = /* @__PURE__ */ template(`<option>`);
|
|
8018
8124
|
function SelectComponent(props) {
|
|
8019
8125
|
return (() => {
|
|
8020
8126
|
const _el$ = _tmpl$17();
|
|
@@ -8042,7 +8148,7 @@ function SelectComponent(props) {
|
|
|
8042
8148
|
children: (option, _index) => {
|
|
8043
8149
|
const index = _index();
|
|
8044
8150
|
return (() => {
|
|
8045
|
-
const _el$2 = _tmpl$
|
|
8151
|
+
const _el$2 = _tmpl$27();
|
|
8046
8152
|
insert(_el$2, () => option.name || option.value);
|
|
8047
8153
|
effect(() => setAttribute(_el$2, "key", `${option.name}-${index}`));
|
|
8048
8154
|
effect(() => _el$2.value = option.value);
|
|
@@ -8286,7 +8392,7 @@ var componentInfo20 = {
|
|
|
8286
8392
|
}
|
|
8287
8393
|
};
|
|
8288
8394
|
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
8289
|
-
var _tmpl$
|
|
8395
|
+
var _tmpl$28 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
8290
8396
|
function Video(props) {
|
|
8291
8397
|
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
8292
8398
|
const videoProps = createMemo(() => {
|
|
@@ -8342,7 +8448,7 @@ function Video(props) {
|
|
|
8342
8448
|
}
|
|
8343
8449
|
});
|
|
8344
8450
|
return (() => {
|
|
8345
|
-
const _el$ = _tmpl$
|
|
8451
|
+
const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
8346
8452
|
_el$.style.setProperty("position", "relative");
|
|
8347
8453
|
const _ref$ = videoRef;
|
|
8348
8454
|
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
@@ -8479,7 +8585,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
8479
8585
|
}, {
|
|
8480
8586
|
component: text_default,
|
|
8481
8587
|
...componentInfo11
|
|
8482
|
-
}, ...TARGET
|
|
8588
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
8483
8589
|
component: personalization_container_default,
|
|
8484
8590
|
...componentInfo6
|
|
8485
8591
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -8516,7 +8622,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
8516
8622
|
|
|
8517
8623
|
// src/components/content-variants/helpers.ts
|
|
8518
8624
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
8519
|
-
var
|
|
8625
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
8520
8626
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
8521
8627
|
...variant,
|
|
8522
8628
|
testVariationId: variant.id,
|
|
@@ -8541,20 +8647,20 @@ var checkShouldRenderVariants2 = ({
|
|
|
8541
8647
|
};
|
|
8542
8648
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
8543
8649
|
var isAngularSDK = TARGET === "angular";
|
|
8544
|
-
var
|
|
8650
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
8545
8651
|
var getInitVariantsFnsScriptString = () => `
|
|
8546
8652
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
8547
|
-
window.${
|
|
8653
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
8548
8654
|
`;
|
|
8549
8655
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
8550
8656
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
8551
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
8657
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
8552
8658
|
)`;
|
|
8553
8659
|
var getUpdateVariantVisibilityScript = ({
|
|
8554
8660
|
contentId,
|
|
8555
8661
|
variationId
|
|
8556
|
-
}) => `window.${
|
|
8557
|
-
"${variationId}", "${contentId}", ${
|
|
8662
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
8663
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
8558
8664
|
)`;
|
|
8559
8665
|
|
|
8560
8666
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -8563,7 +8669,7 @@ function getPreviewContent(_searchParams) {
|
|
|
8563
8669
|
}
|
|
8564
8670
|
|
|
8565
8671
|
// src/constants/sdk-version.ts
|
|
8566
|
-
var SDK_VERSION = "4.0.
|
|
8672
|
+
var SDK_VERSION = "4.0.10";
|
|
8567
8673
|
|
|
8568
8674
|
// src/helpers/sdk-headers.ts
|
|
8569
8675
|
var getSdkHeaders = () => ({
|
|
@@ -9986,7 +10092,7 @@ function ContentVariants(props) {
|
|
|
9986
10092
|
return !props.isNestedRender && TARGET !== "reactNative";
|
|
9987
10093
|
},
|
|
9988
10094
|
get children() {
|
|
9989
|
-
return createComponent(inlined_script_default, {
|
|
10095
|
+
return [createComponent(inlined_script_default, {
|
|
9990
10096
|
id: "builderio-init-variants-fns",
|
|
9991
10097
|
get scriptStr() {
|
|
9992
10098
|
return getInitVariantsFnsScriptString();
|
|
@@ -9994,7 +10100,22 @@ function ContentVariants(props) {
|
|
|
9994
10100
|
get nonce() {
|
|
9995
10101
|
return props.nonce || "";
|
|
9996
10102
|
}
|
|
9997
|
-
})
|
|
10103
|
+
}), createComponent(Show, {
|
|
10104
|
+
get when() {
|
|
10105
|
+
return SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET);
|
|
10106
|
+
},
|
|
10107
|
+
get children() {
|
|
10108
|
+
return createComponent(inlined_script_default, {
|
|
10109
|
+
id: "builderio-init-personalization-variants-fns",
|
|
10110
|
+
get nonce() {
|
|
10111
|
+
return props.nonce || "";
|
|
10112
|
+
},
|
|
10113
|
+
get scriptStr() {
|
|
10114
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
10115
|
+
}
|
|
10116
|
+
});
|
|
10117
|
+
}
|
|
10118
|
+
})];
|
|
9998
10119
|
}
|
|
9999
10120
|
}), createComponent(Show, {
|
|
10000
10121
|
get when() {
|
|
@@ -10182,7 +10303,7 @@ var fetchSymbolContent = async ({
|
|
|
10182
10303
|
};
|
|
10183
10304
|
|
|
10184
10305
|
// src/blocks/symbol/symbol.tsx
|
|
10185
|
-
var _tmpl$
|
|
10306
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
10186
10307
|
function Symbol2(props) {
|
|
10187
10308
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
10188
10309
|
const [symbolEntry, setSymbolEntry] = createSignal(props.symbol?.entry);
|
|
@@ -10216,7 +10337,7 @@ function Symbol2(props) {
|
|
|
10216
10337
|
}
|
|
10217
10338
|
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
10218
10339
|
return (() => {
|
|
10219
|
-
const _el$ = _tmpl$
|
|
10340
|
+
const _el$ = _tmpl$29();
|
|
10220
10341
|
spread(_el$, mergeProps({
|
|
10221
10342
|
get ["class"]() {
|
|
10222
10343
|
return className();
|