@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/browser/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
|
// src/blocks/button/button.tsx
|
|
@@ -1668,7 +1668,7 @@ function Block(props) {
|
|
|
1668
1668
|
});
|
|
1669
1669
|
}
|
|
1670
1670
|
var block_default = Block;
|
|
1671
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1671
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-450facf4 {
|
|
1672
1672
|
display: flex;
|
|
1673
1673
|
flex-direction: column;
|
|
1674
1674
|
align-items: stretch;
|
|
@@ -1717,7 +1717,7 @@ function BlocksWrapper(props) {
|
|
|
1717
1717
|
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1718
1718
|
return [createComponent(Dynamic, mergeProps({
|
|
1719
1719
|
get ["class"]() {
|
|
1720
|
-
return className() + " dynamic-
|
|
1720
|
+
return className() + " dynamic-450facf4";
|
|
1721
1721
|
},
|
|
1722
1722
|
ref(r$) {
|
|
1723
1723
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1764,17 +1764,17 @@ function Blocks(props) {
|
|
|
1764
1764
|
get styleProp() {
|
|
1765
1765
|
return props.styleProp;
|
|
1766
1766
|
},
|
|
1767
|
+
get BlocksWrapperProps() {
|
|
1768
|
+
return props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1769
|
+
},
|
|
1767
1770
|
get classNameProp() {
|
|
1768
1771
|
return props.className;
|
|
1769
1772
|
},
|
|
1770
1773
|
get BlocksWrapper() {
|
|
1771
1774
|
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
1772
1775
|
},
|
|
1773
|
-
get BlocksWrapperProps() {
|
|
1774
|
-
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1775
|
-
},
|
|
1776
1776
|
get children() {
|
|
1777
|
-
return createComponent(Show, {
|
|
1777
|
+
return [memo(() => props.children), createComponent(Show, {
|
|
1778
1778
|
get when() {
|
|
1779
1779
|
return props.blocks;
|
|
1780
1780
|
},
|
|
@@ -1803,7 +1803,7 @@ function Blocks(props) {
|
|
|
1803
1803
|
}
|
|
1804
1804
|
});
|
|
1805
1805
|
}
|
|
1806
|
-
});
|
|
1806
|
+
})];
|
|
1807
1807
|
}
|
|
1808
1808
|
});
|
|
1809
1809
|
}
|
|
@@ -2228,6 +2228,166 @@ function SectionComponent(props) {
|
|
|
2228
2228
|
}
|
|
2229
2229
|
var section_default = SectionComponent;
|
|
2230
2230
|
|
|
2231
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
2232
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
2233
|
+
function isString(val) {
|
|
2234
|
+
return typeof val === "string";
|
|
2235
|
+
}
|
|
2236
|
+
function isNumber(val) {
|
|
2237
|
+
return typeof val === "number";
|
|
2238
|
+
}
|
|
2239
|
+
function objectMatchesQuery(userattr, query2) {
|
|
2240
|
+
const result = (() => {
|
|
2241
|
+
const property = query2.property;
|
|
2242
|
+
const operator = query2.operator;
|
|
2243
|
+
let testValue = query2.value;
|
|
2244
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
2245
|
+
testValue = query2.value.slice(0, -1);
|
|
2246
|
+
}
|
|
2247
|
+
if (!(property && operator)) {
|
|
2248
|
+
return true;
|
|
2249
|
+
}
|
|
2250
|
+
if (Array.isArray(testValue)) {
|
|
2251
|
+
if (operator === "isNot") {
|
|
2252
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
2253
|
+
property,
|
|
2254
|
+
operator,
|
|
2255
|
+
value: val
|
|
2256
|
+
}));
|
|
2257
|
+
}
|
|
2258
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
2259
|
+
property,
|
|
2260
|
+
operator,
|
|
2261
|
+
value: val
|
|
2262
|
+
}));
|
|
2263
|
+
}
|
|
2264
|
+
const value = userattr[property];
|
|
2265
|
+
if (Array.isArray(value)) {
|
|
2266
|
+
return value.includes(testValue);
|
|
2267
|
+
}
|
|
2268
|
+
switch (operator) {
|
|
2269
|
+
case "is":
|
|
2270
|
+
return value === testValue;
|
|
2271
|
+
case "isNot":
|
|
2272
|
+
return value !== testValue;
|
|
2273
|
+
case "contains":
|
|
2274
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
2275
|
+
case "startsWith":
|
|
2276
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
2277
|
+
case "endsWith":
|
|
2278
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
2279
|
+
case "greaterThan":
|
|
2280
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
2281
|
+
case "lessThan":
|
|
2282
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
2283
|
+
case "greaterThanOrEqualTo":
|
|
2284
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
2285
|
+
case "lessThanOrEqualTo":
|
|
2286
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
2287
|
+
default:
|
|
2288
|
+
return false;
|
|
2289
|
+
}
|
|
2290
|
+
})();
|
|
2291
|
+
return result;
|
|
2292
|
+
}
|
|
2293
|
+
const item = {
|
|
2294
|
+
query,
|
|
2295
|
+
startDate,
|
|
2296
|
+
endDate
|
|
2297
|
+
};
|
|
2298
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
2299
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
2300
|
+
return false;
|
|
2301
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
2302
|
+
return false;
|
|
2303
|
+
}
|
|
2304
|
+
if (!item.query || !item.query.length) {
|
|
2305
|
+
return true;
|
|
2306
|
+
}
|
|
2307
|
+
return item.query.every((filter) => {
|
|
2308
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
2309
|
+
});
|
|
2310
|
+
}
|
|
2311
|
+
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}";
|
|
2312
|
+
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}";
|
|
2313
|
+
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}";
|
|
2314
|
+
|
|
2315
|
+
// src/blocks/personalization-container/helpers.ts
|
|
2316
|
+
var DEFAULT_INDEX = "default";
|
|
2317
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
2318
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
2319
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
2320
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte", "qwik"];
|
|
2321
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte", "qwik"];
|
|
2322
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
2323
|
+
const hasVariants = variants && variants.length > 0;
|
|
2324
|
+
if (TARGET === "reactNative")
|
|
2325
|
+
return false;
|
|
2326
|
+
if (!hasVariants)
|
|
2327
|
+
return false;
|
|
2328
|
+
if (!canTrack)
|
|
2329
|
+
return false;
|
|
2330
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
2331
|
+
return true;
|
|
2332
|
+
if (isBrowser())
|
|
2333
|
+
return false;
|
|
2334
|
+
return true;
|
|
2335
|
+
}
|
|
2336
|
+
function getBlocksToRender({
|
|
2337
|
+
variants,
|
|
2338
|
+
previewingIndex,
|
|
2339
|
+
isHydrated,
|
|
2340
|
+
filteredVariants,
|
|
2341
|
+
fallbackBlocks
|
|
2342
|
+
}) {
|
|
2343
|
+
const fallback = {
|
|
2344
|
+
blocks: fallbackBlocks ?? [],
|
|
2345
|
+
path: "this.children",
|
|
2346
|
+
index: DEFAULT_INDEX
|
|
2347
|
+
};
|
|
2348
|
+
if (isHydrated && isEditing()) {
|
|
2349
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
2350
|
+
const variant = variants?.[previewingIndex];
|
|
2351
|
+
if (variant) {
|
|
2352
|
+
return {
|
|
2353
|
+
blocks: variant.blocks,
|
|
2354
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
2355
|
+
index: previewingIndex
|
|
2356
|
+
};
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
return fallback;
|
|
2360
|
+
}
|
|
2361
|
+
if (isBrowser()) {
|
|
2362
|
+
const winningVariant = filteredVariants?.[0];
|
|
2363
|
+
if (winningVariant && variants) {
|
|
2364
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
2365
|
+
if (variantIndex !== -1) {
|
|
2366
|
+
return {
|
|
2367
|
+
blocks: winningVariant.blocks,
|
|
2368
|
+
path: `variants.${variantIndex}.blocks`,
|
|
2369
|
+
index: variantIndex
|
|
2370
|
+
};
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
return fallback;
|
|
2375
|
+
}
|
|
2376
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
2377
|
+
return `
|
|
2378
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
2379
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
2380
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
2381
|
+
`;
|
|
2382
|
+
};
|
|
2383
|
+
var isHydrationTarget = TARGET === "react";
|
|
2384
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
2385
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2386
|
+
};
|
|
2387
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
2388
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2389
|
+
};
|
|
2390
|
+
|
|
2231
2391
|
// src/helpers/url.ts
|
|
2232
2392
|
var getTopLevelDomain = (host) => {
|
|
2233
2393
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -2416,6 +2576,11 @@ var handleABTesting = async ({
|
|
|
2416
2576
|
};
|
|
2417
2577
|
};
|
|
2418
2578
|
|
|
2579
|
+
// src/helpers/no-serialize-wrapper.ts
|
|
2580
|
+
function noSerializeWrapper(fn) {
|
|
2581
|
+
return fn;
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2419
2584
|
// src/helpers/user-attributes.ts
|
|
2420
2585
|
var USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
2421
2586
|
function createUserAttributesService() {
|
|
@@ -2446,18 +2611,32 @@ function createUserAttributesService() {
|
|
|
2446
2611
|
canTrack
|
|
2447
2612
|
}) || "{}");
|
|
2448
2613
|
},
|
|
2449
|
-
subscribeOnUserAttributesChange(callback
|
|
2614
|
+
subscribeOnUserAttributesChange(callback, {
|
|
2615
|
+
fireImmediately
|
|
2616
|
+
} = {}) {
|
|
2450
2617
|
subscribers.add(callback);
|
|
2451
|
-
|
|
2618
|
+
if (fireImmediately) {
|
|
2619
|
+
callback(this.getUserAttributes());
|
|
2620
|
+
}
|
|
2621
|
+
return noSerializeWrapper(function() {
|
|
2452
2622
|
subscribers.delete(callback);
|
|
2453
|
-
};
|
|
2623
|
+
});
|
|
2454
2624
|
},
|
|
2455
2625
|
setCanTrack(value) {
|
|
2456
2626
|
canTrack = value;
|
|
2457
2627
|
}
|
|
2458
2628
|
};
|
|
2459
2629
|
}
|
|
2460
|
-
var
|
|
2630
|
+
var _userAttributesService;
|
|
2631
|
+
if (isBrowser() && TARGET === "qwik") {
|
|
2632
|
+
if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__) {
|
|
2633
|
+
window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
|
|
2634
|
+
}
|
|
2635
|
+
_userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
|
|
2636
|
+
} else {
|
|
2637
|
+
_userAttributesService = createUserAttributesService();
|
|
2638
|
+
}
|
|
2639
|
+
var userAttributesService = _userAttributesService;
|
|
2461
2640
|
var setClientUserAttributes = (attributes) => {
|
|
2462
2641
|
userAttributesService.setUserAttributes(attributes);
|
|
2463
2642
|
};
|
|
@@ -3207,7 +3386,8 @@ var componentInfo6 = {
|
|
|
3207
3386
|
name: "PersonalizationContainer",
|
|
3208
3387
|
shouldReceiveBuilderProps: {
|
|
3209
3388
|
builderBlock: true,
|
|
3210
|
-
builderContext: true
|
|
3389
|
+
builderContext: true,
|
|
3390
|
+
builderComponents: true
|
|
3211
3391
|
},
|
|
3212
3392
|
noWrap: true,
|
|
3213
3393
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -3269,208 +3449,22 @@ function isPreviewing(_search) {
|
|
|
3269
3449
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
3270
3450
|
}
|
|
3271
3451
|
|
|
3272
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
3273
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
3274
|
-
function isString(val) {
|
|
3275
|
-
return typeof val === "string";
|
|
3276
|
-
}
|
|
3277
|
-
function isNumber(val) {
|
|
3278
|
-
return typeof val === "number";
|
|
3279
|
-
}
|
|
3280
|
-
function objectMatchesQuery(userattr, query2) {
|
|
3281
|
-
const result = (() => {
|
|
3282
|
-
const property = query2.property;
|
|
3283
|
-
const operator = query2.operator;
|
|
3284
|
-
let testValue = query2.value;
|
|
3285
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
3286
|
-
testValue = query2.value.slice(0, -1);
|
|
3287
|
-
}
|
|
3288
|
-
if (!(property && operator)) {
|
|
3289
|
-
return true;
|
|
3290
|
-
}
|
|
3291
|
-
if (Array.isArray(testValue)) {
|
|
3292
|
-
if (operator === "isNot") {
|
|
3293
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
3294
|
-
property,
|
|
3295
|
-
operator,
|
|
3296
|
-
value: val
|
|
3297
|
-
}));
|
|
3298
|
-
}
|
|
3299
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
3300
|
-
property,
|
|
3301
|
-
operator,
|
|
3302
|
-
value: val
|
|
3303
|
-
}));
|
|
3304
|
-
}
|
|
3305
|
-
const value = userattr[property];
|
|
3306
|
-
if (Array.isArray(value)) {
|
|
3307
|
-
return value.includes(testValue);
|
|
3308
|
-
}
|
|
3309
|
-
switch (operator) {
|
|
3310
|
-
case "is":
|
|
3311
|
-
return value === testValue;
|
|
3312
|
-
case "isNot":
|
|
3313
|
-
return value !== testValue;
|
|
3314
|
-
case "contains":
|
|
3315
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
3316
|
-
case "startsWith":
|
|
3317
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
3318
|
-
case "endsWith":
|
|
3319
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
3320
|
-
case "greaterThan":
|
|
3321
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
3322
|
-
case "lessThan":
|
|
3323
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
3324
|
-
case "greaterThanOrEqualTo":
|
|
3325
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
3326
|
-
case "lessThanOrEqualTo":
|
|
3327
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
3328
|
-
default:
|
|
3329
|
-
return false;
|
|
3330
|
-
}
|
|
3331
|
-
})();
|
|
3332
|
-
return result;
|
|
3333
|
-
}
|
|
3334
|
-
const item = {
|
|
3335
|
-
query,
|
|
3336
|
-
startDate,
|
|
3337
|
-
endDate
|
|
3338
|
-
};
|
|
3339
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
3340
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
3341
|
-
return false;
|
|
3342
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
3343
|
-
return false;
|
|
3344
|
-
}
|
|
3345
|
-
if (!item.query || !item.query.length) {
|
|
3346
|
-
return true;
|
|
3347
|
-
}
|
|
3348
|
-
return item.query.every((filter) => {
|
|
3349
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
3350
|
-
});
|
|
3351
|
-
}
|
|
3352
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
3353
|
-
if (!navigator.cookieEnabled) {
|
|
3354
|
-
return;
|
|
3355
|
-
}
|
|
3356
|
-
function getCookie(name) {
|
|
3357
|
-
const nameEQ = name + '=';
|
|
3358
|
-
const ca = document.cookie.split(';');
|
|
3359
|
-
for (let i = 0; i < ca.length; i++) {
|
|
3360
|
-
let c = ca[i];
|
|
3361
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
3362
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
3363
|
-
}
|
|
3364
|
-
return null;
|
|
3365
|
-
}
|
|
3366
|
-
function removeVariants() {
|
|
3367
|
-
variants?.forEach(function (_, index) {
|
|
3368
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
3369
|
-
});
|
|
3370
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
3371
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
3372
|
-
}
|
|
3373
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
3374
|
-
if (locale) {
|
|
3375
|
-
attributes.locale = locale;
|
|
3376
|
-
}
|
|
3377
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
3378
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
3379
|
-
});
|
|
3380
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
3381
|
-
if (isDebug) {
|
|
3382
|
-
console.debug('PersonalizationContainer', {
|
|
3383
|
-
attributes,
|
|
3384
|
-
variants,
|
|
3385
|
-
winningVariantIndex
|
|
3386
|
-
});
|
|
3387
|
-
}
|
|
3388
|
-
if (winningVariantIndex !== -1) {
|
|
3389
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
3390
|
-
if (winningVariant) {
|
|
3391
|
-
const parentNode = winningVariant.parentNode;
|
|
3392
|
-
if (parentNode) {
|
|
3393
|
-
const newParent = parentNode.cloneNode(false);
|
|
3394
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
3395
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
3396
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
3397
|
-
}
|
|
3398
|
-
if (isDebug) {
|
|
3399
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
3400
|
-
}
|
|
3401
|
-
}
|
|
3402
|
-
} else if (variants && variants.length > 0) {
|
|
3403
|
-
removeVariants();
|
|
3404
|
-
}
|
|
3405
|
-
}`;
|
|
3406
|
-
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}";
|
|
3407
|
-
|
|
3408
|
-
// src/blocks/personalization-container/helpers.ts
|
|
3409
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
3410
|
-
const hasVariants = variants && variants.length > 0;
|
|
3411
|
-
if (TARGET === "reactNative")
|
|
3412
|
-
return false;
|
|
3413
|
-
if (!hasVariants)
|
|
3414
|
-
return false;
|
|
3415
|
-
if (!canTrack)
|
|
3416
|
-
return false;
|
|
3417
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
3418
|
-
return true;
|
|
3419
|
-
if (isBrowser())
|
|
3420
|
-
return false;
|
|
3421
|
-
return true;
|
|
3422
|
-
}
|
|
3423
|
-
function getBlocksToRender({
|
|
3424
|
-
variants,
|
|
3425
|
-
previewingIndex,
|
|
3426
|
-
isHydrated,
|
|
3427
|
-
filteredVariants,
|
|
3428
|
-
fallbackBlocks
|
|
3429
|
-
}) {
|
|
3430
|
-
const fallback = {
|
|
3431
|
-
blocks: fallbackBlocks ?? [],
|
|
3432
|
-
path: "this.children"
|
|
3433
|
-
};
|
|
3434
|
-
if (isHydrated && isEditing()) {
|
|
3435
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
3436
|
-
const variant = variants[previewingIndex];
|
|
3437
|
-
return {
|
|
3438
|
-
blocks: variant.blocks,
|
|
3439
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
3440
|
-
};
|
|
3441
|
-
}
|
|
3442
|
-
return fallback;
|
|
3443
|
-
}
|
|
3444
|
-
if (isBrowser()) {
|
|
3445
|
-
const winningVariant = filteredVariants?.[0];
|
|
3446
|
-
if (winningVariant) {
|
|
3447
|
-
return {
|
|
3448
|
-
blocks: winningVariant.blocks,
|
|
3449
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
3450
|
-
};
|
|
3451
|
-
}
|
|
3452
|
-
}
|
|
3453
|
-
return fallback;
|
|
3454
|
-
}
|
|
3455
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
3456
|
-
return `
|
|
3457
|
-
(function() {
|
|
3458
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
3459
|
-
${PERSONALIZATION_SCRIPT}
|
|
3460
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
3461
|
-
})();
|
|
3462
|
-
`;
|
|
3463
|
-
};
|
|
3464
|
-
|
|
3465
3452
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
3466
3453
|
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
3467
|
-
var _tmpl$25 = /* @__PURE__ */ template(`<template>`);
|
|
3468
3454
|
function PersonalizationContainer(props) {
|
|
3469
3455
|
const [userAttributes, setUserAttributes] = createSignal(userAttributesService.getUserAttributes());
|
|
3470
3456
|
const [scriptStr, setScriptStr] = createSignal(getPersonalizationScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3457
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal(getUpdateVisibilityStylesScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3471
3458
|
const [unsubscribers, setUnsubscribers] = createSignal([]);
|
|
3472
3459
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRenderVariants(props.variants, getDefaultCanTrack(props.builderContext?.canTrack)));
|
|
3473
|
-
const [
|
|
3460
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal(false);
|
|
3461
|
+
const attrs = createMemo(() => {
|
|
3462
|
+
return {
|
|
3463
|
+
...props.attributes,
|
|
3464
|
+
...{},
|
|
3465
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
3466
|
+
};
|
|
3467
|
+
});
|
|
3474
3468
|
const filteredVariants = createMemo(() => {
|
|
3475
3469
|
return (props.variants || []).filter((variant) => {
|
|
3476
3470
|
return filterWithCustomTargeting({
|
|
@@ -3485,26 +3479,28 @@ function PersonalizationContainer(props) {
|
|
|
3485
3479
|
return getBlocksToRender({
|
|
3486
3480
|
variants: props.variants,
|
|
3487
3481
|
fallbackBlocks: props.builderBlock?.children,
|
|
3488
|
-
isHydrated:
|
|
3482
|
+
isHydrated: shouldResetVariants(),
|
|
3489
3483
|
filteredVariants: filteredVariants(),
|
|
3490
3484
|
previewingIndex: props.previewingIndex
|
|
3491
3485
|
});
|
|
3492
3486
|
});
|
|
3493
3487
|
const hideVariantsStyleString = createMemo(() => {
|
|
3494
|
-
return (props.variants || []).map((_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `).join("");
|
|
3488
|
+
return (props.variants || []).map((_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `).join("");
|
|
3495
3489
|
});
|
|
3496
3490
|
let rootRef;
|
|
3497
3491
|
onMount(() => {
|
|
3498
|
-
|
|
3499
|
-
const unsub = userAttributesService.subscribeOnUserAttributesChange((
|
|
3500
|
-
setUserAttributes(
|
|
3492
|
+
setShouldResetVariants(true);
|
|
3493
|
+
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
3494
|
+
setUserAttributes(attrs2);
|
|
3495
|
+
}, {
|
|
3496
|
+
fireImmediately: TARGET === "qwik"
|
|
3501
3497
|
});
|
|
3502
3498
|
if (!(isEditing() || isPreviewing())) {
|
|
3503
3499
|
const variant = filteredVariants()[0];
|
|
3504
3500
|
if (rootRef) {
|
|
3505
3501
|
rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
|
|
3506
3502
|
detail: {
|
|
3507
|
-
variant: variant ||
|
|
3503
|
+
variant: variant || DEFAULT_INDEX,
|
|
3508
3504
|
content: props.builderContext?.content
|
|
3509
3505
|
},
|
|
3510
3506
|
bubbles: true
|
|
@@ -3514,7 +3510,7 @@ function PersonalizationContainer(props) {
|
|
|
3514
3510
|
if (entry.isIntersecting && rootRef) {
|
|
3515
3511
|
rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
|
|
3516
3512
|
detail: {
|
|
3517
|
-
variant: variant ||
|
|
3513
|
+
variant: variant || DEFAULT_INDEX,
|
|
3518
3514
|
content: props.builderContext?.content
|
|
3519
3515
|
},
|
|
3520
3516
|
bubbles: true
|
|
@@ -3531,70 +3527,158 @@ function PersonalizationContainer(props) {
|
|
|
3531
3527
|
const _el$ = _tmpl$9();
|
|
3532
3528
|
const _ref$ = rootRef;
|
|
3533
3529
|
typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
|
|
3534
|
-
spread(_el$, mergeProps(
|
|
3535
|
-
get ["class"]() {
|
|
3536
|
-
return `builder-personalization-container ${props.attributes?.className || ""}`;
|
|
3537
|
-
}
|
|
3538
|
-
}, () => props.attributes), false, true);
|
|
3530
|
+
spread(_el$, mergeProps(attrs), false, true);
|
|
3539
3531
|
insert(_el$, createComponent(Show, {
|
|
3540
3532
|
get when() {
|
|
3541
|
-
return
|
|
3533
|
+
return memo(() => !!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3542
3534
|
},
|
|
3543
3535
|
get children() {
|
|
3544
|
-
return
|
|
3545
|
-
get
|
|
3546
|
-
return
|
|
3536
|
+
return createComponent(blocks_default, {
|
|
3537
|
+
get blocks() {
|
|
3538
|
+
return blocksToRender().blocks;
|
|
3547
3539
|
},
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
return (() => {
|
|
3551
|
-
const _el$2 = _tmpl$25();
|
|
3552
|
-
setAttribute(_el$2, "key", index);
|
|
3553
|
-
insert(_el$2, createComponent(blocks_default, {
|
|
3554
|
-
get blocks() {
|
|
3555
|
-
return variant.blocks;
|
|
3556
|
-
},
|
|
3557
|
-
get parent() {
|
|
3558
|
-
return props.builderBlock?.id;
|
|
3559
|
-
},
|
|
3560
|
-
path: `component.options.variants.${index}.blocks`
|
|
3561
|
-
}));
|
|
3562
|
-
effect(() => setAttribute(_el$2, "data-variant-id", `${props.builderBlock?.id}-${index}`));
|
|
3563
|
-
return _el$2;
|
|
3564
|
-
})();
|
|
3565
|
-
}
|
|
3566
|
-
}), createComponent(inlined_styles_default, {
|
|
3567
|
-
get nonce() {
|
|
3568
|
-
return props.builderContext?.nonce || "";
|
|
3540
|
+
get parent() {
|
|
3541
|
+
return props.builderBlock?.id;
|
|
3569
3542
|
},
|
|
3570
|
-
get
|
|
3571
|
-
return
|
|
3543
|
+
get path() {
|
|
3544
|
+
return blocksToRender().path;
|
|
3572
3545
|
},
|
|
3573
|
-
get
|
|
3574
|
-
return
|
|
3575
|
-
}
|
|
3576
|
-
}), createComponent(inlined_script_default, {
|
|
3577
|
-
get nonce() {
|
|
3578
|
-
return props.builderContext?.nonce || "";
|
|
3546
|
+
get context() {
|
|
3547
|
+
return props.builderContext;
|
|
3579
3548
|
},
|
|
3580
|
-
get
|
|
3581
|
-
return
|
|
3549
|
+
get registeredComponents() {
|
|
3550
|
+
return props.builderComponents;
|
|
3582
3551
|
},
|
|
3583
|
-
get
|
|
3584
|
-
return
|
|
3552
|
+
get BlocksWrapperProps() {
|
|
3553
|
+
return {
|
|
3554
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3555
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3556
|
+
};
|
|
3585
3557
|
}
|
|
3586
|
-
})
|
|
3558
|
+
});
|
|
3587
3559
|
}
|
|
3588
3560
|
}), null);
|
|
3589
|
-
insert(_el$, createComponent(
|
|
3590
|
-
get
|
|
3591
|
-
return
|
|
3592
|
-
},
|
|
3593
|
-
get parent() {
|
|
3594
|
-
return props.builderBlock?.id;
|
|
3561
|
+
insert(_el$, createComponent(Show, {
|
|
3562
|
+
get when() {
|
|
3563
|
+
return memo(() => !!!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3595
3564
|
},
|
|
3596
|
-
get
|
|
3597
|
-
return
|
|
3565
|
+
get children() {
|
|
3566
|
+
return [createComponent(Show, {
|
|
3567
|
+
get when() {
|
|
3568
|
+
return shouldRenderVariants();
|
|
3569
|
+
},
|
|
3570
|
+
get children() {
|
|
3571
|
+
return [createComponent(inlined_styles_default, {
|
|
3572
|
+
get nonce() {
|
|
3573
|
+
return props.builderContext?.nonce || "";
|
|
3574
|
+
},
|
|
3575
|
+
get styles() {
|
|
3576
|
+
return hideVariantsStyleString();
|
|
3577
|
+
},
|
|
3578
|
+
get id() {
|
|
3579
|
+
return `variants-styles-${props.builderBlock?.id}`;
|
|
3580
|
+
}
|
|
3581
|
+
}), createComponent(inlined_script_default, {
|
|
3582
|
+
get nonce() {
|
|
3583
|
+
return props.builderContext?.nonce || "";
|
|
3584
|
+
},
|
|
3585
|
+
get scriptStr() {
|
|
3586
|
+
return updateVisibilityStylesScript();
|
|
3587
|
+
},
|
|
3588
|
+
get id() {
|
|
3589
|
+
return `variants-visibility-script-${props.builderBlock?.id}`;
|
|
3590
|
+
}
|
|
3591
|
+
}), createComponent(For, {
|
|
3592
|
+
get each() {
|
|
3593
|
+
return props.variants;
|
|
3594
|
+
},
|
|
3595
|
+
children: (variant, _index) => {
|
|
3596
|
+
const index = _index();
|
|
3597
|
+
return createComponent(blocks_default, {
|
|
3598
|
+
get key() {
|
|
3599
|
+
return `${props.builderBlock?.id}-${index}`;
|
|
3600
|
+
},
|
|
3601
|
+
get BlocksWrapperProps() {
|
|
3602
|
+
return {
|
|
3603
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3604
|
+
"aria-hidden": true,
|
|
3605
|
+
hidden: true,
|
|
3606
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
3607
|
+
};
|
|
3608
|
+
},
|
|
3609
|
+
get blocks() {
|
|
3610
|
+
return variant.blocks;
|
|
3611
|
+
},
|
|
3612
|
+
get parent() {
|
|
3613
|
+
return props.builderBlock?.id;
|
|
3614
|
+
},
|
|
3615
|
+
path: `component.options.variants.${index}.blocks`,
|
|
3616
|
+
get context() {
|
|
3617
|
+
return props.builderContext;
|
|
3618
|
+
},
|
|
3619
|
+
get registeredComponents() {
|
|
3620
|
+
return props.builderComponents;
|
|
3621
|
+
},
|
|
3622
|
+
get children() {
|
|
3623
|
+
return createComponent(inlined_script_default, {
|
|
3624
|
+
get nonce() {
|
|
3625
|
+
return props.builderContext?.nonce || "";
|
|
3626
|
+
},
|
|
3627
|
+
get scriptStr() {
|
|
3628
|
+
return scriptStr();
|
|
3629
|
+
},
|
|
3630
|
+
get id() {
|
|
3631
|
+
return `variants-script-${props.builderBlock?.id}-${index}`;
|
|
3632
|
+
}
|
|
3633
|
+
});
|
|
3634
|
+
}
|
|
3635
|
+
});
|
|
3636
|
+
}
|
|
3637
|
+
})];
|
|
3638
|
+
}
|
|
3639
|
+
}), createComponent(blocks_default, {
|
|
3640
|
+
get blocks() {
|
|
3641
|
+
return blocksToRender().blocks;
|
|
3642
|
+
},
|
|
3643
|
+
get parent() {
|
|
3644
|
+
return props.builderBlock?.id;
|
|
3645
|
+
},
|
|
3646
|
+
get path() {
|
|
3647
|
+
return blocksToRender().path;
|
|
3648
|
+
},
|
|
3649
|
+
get context() {
|
|
3650
|
+
return props.builderContext;
|
|
3651
|
+
},
|
|
3652
|
+
get registeredComponents() {
|
|
3653
|
+
return props.builderComponents;
|
|
3654
|
+
},
|
|
3655
|
+
get BlocksWrapperProps() {
|
|
3656
|
+
return {
|
|
3657
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3658
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3659
|
+
};
|
|
3660
|
+
},
|
|
3661
|
+
get children() {
|
|
3662
|
+
return createComponent(Show, {
|
|
3663
|
+
get when() {
|
|
3664
|
+
return shouldRenderVariants();
|
|
3665
|
+
},
|
|
3666
|
+
get children() {
|
|
3667
|
+
return createComponent(inlined_script_default, {
|
|
3668
|
+
get nonce() {
|
|
3669
|
+
return props.builderContext?.nonce || "";
|
|
3670
|
+
},
|
|
3671
|
+
get scriptStr() {
|
|
3672
|
+
return scriptStr();
|
|
3673
|
+
},
|
|
3674
|
+
get id() {
|
|
3675
|
+
return `variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`;
|
|
3676
|
+
}
|
|
3677
|
+
});
|
|
3678
|
+
}
|
|
3679
|
+
});
|
|
3680
|
+
}
|
|
3681
|
+
})];
|
|
3598
3682
|
}
|
|
3599
3683
|
}), null);
|
|
3600
3684
|
return _el$;
|
|
@@ -3881,7 +3965,7 @@ var componentInfo10 = {
|
|
|
3881
3965
|
}
|
|
3882
3966
|
};
|
|
3883
3967
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
3884
|
-
var _tmpl$
|
|
3968
|
+
var _tmpl$25 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
|
|
3885
3969
|
var _tmpl$33 = /* @__PURE__ */ template(`<span>`);
|
|
3886
3970
|
function Tabs(props) {
|
|
3887
3971
|
const [activeTab, setActiveTab] = createSignal(props.defaultActiveTab ? props.defaultActiveTab - 1 : 0);
|
|
@@ -3896,7 +3980,7 @@ function Tabs(props) {
|
|
|
3896
3980
|
}
|
|
3897
3981
|
}
|
|
3898
3982
|
return (() => {
|
|
3899
|
-
const _el$ = _tmpl$
|
|
3983
|
+
const _el$ = _tmpl$25(), _el$2 = _el$.firstChild;
|
|
3900
3984
|
_el$2.style.setProperty("display", "flex");
|
|
3901
3985
|
_el$2.style.setProperty("flex-direction", "row");
|
|
3902
3986
|
_el$2.style.setProperty("overflow", "auto");
|
|
@@ -4427,9 +4511,9 @@ function logFetch(url) {
|
|
|
4427
4511
|
}
|
|
4428
4512
|
|
|
4429
4513
|
// src/blocks/form/form/form.tsx
|
|
4430
|
-
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-
|
|
4431
|
-
var _tmpl$
|
|
4432
|
-
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-
|
|
4514
|
+
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-7430044e">`);
|
|
4515
|
+
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
4516
|
+
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-7430044e {
|
|
4433
4517
|
padding: 10px;
|
|
4434
4518
|
color: red;
|
|
4435
4519
|
text-align: center;
|
|
@@ -4541,6 +4625,15 @@ function FormComponent(props) {
|
|
|
4541
4625
|
}
|
|
4542
4626
|
}
|
|
4543
4627
|
setFormState("sending");
|
|
4628
|
+
if (props.sendSubmissionsTo === "email" && (props.sendSubmissionsToEmail === "your@email.com" || !props.sendSubmissionsToEmail)) {
|
|
4629
|
+
const message = "SubmissionsToEmail is required when sendSubmissionsTo is set to email";
|
|
4630
|
+
console.error(message);
|
|
4631
|
+
setFormState("error");
|
|
4632
|
+
mergeNewRootState({
|
|
4633
|
+
formErrorMessage: message
|
|
4634
|
+
});
|
|
4635
|
+
return;
|
|
4636
|
+
}
|
|
4544
4637
|
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 || "")}`;
|
|
4545
4638
|
const url = props.sendSubmissionsTo === "email" ? formUrl : props.action;
|
|
4546
4639
|
logFetch(url);
|
|
@@ -4556,17 +4649,30 @@ function FormComponent(props) {
|
|
|
4556
4649
|
} else {
|
|
4557
4650
|
body2 = await res.text();
|
|
4558
4651
|
}
|
|
4559
|
-
if (!res.ok
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4652
|
+
if (!res.ok) {
|
|
4653
|
+
const submitErrorEvent = new CustomEvent("submit:error", {
|
|
4654
|
+
detail: {
|
|
4655
|
+
error: body2,
|
|
4656
|
+
status: res.status
|
|
4657
|
+
}
|
|
4658
|
+
});
|
|
4659
|
+
if (formRef?.nativeElement) {
|
|
4660
|
+
formRef?.nativeElement.dispatchEvent(submitErrorEvent);
|
|
4661
|
+
if (submitErrorEvent.defaultPrevented) {
|
|
4662
|
+
return;
|
|
4564
4663
|
}
|
|
4565
|
-
setFormErrorMessage(message);
|
|
4566
|
-
mergeNewRootState({
|
|
4567
|
-
formErrorMessage: message
|
|
4568
|
-
});
|
|
4569
4664
|
}
|
|
4665
|
+
setResponseData(body2);
|
|
4666
|
+
setFormState("error");
|
|
4667
|
+
let message = props.errorMessagePath ? get(body2, props.errorMessagePath) : body2.message || body2.error || body2;
|
|
4668
|
+
if (typeof message !== "string") {
|
|
4669
|
+
message = JSON.stringify(message);
|
|
4670
|
+
}
|
|
4671
|
+
setFormErrorMessage(message);
|
|
4672
|
+
mergeNewRootState({
|
|
4673
|
+
formErrorMessage: message
|
|
4674
|
+
});
|
|
4675
|
+
return;
|
|
4570
4676
|
}
|
|
4571
4677
|
setResponseData(body2);
|
|
4572
4678
|
setFormState(res.ok ? "success" : "error");
|
|
@@ -4621,7 +4727,7 @@ function FormComponent(props) {
|
|
|
4621
4727
|
}
|
|
4622
4728
|
let formRef;
|
|
4623
4729
|
return [(() => {
|
|
4624
|
-
const _el$ = _tmpl$
|
|
4730
|
+
const _el$ = _tmpl$26();
|
|
4625
4731
|
_el$.addEventListener("submit", (event) => onSubmit(event));
|
|
4626
4732
|
const _ref$ = formRef;
|
|
4627
4733
|
typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
|
|
@@ -4833,7 +4939,7 @@ var componentInfo16 = {
|
|
|
4833
4939
|
noWrap: true
|
|
4834
4940
|
};
|
|
4835
4941
|
var _tmpl$17 = /* @__PURE__ */ template(`<select>`);
|
|
4836
|
-
var _tmpl$
|
|
4942
|
+
var _tmpl$27 = /* @__PURE__ */ template(`<option>`);
|
|
4837
4943
|
function SelectComponent(props) {
|
|
4838
4944
|
return (() => {
|
|
4839
4945
|
const _el$ = _tmpl$17();
|
|
@@ -4861,7 +4967,7 @@ function SelectComponent(props) {
|
|
|
4861
4967
|
children: (option, _index) => {
|
|
4862
4968
|
const index = _index();
|
|
4863
4969
|
return (() => {
|
|
4864
|
-
const _el$2 = _tmpl$
|
|
4970
|
+
const _el$2 = _tmpl$27();
|
|
4865
4971
|
insert(_el$2, () => option.name || option.value);
|
|
4866
4972
|
effect(() => setAttribute(_el$2, "key", `${option.name}-${index}`));
|
|
4867
4973
|
effect(() => _el$2.value = option.value);
|
|
@@ -5105,7 +5211,7 @@ var componentInfo20 = {
|
|
|
5105
5211
|
}
|
|
5106
5212
|
};
|
|
5107
5213
|
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
5108
|
-
var _tmpl$
|
|
5214
|
+
var _tmpl$28 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
5109
5215
|
function Video(props) {
|
|
5110
5216
|
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
5111
5217
|
const videoProps = createMemo(() => {
|
|
@@ -5161,7 +5267,7 @@ function Video(props) {
|
|
|
5161
5267
|
}
|
|
5162
5268
|
});
|
|
5163
5269
|
return (() => {
|
|
5164
|
-
const _el$ = _tmpl$
|
|
5270
|
+
const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
5165
5271
|
_el$.style.setProperty("position", "relative");
|
|
5166
5272
|
const _ref$ = videoRef;
|
|
5167
5273
|
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
@@ -5298,7 +5404,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
5298
5404
|
}, {
|
|
5299
5405
|
component: text_default,
|
|
5300
5406
|
...componentInfo11
|
|
5301
|
-
}, ...TARGET
|
|
5407
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
5302
5408
|
component: personalization_container_default,
|
|
5303
5409
|
...componentInfo6
|
|
5304
5410
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -5335,7 +5441,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
5335
5441
|
|
|
5336
5442
|
// src/components/content-variants/helpers.ts
|
|
5337
5443
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
5338
|
-
var
|
|
5444
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
5339
5445
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
5340
5446
|
...variant,
|
|
5341
5447
|
testVariationId: variant.id,
|
|
@@ -5360,20 +5466,20 @@ var checkShouldRenderVariants2 = ({
|
|
|
5360
5466
|
};
|
|
5361
5467
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
5362
5468
|
var isAngularSDK = TARGET === "angular";
|
|
5363
|
-
var
|
|
5469
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
5364
5470
|
var getInitVariantsFnsScriptString = () => `
|
|
5365
5471
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
5366
|
-
window.${
|
|
5472
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
5367
5473
|
`;
|
|
5368
5474
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
5369
5475
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
5370
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
5476
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
5371
5477
|
)`;
|
|
5372
5478
|
var getUpdateVariantVisibilityScript = ({
|
|
5373
5479
|
contentId,
|
|
5374
5480
|
variationId
|
|
5375
|
-
}) => `window.${
|
|
5376
|
-
"${variationId}", "${contentId}", ${
|
|
5481
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
5482
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
5377
5483
|
)`;
|
|
5378
5484
|
|
|
5379
5485
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -5382,7 +5488,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5382
5488
|
}
|
|
5383
5489
|
|
|
5384
5490
|
// src/constants/sdk-version.ts
|
|
5385
|
-
var SDK_VERSION = "4.0.
|
|
5491
|
+
var SDK_VERSION = "4.0.10";
|
|
5386
5492
|
|
|
5387
5493
|
// src/helpers/sdk-headers.ts
|
|
5388
5494
|
var getSdkHeaders = () => ({
|
|
@@ -6805,7 +6911,7 @@ function ContentVariants(props) {
|
|
|
6805
6911
|
return !props.isNestedRender && TARGET !== "reactNative";
|
|
6806
6912
|
},
|
|
6807
6913
|
get children() {
|
|
6808
|
-
return createComponent(inlined_script_default, {
|
|
6914
|
+
return [createComponent(inlined_script_default, {
|
|
6809
6915
|
id: "builderio-init-variants-fns",
|
|
6810
6916
|
get scriptStr() {
|
|
6811
6917
|
return getInitVariantsFnsScriptString();
|
|
@@ -6813,7 +6919,22 @@ function ContentVariants(props) {
|
|
|
6813
6919
|
get nonce() {
|
|
6814
6920
|
return props.nonce || "";
|
|
6815
6921
|
}
|
|
6816
|
-
})
|
|
6922
|
+
}), createComponent(Show, {
|
|
6923
|
+
get when() {
|
|
6924
|
+
return SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET);
|
|
6925
|
+
},
|
|
6926
|
+
get children() {
|
|
6927
|
+
return createComponent(inlined_script_default, {
|
|
6928
|
+
id: "builderio-init-personalization-variants-fns",
|
|
6929
|
+
get nonce() {
|
|
6930
|
+
return props.nonce || "";
|
|
6931
|
+
},
|
|
6932
|
+
get scriptStr() {
|
|
6933
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
6934
|
+
}
|
|
6935
|
+
});
|
|
6936
|
+
}
|
|
6937
|
+
})];
|
|
6817
6938
|
}
|
|
6818
6939
|
}), createComponent(Show, {
|
|
6819
6940
|
get when() {
|
|
@@ -7001,7 +7122,7 @@ var fetchSymbolContent = async ({
|
|
|
7001
7122
|
};
|
|
7002
7123
|
|
|
7003
7124
|
// src/blocks/symbol/symbol.tsx
|
|
7004
|
-
var _tmpl$
|
|
7125
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
7005
7126
|
function Symbol(props) {
|
|
7006
7127
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
7007
7128
|
const [symbolEntry, setSymbolEntry] = createSignal(props.symbol?.entry);
|
|
@@ -7035,7 +7156,7 @@ function Symbol(props) {
|
|
|
7035
7156
|
}
|
|
7036
7157
|
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
7037
7158
|
return (() => {
|
|
7038
|
-
const _el$ = _tmpl$
|
|
7159
|
+
const _el$ = _tmpl$29();
|
|
7039
7160
|
spread(_el$, mergeProps({
|
|
7040
7161
|
get ["class"]() {
|
|
7041
7162
|
return className();
|