@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/index.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, {
|
|
@@ -4840,7 +4840,7 @@ function Block(props) {
|
|
|
4840
4840
|
});
|
|
4841
4841
|
}
|
|
4842
4842
|
var block_default = Block;
|
|
4843
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
4843
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-450facf4 {
|
|
4844
4844
|
display: flex;
|
|
4845
4845
|
flex-direction: column;
|
|
4846
4846
|
align-items: stretch;
|
|
@@ -4889,7 +4889,7 @@ function BlocksWrapper(props) {
|
|
|
4889
4889
|
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
4890
4890
|
return [createComponent(Dynamic, mergeProps({
|
|
4891
4891
|
get ["class"]() {
|
|
4892
|
-
return className() + " dynamic-
|
|
4892
|
+
return className() + " dynamic-450facf4";
|
|
4893
4893
|
},
|
|
4894
4894
|
ref(r$) {
|
|
4895
4895
|
const _ref$ = blocksWrapperRef;
|
|
@@ -4936,17 +4936,17 @@ function Blocks(props) {
|
|
|
4936
4936
|
get styleProp() {
|
|
4937
4937
|
return props.styleProp;
|
|
4938
4938
|
},
|
|
4939
|
+
get BlocksWrapperProps() {
|
|
4940
|
+
return props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
4941
|
+
},
|
|
4939
4942
|
get classNameProp() {
|
|
4940
4943
|
return props.className;
|
|
4941
4944
|
},
|
|
4942
4945
|
get BlocksWrapper() {
|
|
4943
4946
|
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
4944
4947
|
},
|
|
4945
|
-
get BlocksWrapperProps() {
|
|
4946
|
-
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
4947
|
-
},
|
|
4948
4948
|
get children() {
|
|
4949
|
-
return createComponent(Show, {
|
|
4949
|
+
return [memo(() => props.children), createComponent(Show, {
|
|
4950
4950
|
get when() {
|
|
4951
4951
|
return props.blocks;
|
|
4952
4952
|
},
|
|
@@ -4975,7 +4975,7 @@ function Blocks(props) {
|
|
|
4975
4975
|
}
|
|
4976
4976
|
});
|
|
4977
4977
|
}
|
|
4978
|
-
});
|
|
4978
|
+
})];
|
|
4979
4979
|
}
|
|
4980
4980
|
});
|
|
4981
4981
|
}
|
|
@@ -5399,6 +5399,166 @@ function SectionComponent(props) {
|
|
|
5399
5399
|
}
|
|
5400
5400
|
var section_default = SectionComponent;
|
|
5401
5401
|
|
|
5402
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
5403
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
5404
|
+
function isString(val) {
|
|
5405
|
+
return typeof val === "string";
|
|
5406
|
+
}
|
|
5407
|
+
function isNumber(val) {
|
|
5408
|
+
return typeof val === "number";
|
|
5409
|
+
}
|
|
5410
|
+
function objectMatchesQuery(userattr, query2) {
|
|
5411
|
+
const result = (() => {
|
|
5412
|
+
const property = query2.property;
|
|
5413
|
+
const operator = query2.operator;
|
|
5414
|
+
let testValue = query2.value;
|
|
5415
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
5416
|
+
testValue = query2.value.slice(0, -1);
|
|
5417
|
+
}
|
|
5418
|
+
if (!(property && operator)) {
|
|
5419
|
+
return true;
|
|
5420
|
+
}
|
|
5421
|
+
if (Array.isArray(testValue)) {
|
|
5422
|
+
if (operator === "isNot") {
|
|
5423
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
5424
|
+
property,
|
|
5425
|
+
operator,
|
|
5426
|
+
value: val
|
|
5427
|
+
}));
|
|
5428
|
+
}
|
|
5429
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
5430
|
+
property,
|
|
5431
|
+
operator,
|
|
5432
|
+
value: val
|
|
5433
|
+
}));
|
|
5434
|
+
}
|
|
5435
|
+
const value = userattr[property];
|
|
5436
|
+
if (Array.isArray(value)) {
|
|
5437
|
+
return value.includes(testValue);
|
|
5438
|
+
}
|
|
5439
|
+
switch (operator) {
|
|
5440
|
+
case "is":
|
|
5441
|
+
return value === testValue;
|
|
5442
|
+
case "isNot":
|
|
5443
|
+
return value !== testValue;
|
|
5444
|
+
case "contains":
|
|
5445
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
5446
|
+
case "startsWith":
|
|
5447
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
5448
|
+
case "endsWith":
|
|
5449
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
5450
|
+
case "greaterThan":
|
|
5451
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
5452
|
+
case "lessThan":
|
|
5453
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
5454
|
+
case "greaterThanOrEqualTo":
|
|
5455
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
5456
|
+
case "lessThanOrEqualTo":
|
|
5457
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
5458
|
+
default:
|
|
5459
|
+
return false;
|
|
5460
|
+
}
|
|
5461
|
+
})();
|
|
5462
|
+
return result;
|
|
5463
|
+
}
|
|
5464
|
+
const item = {
|
|
5465
|
+
query,
|
|
5466
|
+
startDate,
|
|
5467
|
+
endDate
|
|
5468
|
+
};
|
|
5469
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
5470
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
5471
|
+
return false;
|
|
5472
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
5473
|
+
return false;
|
|
5474
|
+
}
|
|
5475
|
+
if (!item.query || !item.query.length) {
|
|
5476
|
+
return true;
|
|
5477
|
+
}
|
|
5478
|
+
return item.query.every((filter) => {
|
|
5479
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
5480
|
+
});
|
|
5481
|
+
}
|
|
5482
|
+
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}";
|
|
5483
|
+
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}";
|
|
5484
|
+
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}";
|
|
5485
|
+
|
|
5486
|
+
// src/blocks/personalization-container/helpers.ts
|
|
5487
|
+
var DEFAULT_INDEX = "default";
|
|
5488
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
5489
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
5490
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
5491
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte", "qwik"];
|
|
5492
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte", "qwik"];
|
|
5493
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
5494
|
+
const hasVariants = variants && variants.length > 0;
|
|
5495
|
+
if (TARGET === "reactNative")
|
|
5496
|
+
return false;
|
|
5497
|
+
if (!hasVariants)
|
|
5498
|
+
return false;
|
|
5499
|
+
if (!canTrack)
|
|
5500
|
+
return false;
|
|
5501
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
5502
|
+
return true;
|
|
5503
|
+
if (isBrowser())
|
|
5504
|
+
return false;
|
|
5505
|
+
return true;
|
|
5506
|
+
}
|
|
5507
|
+
function getBlocksToRender({
|
|
5508
|
+
variants,
|
|
5509
|
+
previewingIndex,
|
|
5510
|
+
isHydrated,
|
|
5511
|
+
filteredVariants,
|
|
5512
|
+
fallbackBlocks
|
|
5513
|
+
}) {
|
|
5514
|
+
const fallback = {
|
|
5515
|
+
blocks: fallbackBlocks ?? [],
|
|
5516
|
+
path: "this.children",
|
|
5517
|
+
index: DEFAULT_INDEX
|
|
5518
|
+
};
|
|
5519
|
+
if (isHydrated && isEditing()) {
|
|
5520
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
5521
|
+
const variant = variants?.[previewingIndex];
|
|
5522
|
+
if (variant) {
|
|
5523
|
+
return {
|
|
5524
|
+
blocks: variant.blocks,
|
|
5525
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
5526
|
+
index: previewingIndex
|
|
5527
|
+
};
|
|
5528
|
+
}
|
|
5529
|
+
}
|
|
5530
|
+
return fallback;
|
|
5531
|
+
}
|
|
5532
|
+
if (isBrowser()) {
|
|
5533
|
+
const winningVariant = filteredVariants?.[0];
|
|
5534
|
+
if (winningVariant && variants) {
|
|
5535
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
5536
|
+
if (variantIndex !== -1) {
|
|
5537
|
+
return {
|
|
5538
|
+
blocks: winningVariant.blocks,
|
|
5539
|
+
path: `variants.${variantIndex}.blocks`,
|
|
5540
|
+
index: variantIndex
|
|
5541
|
+
};
|
|
5542
|
+
}
|
|
5543
|
+
}
|
|
5544
|
+
}
|
|
5545
|
+
return fallback;
|
|
5546
|
+
}
|
|
5547
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
5548
|
+
return `
|
|
5549
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
5550
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
5551
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
5552
|
+
`;
|
|
5553
|
+
};
|
|
5554
|
+
var isHydrationTarget = TARGET === "react";
|
|
5555
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
5556
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
5557
|
+
};
|
|
5558
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
5559
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
5560
|
+
};
|
|
5561
|
+
|
|
5402
5562
|
// src/helpers/url.ts
|
|
5403
5563
|
var getTopLevelDomain = (host) => {
|
|
5404
5564
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -5587,6 +5747,11 @@ var handleABTesting = async ({
|
|
|
5587
5747
|
};
|
|
5588
5748
|
};
|
|
5589
5749
|
|
|
5750
|
+
// src/helpers/no-serialize-wrapper.ts
|
|
5751
|
+
function noSerializeWrapper(fn) {
|
|
5752
|
+
return fn;
|
|
5753
|
+
}
|
|
5754
|
+
|
|
5590
5755
|
// src/helpers/user-attributes.ts
|
|
5591
5756
|
var USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
5592
5757
|
function createUserAttributesService() {
|
|
@@ -5617,18 +5782,32 @@ function createUserAttributesService() {
|
|
|
5617
5782
|
canTrack
|
|
5618
5783
|
}) || "{}");
|
|
5619
5784
|
},
|
|
5620
|
-
subscribeOnUserAttributesChange(callback
|
|
5785
|
+
subscribeOnUserAttributesChange(callback, {
|
|
5786
|
+
fireImmediately
|
|
5787
|
+
} = {}) {
|
|
5621
5788
|
subscribers.add(callback);
|
|
5622
|
-
|
|
5789
|
+
if (fireImmediately) {
|
|
5790
|
+
callback(this.getUserAttributes());
|
|
5791
|
+
}
|
|
5792
|
+
return noSerializeWrapper(function() {
|
|
5623
5793
|
subscribers.delete(callback);
|
|
5624
|
-
};
|
|
5794
|
+
});
|
|
5625
5795
|
},
|
|
5626
5796
|
setCanTrack(value) {
|
|
5627
5797
|
canTrack = value;
|
|
5628
5798
|
}
|
|
5629
5799
|
};
|
|
5630
5800
|
}
|
|
5631
|
-
var
|
|
5801
|
+
var _userAttributesService;
|
|
5802
|
+
if (isBrowser() && TARGET === "qwik") {
|
|
5803
|
+
if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__) {
|
|
5804
|
+
window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
|
|
5805
|
+
}
|
|
5806
|
+
_userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
|
|
5807
|
+
} else {
|
|
5808
|
+
_userAttributesService = createUserAttributesService();
|
|
5809
|
+
}
|
|
5810
|
+
var userAttributesService = _userAttributesService;
|
|
5632
5811
|
var setClientUserAttributes = (attributes) => {
|
|
5633
5812
|
userAttributesService.setUserAttributes(attributes);
|
|
5634
5813
|
};
|
|
@@ -6377,7 +6556,8 @@ var componentInfo6 = {
|
|
|
6377
6556
|
name: "PersonalizationContainer",
|
|
6378
6557
|
shouldReceiveBuilderProps: {
|
|
6379
6558
|
builderBlock: true,
|
|
6380
|
-
builderContext: true
|
|
6559
|
+
builderContext: true,
|
|
6560
|
+
builderComponents: true
|
|
6381
6561
|
},
|
|
6382
6562
|
noWrap: true,
|
|
6383
6563
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -6439,208 +6619,22 @@ function isPreviewing(_search) {
|
|
|
6439
6619
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
6440
6620
|
}
|
|
6441
6621
|
|
|
6442
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
6443
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
6444
|
-
function isString(val) {
|
|
6445
|
-
return typeof val === "string";
|
|
6446
|
-
}
|
|
6447
|
-
function isNumber(val) {
|
|
6448
|
-
return typeof val === "number";
|
|
6449
|
-
}
|
|
6450
|
-
function objectMatchesQuery(userattr, query2) {
|
|
6451
|
-
const result = (() => {
|
|
6452
|
-
const property = query2.property;
|
|
6453
|
-
const operator = query2.operator;
|
|
6454
|
-
let testValue = query2.value;
|
|
6455
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
6456
|
-
testValue = query2.value.slice(0, -1);
|
|
6457
|
-
}
|
|
6458
|
-
if (!(property && operator)) {
|
|
6459
|
-
return true;
|
|
6460
|
-
}
|
|
6461
|
-
if (Array.isArray(testValue)) {
|
|
6462
|
-
if (operator === "isNot") {
|
|
6463
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
6464
|
-
property,
|
|
6465
|
-
operator,
|
|
6466
|
-
value: val
|
|
6467
|
-
}));
|
|
6468
|
-
}
|
|
6469
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
6470
|
-
property,
|
|
6471
|
-
operator,
|
|
6472
|
-
value: val
|
|
6473
|
-
}));
|
|
6474
|
-
}
|
|
6475
|
-
const value = userattr[property];
|
|
6476
|
-
if (Array.isArray(value)) {
|
|
6477
|
-
return value.includes(testValue);
|
|
6478
|
-
}
|
|
6479
|
-
switch (operator) {
|
|
6480
|
-
case "is":
|
|
6481
|
-
return value === testValue;
|
|
6482
|
-
case "isNot":
|
|
6483
|
-
return value !== testValue;
|
|
6484
|
-
case "contains":
|
|
6485
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
6486
|
-
case "startsWith":
|
|
6487
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
6488
|
-
case "endsWith":
|
|
6489
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
6490
|
-
case "greaterThan":
|
|
6491
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
6492
|
-
case "lessThan":
|
|
6493
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
6494
|
-
case "greaterThanOrEqualTo":
|
|
6495
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
6496
|
-
case "lessThanOrEqualTo":
|
|
6497
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
6498
|
-
default:
|
|
6499
|
-
return false;
|
|
6500
|
-
}
|
|
6501
|
-
})();
|
|
6502
|
-
return result;
|
|
6503
|
-
}
|
|
6504
|
-
const item = {
|
|
6505
|
-
query,
|
|
6506
|
-
startDate,
|
|
6507
|
-
endDate
|
|
6508
|
-
};
|
|
6509
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
6510
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
6511
|
-
return false;
|
|
6512
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
6513
|
-
return false;
|
|
6514
|
-
}
|
|
6515
|
-
if (!item.query || !item.query.length) {
|
|
6516
|
-
return true;
|
|
6517
|
-
}
|
|
6518
|
-
return item.query.every((filter) => {
|
|
6519
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
6520
|
-
});
|
|
6521
|
-
}
|
|
6522
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
6523
|
-
if (!navigator.cookieEnabled) {
|
|
6524
|
-
return;
|
|
6525
|
-
}
|
|
6526
|
-
function getCookie(name) {
|
|
6527
|
-
const nameEQ = name + '=';
|
|
6528
|
-
const ca = document.cookie.split(';');
|
|
6529
|
-
for (let i = 0; i < ca.length; i++) {
|
|
6530
|
-
let c = ca[i];
|
|
6531
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
6532
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
6533
|
-
}
|
|
6534
|
-
return null;
|
|
6535
|
-
}
|
|
6536
|
-
function removeVariants() {
|
|
6537
|
-
variants?.forEach(function (_, index) {
|
|
6538
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
6539
|
-
});
|
|
6540
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
6541
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
6542
|
-
}
|
|
6543
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
6544
|
-
if (locale) {
|
|
6545
|
-
attributes.locale = locale;
|
|
6546
|
-
}
|
|
6547
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
6548
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
6549
|
-
});
|
|
6550
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
6551
|
-
if (isDebug) {
|
|
6552
|
-
console.debug('PersonalizationContainer', {
|
|
6553
|
-
attributes,
|
|
6554
|
-
variants,
|
|
6555
|
-
winningVariantIndex
|
|
6556
|
-
});
|
|
6557
|
-
}
|
|
6558
|
-
if (winningVariantIndex !== -1) {
|
|
6559
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
6560
|
-
if (winningVariant) {
|
|
6561
|
-
const parentNode = winningVariant.parentNode;
|
|
6562
|
-
if (parentNode) {
|
|
6563
|
-
const newParent = parentNode.cloneNode(false);
|
|
6564
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
6565
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
6566
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
6567
|
-
}
|
|
6568
|
-
if (isDebug) {
|
|
6569
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
6570
|
-
}
|
|
6571
|
-
}
|
|
6572
|
-
} else if (variants && variants.length > 0) {
|
|
6573
|
-
removeVariants();
|
|
6574
|
-
}
|
|
6575
|
-
}`;
|
|
6576
|
-
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}";
|
|
6577
|
-
|
|
6578
|
-
// src/blocks/personalization-container/helpers.ts
|
|
6579
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
6580
|
-
const hasVariants = variants && variants.length > 0;
|
|
6581
|
-
if (TARGET === "reactNative")
|
|
6582
|
-
return false;
|
|
6583
|
-
if (!hasVariants)
|
|
6584
|
-
return false;
|
|
6585
|
-
if (!canTrack)
|
|
6586
|
-
return false;
|
|
6587
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
6588
|
-
return true;
|
|
6589
|
-
if (isBrowser())
|
|
6590
|
-
return false;
|
|
6591
|
-
return true;
|
|
6592
|
-
}
|
|
6593
|
-
function getBlocksToRender({
|
|
6594
|
-
variants,
|
|
6595
|
-
previewingIndex,
|
|
6596
|
-
isHydrated,
|
|
6597
|
-
filteredVariants,
|
|
6598
|
-
fallbackBlocks
|
|
6599
|
-
}) {
|
|
6600
|
-
const fallback = {
|
|
6601
|
-
blocks: fallbackBlocks ?? [],
|
|
6602
|
-
path: "this.children"
|
|
6603
|
-
};
|
|
6604
|
-
if (isHydrated && isEditing()) {
|
|
6605
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
6606
|
-
const variant = variants[previewingIndex];
|
|
6607
|
-
return {
|
|
6608
|
-
blocks: variant.blocks,
|
|
6609
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
6610
|
-
};
|
|
6611
|
-
}
|
|
6612
|
-
return fallback;
|
|
6613
|
-
}
|
|
6614
|
-
if (isBrowser()) {
|
|
6615
|
-
const winningVariant = filteredVariants?.[0];
|
|
6616
|
-
if (winningVariant) {
|
|
6617
|
-
return {
|
|
6618
|
-
blocks: winningVariant.blocks,
|
|
6619
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
6620
|
-
};
|
|
6621
|
-
}
|
|
6622
|
-
}
|
|
6623
|
-
return fallback;
|
|
6624
|
-
}
|
|
6625
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
6626
|
-
return `
|
|
6627
|
-
(function() {
|
|
6628
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
6629
|
-
${PERSONALIZATION_SCRIPT}
|
|
6630
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
6631
|
-
})();
|
|
6632
|
-
`;
|
|
6633
|
-
};
|
|
6634
|
-
|
|
6635
6622
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
6636
6623
|
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
6637
|
-
var _tmpl$25 = /* @__PURE__ */ template(`<template>`);
|
|
6638
6624
|
function PersonalizationContainer(props) {
|
|
6639
6625
|
const [userAttributes, setUserAttributes] = createSignal(userAttributesService.getUserAttributes());
|
|
6640
6626
|
const [scriptStr, setScriptStr] = createSignal(getPersonalizationScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
6627
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal(getUpdateVisibilityStylesScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
6641
6628
|
const [unsubscribers, setUnsubscribers] = createSignal([]);
|
|
6642
6629
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRenderVariants(props.variants, getDefaultCanTrack(props.builderContext?.canTrack)));
|
|
6643
|
-
const [
|
|
6630
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal(false);
|
|
6631
|
+
const attrs = createMemo(() => {
|
|
6632
|
+
return {
|
|
6633
|
+
...props.attributes,
|
|
6634
|
+
...{},
|
|
6635
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
6636
|
+
};
|
|
6637
|
+
});
|
|
6644
6638
|
const filteredVariants = createMemo(() => {
|
|
6645
6639
|
return (props.variants || []).filter((variant) => {
|
|
6646
6640
|
return filterWithCustomTargeting({
|
|
@@ -6655,26 +6649,28 @@ function PersonalizationContainer(props) {
|
|
|
6655
6649
|
return getBlocksToRender({
|
|
6656
6650
|
variants: props.variants,
|
|
6657
6651
|
fallbackBlocks: props.builderBlock?.children,
|
|
6658
|
-
isHydrated:
|
|
6652
|
+
isHydrated: shouldResetVariants(),
|
|
6659
6653
|
filteredVariants: filteredVariants(),
|
|
6660
6654
|
previewingIndex: props.previewingIndex
|
|
6661
6655
|
});
|
|
6662
6656
|
});
|
|
6663
6657
|
const hideVariantsStyleString = createMemo(() => {
|
|
6664
|
-
return (props.variants || []).map((_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `).join("");
|
|
6658
|
+
return (props.variants || []).map((_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `).join("");
|
|
6665
6659
|
});
|
|
6666
6660
|
let rootRef;
|
|
6667
6661
|
onMount(() => {
|
|
6668
|
-
|
|
6669
|
-
const unsub = userAttributesService.subscribeOnUserAttributesChange((
|
|
6670
|
-
setUserAttributes(
|
|
6662
|
+
setShouldResetVariants(true);
|
|
6663
|
+
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
6664
|
+
setUserAttributes(attrs2);
|
|
6665
|
+
}, {
|
|
6666
|
+
fireImmediately: TARGET === "qwik"
|
|
6671
6667
|
});
|
|
6672
6668
|
if (!(isEditing() || isPreviewing())) {
|
|
6673
6669
|
const variant = filteredVariants()[0];
|
|
6674
6670
|
if (rootRef) {
|
|
6675
6671
|
rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
|
|
6676
6672
|
detail: {
|
|
6677
|
-
variant: variant ||
|
|
6673
|
+
variant: variant || DEFAULT_INDEX,
|
|
6678
6674
|
content: props.builderContext?.content
|
|
6679
6675
|
},
|
|
6680
6676
|
bubbles: true
|
|
@@ -6684,7 +6680,7 @@ function PersonalizationContainer(props) {
|
|
|
6684
6680
|
if (entry.isIntersecting && rootRef) {
|
|
6685
6681
|
rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
|
|
6686
6682
|
detail: {
|
|
6687
|
-
variant: variant ||
|
|
6683
|
+
variant: variant || DEFAULT_INDEX,
|
|
6688
6684
|
content: props.builderContext?.content
|
|
6689
6685
|
},
|
|
6690
6686
|
bubbles: true
|
|
@@ -6701,70 +6697,158 @@ function PersonalizationContainer(props) {
|
|
|
6701
6697
|
const _el$ = _tmpl$9();
|
|
6702
6698
|
const _ref$ = rootRef;
|
|
6703
6699
|
typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
|
|
6704
|
-
spread(_el$, mergeProps(
|
|
6705
|
-
get ["class"]() {
|
|
6706
|
-
return `builder-personalization-container ${props.attributes?.className || ""}`;
|
|
6707
|
-
}
|
|
6708
|
-
}, () => props.attributes), false, true);
|
|
6700
|
+
spread(_el$, mergeProps(attrs), false, true);
|
|
6709
6701
|
insert(_el$, createComponent(Show, {
|
|
6710
6702
|
get when() {
|
|
6711
|
-
return
|
|
6703
|
+
return memo(() => !!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
6712
6704
|
},
|
|
6713
6705
|
get children() {
|
|
6714
|
-
return
|
|
6715
|
-
get
|
|
6716
|
-
return
|
|
6706
|
+
return createComponent(blocks_default, {
|
|
6707
|
+
get blocks() {
|
|
6708
|
+
return blocksToRender().blocks;
|
|
6717
6709
|
},
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
return (() => {
|
|
6721
|
-
const _el$2 = _tmpl$25();
|
|
6722
|
-
setAttribute(_el$2, "key", index);
|
|
6723
|
-
insert(_el$2, createComponent(blocks_default, {
|
|
6724
|
-
get blocks() {
|
|
6725
|
-
return variant.blocks;
|
|
6726
|
-
},
|
|
6727
|
-
get parent() {
|
|
6728
|
-
return props.builderBlock?.id;
|
|
6729
|
-
},
|
|
6730
|
-
path: `component.options.variants.${index}.blocks`
|
|
6731
|
-
}));
|
|
6732
|
-
effect(() => setAttribute(_el$2, "data-variant-id", `${props.builderBlock?.id}-${index}`));
|
|
6733
|
-
return _el$2;
|
|
6734
|
-
})();
|
|
6735
|
-
}
|
|
6736
|
-
}), createComponent(inlined_styles_default, {
|
|
6737
|
-
get nonce() {
|
|
6738
|
-
return props.builderContext?.nonce || "";
|
|
6710
|
+
get parent() {
|
|
6711
|
+
return props.builderBlock?.id;
|
|
6739
6712
|
},
|
|
6740
|
-
get
|
|
6741
|
-
return
|
|
6713
|
+
get path() {
|
|
6714
|
+
return blocksToRender().path;
|
|
6742
6715
|
},
|
|
6743
|
-
get
|
|
6744
|
-
return
|
|
6745
|
-
}
|
|
6746
|
-
}), createComponent(inlined_script_default, {
|
|
6747
|
-
get nonce() {
|
|
6748
|
-
return props.builderContext?.nonce || "";
|
|
6716
|
+
get context() {
|
|
6717
|
+
return props.builderContext;
|
|
6749
6718
|
},
|
|
6750
|
-
get
|
|
6751
|
-
return
|
|
6719
|
+
get registeredComponents() {
|
|
6720
|
+
return props.builderComponents;
|
|
6752
6721
|
},
|
|
6753
|
-
get
|
|
6754
|
-
return
|
|
6722
|
+
get BlocksWrapperProps() {
|
|
6723
|
+
return {
|
|
6724
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6725
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
6726
|
+
};
|
|
6755
6727
|
}
|
|
6756
|
-
})
|
|
6728
|
+
});
|
|
6757
6729
|
}
|
|
6758
6730
|
}), null);
|
|
6759
|
-
insert(_el$, createComponent(
|
|
6760
|
-
get
|
|
6761
|
-
return
|
|
6762
|
-
},
|
|
6763
|
-
get parent() {
|
|
6764
|
-
return props.builderBlock?.id;
|
|
6731
|
+
insert(_el$, createComponent(Show, {
|
|
6732
|
+
get when() {
|
|
6733
|
+
return memo(() => !!!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
6765
6734
|
},
|
|
6766
|
-
get
|
|
6767
|
-
return
|
|
6735
|
+
get children() {
|
|
6736
|
+
return [createComponent(Show, {
|
|
6737
|
+
get when() {
|
|
6738
|
+
return shouldRenderVariants();
|
|
6739
|
+
},
|
|
6740
|
+
get children() {
|
|
6741
|
+
return [createComponent(inlined_styles_default, {
|
|
6742
|
+
get nonce() {
|
|
6743
|
+
return props.builderContext?.nonce || "";
|
|
6744
|
+
},
|
|
6745
|
+
get styles() {
|
|
6746
|
+
return hideVariantsStyleString();
|
|
6747
|
+
},
|
|
6748
|
+
get id() {
|
|
6749
|
+
return `variants-styles-${props.builderBlock?.id}`;
|
|
6750
|
+
}
|
|
6751
|
+
}), createComponent(inlined_script_default, {
|
|
6752
|
+
get nonce() {
|
|
6753
|
+
return props.builderContext?.nonce || "";
|
|
6754
|
+
},
|
|
6755
|
+
get scriptStr() {
|
|
6756
|
+
return updateVisibilityStylesScript();
|
|
6757
|
+
},
|
|
6758
|
+
get id() {
|
|
6759
|
+
return `variants-visibility-script-${props.builderBlock?.id}`;
|
|
6760
|
+
}
|
|
6761
|
+
}), createComponent(For, {
|
|
6762
|
+
get each() {
|
|
6763
|
+
return props.variants;
|
|
6764
|
+
},
|
|
6765
|
+
children: (variant, _index) => {
|
|
6766
|
+
const index = _index();
|
|
6767
|
+
return createComponent(blocks_default, {
|
|
6768
|
+
get key() {
|
|
6769
|
+
return `${props.builderBlock?.id}-${index}`;
|
|
6770
|
+
},
|
|
6771
|
+
get BlocksWrapperProps() {
|
|
6772
|
+
return {
|
|
6773
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6774
|
+
"aria-hidden": true,
|
|
6775
|
+
hidden: true,
|
|
6776
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
6777
|
+
};
|
|
6778
|
+
},
|
|
6779
|
+
get blocks() {
|
|
6780
|
+
return variant.blocks;
|
|
6781
|
+
},
|
|
6782
|
+
get parent() {
|
|
6783
|
+
return props.builderBlock?.id;
|
|
6784
|
+
},
|
|
6785
|
+
path: `component.options.variants.${index}.blocks`,
|
|
6786
|
+
get context() {
|
|
6787
|
+
return props.builderContext;
|
|
6788
|
+
},
|
|
6789
|
+
get registeredComponents() {
|
|
6790
|
+
return props.builderComponents;
|
|
6791
|
+
},
|
|
6792
|
+
get children() {
|
|
6793
|
+
return createComponent(inlined_script_default, {
|
|
6794
|
+
get nonce() {
|
|
6795
|
+
return props.builderContext?.nonce || "";
|
|
6796
|
+
},
|
|
6797
|
+
get scriptStr() {
|
|
6798
|
+
return scriptStr();
|
|
6799
|
+
},
|
|
6800
|
+
get id() {
|
|
6801
|
+
return `variants-script-${props.builderBlock?.id}-${index}`;
|
|
6802
|
+
}
|
|
6803
|
+
});
|
|
6804
|
+
}
|
|
6805
|
+
});
|
|
6806
|
+
}
|
|
6807
|
+
})];
|
|
6808
|
+
}
|
|
6809
|
+
}), createComponent(blocks_default, {
|
|
6810
|
+
get blocks() {
|
|
6811
|
+
return blocksToRender().blocks;
|
|
6812
|
+
},
|
|
6813
|
+
get parent() {
|
|
6814
|
+
return props.builderBlock?.id;
|
|
6815
|
+
},
|
|
6816
|
+
get path() {
|
|
6817
|
+
return blocksToRender().path;
|
|
6818
|
+
},
|
|
6819
|
+
get context() {
|
|
6820
|
+
return props.builderContext;
|
|
6821
|
+
},
|
|
6822
|
+
get registeredComponents() {
|
|
6823
|
+
return props.builderComponents;
|
|
6824
|
+
},
|
|
6825
|
+
get BlocksWrapperProps() {
|
|
6826
|
+
return {
|
|
6827
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6828
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
6829
|
+
};
|
|
6830
|
+
},
|
|
6831
|
+
get children() {
|
|
6832
|
+
return createComponent(Show, {
|
|
6833
|
+
get when() {
|
|
6834
|
+
return shouldRenderVariants();
|
|
6835
|
+
},
|
|
6836
|
+
get children() {
|
|
6837
|
+
return createComponent(inlined_script_default, {
|
|
6838
|
+
get nonce() {
|
|
6839
|
+
return props.builderContext?.nonce || "";
|
|
6840
|
+
},
|
|
6841
|
+
get scriptStr() {
|
|
6842
|
+
return scriptStr();
|
|
6843
|
+
},
|
|
6844
|
+
get id() {
|
|
6845
|
+
return `variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`;
|
|
6846
|
+
}
|
|
6847
|
+
});
|
|
6848
|
+
}
|
|
6849
|
+
});
|
|
6850
|
+
}
|
|
6851
|
+
})];
|
|
6768
6852
|
}
|
|
6769
6853
|
}), null);
|
|
6770
6854
|
return _el$;
|
|
@@ -7051,7 +7135,7 @@ var componentInfo10 = {
|
|
|
7051
7135
|
}
|
|
7052
7136
|
};
|
|
7053
7137
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
7054
|
-
var _tmpl$
|
|
7138
|
+
var _tmpl$25 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
|
|
7055
7139
|
var _tmpl$33 = /* @__PURE__ */ template(`<span>`);
|
|
7056
7140
|
function Tabs(props) {
|
|
7057
7141
|
const [activeTab, setActiveTab] = createSignal(props.defaultActiveTab ? props.defaultActiveTab - 1 : 0);
|
|
@@ -7066,7 +7150,7 @@ function Tabs(props) {
|
|
|
7066
7150
|
}
|
|
7067
7151
|
}
|
|
7068
7152
|
return (() => {
|
|
7069
|
-
const _el$ = _tmpl$
|
|
7153
|
+
const _el$ = _tmpl$25(), _el$2 = _el$.firstChild;
|
|
7070
7154
|
_el$2.style.setProperty("display", "flex");
|
|
7071
7155
|
_el$2.style.setProperty("flex-direction", "row");
|
|
7072
7156
|
_el$2.style.setProperty("overflow", "auto");
|
|
@@ -7597,9 +7681,9 @@ function logFetch(url) {
|
|
|
7597
7681
|
}
|
|
7598
7682
|
|
|
7599
7683
|
// src/blocks/form/form/form.tsx
|
|
7600
|
-
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-
|
|
7601
|
-
var _tmpl$
|
|
7602
|
-
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-
|
|
7684
|
+
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-7430044e">`);
|
|
7685
|
+
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
7686
|
+
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-7430044e {
|
|
7603
7687
|
padding: 10px;
|
|
7604
7688
|
color: red;
|
|
7605
7689
|
text-align: center;
|
|
@@ -7711,6 +7795,14 @@ function FormComponent(props) {
|
|
|
7711
7795
|
}
|
|
7712
7796
|
}
|
|
7713
7797
|
setFormState("sending");
|
|
7798
|
+
if (props.sendSubmissionsTo === "email" && (props.sendSubmissionsToEmail === "your@email.com" || !props.sendSubmissionsToEmail)) {
|
|
7799
|
+
const message = "SubmissionsToEmail is required when sendSubmissionsTo is set to email";
|
|
7800
|
+
setFormState("error");
|
|
7801
|
+
mergeNewRootState({
|
|
7802
|
+
formErrorMessage: message
|
|
7803
|
+
});
|
|
7804
|
+
return;
|
|
7805
|
+
}
|
|
7714
7806
|
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 || "")}`;
|
|
7715
7807
|
const url = props.sendSubmissionsTo === "email" ? formUrl : props.action;
|
|
7716
7808
|
logFetch(url);
|
|
@@ -7726,17 +7818,30 @@ function FormComponent(props) {
|
|
|
7726
7818
|
} else {
|
|
7727
7819
|
body2 = await res.text();
|
|
7728
7820
|
}
|
|
7729
|
-
if (!res.ok
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7821
|
+
if (!res.ok) {
|
|
7822
|
+
const submitErrorEvent = new CustomEvent("submit:error", {
|
|
7823
|
+
detail: {
|
|
7824
|
+
error: body2,
|
|
7825
|
+
status: res.status
|
|
7734
7826
|
}
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7827
|
+
});
|
|
7828
|
+
if (formRef?.nativeElement) {
|
|
7829
|
+
formRef?.nativeElement.dispatchEvent(submitErrorEvent);
|
|
7830
|
+
if (submitErrorEvent.defaultPrevented) {
|
|
7831
|
+
return;
|
|
7832
|
+
}
|
|
7833
|
+
}
|
|
7834
|
+
setResponseData(body2);
|
|
7835
|
+
setFormState("error");
|
|
7836
|
+
let message = props.errorMessagePath ? get(body2, props.errorMessagePath) : body2.message || body2.error || body2;
|
|
7837
|
+
if (typeof message !== "string") {
|
|
7838
|
+
message = JSON.stringify(message);
|
|
7739
7839
|
}
|
|
7840
|
+
setFormErrorMessage(message);
|
|
7841
|
+
mergeNewRootState({
|
|
7842
|
+
formErrorMessage: message
|
|
7843
|
+
});
|
|
7844
|
+
return;
|
|
7740
7845
|
}
|
|
7741
7846
|
setResponseData(body2);
|
|
7742
7847
|
setFormState(res.ok ? "success" : "error");
|
|
@@ -7791,7 +7896,7 @@ function FormComponent(props) {
|
|
|
7791
7896
|
}
|
|
7792
7897
|
let formRef;
|
|
7793
7898
|
return [(() => {
|
|
7794
|
-
const _el$ = _tmpl$
|
|
7899
|
+
const _el$ = _tmpl$26();
|
|
7795
7900
|
_el$.addEventListener("submit", (event) => onSubmit(event));
|
|
7796
7901
|
const _ref$ = formRef;
|
|
7797
7902
|
typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
|
|
@@ -8003,7 +8108,7 @@ var componentInfo16 = {
|
|
|
8003
8108
|
noWrap: true
|
|
8004
8109
|
};
|
|
8005
8110
|
var _tmpl$17 = /* @__PURE__ */ template(`<select>`);
|
|
8006
|
-
var _tmpl$
|
|
8111
|
+
var _tmpl$27 = /* @__PURE__ */ template(`<option>`);
|
|
8007
8112
|
function SelectComponent(props) {
|
|
8008
8113
|
return (() => {
|
|
8009
8114
|
const _el$ = _tmpl$17();
|
|
@@ -8031,7 +8136,7 @@ function SelectComponent(props) {
|
|
|
8031
8136
|
children: (option, _index) => {
|
|
8032
8137
|
const index = _index();
|
|
8033
8138
|
return (() => {
|
|
8034
|
-
const _el$2 = _tmpl$
|
|
8139
|
+
const _el$2 = _tmpl$27();
|
|
8035
8140
|
insert(_el$2, () => option.name || option.value);
|
|
8036
8141
|
effect(() => setAttribute(_el$2, "key", `${option.name}-${index}`));
|
|
8037
8142
|
effect(() => _el$2.value = option.value);
|
|
@@ -8275,7 +8380,7 @@ var componentInfo20 = {
|
|
|
8275
8380
|
}
|
|
8276
8381
|
};
|
|
8277
8382
|
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
8278
|
-
var _tmpl$
|
|
8383
|
+
var _tmpl$28 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
8279
8384
|
function Video(props) {
|
|
8280
8385
|
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
8281
8386
|
const videoProps = createMemo(() => {
|
|
@@ -8330,7 +8435,7 @@ function Video(props) {
|
|
|
8330
8435
|
}
|
|
8331
8436
|
});
|
|
8332
8437
|
return (() => {
|
|
8333
|
-
const _el$ = _tmpl$
|
|
8438
|
+
const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
8334
8439
|
_el$.style.setProperty("position", "relative");
|
|
8335
8440
|
const _ref$ = videoRef;
|
|
8336
8441
|
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
@@ -8467,7 +8572,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
8467
8572
|
}, {
|
|
8468
8573
|
component: text_default,
|
|
8469
8574
|
...componentInfo11
|
|
8470
|
-
}, ...TARGET
|
|
8575
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
8471
8576
|
component: personalization_container_default,
|
|
8472
8577
|
...componentInfo6
|
|
8473
8578
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -8504,7 +8609,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
8504
8609
|
|
|
8505
8610
|
// src/components/content-variants/helpers.ts
|
|
8506
8611
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
8507
|
-
var
|
|
8612
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
8508
8613
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
8509
8614
|
...variant,
|
|
8510
8615
|
testVariationId: variant.id,
|
|
@@ -8529,20 +8634,20 @@ var checkShouldRenderVariants2 = ({
|
|
|
8529
8634
|
};
|
|
8530
8635
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
8531
8636
|
var isAngularSDK = TARGET === "angular";
|
|
8532
|
-
var
|
|
8637
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
8533
8638
|
var getInitVariantsFnsScriptString = () => `
|
|
8534
8639
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
8535
|
-
window.${
|
|
8640
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
8536
8641
|
`;
|
|
8537
8642
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
8538
8643
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
8539
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
8644
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
8540
8645
|
)`;
|
|
8541
8646
|
var getUpdateVariantVisibilityScript = ({
|
|
8542
8647
|
contentId,
|
|
8543
8648
|
variationId
|
|
8544
|
-
}) => `window.${
|
|
8545
|
-
"${variationId}", "${contentId}", ${
|
|
8649
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
8650
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
8546
8651
|
)`;
|
|
8547
8652
|
|
|
8548
8653
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -8551,7 +8656,7 @@ function getPreviewContent(_searchParams) {
|
|
|
8551
8656
|
}
|
|
8552
8657
|
|
|
8553
8658
|
// src/constants/sdk-version.ts
|
|
8554
|
-
var SDK_VERSION = "4.0.
|
|
8659
|
+
var SDK_VERSION = "4.0.10";
|
|
8555
8660
|
|
|
8556
8661
|
// src/helpers/sdk-headers.ts
|
|
8557
8662
|
var getSdkHeaders = () => ({
|
|
@@ -9967,7 +10072,7 @@ function ContentVariants(props) {
|
|
|
9967
10072
|
return !props.isNestedRender && TARGET !== "reactNative";
|
|
9968
10073
|
},
|
|
9969
10074
|
get children() {
|
|
9970
|
-
return createComponent(inlined_script_default, {
|
|
10075
|
+
return [createComponent(inlined_script_default, {
|
|
9971
10076
|
id: "builderio-init-variants-fns",
|
|
9972
10077
|
get scriptStr() {
|
|
9973
10078
|
return getInitVariantsFnsScriptString();
|
|
@@ -9975,7 +10080,22 @@ function ContentVariants(props) {
|
|
|
9975
10080
|
get nonce() {
|
|
9976
10081
|
return props.nonce || "";
|
|
9977
10082
|
}
|
|
9978
|
-
})
|
|
10083
|
+
}), createComponent(Show, {
|
|
10084
|
+
get when() {
|
|
10085
|
+
return SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET);
|
|
10086
|
+
},
|
|
10087
|
+
get children() {
|
|
10088
|
+
return createComponent(inlined_script_default, {
|
|
10089
|
+
id: "builderio-init-personalization-variants-fns",
|
|
10090
|
+
get nonce() {
|
|
10091
|
+
return props.nonce || "";
|
|
10092
|
+
},
|
|
10093
|
+
get scriptStr() {
|
|
10094
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
10095
|
+
}
|
|
10096
|
+
});
|
|
10097
|
+
}
|
|
10098
|
+
})];
|
|
9979
10099
|
}
|
|
9980
10100
|
}), createComponent(Show, {
|
|
9981
10101
|
get when() {
|
|
@@ -10163,7 +10283,7 @@ var fetchSymbolContent = async ({
|
|
|
10163
10283
|
};
|
|
10164
10284
|
|
|
10165
10285
|
// src/blocks/symbol/symbol.tsx
|
|
10166
|
-
var _tmpl$
|
|
10286
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
10167
10287
|
function Symbol2(props) {
|
|
10168
10288
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
10169
10289
|
const [symbolEntry, setSymbolEntry] = createSignal(props.symbol?.entry);
|
|
@@ -10197,7 +10317,7 @@ function Symbol2(props) {
|
|
|
10197
10317
|
}
|
|
10198
10318
|
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
10199
10319
|
return (() => {
|
|
10200
|
-
const _el$ = _tmpl$
|
|
10320
|
+
const _el$ = _tmpl$29();
|
|
10201
10321
|
spread(_el$, mergeProps({
|
|
10202
10322
|
get ["class"]() {
|
|
10203
10323
|
return className();
|