@getlupa/client 1.6.6 → 1.8.0-alpha.0
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/lupaSearch.iife.js +374 -23
- package/dist/lupaSearch.js +374 -23
- package/dist/lupaSearch.mjs +374 -23
- package/dist/lupaSearch.umd.js +374 -23
- package/dist/src/index.d.ts +11 -1
- package/dist/src/modules/preconfiguredContainer/SearchContainerConfigurationService.d.ts +7 -0
- package/dist/src/modules/preconfiguredContainer/configuratorUtils.d.ts +15 -0
- package/dist/src/types/PreconfiguredSearchContainerOptions.d.ts +57 -0
- package/package.json +3 -3
package/dist/lupaSearch.iife.js
CHANGED
|
@@ -81,11 +81,11 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
81
81
|
const hyphenate = cacheStringFunction(
|
|
82
82
|
(str) => str.replace(hyphenateRE, "-$1").toLowerCase()
|
|
83
83
|
);
|
|
84
|
-
const capitalize$
|
|
84
|
+
const capitalize$2 = cacheStringFunction(
|
|
85
85
|
(str) => str.charAt(0).toUpperCase() + str.slice(1)
|
|
86
86
|
);
|
|
87
87
|
const toHandlerKey = cacheStringFunction(
|
|
88
|
-
(str) => str ? `on${capitalize$
|
|
88
|
+
(str) => str ? `on${capitalize$2(str)}` : ``
|
|
89
89
|
);
|
|
90
90
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
91
91
|
const invokeArrayFns = (fns, arg) => {
|
|
@@ -2115,7 +2115,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
2115
2115
|
false
|
|
2116
2116
|
/* do not include inferred name to avoid breaking existing code */
|
|
2117
2117
|
);
|
|
2118
|
-
if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize$
|
|
2118
|
+
if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize$2(camelize(name)))) {
|
|
2119
2119
|
return Component;
|
|
2120
2120
|
}
|
|
2121
2121
|
}
|
|
@@ -2132,7 +2132,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
2132
2132
|
}
|
|
2133
2133
|
}
|
|
2134
2134
|
function resolve(registry, name) {
|
|
2135
|
-
return registry && (registry[name] || registry[camelize(name)] || registry[capitalize$
|
|
2135
|
+
return registry && (registry[name] || registry[camelize(name)] || registry[capitalize$2(camelize(name))]);
|
|
2136
2136
|
}
|
|
2137
2137
|
function renderList(source, renderItem, cache, index) {
|
|
2138
2138
|
let ret;
|
|
@@ -5378,7 +5378,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
5378
5378
|
if (name !== "filter" && name in style) {
|
|
5379
5379
|
return prefixCache[rawName] = name;
|
|
5380
5380
|
}
|
|
5381
|
-
name = capitalize$
|
|
5381
|
+
name = capitalize$2(name);
|
|
5382
5382
|
for (let i = 0; i < prefixes.length; i++) {
|
|
5383
5383
|
const prefixed = prefixes[i] + name;
|
|
5384
5384
|
if (prefixed in style) {
|
|
@@ -6324,7 +6324,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
6324
6324
|
const transformedStr = typeof str === "string" ? str : str.toString();
|
|
6325
6325
|
return transformedStr.normalize === void 0 ? transformedStr.toLocaleLowerCase() : transformedStr.toLocaleLowerCase().normalize("NFKD").replace(/[^\w\s.-_/]/g, "");
|
|
6326
6326
|
};
|
|
6327
|
-
const capitalize = (str) => {
|
|
6327
|
+
const capitalize$1 = (str) => {
|
|
6328
6328
|
if (!str) {
|
|
6329
6329
|
return "";
|
|
6330
6330
|
}
|
|
@@ -6373,7 +6373,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
6373
6373
|
}
|
|
6374
6374
|
return +((_a = value == null ? void 0 : value.replace(/[^0-9,.]/g, "")) == null ? void 0 : _a.replace(",", "."));
|
|
6375
6375
|
};
|
|
6376
|
-
const escapeHtml = (value) => {
|
|
6376
|
+
const escapeHtml$1 = (value) => {
|
|
6377
6377
|
if (!value) {
|
|
6378
6378
|
return "";
|
|
6379
6379
|
}
|
|
@@ -7062,7 +7062,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
7062
7062
|
return filters.map((f2) => {
|
|
7063
7063
|
var _a, _b;
|
|
7064
7064
|
return __spreadProps2(__spreadValues2({}, f2), {
|
|
7065
|
-
label: (_b = (_a = facets == null ? void 0 : facets.find((ft) => ft.key === f2.key)) == null ? void 0 : _a.label) != null ? _b : capitalize(f2.key)
|
|
7065
|
+
label: (_b = (_a = facets == null ? void 0 : facets.find((ft) => ft.key === f2.key)) == null ? void 0 : _a.label) != null ? _b : capitalize$1(f2.key)
|
|
7066
7066
|
});
|
|
7067
7067
|
});
|
|
7068
7068
|
};
|
|
@@ -7107,9 +7107,9 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
7107
7107
|
const getHint = (suggestion, inputValue) => {
|
|
7108
7108
|
var _a;
|
|
7109
7109
|
if (!inputValue) {
|
|
7110
|
-
return escapeHtml(suggestion);
|
|
7110
|
+
return escapeHtml$1(suggestion);
|
|
7111
7111
|
}
|
|
7112
|
-
return (_a = suggestion == null ? void 0 : suggestion.replace(inputValue, `<strong>${escapeHtml(inputValue)}</strong>`)) != null ? _a : "";
|
|
7112
|
+
return (_a = suggestion == null ? void 0 : suggestion.replace(inputValue, `<strong>${escapeHtml$1(inputValue)}</strong>`)) != null ? _a : "";
|
|
7113
7113
|
};
|
|
7114
7114
|
const reverseKeyValue = (obj) => {
|
|
7115
7115
|
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
|
|
@@ -8953,6 +8953,10 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
8953
8953
|
var _a;
|
|
8954
8954
|
return (_a = props.panelOptions.elements) == null ? void 0 : _a.find((e) => e.type === DocumentElementType.ADDTOCART);
|
|
8955
8955
|
});
|
|
8956
|
+
const customDocumentHtmlAttributes = computed(() => {
|
|
8957
|
+
var _a, _b, _c;
|
|
8958
|
+
return (_c = (_b = (_a = props.panelOptions).customDocumentHtmlAttributes) == null ? void 0 : _b.call(_a, props.item)) != null ? _c : {};
|
|
8959
|
+
});
|
|
8956
8960
|
const handleClick = (event) => {
|
|
8957
8961
|
emit2("product-click", {
|
|
8958
8962
|
item: props.item,
|
|
@@ -8967,12 +8971,13 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
8967
8971
|
isInStock.value = props.panelOptions.isInStock ? yield props.panelOptions.isInStock(props.item) : true;
|
|
8968
8972
|
});
|
|
8969
8973
|
return (_ctx, _cache) => {
|
|
8970
|
-
return openBlock(), createElementBlock("a", {
|
|
8971
|
-
class:
|
|
8974
|
+
return openBlock(), createElementBlock("a", mergeProps({
|
|
8975
|
+
class: ["lupa-search-box-product", { "lupa-search-box-product-highlighted": _ctx.highlighted }],
|
|
8976
|
+
href: link.value
|
|
8977
|
+
}, customDocumentHtmlAttributes.value, {
|
|
8972
8978
|
"data-cy": "lupa-search-box-product",
|
|
8973
|
-
href: link.value,
|
|
8974
8979
|
onClick: handleClick
|
|
8975
|
-
}, [
|
|
8980
|
+
}), [
|
|
8976
8981
|
createBaseVNode("div", _hoisted_2$I, [
|
|
8977
8982
|
(openBlock(true), createElementBlock(Fragment, null, renderList(imageElements.value, (element) => {
|
|
8978
8983
|
return openBlock(), createBlock(_sfc_main$13, {
|
|
@@ -9007,7 +9012,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9007
9012
|
isInStock: isInStock.value
|
|
9008
9013
|
}, null, 8, ["item", "element", "labels", "link", "isInStock"])
|
|
9009
9014
|
])) : createCommentVNode("", true)
|
|
9010
|
-
],
|
|
9015
|
+
], 16, _hoisted_1$_);
|
|
9011
9016
|
};
|
|
9012
9017
|
}
|
|
9013
9018
|
});
|
|
@@ -13519,6 +13524,10 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
13519
13524
|
}
|
|
13520
13525
|
return (_b = (_a = props.options) == null ? void 0 : _a.labels) == null ? void 0 : _b.htmlTitleTemplate;
|
|
13521
13526
|
});
|
|
13527
|
+
const customDocumentHtmlAttributes = computed(() => {
|
|
13528
|
+
var _a, _b, _c;
|
|
13529
|
+
return (_c = (_b = (_a = props.options).customDocumentHtmlAttributes) == null ? void 0 : _b.call(_a, props.product)) != null ? _c : {};
|
|
13530
|
+
});
|
|
13522
13531
|
const getGroupElements = (group) => {
|
|
13523
13532
|
var _a, _b;
|
|
13524
13533
|
return (_b = (_a = props.options.elements) == null ? void 0 : _a.filter((e) => e.group === group)) != null ? _b : [];
|
|
@@ -13575,12 +13584,11 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
13575
13584
|
}
|
|
13576
13585
|
return (_ctx, _cache) => {
|
|
13577
13586
|
var _a;
|
|
13578
|
-
return openBlock(), createElementBlock("div", {
|
|
13587
|
+
return openBlock(), createElementBlock("div", mergeProps({
|
|
13579
13588
|
id: "lupa-search-result-product-card",
|
|
13580
13589
|
"data-cy": "lupa-search-result-product-card",
|
|
13581
|
-
class:
|
|
13582
|
-
|
|
13583
|
-
}, [
|
|
13590
|
+
class: ["lupa-search-result-product-card", !isInStock.value ? "lupa-out-of-stock" : ""]
|
|
13591
|
+
}, customDocumentHtmlAttributes.value, { onClick: handleClick }), [
|
|
13584
13592
|
createVNode(_sfc_main$w, { options: badgesOptions.value }, null, 8, ["options"]),
|
|
13585
13593
|
createBaseVNode("div", {
|
|
13586
13594
|
class: normalizeClass(["lupa-search-result-product-contents", listLayoutClass.value])
|
|
@@ -13642,7 +13650,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
13642
13650
|
], 2);
|
|
13643
13651
|
}), 128))
|
|
13644
13652
|
], 2)
|
|
13645
|
-
],
|
|
13653
|
+
], 16);
|
|
13646
13654
|
};
|
|
13647
13655
|
}
|
|
13648
13656
|
});
|
|
@@ -13683,7 +13691,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
13683
13691
|
return (_b = (_a = props.labels.similarQuery) == null ? void 0 : _a.replace("{1}", "")) != null ? _b : "";
|
|
13684
13692
|
});
|
|
13685
13693
|
const getSimilarQueryContent = (displayQuery) => {
|
|
13686
|
-
return escapeHtml(displayQuery);
|
|
13694
|
+
return escapeHtml$1(displayQuery);
|
|
13687
13695
|
};
|
|
13688
13696
|
const goToResults = ({
|
|
13689
13697
|
searchText,
|
|
@@ -13969,7 +13977,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
13969
13977
|
"queryKey",
|
|
13970
13978
|
"idKey",
|
|
13971
13979
|
"titleKey",
|
|
13972
|
-
"routingBehavior"
|
|
13980
|
+
"routingBehavior",
|
|
13981
|
+
"customDocumentHtmlAttributes"
|
|
13973
13982
|
]);
|
|
13974
13983
|
});
|
|
13975
13984
|
const similarQueriesLabels = computed(() => {
|
|
@@ -27412,6 +27421,328 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
27412
27421
|
shadow.appendChild(style);
|
|
27413
27422
|
}
|
|
27414
27423
|
};
|
|
27424
|
+
const displayDiscountedPriceSection = (doc2, options) => {
|
|
27425
|
+
var _a, _b;
|
|
27426
|
+
const discountPrice = doc2[(_a = options.fields.discountPriceKey) != null ? _a : ""];
|
|
27427
|
+
const regularPrice = doc2[(_b = options.fields.regularPriceKey) != null ? _b : ""];
|
|
27428
|
+
return discountPrice && regularPrice && discountPrice < regularPrice;
|
|
27429
|
+
};
|
|
27430
|
+
const displayRegularPriceSection = (doc2, options) => {
|
|
27431
|
+
var _a, _b;
|
|
27432
|
+
const discountPrice = doc2[(_a = options.fields.discountPriceKey) != null ? _a : ""];
|
|
27433
|
+
const regularPrice = doc2[(_b = options.fields.regularPriceKey) != null ? _b : ""];
|
|
27434
|
+
const anyPrice = discountPrice || regularPrice;
|
|
27435
|
+
return anyPrice && !displayDiscountedPriceSection(doc2, options);
|
|
27436
|
+
};
|
|
27437
|
+
const escapeHtml = (source) => {
|
|
27438
|
+
if (!source) {
|
|
27439
|
+
return source;
|
|
27440
|
+
}
|
|
27441
|
+
return `${source}`.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
27442
|
+
};
|
|
27443
|
+
const toMaxDecimalPlaces = (value, maxDecimal = 2) => {
|
|
27444
|
+
if (!value) {
|
|
27445
|
+
return 0;
|
|
27446
|
+
}
|
|
27447
|
+
try {
|
|
27448
|
+
return +parseFloat(`${value}`).toFixed(maxDecimal);
|
|
27449
|
+
} catch (e) {
|
|
27450
|
+
return `${value}`;
|
|
27451
|
+
}
|
|
27452
|
+
};
|
|
27453
|
+
const capitalize = (value) => {
|
|
27454
|
+
if (!value) {
|
|
27455
|
+
return "";
|
|
27456
|
+
}
|
|
27457
|
+
return value.charAt(0).toLocaleUpperCase() + value.slice(1);
|
|
27458
|
+
};
|
|
27459
|
+
const getAlphanumeric = (value) => {
|
|
27460
|
+
if (!value) {
|
|
27461
|
+
return "";
|
|
27462
|
+
}
|
|
27463
|
+
return value.replace(/[\W_]/g, " ");
|
|
27464
|
+
};
|
|
27465
|
+
const getAdditionalElements = (fields) => {
|
|
27466
|
+
return fields.map((key) => ({
|
|
27467
|
+
type: "custom",
|
|
27468
|
+
key,
|
|
27469
|
+
label: capitalize(getAlphanumeric(key)),
|
|
27470
|
+
className: "lupa-custom",
|
|
27471
|
+
display: (doc2) => Boolean(doc2[key])
|
|
27472
|
+
}));
|
|
27473
|
+
};
|
|
27474
|
+
const addFieldIfKeyExists = (field, key, config) => {
|
|
27475
|
+
if (key) {
|
|
27476
|
+
return config;
|
|
27477
|
+
}
|
|
27478
|
+
return { key: field, type: "customHtml", display: () => false };
|
|
27479
|
+
};
|
|
27480
|
+
const getSearchBoxComponent = ({
|
|
27481
|
+
searchBoxOptions,
|
|
27482
|
+
labels,
|
|
27483
|
+
panelOptions,
|
|
27484
|
+
redirections,
|
|
27485
|
+
placeholderImage
|
|
27486
|
+
}) => {
|
|
27487
|
+
var _a, _b;
|
|
27488
|
+
const panels = [
|
|
27489
|
+
...(panelOptions == null ? void 0 : panelOptions.suggestionPanel) ? [
|
|
27490
|
+
{
|
|
27491
|
+
type: SearchBoxPanelType.SUGGESTION,
|
|
27492
|
+
queryKey: searchBoxOptions.suggestionQueryKey,
|
|
27493
|
+
highlight: true,
|
|
27494
|
+
limit: 8,
|
|
27495
|
+
labels: {
|
|
27496
|
+
topResultsTitle: labels.searchBox.topSuggestionsTitle
|
|
27497
|
+
}
|
|
27498
|
+
}
|
|
27499
|
+
] : [],
|
|
27500
|
+
...(panelOptions == null ? void 0 : panelOptions.docPanel) ? [
|
|
27501
|
+
{
|
|
27502
|
+
type: SearchBoxPanelType.DOCUMENT,
|
|
27503
|
+
queryKey: searchBoxOptions.documentQueryKey,
|
|
27504
|
+
limit: 5,
|
|
27505
|
+
elements: [
|
|
27506
|
+
{
|
|
27507
|
+
type: "image",
|
|
27508
|
+
placeholder: placeholderImage,
|
|
27509
|
+
key: searchBoxOptions.fields.imageKey,
|
|
27510
|
+
baseUrl: searchBoxOptions.fields.baseImageUrl
|
|
27511
|
+
},
|
|
27512
|
+
{
|
|
27513
|
+
type: "title",
|
|
27514
|
+
key: searchBoxOptions.fields.titleKey,
|
|
27515
|
+
maxLines: 2
|
|
27516
|
+
},
|
|
27517
|
+
{
|
|
27518
|
+
type: "regularPrice",
|
|
27519
|
+
key: searchBoxOptions.fields.regularPriceKey,
|
|
27520
|
+
display: (doc2) => searchBoxOptions.fields.regularPriceKey && searchBoxOptions.fields.discountPriceKey && parseFloat(doc2[searchBoxOptions.fields.regularPriceKey]) > parseFloat(doc2[searchBoxOptions.fields.discountPriceKey])
|
|
27521
|
+
},
|
|
27522
|
+
{
|
|
27523
|
+
type: "price",
|
|
27524
|
+
key: searchBoxOptions.fields.discountPriceKey
|
|
27525
|
+
}
|
|
27526
|
+
]
|
|
27527
|
+
}
|
|
27528
|
+
] : []
|
|
27529
|
+
];
|
|
27530
|
+
return {
|
|
27531
|
+
inputSelector: searchBoxOptions.inputSelector,
|
|
27532
|
+
options: {
|
|
27533
|
+
environment: (_a = searchBoxOptions.environment) != null ? _a : "production",
|
|
27534
|
+
customUrl: searchBoxOptions.customUrl,
|
|
27535
|
+
customBaseUrl: searchBoxOptions.customBaseUrl,
|
|
27536
|
+
customPayload: searchBoxOptions.customPayload,
|
|
27537
|
+
customHeaders: searchBoxOptions.customHeaders
|
|
27538
|
+
},
|
|
27539
|
+
showTotalCount: true,
|
|
27540
|
+
expandOnSinglePanel: true,
|
|
27541
|
+
minInputLength: (_b = searchBoxOptions.fields.minInputLength) != null ? _b : 0,
|
|
27542
|
+
debounce: 250,
|
|
27543
|
+
labels: labels.searchBox,
|
|
27544
|
+
links: {
|
|
27545
|
+
searchResults: ""
|
|
27546
|
+
},
|
|
27547
|
+
panels,
|
|
27548
|
+
redirections,
|
|
27549
|
+
history: {
|
|
27550
|
+
labels: {
|
|
27551
|
+
clear: labels.searchBox.clearHistory
|
|
27552
|
+
}
|
|
27553
|
+
}
|
|
27554
|
+
};
|
|
27555
|
+
};
|
|
27556
|
+
const getSearchResultsComponent = ({
|
|
27557
|
+
searchResultOptions,
|
|
27558
|
+
labels,
|
|
27559
|
+
redirections,
|
|
27560
|
+
placeholderImage,
|
|
27561
|
+
configuratorOverrides,
|
|
27562
|
+
callbacks,
|
|
27563
|
+
additionalFields
|
|
27564
|
+
}) => {
|
|
27565
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
27566
|
+
const filters = searchResultOptions.showFacets ? {
|
|
27567
|
+
currentFilters: {
|
|
27568
|
+
visibility: {
|
|
27569
|
+
mobileSidebar: true,
|
|
27570
|
+
mobileToolbar: true
|
|
27571
|
+
},
|
|
27572
|
+
labels: {
|
|
27573
|
+
title: "",
|
|
27574
|
+
clearAll: (_a = labels.facets) == null ? void 0 : _a.clearAll
|
|
27575
|
+
}
|
|
27576
|
+
},
|
|
27577
|
+
facets: {
|
|
27578
|
+
labels: {
|
|
27579
|
+
title: labels.facets.facetTitle,
|
|
27580
|
+
showAll: labels.facets.showAll,
|
|
27581
|
+
facetFilter: labels.facets.facetFilter,
|
|
27582
|
+
facetClear: labels.facets.facetClear
|
|
27583
|
+
},
|
|
27584
|
+
filterable: {
|
|
27585
|
+
minValues: 5
|
|
27586
|
+
},
|
|
27587
|
+
hierarchy: {
|
|
27588
|
+
maxInitialLevel: 2,
|
|
27589
|
+
topLevelValueCountLimit: 5,
|
|
27590
|
+
filterable: true
|
|
27591
|
+
},
|
|
27592
|
+
stats: {
|
|
27593
|
+
slider: true,
|
|
27594
|
+
inputs: true,
|
|
27595
|
+
labels: {
|
|
27596
|
+
from: "",
|
|
27597
|
+
to: ""
|
|
27598
|
+
}
|
|
27599
|
+
},
|
|
27600
|
+
facetValueCountLimit: 8,
|
|
27601
|
+
showDocumentCount: true,
|
|
27602
|
+
style: {
|
|
27603
|
+
type: "sidebar"
|
|
27604
|
+
}
|
|
27605
|
+
}
|
|
27606
|
+
} : {};
|
|
27607
|
+
const columns = (_g = searchResultOptions.gridConfiguration) != null ? _g : {
|
|
27608
|
+
xl: (_b = searchResultOptions.maxColumns) != null ? _b : 4,
|
|
27609
|
+
l: (_c = searchResultOptions.maxColumns) != null ? _c : 3,
|
|
27610
|
+
md: (_d = searchResultOptions.maxColumns) != null ? _d : 3,
|
|
27611
|
+
sm: (_e = searchResultOptions.maxColumns) != null ? _e : 2,
|
|
27612
|
+
xs: (_f = searchResultOptions.maxColumns) != null ? _f : 1
|
|
27613
|
+
};
|
|
27614
|
+
const badges = searchResultOptions.showRelevance ? {
|
|
27615
|
+
badges: {
|
|
27616
|
+
anchor: "tr",
|
|
27617
|
+
elements: [
|
|
27618
|
+
{
|
|
27619
|
+
key: "",
|
|
27620
|
+
type: "customHtml",
|
|
27621
|
+
className: "relevance",
|
|
27622
|
+
html: (doc2) => `${toMaxDecimalPlaces(escapeHtml(doc2._relevance), 3)}`,
|
|
27623
|
+
display: (doc2) => Boolean(doc2._relevance !== void 0)
|
|
27624
|
+
}
|
|
27625
|
+
]
|
|
27626
|
+
}
|
|
27627
|
+
} : {};
|
|
27628
|
+
return __spreadValues(__spreadProps(__spreadValues({
|
|
27629
|
+
options: {
|
|
27630
|
+
environment: (_h = searchResultOptions.environment) != null ? _h : "production",
|
|
27631
|
+
customUrl: searchResultOptions.customUrl,
|
|
27632
|
+
customBaseUrl: searchResultOptions.customBaseUrl,
|
|
27633
|
+
customPayload: searchResultOptions.customPayload,
|
|
27634
|
+
customHeaders: searchResultOptions.customHeaders,
|
|
27635
|
+
onError: searchResultOptions.errorHandler
|
|
27636
|
+
},
|
|
27637
|
+
queryKey: searchResultOptions.queryKey,
|
|
27638
|
+
containerSelector: searchResultOptions.containerSelector,
|
|
27639
|
+
searchTitlePosition: "search-results-top",
|
|
27640
|
+
titleKey: searchResultOptions.fields.titleKey,
|
|
27641
|
+
labels: labels.searchResults,
|
|
27642
|
+
grid: {
|
|
27643
|
+
columns
|
|
27644
|
+
},
|
|
27645
|
+
pagination: {
|
|
27646
|
+
sizeSelection: {
|
|
27647
|
+
position: {
|
|
27648
|
+
top: true,
|
|
27649
|
+
bottom: false
|
|
27650
|
+
},
|
|
27651
|
+
sizes: [12, 24, 36, 48]
|
|
27652
|
+
},
|
|
27653
|
+
pageSelection: {
|
|
27654
|
+
position: {
|
|
27655
|
+
top: false,
|
|
27656
|
+
bottom: true
|
|
27657
|
+
},
|
|
27658
|
+
displayMobile: 3,
|
|
27659
|
+
display: 5
|
|
27660
|
+
}
|
|
27661
|
+
},
|
|
27662
|
+
filters,
|
|
27663
|
+
toolbar: {
|
|
27664
|
+
layoutSelector: false,
|
|
27665
|
+
itemSummary: true,
|
|
27666
|
+
clearFilters: false
|
|
27667
|
+
},
|
|
27668
|
+
isInStock: () => {
|
|
27669
|
+
return true;
|
|
27670
|
+
}
|
|
27671
|
+
}, badges), {
|
|
27672
|
+
links: {
|
|
27673
|
+
details: searchResultOptions.fields.productUrl ? `{${searchResultOptions.fields.productUrl}}` : void 0
|
|
27674
|
+
},
|
|
27675
|
+
callbacks,
|
|
27676
|
+
routingBehavior: callbacks ? "event" : "direct-link",
|
|
27677
|
+
idKey: "id",
|
|
27678
|
+
elements: [
|
|
27679
|
+
{
|
|
27680
|
+
type: "image",
|
|
27681
|
+
placeholder: placeholderImage,
|
|
27682
|
+
key: searchResultOptions.fields.imageKey,
|
|
27683
|
+
baseUrl: searchResultOptions.fields.baseImageUrl,
|
|
27684
|
+
display: () => searchResultOptions.fields.imageKey
|
|
27685
|
+
},
|
|
27686
|
+
addFieldIfKeyExists("_emphasis", (_i = searchResultOptions.fields) == null ? void 0 : _i.emphasizedField, {
|
|
27687
|
+
type: "custom",
|
|
27688
|
+
className: "lupa-custom-emphasis",
|
|
27689
|
+
key: searchResultOptions.fields.emphasizedField,
|
|
27690
|
+
display: () => true
|
|
27691
|
+
}),
|
|
27692
|
+
{
|
|
27693
|
+
type: "title",
|
|
27694
|
+
key: searchResultOptions.fields.titleKey,
|
|
27695
|
+
maxLines: (_j = searchResultOptions.maxLines) != null ? _j : 2,
|
|
27696
|
+
display: (doc2) => searchResultOptions.fields.titleKey && Boolean(doc2[searchResultOptions.fields.titleKey])
|
|
27697
|
+
},
|
|
27698
|
+
...getAdditionalElements(additionalFields),
|
|
27699
|
+
addFieldIfKeyExists("_discountPrice", searchResultOptions.fields.discountPriceKey, {
|
|
27700
|
+
key: searchResultOptions.fields.discountPriceKey,
|
|
27701
|
+
type: "customHtml",
|
|
27702
|
+
className: "lupa-price lupa-price-discounted",
|
|
27703
|
+
display: (doc2) => displayDiscountedPriceSection(doc2, searchResultOptions),
|
|
27704
|
+
html: (doc2) => {
|
|
27705
|
+
var _a2, _b2, _c2, _d2;
|
|
27706
|
+
const currency = escapeHtml(searchResultOptions.fields.currency || "€");
|
|
27707
|
+
const discountPrice = (_b2 = parseFloat(
|
|
27708
|
+
doc2[(_a2 = searchResultOptions.fields.discountPriceKey) != null ? _a2 : ""]
|
|
27709
|
+
)) == null ? void 0 : _b2.toFixed(2);
|
|
27710
|
+
const regularPrice = (_d2 = parseFloat(
|
|
27711
|
+
doc2[(_c2 = searchResultOptions.fields.regularPriceKey) != null ? _c2 : ""]
|
|
27712
|
+
)) == null ? void 0 : _d2.toFixed(2);
|
|
27713
|
+
const discount = `<span class="lupa-discount">${escapeHtml(
|
|
27714
|
+
discountPrice
|
|
27715
|
+
)} ${currency}</span>`;
|
|
27716
|
+
const regular = `<span class="lupa-regular">${escapeHtml(
|
|
27717
|
+
regularPrice
|
|
27718
|
+
)} ${currency}</span>`;
|
|
27719
|
+
return discount + regular;
|
|
27720
|
+
}
|
|
27721
|
+
}),
|
|
27722
|
+
addFieldIfKeyExists("_regularPrice", searchResultOptions.fields.regularPriceKey, {
|
|
27723
|
+
key: searchResultOptions.fields.regularPriceKey,
|
|
27724
|
+
type: "customHtml",
|
|
27725
|
+
className: "lupa-price lupa-price-single",
|
|
27726
|
+
display: (doc2) => displayRegularPriceSection(doc2, searchResultOptions),
|
|
27727
|
+
html: (doc2) => {
|
|
27728
|
+
var _a2, _b2, _c2, _d2;
|
|
27729
|
+
const currency = escapeHtml(searchResultOptions.fields.currency || "€");
|
|
27730
|
+
const price = (_d2 = parseFloat(
|
|
27731
|
+
(_c2 = doc2[(_a2 = searchResultOptions.fields.regularPriceKey) != null ? _a2 : ""]) != null ? _c2 : doc2[(_b2 = searchResultOptions.fields.discountPriceKey) != null ? _b2 : ""]
|
|
27732
|
+
)) == null ? void 0 : _d2.toFixed(2);
|
|
27733
|
+
return `<span class="lupa-final">${escapeHtml(price)} ${currency}</span>`;
|
|
27734
|
+
}
|
|
27735
|
+
})
|
|
27736
|
+
],
|
|
27737
|
+
breadcrumbs: [],
|
|
27738
|
+
sort: [],
|
|
27739
|
+
redirections
|
|
27740
|
+
}), configuratorOverrides);
|
|
27741
|
+
};
|
|
27742
|
+
const SearchContainerConfigurationService = {
|
|
27743
|
+
getSearchBoxComponent,
|
|
27744
|
+
getSearchResultsComponent
|
|
27745
|
+
};
|
|
27415
27746
|
const app = {
|
|
27416
27747
|
box: {},
|
|
27417
27748
|
results: {},
|
|
@@ -27546,6 +27877,23 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
27546
27877
|
}
|
|
27547
27878
|
app.searchContainer[options.trigger] = instance;
|
|
27548
27879
|
};
|
|
27880
|
+
const preconfiguredSearchContainer = (preconfiguredSearchContainerOptions, mountOptions) => {
|
|
27881
|
+
const searchBox2 = SearchContainerConfigurationService.getSearchBoxComponent(
|
|
27882
|
+
preconfiguredSearchContainerOptions
|
|
27883
|
+
);
|
|
27884
|
+
const searchResults2 = SearchContainerConfigurationService.getSearchResultsComponent(
|
|
27885
|
+
preconfiguredSearchContainerOptions
|
|
27886
|
+
);
|
|
27887
|
+
searchContainer(
|
|
27888
|
+
{
|
|
27889
|
+
trigger: preconfiguredSearchContainerOptions.trigger,
|
|
27890
|
+
searchBox: searchBox2,
|
|
27891
|
+
searchResults: searchResults2,
|
|
27892
|
+
options: preconfiguredSearchContainerOptions.configuration
|
|
27893
|
+
},
|
|
27894
|
+
mountOptions
|
|
27895
|
+
);
|
|
27896
|
+
};
|
|
27549
27897
|
const recommendations = (options, mountOptions) => {
|
|
27550
27898
|
const existingInstance = app.recommendations[options.containerSelector];
|
|
27551
27899
|
if (existingInstance) {
|
|
@@ -27683,7 +28031,10 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
27683
28031
|
clearSearchContainer,
|
|
27684
28032
|
clearRecommendations,
|
|
27685
28033
|
chat,
|
|
27686
|
-
clearChat
|
|
28034
|
+
clearChat,
|
|
28035
|
+
preconfiguredSearchContainer,
|
|
28036
|
+
getSearchBoxComponent: SearchContainerConfigurationService.getSearchBoxComponent,
|
|
28037
|
+
getSearchResultsComponent: SearchContainerConfigurationService.getSearchResultsComponent
|
|
27687
28038
|
};
|
|
27688
28039
|
if (typeof window !== "undefined") {
|
|
27689
28040
|
window.getLupa = lupaSearch;
|