@getlupa/client 1.14.17 → 1.15.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.
@@ -7862,7 +7862,10 @@ var __async = (__this, __arguments, generator) => {
7862
7862
  if (!inputValue) {
7863
7863
  return escapeHtml$1(suggestion);
7864
7864
  }
7865
- return (_a = suggestion == null ? void 0 : suggestion.replace(inputValue, `<strong>${escapeHtml$1(inputValue)}</strong>`)) != null ? _a : "";
7865
+ return (_a = suggestion == null ? void 0 : suggestion.replace(
7866
+ inputValue == null ? void 0 : inputValue.toLocaleLowerCase(),
7867
+ `<strong>${escapeHtml$1(inputValue == null ? void 0 : inputValue.toLocaleLowerCase())}</strong>`
7868
+ )) != null ? _a : "";
7866
7869
  };
7867
7870
  const reverseKeyValue = (obj) => {
7868
7871
  return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
@@ -8080,14 +8083,16 @@ var __async = (__this, __arguments, generator) => {
8080
8083
  paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
8081
8084
  });
8082
8085
  };
8086
+ const replaceHierarchyParam = (params = [], param = "") => {
8087
+ if (params.some((p2) => p2.startsWith(param))) {
8088
+ return toggleLastPram(params, param);
8089
+ }
8090
+ return [param];
8091
+ };
8083
8092
  const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
8084
- var _a;
8093
+ var _a, _b;
8085
8094
  const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
