@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/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
|
// src/blocks/button/button.tsx
|
|
@@ -1659,7 +1659,7 @@ function Block(props) {
|
|
|
1659
1659
|
});
|
|
1660
1660
|
}
|
|
1661
1661
|
var block_default = Block;
|
|
1662
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1662
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-450facf4 {
|
|
1663
1663
|
display: flex;
|
|
1664
1664
|
flex-direction: column;
|
|
1665
1665
|
align-items: stretch;
|
|
@@ -1708,7 +1708,7 @@ function BlocksWrapper(props) {
|
|
|
1708
1708
|
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1709
1709
|
return [createComponent(Dynamic, mergeProps({
|
|
1710
1710
|
get ["class"]() {
|
|
1711
|
-
return className() + " dynamic-
|
|
1711
|
+
return className() + " dynamic-450facf4";
|
|
1712
1712
|
},
|
|
1713
1713
|
ref(r$) {
|
|
1714
1714
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1755,17 +1755,17 @@ function Blocks(props) {
|
|
|
1755
1755
|
get styleProp() {
|
|
1756
1756
|
return props.styleProp;
|
|
1757
1757
|
},
|
|
1758
|
+
get BlocksWrapperProps() {
|
|
1759
|
+
return props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1760
|
+
},
|
|
1758
1761
|
get classNameProp() {
|
|
1759
1762
|
return props.className;
|
|
1760
1763
|
},
|
|
1761
1764
|
get BlocksWrapper() {
|
|
1762
1765
|
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
1763
1766
|
},
|
|
1764
|
-
get BlocksWrapperProps() {
|
|
1765
|
-
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1766
|
-
},
|
|
1767
1767
|
get children() {
|
|
1768
|
-
return createComponent(Show, {
|
|
1768
|
+
return [memo(() => props.children), createComponent(Show, {
|
|
1769
1769
|
get when() {
|
|
1770
1770
|
return props.blocks;
|
|
1771
1771
|
},
|
|
@@ -1794,7 +1794,7 @@ function Blocks(props) {
|
|
|
1794
1794
|
}
|
|
1795
1795
|
});
|
|
1796
1796
|
}
|
|
1797
|
-
});
|
|
1797
|
+
})];
|
|
1798
1798
|
}
|
|
1799
1799
|
});
|
|
1800
1800
|
}
|
|
@@ -2218,6 +2218,166 @@ function SectionComponent(props) {
|
|
|
2218
2218
|
}
|
|
2219
2219
|
var section_default = SectionComponent;
|
|
2220
2220
|
|
|
2221
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
2222
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
2223
|
+
function isString(val) {
|
|
2224
|
+
return typeof val === "string";
|
|
2225
|
+
}
|
|
2226
|
+
function isNumber(val) {
|
|
2227
|
+
return typeof val === "number";
|
|
2228
|
+
}
|
|
2229
|
+
function objectMatchesQuery(userattr, query2) {
|
|
2230
|
+
const result = (() => {
|
|
2231
|
+
const property = query2.property;
|
|
2232
|
+
const operator = query2.operator;
|
|
2233
|
+
let testValue = query2.value;
|
|
2234
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
2235
|
+
testValue = query2.value.slice(0, -1);
|
|
2236
|
+
}
|
|
2237
|
+
if (!(property && operator)) {
|
|
2238
|
+
return true;
|
|
2239
|
+
}
|
|
2240
|
+
if (Array.isArray(testValue)) {
|
|
2241
|
+
if (operator === "isNot") {
|
|
2242
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
2243
|
+
property,
|
|
2244
|
+
operator,
|
|
2245
|
+
value: val
|
|
2246
|
+
}));
|
|
2247
|
+
}
|
|
2248
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
2249
|
+
property,
|
|
2250
|
+
operator,
|
|
2251
|
+
value: val
|
|
2252
|
+
}));
|
|
2253
|
+
}
|
|
2254
|
+
const value = userattr[property];
|
|
2255
|
+
if (Array.isArray(value)) {
|
|
2256
|
+
return value.includes(testValue);
|
|
2257
|
+
}
|
|
2258
|
+
switch (operator) {
|
|
2259
|
+
case "is":
|
|
2260
|
+
return value === testValue;
|
|
2261
|
+
case "isNot":
|
|
2262
|
+
return value !== testValue;
|
|
2263
|
+
case "contains":
|
|
2264
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
2265
|
+
case "startsWith":
|
|
2266
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
2267
|
+
case "endsWith":
|
|
2268
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
2269
|
+
case "greaterThan":
|
|
2270
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
2271
|
+
case "lessThan":
|
|
2272
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
2273
|
+
case "greaterThanOrEqualTo":
|
|
2274
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
2275
|
+
case "lessThanOrEqualTo":
|
|
2276
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
2277
|
+
default:
|
|
2278
|
+
return false;
|
|
2279
|
+
}
|
|
2280
|
+
})();
|
|
2281
|
+
return result;
|
|
2282
|
+
}
|
|
2283
|
+
const item = {
|
|
2284
|
+
query,
|
|
2285
|
+
startDate,
|
|
2286
|
+
endDate
|
|
2287
|
+
};
|
|
2288
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
2289
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
2290
|
+
return false;
|
|
2291
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
2292
|
+
return false;
|
|
2293
|
+
}
|
|
2294
|
+
if (!item.query || !item.query.length) {
|
|
2295
|
+
return true;
|
|
2296
|
+
}
|
|
2297
|
+
return item.query.every((filter) => {
|
|
2298
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
2299
|
+
});
|
|
2300
|
+
}
|
|
2301
|
+
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}";
|
|
2302
|
+
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}";
|
|
2303
|
+
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}";
|
|
2304
|
+
|
|
2305
|
+
// src/blocks/personalization-container/helpers.ts
|
|
2306
|
+
var DEFAULT_INDEX = "default";
|
|
2307
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
2308
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
2309
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
2310
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte", "qwik"];
|
|
2311
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte", "qwik"];
|
|
2312
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
2313
|
+
const hasVariants = variants && variants.length > 0;
|
|
2314
|
+
if (TARGET === "reactNative")
|
|
2315
|
+
return false;
|
|
2316
|
+
if (!hasVariants)
|
|
2317
|
+
return false;
|
|
2318
|
+
if (!canTrack)
|
|
2319
|
+
return false;
|
|
2320
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
2321
|
+
return true;
|
|
2322
|
+
if (isBrowser())
|
|
2323
|
+
return false;
|
|
2324
|
+
return true;
|
|
2325
|
+
}
|
|
2326
|
+
function getBlocksToRender({
|
|
2327
|
+
variants,
|
|
2328
|
+
previewingIndex,
|
|
2329
|
+
isHydrated,
|
|
2330
|
+
filteredVariants,
|
|
2331
|
+
fallbackBlocks
|
|
2332
|
+
}) {
|
|
2333
|
+
const fallback = {
|
|
2334
|
+
blocks: fallbackBlocks ?? [],
|
|
2335
|
+
path: "this.children",
|
|
2336
|
+
index: DEFAULT_INDEX
|
|
2337
|
+
};
|
|
2338
|
+
if (isHydrated && isEditing()) {
|
|
2339
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
2340
|
+
const variant = variants?.[previewingIndex];
|
|
2341
|
+
if (variant) {
|
|
2342
|
+
return {
|
|
2343
|
+
blocks: variant.blocks,
|
|
2344
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
2345
|
+
index: previewingIndex
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
return fallback;
|
|
2350
|
+
}
|
|
2351
|
+
if (isBrowser()) {
|
|
2352
|
+
const winningVariant = filteredVariants?.[0];
|
|
2353
|
+
if (winningVariant && variants) {
|
|
2354
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
2355
|
+
if (variantIndex !== -1) {
|
|
2356
|
+
return {
|
|
2357
|
+
blocks: winningVariant.blocks,
|
|
2358
|
+
path: `variants.${variantIndex}.blocks`,
|
|
2359
|
+
index: variantIndex
|
|
2360
|
+
};
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
return fallback;
|
|
2365
|
+
}
|
|
2366
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
2367
|
+
return `
|
|
2368
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
2369
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
2370
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
2371
|
+
`;
|
|
2372
|
+
};
|
|
2373
|
+
var isHydrationTarget = TARGET === "react";
|
|
2374
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
2375
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2376
|
+
};
|
|
2377
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
2378
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2379
|
+
};
|
|
2380
|
+
|
|
2221
2381
|
// src/helpers/url.ts
|
|
2222
2382
|
var getTopLevelDomain = (host) => {
|
|
2223
2383
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -2406,6 +2566,11 @@ var handleABTesting = async ({
|
|
|
2406
2566
|
};
|
|
2407
2567
|
};
|
|
2408
2568
|
|
|
2569
|
+
// src/helpers/no-serialize-wrapper.ts
|
|
2570
|
+
function noSerializeWrapper(fn) {
|
|
2571
|
+
return fn;
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2409
2574
|
// src/helpers/user-attributes.ts
|
|
2410
2575
|
var USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
2411
2576
|
function createUserAttributesService() {
|
|
@@ -2436,18 +2601,32 @@ function createUserAttributesService() {
|
|
|
2436
2601
|
canTrack
|
|
2437
2602
|
}) || "{}");
|
|
2438
2603
|
},
|
|
2439
|
-
subscribeOnUserAttributesChange(callback
|
|
2604
|
+
subscribeOnUserAttributesChange(callback, {
|
|
2605
|
+
fireImmediately
|
|
2606
|
+
} = {}) {
|
|
2440
2607
|
subscribers.add(callback);
|
|
2441
|
-
|
|
2608
|
+
if (fireImmediately) {
|
|
2609
|
+
callback(this.getUserAttributes());
|
|
2610
|
+
}
|
|
2611
|
+
return noSerializeWrapper(function() {
|
|
2442
2612
|
subscribers.delete(callback);
|
|
2443
|
-
};
|
|
2613
|
+
});
|
|
2444
2614
|
},
|
|
2445
2615
|
setCanTrack(value) {
|
|
2446
2616
|
canTrack = value;
|
|
2447
2617
|
}
|
|
2448
2618
|
};
|
|
2449
2619
|
}
|
|
2450
|
-
var
|
|
2620
|
+
var _userAttributesService;
|
|
2621
|
+
if (isBrowser() && TARGET === "qwik") {
|
|
2622
|
+
if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__) {
|
|
2623
|
+
window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
|
|
2624
|
+
}
|
|
2625
|
+
_userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
|
|
2626
|
+
} else {
|
|
2627
|
+
_userAttributesService = createUserAttributesService();
|
|
2628
|
+
}
|
|
2629
|
+
var userAttributesService = _userAttributesService;
|
|
2451
2630
|
var setClientUserAttributes = (attributes) => {
|
|
2452
2631
|
userAttributesService.setUserAttributes(attributes);
|
|
2453
2632
|
};
|
|
@@ -3196,7 +3375,8 @@ var componentInfo6 = {
|
|
|
3196
3375
|
name: "PersonalizationContainer",
|
|
3197
3376
|
shouldReceiveBuilderProps: {
|
|
3198
3377
|
builderBlock: true,
|
|
3199
|
-
builderContext: true
|
|
3378
|
+
builderContext: true,
|
|
3379
|
+
builderComponents: true
|
|
3200
3380
|
},
|
|
3201
3381
|
noWrap: true,
|
|
3202
3382
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -3258,208 +3438,22 @@ function isPreviewing(_search) {
|
|
|
3258
3438
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
3259
3439
|
}
|
|
3260
3440
|
|
|
3261
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
3262
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
3263
|
-
function isString(val) {
|
|
3264
|
-
return typeof val === "string";
|
|
3265
|
-
}
|
|
3266
|
-
function isNumber(val) {
|
|
3267
|
-
return typeof val === "number";
|
|
3268
|
-
}
|
|
3269
|
-
function objectMatchesQuery(userattr, query2) {
|
|
3270
|
-
const result = (() => {
|
|
3271
|
-
const property = query2.property;
|
|
3272
|
-
const operator = query2.operator;
|
|
3273
|
-
let testValue = query2.value;
|
|
3274
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
3275
|
-
testValue = query2.value.slice(0, -1);
|
|
3276
|
-
}
|
|
3277
|
-
if (!(property && operator)) {
|
|
3278
|
-
return true;
|
|
3279
|
-
}
|
|
3280
|
-
if (Array.isArray(testValue)) {
|
|
3281
|
-
if (operator === "isNot") {
|
|
3282
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
3283
|
-
property,
|
|
3284
|
-
operator,
|
|
3285
|
-
value: val
|
|
3286
|
-
}));
|
|
3287
|
-
}
|
|
3288
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
3289
|
-
property,
|
|
3290
|
-
operator,
|
|
3291
|
-
value: val
|
|
3292
|
-
}));
|
|
3293
|
-
}
|
|
3294
|
-
const value = userattr[property];
|
|
3295
|
-
if (Array.isArray(value)) {
|
|
3296
|
-
return value.includes(testValue);
|
|
3297
|
-
}
|
|
3298
|
-
switch (operator) {
|
|
3299
|
-
case "is":
|
|
3300
|
-
return value === testValue;
|
|
3301
|
-
case "isNot":
|
|
3302
|
-
return value !== testValue;
|
|
3303
|
-
case "contains":
|
|
3304
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
3305
|
-
case "startsWith":
|
|
3306
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
3307
|
-
case "endsWith":
|
|
3308
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
3309
|
-
case "greaterThan":
|
|
3310
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
3311
|
-
case "lessThan":
|
|
3312
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
3313
|
-
case "greaterThanOrEqualTo":
|
|
3314
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
3315
|
-
case "lessThanOrEqualTo":
|
|
3316
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
3317
|
-
default:
|
|
3318
|
-
return false;
|
|
3319
|
-
}
|
|
3320
|
-
})();
|
|
3321
|
-
return result;
|
|
3322
|
-
}
|
|
3323
|
-
const item = {
|
|
3324
|
-
query,
|
|
3325
|
-
startDate,
|
|
3326
|
-
endDate
|
|
3327
|
-
};
|
|
3328
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
3329
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
3330
|
-
return false;
|
|
3331
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
3332
|
-
return false;
|
|
3333
|
-
}
|
|
3334
|
-
if (!item.query || !item.query.length) {
|
|
3335
|
-
return true;
|
|
3336
|
-
}
|
|
3337
|
-
return item.query.every((filter) => {
|
|
3338
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
3339
|
-
});
|
|
3340
|
-
}
|
|
3341
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
3342
|
-
if (!navigator.cookieEnabled) {
|
|
3343
|
-
return;
|
|
3344
|
-
}
|
|
3345
|
-
function getCookie(name) {
|
|
3346
|
-
const nameEQ = name + '=';
|
|
3347
|
-
const ca = document.cookie.split(';');
|
|
3348
|
-
for (let i = 0; i < ca.length; i++) {
|
|
3349
|
-
let c = ca[i];
|
|
3350
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
3351
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
3352
|
-
}
|
|
3353
|
-
return null;
|
|
3354
|
-
}
|
|
3355
|
-
function removeVariants() {
|
|
3356
|
-
variants?.forEach(function (_, index) {
|
|
3357
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
3358
|
-
});
|
|
3359
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
3360
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
3361
|
-
}
|
|
3362
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
3363
|
-
if (locale) {
|
|
3364
|
-
attributes.locale = locale;
|
|
3365
|
-
}
|
|
3366
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
3367
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
3368
|
-
});
|
|
3369
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
3370
|
-
if (isDebug) {
|
|
3371
|
-
console.debug('PersonalizationContainer', {
|
|
3372
|
-
attributes,
|
|
3373
|
-
variants,
|
|
3374
|
-
winningVariantIndex
|
|
3375
|
-
});
|
|
3376
|
-
}
|
|
3377
|
-
if (winningVariantIndex !== -1) {
|
|
3378
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
3379
|
-
if (winningVariant) {
|
|
3380
|
-
const parentNode = winningVariant.parentNode;
|
|
3381
|
-
if (parentNode) {
|
|
3382
|
-
const newParent = parentNode.cloneNode(false);
|
|
3383
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
3384
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
3385
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
3386
|
-
}
|
|
3387
|
-
if (isDebug) {
|
|
3388
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
3389
|
-
}
|
|
3390
|
-
}
|
|
3391
|
-
} else if (variants && variants.length > 0) {
|
|
3392
|
-
removeVariants();
|
|
3393
|
-
}
|
|
3394
|
-
}`;
|
|
3395
|
-
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}";
|
|
3396
|
-
|
|
3397
|
-
// src/blocks/personalization-container/helpers.ts
|
|
3398
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
3399
|
-
const hasVariants = variants && variants.length > 0;
|
|
3400
|
-
if (TARGET === "reactNative")
|
|
3401
|
-
return false;
|
|
3402
|
-
if (!hasVariants)
|
|
3403
|
-
return false;
|
|
3404
|
-
if (!canTrack)
|
|
3405
|
-
return false;
|
|
3406
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
3407
|
-
return true;
|
|
3408
|
-
if (isBrowser())
|
|
3409
|
-
return false;
|
|
3410
|
-
return true;
|
|
3411
|
-
}
|
|
3412
|
-
function getBlocksToRender({
|
|
3413
|
-
variants,
|
|
3414
|
-
previewingIndex,
|
|
3415
|
-
isHydrated,
|
|
3416
|
-
filteredVariants,
|
|
3417
|
-
fallbackBlocks
|
|
3418
|
-
}) {
|
|
3419
|
-
const fallback = {
|
|
3420
|
-
blocks: fallbackBlocks ?? [],
|
|
3421
|
-
path: "this.children"
|
|
3422
|
-
};
|
|
3423
|
-
if (isHydrated && isEditing()) {
|
|
3424
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
3425
|
-
const variant = variants[previewingIndex];
|
|
3426
|
-
return {
|
|
3427
|
-
blocks: variant.blocks,
|
|
3428
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
3429
|
-
};
|
|
3430
|
-
}
|
|
3431
|
-
return fallback;
|
|
3432
|
-
}
|
|
3433
|
-
if (isBrowser()) {
|
|
3434
|
-
const winningVariant = filteredVariants?.[0];
|
|
3435
|
-
if (winningVariant) {
|
|
3436
|
-
return {
|
|
3437
|
-
blocks: winningVariant.blocks,
|
|
3438
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
3439
|
-
};
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
return fallback;
|
|
3443
|
-
}
|
|
3444
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
3445
|
-
return `
|
|
3446
|
-
(function() {
|
|
3447
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
3448
|
-
${PERSONALIZATION_SCRIPT}
|
|
3449
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
3450
|
-
})();
|
|
3451
|
-
`;
|
|
3452
|
-
};
|
|
3453
|
-
|
|
3454
3441
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
3455
3442
|
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
3456
|
-
var _tmpl$25 = /* @__PURE__ */ template(`<template>`);
|
|
3457
3443
|
function PersonalizationContainer(props) {
|
|
3458
3444
|
const [userAttributes, setUserAttributes] = createSignal(userAttributesService.getUserAttributes());
|
|
3459
3445
|
const [scriptStr, setScriptStr] = createSignal(getPersonalizationScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3446
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal(getUpdateVisibilityStylesScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3460
3447
|
const [unsubscribers, setUnsubscribers] = createSignal([]);
|
|
3461
3448
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRenderVariants(props.variants, getDefaultCanTrack(props.builderContext?.canTrack)));
|
|
3462
|
-
const [
|
|
3449
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal(false);
|
|
3450
|
+
const attrs = createMemo(() => {
|
|
3451
|
+
return {
|
|
3452
|
+
...props.attributes,
|
|
3453
|
+
...{},
|
|
3454
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
3455
|
+
};
|
|
3456
|
+
});
|
|
3463
3457
|
const filteredVariants = createMemo(() => {
|
|
3464
3458
|
return (props.variants || []).filter((variant) => {
|
|
3465
3459
|
return filterWithCustomTargeting({
|
|
@@ -3474,26 +3468,28 @@ function PersonalizationContainer(props) {
|
|
|
3474
3468
|
return getBlocksToRender({
|
|
3475
3469
|
variants: props.variants,
|
|
3476
3470
|
fallbackBlocks: props.builderBlock?.children,
|
|
3477
|
-
isHydrated:
|
|
3471
|
+
isHydrated: shouldResetVariants(),
|
|
3478
3472
|
filteredVariants: filteredVariants(),
|
|
3479
3473
|
previewingIndex: props.previewingIndex
|
|
3480
3474
|
});
|
|
3481
3475
|
});
|
|
3482
3476
|
const hideVariantsStyleString = createMemo(() => {
|
|
3483
|
-
return (props.variants || []).map((_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `).join("");
|
|
3477
|
+
return (props.variants || []).map((_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `).join("");
|
|
3484
3478
|
});
|
|
3485
3479
|
let rootRef;
|
|
3486
3480
|
onMount(() => {
|
|
3487
|
-
|
|
3488
|
-
const unsub = userAttributesService.subscribeOnUserAttributesChange((
|
|
3489
|
-
setUserAttributes(
|
|
3481
|
+
setShouldResetVariants(true);
|
|
3482
|
+
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
3483
|
+
setUserAttributes(attrs2);
|
|
3484
|
+
}, {
|
|
3485
|
+
fireImmediately: TARGET === "qwik"
|
|
3490
3486
|
});
|
|
3491
3487
|
if (!(isEditing() || isPreviewing())) {
|
|
3492
3488
|
const variant = filteredVariants()[0];
|
|
3493
3489
|
if (rootRef) {
|
|
3494
3490
|
rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
|
|
3495
3491
|
detail: {
|
|
3496
|
-
variant: variant ||
|
|
3492
|
+
variant: variant || DEFAULT_INDEX,
|
|
3497
3493
|
content: props.builderContext?.content
|
|
3498
3494
|
},
|
|
3499
3495
|
bubbles: true
|
|
@@ -3503,7 +3499,7 @@ function PersonalizationContainer(props) {
|
|
|
3503
3499
|
if (entry.isIntersecting && rootRef) {
|
|
3504
3500
|
rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
|
|
3505
3501
|
detail: {
|
|
3506
|
-
variant: variant ||
|
|
3502
|
+
variant: variant || DEFAULT_INDEX,
|
|
3507
3503
|
content: props.builderContext?.content
|
|
3508
3504
|
},
|
|
3509
3505
|
bubbles: true
|
|
@@ -3520,70 +3516,158 @@ function PersonalizationContainer(props) {
|
|
|
3520
3516
|
const _el$ = _tmpl$9();
|
|
3521
3517
|
const _ref$ = rootRef;
|
|
3522
3518
|
typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
|
|
3523
|
-
spread(_el$, mergeProps(
|
|
3524
|
-
get ["class"]() {
|
|
3525
|
-
return `builder-personalization-container ${props.attributes?.className || ""}`;
|
|
3526
|
-
}
|
|
3527
|
-
}, () => props.attributes), false, true);
|
|
3519
|
+
spread(_el$, mergeProps(attrs), false, true);
|
|
3528
3520
|
insert(_el$, createComponent(Show, {
|
|
3529
3521
|
get when() {
|
|
3530
|
-
return
|
|
3522
|
+
return memo(() => !!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3531
3523
|
},
|
|
3532
3524
|
get children() {
|
|
3533
|
-
return
|
|
3534
|
-
get
|
|
3535
|
-
return
|
|
3525
|
+
return createComponent(blocks_default, {
|
|
3526
|
+
get blocks() {
|
|
3527
|
+
return blocksToRender().blocks;
|
|
3536
3528
|
},
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
return (() => {
|
|
3540
|
-
const _el$2 = _tmpl$25();
|
|
3541
|
-
setAttribute(_el$2, "key", index);
|
|
3542
|
-
insert(_el$2, createComponent(blocks_default, {
|
|
3543
|
-
get blocks() {
|
|
3544
|
-
return variant.blocks;
|
|
3545
|
-
},
|
|
3546
|
-
get parent() {
|
|
3547
|
-
return props.builderBlock?.id;
|
|
3548
|
-
},
|
|
3549
|
-
path: `component.options.variants.${index}.blocks`
|
|
3550
|
-
}));
|
|
3551
|
-
effect(() => setAttribute(_el$2, "data-variant-id", `${props.builderBlock?.id}-${index}`));
|
|
3552
|
-
return _el$2;
|
|
3553
|
-
})();
|
|
3554
|
-
}
|
|
3555
|
-
}), createComponent(inlined_styles_default, {
|
|
3556
|
-
get nonce() {
|
|
3557
|
-
return props.builderContext?.nonce || "";
|
|
3529
|
+
get parent() {
|
|
3530
|
+
return props.builderBlock?.id;
|
|
3558
3531
|
},
|
|
3559
|
-
get
|
|
3560
|
-
return
|
|
3532
|
+
get path() {
|
|
3533
|
+
return blocksToRender().path;
|
|
3561
3534
|
},
|
|
3562
|
-
get
|
|
3563
|
-
return
|
|
3564
|
-
}
|
|
3565
|
-
}), createComponent(inlined_script_default, {
|
|
3566
|
-
get nonce() {
|
|
3567
|
-
return props.builderContext?.nonce || "";
|
|
3535
|
+
get context() {
|
|
3536
|
+
return props.builderContext;
|
|
3568
3537
|
},
|
|
3569
|
-
get
|
|
3570
|
-
return
|
|
3538
|
+
get registeredComponents() {
|
|
3539
|
+
return props.builderComponents;
|
|
3571
3540
|
},
|
|
3572
|
-
get
|
|
3573
|
-
return
|
|
3541
|
+
get BlocksWrapperProps() {
|
|
3542
|
+
return {
|
|
3543
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3544
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3545
|
+
};
|
|
3574
3546
|
}
|
|
3575
|
-
})
|
|
3547
|
+
});
|
|
3576
3548
|
}
|
|
3577
3549
|
}), null);
|
|
3578
|
-
insert(_el$, createComponent(
|
|
3579
|
-
get
|
|
3580
|
-
return
|
|
3581
|
-
},
|
|
3582
|
-
get parent() {
|
|
3583
|
-
return props.builderBlock?.id;
|
|
3550
|
+
insert(_el$, createComponent(Show, {
|
|
3551
|
+
get when() {
|
|
3552
|
+
return memo(() => !!!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3584
3553
|
},
|
|
3585
|
-
get
|
|
3586
|
-
return
|
|
3554
|
+
get children() {
|
|
3555
|
+
return [createComponent(Show, {
|
|
3556
|
+
get when() {
|
|
3557
|
+
return shouldRenderVariants();
|
|
3558
|
+
},
|
|
3559
|
+
get children() {
|
|
3560
|
+
return [createComponent(inlined_styles_default, {
|
|
3561
|
+
get nonce() {
|
|
3562
|
+
return props.builderContext?.nonce || "";
|
|
3563
|
+
},
|
|
3564
|
+
get styles() {
|
|
3565
|
+
return hideVariantsStyleString();
|
|
3566
|
+
},
|
|
3567
|
+
get id() {
|
|
3568
|
+
return `variants-styles-${props.builderBlock?.id}`;
|
|
3569
|
+
}
|
|
3570
|
+
}), createComponent(inlined_script_default, {
|
|
3571
|
+
get nonce() {
|
|
3572
|
+
return props.builderContext?.nonce || "";
|
|
3573
|
+
},
|
|
3574
|
+
get scriptStr() {
|
|
3575
|
+
return updateVisibilityStylesScript();
|
|
3576
|
+
},
|
|
3577
|
+
get id() {
|
|
3578
|
+
return `variants-visibility-script-${props.builderBlock?.id}`;
|
|
3579
|
+
}
|
|
3580
|
+
}), createComponent(For, {
|
|
3581
|
+
get each() {
|
|
3582
|
+
return props.variants;
|
|
3583
|
+
},
|
|
3584
|
+
children: (variant, _index) => {
|
|
3585
|
+
const index = _index();
|
|
3586
|
+
return createComponent(blocks_default, {
|
|
3587
|
+
get key() {
|
|
3588
|
+
return `${props.builderBlock?.id}-${index}`;
|
|
3589
|
+
},
|
|
3590
|
+
get BlocksWrapperProps() {
|
|
3591
|
+
return {
|
|
3592
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3593
|
+
"aria-hidden": true,
|
|
3594
|
+
hidden: true,
|
|
3595
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
3596
|
+
};
|
|
3597
|
+
},
|
|
3598
|
+
get blocks() {
|
|
3599
|
+
return variant.blocks;
|
|
3600
|
+
},
|
|
3601
|
+
get parent() {
|
|
3602
|
+
return props.builderBlock?.id;
|
|
3603
|
+
},
|
|
3604
|
+
path: `component.options.variants.${index}.blocks`,
|
|
3605
|
+
get context() {
|
|
3606
|
+
return props.builderContext;
|
|
3607
|
+
},
|
|
3608
|
+
get registeredComponents() {
|
|
3609
|
+
return props.builderComponents;
|
|
3610
|
+
},
|
|
3611
|
+
get children() {
|
|
3612
|
+
return createComponent(inlined_script_default, {
|
|
3613
|
+
get nonce() {
|
|
3614
|
+
return props.builderContext?.nonce || "";
|
|
3615
|
+
},
|
|
3616
|
+
get scriptStr() {
|
|
3617
|
+
return scriptStr();
|
|
3618
|
+
},
|
|
3619
|
+
get id() {
|
|
3620
|
+
return `variants-script-${props.builderBlock?.id}-${index}`;
|
|
3621
|
+
}
|
|
3622
|
+
});
|
|
3623
|
+
}
|
|
3624
|
+
});
|
|
3625
|
+
}
|
|
3626
|
+
})];
|
|
3627
|
+
}
|
|
3628
|
+
}), createComponent(blocks_default, {
|
|
3629
|
+
get blocks() {
|
|
3630
|
+
return blocksToRender().blocks;
|
|
3631
|
+
},
|
|
3632
|
+
get parent() {
|
|
3633
|
+
return props.builderBlock?.id;
|
|
3634
|
+
},
|
|
3635
|
+
get path() {
|
|
3636
|
+
return blocksToRender().path;
|
|
3637
|
+
},
|
|
3638
|
+
get context() {
|
|
3639
|
+
return props.builderContext;
|
|
3640
|
+
},
|
|
3641
|
+
get registeredComponents() {
|
|
3642
|
+
return props.builderComponents;
|
|
3643
|
+
},
|
|
3644
|
+
get BlocksWrapperProps() {
|
|
3645
|
+
return {
|
|
3646
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3647
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3648
|
+
};
|
|
3649
|
+
},
|
|
3650
|
+
get children() {
|
|
3651
|
+
return createComponent(Show, {
|
|
3652
|
+
get when() {
|
|
3653
|
+
return shouldRenderVariants();
|
|
3654
|
+
},
|
|
3655
|
+
get children() {
|
|
3656
|
+
return createComponent(inlined_script_default, {
|
|
3657
|
+
get nonce() {
|
|
3658
|
+
return props.builderContext?.nonce || "";
|
|
3659
|
+
},
|
|
3660
|
+
get scriptStr() {
|
|
3661
|
+
return scriptStr();
|
|
3662
|
+
},
|
|
3663
|
+
get id() {
|
|
3664
|
+
return `variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`;
|
|
3665
|
+
}
|
|
3666
|
+
});
|
|
3667
|
+
}
|
|
3668
|
+
});
|
|
3669
|
+
}
|
|
3670
|
+
})];
|
|
3587
3671
|
}
|
|
3588
3672
|
}), null);
|
|
3589
3673
|
return _el$;
|
|
@@ -3870,7 +3954,7 @@ var componentInfo10 = {
|
|
|
3870
3954
|
}
|
|
3871
3955
|
};
|
|
3872
3956
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
3873
|
-
var _tmpl$
|
|
3957
|
+
var _tmpl$25 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
|
|
3874
3958
|
var _tmpl$33 = /* @__PURE__ */ template(`<span>`);
|
|
3875
3959
|
function Tabs(props) {
|
|
3876
3960
|
const [activeTab, setActiveTab] = createSignal(props.defaultActiveTab ? props.defaultActiveTab - 1 : 0);
|
|
@@ -3885,7 +3969,7 @@ function Tabs(props) {
|
|
|
3885
3969
|
}
|
|
3886
3970
|
}
|
|
3887
3971
|
return (() => {
|
|
3888
|
-
const _el$ = _tmpl$
|
|
3972
|
+
const _el$ = _tmpl$25(), _el$2 = _el$.firstChild;
|
|
3889
3973
|
_el$2.style.setProperty("display", "flex");
|
|
3890
3974
|
_el$2.style.setProperty("flex-direction", "row");
|
|
3891
3975
|
_el$2.style.setProperty("overflow", "auto");
|
|
@@ -4416,9 +4500,9 @@ function logFetch(url) {
|
|
|
4416
4500
|
}
|
|
4417
4501
|
|
|
4418
4502
|
// src/blocks/form/form/form.tsx
|
|
4419
|
-
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-
|
|
4420
|
-
var _tmpl$
|
|
4421
|
-
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-
|
|
4503
|
+
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-7430044e">`);
|
|
4504
|
+
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
4505
|
+
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-7430044e {
|
|
4422
4506
|
padding: 10px;
|
|
4423
4507
|
color: red;
|
|
4424
4508
|
text-align: center;
|
|
@@ -4530,6 +4614,14 @@ function FormComponent(props) {
|
|
|
4530
4614
|
}
|
|
4531
4615
|
}
|
|
4532
4616
|
setFormState("sending");
|
|
4617
|
+
if (props.sendSubmissionsTo === "email" && (props.sendSubmissionsToEmail === "your@email.com" || !props.sendSubmissionsToEmail)) {
|
|
4618
|
+
const message = "SubmissionsToEmail is required when sendSubmissionsTo is set to email";
|
|
4619
|
+
setFormState("error");
|
|
4620
|
+
mergeNewRootState({
|
|
4621
|
+
formErrorMessage: message
|
|
4622
|
+
});
|
|
4623
|
+
return;
|
|
4624
|
+
}
|
|
4533
4625
|
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 || "")}`;
|
|
4534
4626
|
const url = props.sendSubmissionsTo === "email" ? formUrl : props.action;
|
|
4535
4627
|
logFetch(url);
|
|
@@ -4545,17 +4637,30 @@ function FormComponent(props) {
|
|
|
4545
4637
|
} else {
|
|
4546
4638
|
body2 = await res.text();
|
|
4547
4639
|
}
|
|
4548
|
-
if (!res.ok
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4640
|
+
if (!res.ok) {
|
|
4641
|
+
const submitErrorEvent = new CustomEvent("submit:error", {
|
|
4642
|
+
detail: {
|
|
4643
|
+
error: body2,
|
|
4644
|
+
status: res.status
|
|
4645
|
+
}
|
|
4646
|
+
});
|
|
4647
|
+
if (formRef?.nativeElement) {
|
|
4648
|
+
formRef?.nativeElement.dispatchEvent(submitErrorEvent);
|
|
4649
|
+
if (submitErrorEvent.defaultPrevented) {
|
|
4650
|
+
return;
|
|
4553
4651
|
}
|
|
4554
|
-
setFormErrorMessage(message);
|
|
4555
|
-
mergeNewRootState({
|
|
4556
|
-
formErrorMessage: message
|
|
4557
|
-
});
|
|
4558
4652
|
}
|
|
4653
|
+
setResponseData(body2);
|
|
4654
|
+
setFormState("error");
|
|
4655
|
+
let message = props.errorMessagePath ? get(body2, props.errorMessagePath) : body2.message || body2.error || body2;
|
|
4656
|
+
if (typeof message !== "string") {
|
|
4657
|
+
message = JSON.stringify(message);
|
|
4658
|
+
}
|
|
4659
|
+
setFormErrorMessage(message);
|
|
4660
|
+
mergeNewRootState({
|
|
4661
|
+
formErrorMessage: message
|
|
4662
|
+
});
|
|
4663
|
+
return;
|
|
4559
4664
|
}
|
|
4560
4665
|
setResponseData(body2);
|
|
4561
4666
|
setFormState(res.ok ? "success" : "error");
|
|
@@ -4610,7 +4715,7 @@ function FormComponent(props) {
|
|
|
4610
4715
|
}
|
|
4611
4716
|
let formRef;
|
|
4612
4717
|
return [(() => {
|
|
4613
|
-
const _el$ = _tmpl$
|
|
4718
|
+
const _el$ = _tmpl$26();
|
|
4614
4719
|
_el$.addEventListener("submit", (event) => onSubmit(event));
|
|
4615
4720
|
const _ref$ = formRef;
|
|
4616
4721
|
typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
|
|
@@ -4822,7 +4927,7 @@ var componentInfo16 = {
|
|
|
4822
4927
|
noWrap: true
|
|
4823
4928
|
};
|
|
4824
4929
|
var _tmpl$17 = /* @__PURE__ */ template(`<select>`);
|
|
4825
|
-
var _tmpl$
|
|
4930
|
+
var _tmpl$27 = /* @__PURE__ */ template(`<option>`);
|
|
4826
4931
|
function SelectComponent(props) {
|
|
4827
4932
|
return (() => {
|
|
4828
4933
|
const _el$ = _tmpl$17();
|
|
@@ -4850,7 +4955,7 @@ function SelectComponent(props) {
|
|
|
4850
4955
|
children: (option, _index) => {
|
|
4851
4956
|
const index = _index();
|
|
4852
4957
|
return (() => {
|
|
4853
|
-
const _el$2 = _tmpl$
|
|
4958
|
+
const _el$2 = _tmpl$27();
|
|
4854
4959
|
insert(_el$2, () => option.name || option.value);
|
|
4855
4960
|
effect(() => setAttribute(_el$2, "key", `${option.name}-${index}`));
|
|
4856
4961
|
effect(() => _el$2.value = option.value);
|
|
@@ -5094,7 +5199,7 @@ var componentInfo20 = {
|
|
|
5094
5199
|
}
|
|
5095
5200
|
};
|
|
5096
5201
|
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
5097
|
-
var _tmpl$
|
|
5202
|
+
var _tmpl$28 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
5098
5203
|
function Video(props) {
|
|
5099
5204
|
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
5100
5205
|
const videoProps = createMemo(() => {
|
|
@@ -5149,7 +5254,7 @@ function Video(props) {
|
|
|
5149
5254
|
}
|
|
5150
5255
|
});
|
|
5151
5256
|
return (() => {
|
|
5152
|
-
const _el$ = _tmpl$
|
|
5257
|
+
const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
5153
5258
|
_el$.style.setProperty("position", "relative");
|
|
5154
5259
|
const _ref$ = videoRef;
|
|
5155
5260
|
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
@@ -5286,7 +5391,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
5286
5391
|
}, {
|
|
5287
5392
|
component: text_default,
|
|
5288
5393
|
...componentInfo11
|
|
5289
|
-
}, ...TARGET
|
|
5394
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
5290
5395
|
component: personalization_container_default,
|
|
5291
5396
|
...componentInfo6
|
|
5292
5397
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -5323,7 +5428,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
5323
5428
|
|
|
5324
5429
|
// src/components/content-variants/helpers.ts
|
|
5325
5430
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
5326
|
-
var
|
|
5431
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
5327
5432
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
5328
5433
|
...variant,
|
|
5329
5434
|
testVariationId: variant.id,
|
|
@@ -5348,20 +5453,20 @@ var checkShouldRenderVariants2 = ({
|
|
|
5348
5453
|
};
|
|
5349
5454
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
5350
5455
|
var isAngularSDK = TARGET === "angular";
|
|
5351
|
-
var
|
|
5456
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
5352
5457
|
var getInitVariantsFnsScriptString = () => `
|
|
5353
5458
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
5354
|
-
window.${
|
|
5459
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
5355
5460
|
`;
|
|
5356
5461
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
5357
5462
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
5358
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
5463
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
5359
5464
|
)`;
|
|
5360
5465
|
var getUpdateVariantVisibilityScript = ({
|
|
5361
5466
|
contentId,
|
|
5362
5467
|
variationId
|
|
5363
|
-
}) => `window.${
|
|
5364
|
-
"${variationId}", "${contentId}", ${
|
|
5468
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
5469
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
5365
5470
|
)`;
|
|
5366
5471
|
|
|
5367
5472
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -5370,7 +5475,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5370
5475
|
}
|
|
5371
5476
|
|
|
5372
5477
|
// src/constants/sdk-version.ts
|
|
5373
|
-
var SDK_VERSION = "4.0.
|
|
5478
|
+
var SDK_VERSION = "4.0.10";
|
|
5374
5479
|
|
|
5375
5480
|
// src/helpers/sdk-headers.ts
|
|
5376
5481
|
var getSdkHeaders = () => ({
|
|
@@ -6786,7 +6891,7 @@ function ContentVariants(props) {
|
|
|
6786
6891
|
return !props.isNestedRender && TARGET !== "reactNative";
|
|
6787
6892
|
},
|
|
6788
6893
|
get children() {
|
|
6789
|
-
return createComponent(inlined_script_default, {
|
|
6894
|
+
return [createComponent(inlined_script_default, {
|
|
6790
6895
|
id: "builderio-init-variants-fns",
|
|
6791
6896
|
get scriptStr() {
|
|
6792
6897
|
return getInitVariantsFnsScriptString();
|
|
@@ -6794,7 +6899,22 @@ function ContentVariants(props) {
|
|
|
6794
6899
|
get nonce() {
|
|
6795
6900
|
return props.nonce || "";
|
|
6796
6901
|
}
|
|
6797
|
-
})
|
|
6902
|
+
}), createComponent(Show, {
|
|
6903
|
+
get when() {
|
|
6904
|
+
return SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET);
|
|
6905
|
+
},
|
|
6906
|
+
get children() {
|
|
6907
|
+
return createComponent(inlined_script_default, {
|
|
6908
|
+
id: "builderio-init-personalization-variants-fns",
|
|
6909
|
+
get nonce() {
|
|
6910
|
+
return props.nonce || "";
|
|
6911
|
+
},
|
|
6912
|
+
get scriptStr() {
|
|
6913
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
6914
|
+
}
|
|
6915
|
+
});
|
|
6916
|
+
}
|
|
6917
|
+
})];
|
|
6798
6918
|
}
|
|
6799
6919
|
}), createComponent(Show, {
|
|
6800
6920
|
get when() {
|
|
@@ -6982,7 +7102,7 @@ var fetchSymbolContent = async ({
|
|
|
6982
7102
|
};
|
|
6983
7103
|
|
|
6984
7104
|
// src/blocks/symbol/symbol.tsx
|
|
6985
|
-
var _tmpl$
|
|
7105
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
6986
7106
|
function Symbol(props) {
|
|
6987
7107
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
6988
7108
|
const [symbolEntry, setSymbolEntry] = createSignal(props.symbol?.entry);
|
|
@@ -7016,7 +7136,7 @@ function Symbol(props) {
|
|
|
7016
7136
|
}
|
|
7017
7137
|
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
7018
7138
|
return (() => {
|
|
7019
|
-
const _el$ = _tmpl$
|
|
7139
|
+
const _el$ = _tmpl$29();
|
|
7020
7140
|
spread(_el$, mergeProps({
|
|
7021
7141
|
get ["class"]() {
|
|
7022
7142
|
return className();
|