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