8086
- const newParams = toggleHierarchyParam(
8087
- (_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [],
8088
- facetAction.value,
8089
- removeAllLevels
8090
- );
8095
+ const newParams = facetAction.behavior === "replace" ? replaceHierarchyParam((_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [], facetAction.value) : toggleHierarchyParam((_b = currentFilter == null ? void 0 : currentFilter.terms) != null ? _b : [], facetAction.value, removeAllLevels);
8091
8096
  appendParams({
8092
8097
  params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
8093
8098
  paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
@@ -8430,6 +8435,7 @@ var __async = (__this, __arguments, generator) => {
8430
8435
  const highlightedIndex = ref(-1);
8431
8436
  const inputValue = ref("");
8432
8437
  const resultInputValue = ref("");
8438
+ const latestRequestIdByQueryKey = {};
8433
8439
  const historyStore = useHistoryStore();
8434
8440
  const resultsVisible = computed(() => {
8435
8441
  var _a;
@@ -8496,12 +8502,17 @@ var __async = (__this, __arguments, generator) => {
8496
8502
  }) {
8497
8503
  var _a;
8498
8504
  try {
8505
+ const currentRequestId = Date.now();
8506
+ latestRequestIdByQueryKey[queryKey] = currentRequestId;
8499
8507
  const context = getLupaTrackingContext();
8500
8508
  const result2 = yield LupaSearchSdk.suggestions(
8501
8509
  queryKey,
8502
8510
  __spreadValues2(__spreadValues2({}, publicQuery), context),
8503
8511
  options2
8504
8512
  );
8513
+ if (latestRequestIdByQueryKey[queryKey] !== currentRequestId) {
8514
+ return { suggestions: void 0 };
8515
+ }
8505
8516
  if (!result2.success) {
8506
8517
  return { suggestions: void 0 };
8507
8518
  }
@@ -8542,8 +8553,13 @@ var __async = (__this, __arguments, generator) => {
8542
8553
  options: options2
8543
8554
  }) {
8544
8555
  try {
8556
+ const currentRequestId = Date.now();
8557
+ latestRequestIdByQueryKey[queryKey] = currentRequestId;
8545
8558
  const context = getLupaTrackingContext();
8546
8559
  const result2 = yield LupaSearchSdk.query(queryKey, __spreadValues2(__spreadValues2({}, publicQuery), context), options2);
8560
+ if (latestRequestIdByQueryKey[queryKey] !== currentRequestId) {
8561
+ return { suggestions: void 0 };
8562
+ }
8547
8563
  if (!result2.success) {
8548
8564
  return { queryKey, result: { items: [] } };
8549
8565
  }
@@ -22059,8 +22075,12 @@ and ensure you are accounting for this risk.
22059
22075
  var _a;
22060
22076
  return Boolean((_a = props.options.stats) == null ? void 0 : _a.inputs);
22061
22077
  });
22078
+ const pricePrecision = computed(() => {
22079
+ var _a, _b;
22080
+ return (_b = (_a = props.options.stats) == null ? void 0 : _a.pricePrecisionDigits) != null ? _b : 2;
22081
+ });
22062
22082
  const fromValue = computed({
22063
- get: () => isPrice.value ? sliderRange.value[0].toFixed(2).replace(".", separator.value) : `${sliderRange.value[0]}`,
22083
+ get: () => isPrice.value ? sliderRange.value[0].toFixed(pricePrecision.value).replace(".", separator.value) : `${sliderRange.value[0]}`,
22064
22084
  set: (stringValue) => {
22065
22085
  let value = normalizeFloat(stringValue);
22066
22086
  if (value < facetMin.value) {
@@ -22074,7 +22094,7 @@ and ensure you are accounting for this risk.
22074
22094
  }
22075
22095
  });
22076
22096
  const toValue = computed({
22077
- get: () => isPrice.value ? sliderRange.value[1].toFixed(2).replace(".", separator.value) : `${sliderRange.value[1]}`,
22097
+ get: () => isPrice.value ? sliderRange.value[1].toFixed(pricePrecision.value).replace(".", separator.value) : `${sliderRange.value[1]}`,
22078
22098
  set: (stringValue) => {
22079
22099
  let value = normalizeFloat(stringValue);
22080
22100
  if (value > facetMax.value) {
@@ -22383,15 +22403,20 @@ and ensure you are accounting for this risk.
22383
22403
  return Boolean((_a = props.options.hierarchy) == null ? void 0 : _a.filterable) && allValues.value.length >= ((_c = (_b = props.options.filterable) == null ? void 0 : _b.minValues) != null ? _c : MAX_FACET_VALUES);
22384
22404
  });
22385
22405
  const handleFacetClick = ({ value }) => {
22406
+ var _a, _b;
22386
22407
  emit2("select", {
22387
22408
  key: facet.value.key,
22388
22409
  value,
22389
- type: "hierarchy"
22410
+ type: "hierarchy",
22411
+ behavior: (_b = (_a = props.options.hierarchy) == null ? void 0 : _a.behavior) != null ? _b : "append"
22390
22412
  });
22391
22413
  };
22392
22414
  const handleShowAll = () => {
22393
22415
  showAll.value = true;
22394
22416
  };
22417
+ const handleCancelShowAll = () => {
22418
+ showAll.value = false;
22419
+ };
22395
22420
  return (_ctx, _cache) => {
22396
22421
  return openBlock(), createElementBlock("div", _hoisted_1$J, [
22397
22422
  isFilterable.value ? (openBlock(), createElementBlock("div", _hoisted_2$x, [
@@ -22420,7 +22445,11 @@ and ensure you are accounting for this risk.
22420
22445
  class: "lupa-facet-term lupa-show-more-facet-results",
22421
22446
  "data-cy": "lupa-facet-term",
22422
22447
  onClick: handleShowAll
22423
- }, toDisplayString(_ctx.options.labels.showAll), 1)) : createCommentVNode("", true)
22448
+ }, toDisplayString(_ctx.options.labels.showAll), 1)) : showAll.value ? (openBlock(), createElementBlock("div", {
22449
+ key: 2,
22450
+ class: "lupa-facet-term lupa-show-more-facet-results",
22451
+ onClick: handleCancelShowAll
22452
+ }, toDisplayString(_ctx.options.labels.showLess), 1)) : createCommentVNode("", true)
22424
22453
  ]);
22425
22454
  };
22426
22455
  }
@@ -24611,7 +24640,6 @@ and ensure you are accounting for this risk.
24611
24640
  watch(
24612
24641
  () => props.query,
24613
24642
  () => {
24614
- console.log("query changed", props.query);
24615
24643
  searchForRelatedQuery();
24616
24644
  }
24617
24645
  );
@@ -7862,7 +7862,10 @@ const getHint = (suggestion, inputValue) => {
7862
7862
  if (!inputValue) {
7863
7863
  return escapeHtml$1(suggestion);
7864
7864
  }
7865
- return (_a = suggestion == null ? void 0 : suggestion.replace(inputValue, `<strong>${escapeHtml$1(inputValue)}</strong>`)) != null ? _a : "";
7865
+ return (_a = suggestion == null ? void 0 : suggestion.replace(
7866
+ inputValue == null ? void 0 : inputValue.toLocaleLowerCase(),
7867
+ `<strong>${escapeHtml$1(inputValue == null ? void 0 : inputValue.toLocaleLowerCase())}</strong>`
7868
+ )) != null ? _a : "";
7866
7869
  };
7867
7870
  const reverseKeyValue = (obj) => {
7868
7871
  return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
@@ -8080,14 +8083,16 @@ const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentF
8080
8083
  paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
8081
8084
  });
8082
8085
  };
8086
+ const replaceHierarchyParam = (params = [], param = "") => {
8087
+ if (params.some((p2) => p2.startsWith(param))) {
8088
+ return toggleLastPram(params, param);
8089
+ }
8090
+ return [param];
8091
+ };
8083
8092
  const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
8084
- var _a;
8093
+ var _a, _b;
8085
8094
  const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
8086
- const newParams = toggleHierarchyParam(
8087
- (_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [],
8088
- facetAction.value,
8089
- removeAllLevels
8090
- );
8095
+ const newParams = facetAction.behavior === "replace" ? replaceHierarchyParam((_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [], facetAction.value) : toggleHierarchyParam((_b = currentFilter == null ? void 0 : currentFilter.terms) != null ? _b : [], facetAction.value, removeAllLevels);
8091
8096
  appendParams({
8092
8097
  params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
8093
8098
  paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
@@ -8430,6 +8435,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
8430
8435
  const highlightedIndex = ref(-1);
8431
8436
  const inputValue = ref("");
8432
8437
  const resultInputValue = ref("");
8438
+ const latestRequestIdByQueryKey = {};
8433
8439
  const historyStore = useHistoryStore();
8434
8440
  const resultsVisible = computed(() => {
8435
8441
  var _a;
@@ -8496,12 +8502,17 @@ const useSearchBoxStore = defineStore("searchBox", () => {
8496
8502
  }) {
8497
8503
  var _a;
8498
8504
  try {
8505
+ const currentRequestId = Date.now();
8506
+ latestRequestIdByQueryKey[queryKey] = currentRequestId;
8499
8507
  const context = getLupaTrackingContext();
8500
8508
  const result2 = yield LupaSearchSdk.suggestions(
8501
8509
  queryKey,
8502
8510
  __spreadValues2(__spreadValues2({}, publicQuery), context),
8503
8511
  options2
8504
8512
  );
8513
+ if (latestRequestIdByQueryKey[queryKey] !== currentRequestId) {
8514
+ return { suggestions: void 0 };
8515
+ }
8505
8516
  if (!result2.success) {
8506
8517
  return { suggestions: void 0 };
8507
8518
  }
@@ -8542,8 +8553,13 @@ const useSearchBoxStore = defineStore("searchBox", () => {
8542
8553
  options: options2
8543
8554
  }) {
8544
8555
  try {
8556
+ const currentRequestId = Date.now();
8557
+ latestRequestIdByQueryKey[queryKey] = currentRequestId;
8545
8558
  const context = getLupaTrackingContext();
8546
8559
  const result2 = yield LupaSearchSdk.query(queryKey, __spreadValues2(__spreadValues2({}, publicQuery), context), options2);
8560
+ if (latestRequestIdByQueryKey[queryKey] !== currentRequestId) {
8561
+ return { suggestions: void 0 };
8562
+ }
8547
8563
  if (!result2.success) {
8548
8564
  return { queryKey, result: { items: [] } };
8549
8565
  }
@@ -22059,8 +22075,12 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
22059
22075
  var _a;
22060
22076
  return Boolean((_a = props.options.stats) == null ? void 0 : _a.inputs);
22061
22077
  });
22078
+ const pricePrecision = computed(() => {
22079
+ var _a, _b;
22080
+ return (_b = (_a = props.options.stats) == null ? void 0 : _a.pricePrecisionDigits) != null ? _b : 2;
22081
+ });
22062
22082
  const fromValue = computed({
22063
- get: () => isPrice.value ? sliderRange.value[0].toFixed(2).replace(".", separator.value) : `${sliderRange.value[0]}`,
22083
+ get: () => isPrice.value ? sliderRange.value[0].toFixed(pricePrecision.value).replace(".", separator.value) : `${sliderRange.value[0]}`,
22064
22084
  set: (stringValue) => {
22065
22085
  let value = normalizeFloat(stringValue);
22066
22086
  if (value < facetMin.value) {
@@ -22074,7 +22094,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
22074
22094
  }
22075
22095
  });
22076
22096
  const toValue = computed({
22077
- get: () => isPrice.value ? sliderRange.value[1].toFixed(2).replace(".", separator.value) : `${sliderRange.value[1]}`,
22097
+ get: () => isPrice.value ? sliderRange.value[1].toFixed(pricePrecision.value).replace(".", separator.value) : `${sliderRange.value[1]}`,
22078
22098
  set: (stringValue) => {
22079
22099
  let value = normalizeFloat(stringValue);
22080
22100
  if (value > facetMax.value) {
@@ -22383,15 +22403,20 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
22383
22403
  return Boolean((_a = props.options.hierarchy) == null ? void 0 : _a.filterable) && allValues.value.length >= ((_c = (_b = props.options.filterable) == null ? void 0 : _b.minValues) != null ? _c : MAX_FACET_VALUES);
22384
22404
  });
22385
22405
  const handleFacetClick = ({ value }) => {
22406
+ var _a, _b;
22386
22407
  emit2("select", {
22387
22408
  key: facet.value.key,
22388
22409
  value,
22389
- type: "hierarchy"
22410
+ type: "hierarchy",
22411
+ behavior: (_b = (_a = props.options.hierarchy) == null ? void 0 : _a.behavior) != null ? _b : "append"
22390
22412
  });
22391
22413
  };
22392
22414
  const handleShowAll = () => {
22393
22415
  showAll.value = true;
22394
22416
  };
22417
+ const handleCancelShowAll = () => {
22418
+ showAll.value = false;
22419
+ };
22395
22420
  return (_ctx, _cache) => {
22396
22421
  return openBlock(), createElementBlock("div", _hoisted_1$J, [
22397
22422
  isFilterable.value ? (openBlock(), createElementBlock("div", _hoisted_2$x, [
@@ -22420,7 +22445,11 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
22420
22445
  class: "lupa-facet-term lupa-show-more-facet-results",
22421
22446
  "data-cy": "lupa-facet-term",
22422
22447
  onClick: handleShowAll
22423
- }, toDisplayString(_ctx.options.labels.showAll), 1)) : createCommentVNode("", true)
22448
+ }, toDisplayString(_ctx.options.labels.showAll), 1)) : showAll.value ? (openBlock(), createElementBlock("div", {
22449
+ key: 2,
22450
+ class: "lupa-facet-term lupa-show-more-facet-results",
22451
+ onClick: handleCancelShowAll
22452
+ }, toDisplayString(_ctx.options.labels.showLess), 1)) : createCommentVNode("", true)
22424
22453
  ]);
22425
22454
  };
22426
22455
  }
@@ -24611,7 +24640,6 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
24611
24640
  watch(
24612
24641
  () => props.query,
24613
24642
  () => {
24614
- console.log("query changed", props.query);
24615
24643
  searchForRelatedQuery();
24616
24644
  }
24617
24645
  );
@@ -7860,7 +7860,10 @@ const getHint = (suggestion, inputValue) => {
7860
7860
  if (!inputValue) {
7861
7861
  return escapeHtml$1(suggestion);
7862
7862
  }
7863
- return (_a = suggestion == null ? void 0 : suggestion.replace(inputValue, `<strong>${escapeHtml$1(inputValue)}</strong>`)) != null ? _a : "";
7863
+ return (_a = suggestion == null ? void 0 : suggestion.replace(
7864
+ inputValue == null ? void 0 : inputValue.toLocaleLowerCase(),
7865
+ `<strong>${escapeHtml$1(inputValue == null ? void 0 : inputValue.toLocaleLowerCase())}</strong>`
7866
+ )) != null ? _a : "";
7864
7867
  };
7865
7868
  const reverseKeyValue = (obj) => {
7866
7869
  return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
@@ -8078,14 +8081,16 @@ const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentF
8078
8081
  paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
8079
8082
  });
8080
8083
  };
8084
+ const replaceHierarchyParam = (params = [], param = "") => {
8085
+ if (params.some((p2) => p2.startsWith(param))) {
8086
+ return toggleLastPram(params, param);
8087
+ }
8088
+ return [param];
8089
+ };
8081
8090
  const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
8082
- var _a;
8091
+ var _a, _b;
8083
8092
  const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
8084
- const newParams = toggleHierarchyParam(
8085
- (_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [],
8086
- facetAction.value,
8087
- removeAllLevels
8088
- );
8093
+ const newParams = facetAction.behavior === "replace" ? replaceHierarchyParam((_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [], facetAction.value) : toggleHierarchyParam((_b = currentFilter == null ? void 0 : currentFilter.terms) != null ? _b : [], facetAction.value, removeAllLevels);
8089
8094
  appendParams({
8090
8095
  params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
8091
8096
  paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
@@ -8428,6 +8433,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
8428
8433
  const highlightedIndex = ref(-1);
8429
8434
  const inputValue = ref("");
8430
8435
  const resultInputValue = ref("");
8436
+ const latestRequestIdByQueryKey = {};
8431
8437
  const historyStore = useHistoryStore();
8432
8438
  const resultsVisible = computed(() => {
8433
8439
  var _a;
@@ -8494,12 +8500,17 @@ const useSearchBoxStore = defineStore("searchBox", () => {
8494
8500
  }) {
8495
8501
  var _a;
8496
8502
  try {
8503
+ const currentRequestId = Date.now();
8504
+ latestRequestIdByQueryKey[queryKey] = currentRequestId;
8497
8505
  const context = getLupaTrackingContext();
8498
8506
  const result2 = yield LupaSearchSdk.suggestions(
8499
8507
  queryKey,
8500
8508
  __spreadValues2(__spreadValues2({}, publicQuery), context),
8501
8509
  options2
8502
8510
  );
8511
+ if (latestRequestIdByQueryKey[queryKey] !== currentRequestId) {
8512
+ return { suggestions: void 0 };
8513
+ }
8503
8514
  if (!result2.success) {
8504
8515
  return { suggestions: void 0 };
8505
8516
  }
@@ -8540,8 +8551,13 @@ const useSearchBoxStore = defineStore("searchBox", () => {
8540
8551
  options: options2
8541
8552
  }) {
8542
8553
  try {
8554
+ const currentRequestId = Date.now();
8555
+ latestRequestIdByQueryKey[queryKey] = currentRequestId;
8543
8556
  const context = getLupaTrackingContext();
8544
8557
  const result2 = yield LupaSearchSdk.query(queryKey, __spreadValues2(__spreadValues2({}, publicQuery), context), options2);
8558
+ if (latestRequestIdByQueryKey[queryKey] !== currentRequestId) {
8559
+ return { suggestions: void 0 };
8560
+ }
8545
8561
  if (!result2.success) {
8546
8562
  return { queryKey, result: { items: [] } };
8547
8563
  }
@@ -22057,8 +22073,12 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
22057
22073
  var _a;
22058
22074
  return Boolean((_a = props.options.stats) == null ? void 0 : _a.inputs);
22059
22075
  });
22076
+ const pricePrecision = computed(() => {
22077
+ var _a, _b;
22078
+ return (_b = (_a = props.options.stats) == null ? void 0 : _a.pricePrecisionDigits) != null ? _b : 2;
22079
+ });
22060
22080
  const fromValue = computed({
22061
- get: () => isPrice.value ? sliderRange.value[0].toFixed(2).replace(".", separator.value) : `${sliderRange.value[0]}`,
22081
+ get: () => isPrice.value ? sliderRange.value[0].toFixed(pricePrecision.value).replace(".", separator.value) : `${sliderRange.value[0]}`,
22062
22082
  set: (stringValue) => {
22063
22083
  let value = normalizeFloat(stringValue);
22064
22084
  if (value < facetMin.value) {
@@ -22072,7 +22092,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
22072
22092
  }
22073
22093
  });
22074
22094
  const toValue = computed({
22075
- get: () => isPrice.value ? sliderRange.value[1].toFixed(2).replace(".", separator.value) : `${sliderRange.value[1]}`,
22095
+ get: () => isPrice.value ? sliderRange.value[1].toFixed(pricePrecision.value).replace(".", separator.value) : `${sliderRange.value[1]}`,
22076
22096
  set: (stringValue) => {
22077
22097
  let value = normalizeFloat(stringValue);
22078
22098
  if (value > facetMax.value) {
@@ -22381,15 +22401,20 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
22381
22401
  return Boolean((_a = props.options.hierarchy) == null ? void 0 : _a.filterable) && allValues.value.length >= ((_c = (_b = props.options.filterable) == null ? void 0 : _b.minValues) != null ? _c : MAX_FACET_VALUES);
22382
22402
  });
22383
22403
  const handleFacetClick = ({ value }) => {
22404
+ var _a, _b;
22384
22405
  emit2("select", {
22385
22406
  key: facet.value.key,
22386
22407
  value,
22387
- type: "hierarchy"
22408
+ type: "hierarchy",
22409
+ behavior: (_b = (_a = props.options.hierarchy) == null ? void 0 : _a.behavior) != null ? _b : "append"
22388
22410
  });
22389
22411
  };
22390
22412
  const handleShowAll = () => {
22391
22413
  showAll.value = true;
22392
22414
  };
22415
+ const handleCancelShowAll = () => {
22416
+ showAll.value = false;
22417
+ };
22393
22418
  return (_ctx, _cache) => {
22394
22419
  return openBlock(), createElementBlock("div", _hoisted_1$J, [
22395
22420
  isFilterable.value ? (openBlock(), createElementBlock("div", _hoisted_2$x, [
@@ -22418,7 +22443,11 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
22418
22443
  class: "lupa-facet-term lupa-show-more-facet-results",
22419
22444
  "data-cy": "lupa-facet-term",
22420
22445
  onClick: handleShowAll
22421
- }, toDisplayString(_ctx.options.labels.showAll), 1)) : createCommentVNode("", true)
22446
+ }, toDisplayString(_ctx.options.labels.showAll), 1)) : showAll.value ? (openBlock(), createElementBlock("div", {
22447
+ key: 2,
22448
+ class: "lupa-facet-term lupa-show-more-facet-results",
22449
+ onClick: handleCancelShowAll
22450
+ }, toDisplayString(_ctx.options.labels.showLess), 1)) : createCommentVNode("", true)
22422
22451
  ]);
22423
22452
  };
22424
22453
  }
@@ -24609,7 +24638,6 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
24609
24638
  watch(
24610
24639
  () => props.query,
24611
24640
  () => {
24612
- console.log("query changed", props.query);
24613
24641
  searchForRelatedQuery();
24614
24642
  }
24615
24643
  );
@@ -7864,7 +7864,10 @@ var __async = (__this, __arguments, generator) => {
7864
7864
  if (!inputValue) {
7865
7865
  return escapeHtml$1(suggestion);
7866
7866
  }
7867
- return (_a = suggestion == null ? void 0 : suggestion.replace(inputValue, `<strong>${escapeHtml$1(inputValue)}</strong>`)) != null ? _a : "";
7867
+ return (_a = suggestion == null ? void 0 : suggestion.replace(
7868
+ inputValue == null ? void 0 : inputValue.toLocaleLowerCase(),
7869
+ `<strong>${escapeHtml$1(inputValue == null ? void 0 : inputValue.toLocaleLowerCase())}</strong>`
7870
+ )) != null ? _a : "";
7868
7871
  };
7869
7872
  const reverseKeyValue = (obj) => {
7870
7873
  return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
@@ -8082,14 +8085,16 @@ var __async = (__this, __arguments, generator) => {
8082
8085
  paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
8083
8086
  });
8084
8087
  };
8088
+ const replaceHierarchyParam = (params = [], param = "") => {
8089
+ if (params.some((p2) => p2.startsWith(param))) {
8090
+ return toggleLastPram(params, param);
8091
+ }
8092
+ return [param];
8093
+ };
8085
8094
  const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
8086
- var _a;
8095
+ var _a, _b;
8087
8096
  const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
8088
- const newParams = toggleHierarchyParam(
8089
- (_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [],
8090
- facetAction.value,
8091
- removeAllLevels
8092
- );
8097
+ const newParams = facetAction.behavior === "replace" ? replaceHierarchyParam((_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [], facetAction.value) : toggleHierarchyParam((_b = currentFilter == null ? void 0 : currentFilter.terms) != null ? _b : [], facetAction.value, removeAllLevels);
8093
8098
  appendParams({
8094
8099
  params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
8095
8100
  paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
@@ -8432,6 +8437,7 @@ var __async = (__this, __arguments, generator) => {
8432
8437
  const highlightedIndex = ref(-1);
8433
8438
  const inputValue = ref("");
8434
8439
  const resultInputValue = ref("");
8440
+ const latestRequestIdByQueryKey = {};
8435
8441
  const historyStore = useHistoryStore();
8436
8442
  const resultsVisible = computed(() => {
8437
8443
  var _a;
@@ -8498,12 +8504,17 @@ var __async = (__this, __arguments, generator) => {
8498
8504
  }) {
8499
8505
  var _a;
8500
8506
  try {
8507
+ const currentRequestId = Date.now();
8508
+ latestRequestIdByQueryKey[queryKey] = currentRequestId;
8501
8509
  const context = getLupaTrackingContext();
8502
8510
  const result2 = yield LupaSearchSdk.suggestions(
8503
8511
  queryKey,
8504
8512
  __spreadValues2(__spreadValues2({}, publicQuery), context),
8505
8513
  options2
8506
8514
  );
8515
+ if (latestRequestIdByQueryKey[queryKey] !== currentRequestId) {
8516
+ return { suggestions: void 0 };
8517
+ }
8507
8518
  if (!result2.success) {
8508
8519
  return { suggestions: void 0 };
8509
8520
  }
@@ -8544,8 +8555,13 @@ var __async = (__this, __arguments, generator) => {
8544
8555
  options: options2
8545
8556
  }) {
8546
8557
  try {
8558
+ const currentRequestId = Date.now();
8559
+ latestRequestIdByQueryKey[queryKey] = currentRequestId;
8547
8560
  const context = getLupaTrackingContext();
8548
8561
  const result2 = yield LupaSearchSdk.query(queryKey, __spreadValues2(__spreadValues2({}, publicQuery), context), options2);
8562
+ if (latestRequestIdByQueryKey[queryKey] !== currentRequestId) {
8563
+ return { suggestions: void 0 };
8564
+ }
8549
8565
  if (!result2.success) {
8550
8566
  return { queryKey, result: { items: [] } };
8551
8567
  }
@@ -22061,8 +22077,12 @@ and ensure you are accounting for this risk.
22061
22077
  var _a;
22062
22078
  return Boolean((_a = props.options.stats) == null ? void 0 : _a.inputs);
22063
22079
  });
22080
+ const pricePrecision = computed(() => {
22081
+ var _a, _b;
22082
+ return (_b = (_a = props.options.stats) == null ? void 0 : _a.pricePrecisionDigits) != null ? _b : 2;
22083
+ });
22064
22084
  const fromValue = computed({
22065
- get: () => isPrice.value ? sliderRange.value[0].toFixed(2).replace(".", separator.value) : `${sliderRange.value[0]}`,
22085
+ get: () => isPrice.value ? sliderRange.value[0].toFixed(pricePrecision.value).replace(".", separator.value) : `${sliderRange.value[0]}`,
22066
22086
  set: (stringValue) => {
22067
22087
  let value = normalizeFloat(stringValue);
22068
22088
  if (value < facetMin.value) {
@@ -22076,7 +22096,7 @@ and ensure you are accounting for this risk.
22076
22096
  }
22077
22097
  });
22078
22098
  const toValue = computed({
22079
- get: () => isPrice.value ? sliderRange.value[1].toFixed(2).replace(".", separator.value) : `${sliderRange.value[1]}`,
22099
+ get: () => isPrice.value ? sliderRange.value[1].toFixed(pricePrecision.value).replace(".", separator.value) : `${sliderRange.value[1]}`,
22080
22100
  set: (stringValue) => {
22081
22101
  let value = normalizeFloat(stringValue);
22082
22102
  if (value > facetMax.value) {
@@ -22385,15 +22405,20 @@ and ensure you are accounting for this risk.
22385
22405
  return Boolean((_a = props.options.hierarchy) == null ? void 0 : _a.filterable) && allValues.value.length >= ((_c = (_b = props.options.filterable) == null ? void 0 : _b.minValues) != null ? _c : MAX_FACET_VALUES);
22386
22406
  });
22387
22407
  const handleFacetClick = ({ value }) => {
22408
+ var _a, _b;
22388
22409
  emit2("select", {
22389
22410
  key: facet.value.key,
22390
22411
  value,
22391
- type: "hierarchy"
22412
+ type: "hierarchy",
22413
+ behavior: (_b = (_a = props.options.hierarchy) == null ? void 0 : _a.behavior) != null ? _b : "append"
22392
22414
  });
22393
22415
  };
22394
22416
  const handleShowAll = () => {
22395
22417
  showAll.value = true;
22396
22418
  };
22419
+ const handleCancelShowAll = () => {
22420
+ showAll.value = false;
22421
+ };
22397
22422
  return (_ctx, _cache) => {
22398
22423
  return openBlock(), createElementBlock("div", _hoisted_1$J, [
22399
22424
  isFilterable.value ? (openBlock(), createElementBlock("div", _hoisted_2$x, [
@@ -22422,7 +22447,11 @@ and ensure you are accounting for this risk.
22422
22447
  class: "lupa-facet-term lupa-show-more-facet-results",
22423
22448
  "data-cy": "lupa-facet-term",
22424
22449
  onClick: handleShowAll
22425
- }, toDisplayString(_ctx.options.labels.showAll), 1)) : createCommentVNode("", true)
22450
+ }, toDisplayString(_ctx.options.labels.showAll), 1)) : showAll.value ? (openBlock(), createElementBlock("div", {
22451
+ key: 2,
22452
+ class: "lupa-facet-term lupa-show-more-facet-results",
22453
+ onClick: handleCancelShowAll
22454
+ }, toDisplayString(_ctx.options.labels.showLess), 1)) : createCommentVNode("", true)
22426
22455
  ]);
22427
22456
  };
22428
22457
  }
@@ -24613,7 +24642,6 @@ and ensure you are accounting for this risk.
24613
24642
  watch(
24614
24643
  () => props.query,
24615
24644
  () => {
24616
- console.log("query changed", props.query);
24617
24645
  searchForRelatedQuery();
24618
24646
  }
24619
24647
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/client",
3
- "version": "1.14.17",
3
+ "version": "1.15.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.14.17",
23
+ "@getlupa/vue": "0.15.0",
24
24
  "@rushstack/eslint-patch": "^1.3.2",
25
25
  "@tsconfig/node18": "^2.0.1",
26
26
  "@types/jsdom": "^21.1.1",