@getlupa/vue 0.23.0 → 0.23.2

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.
@@ -9,12 +9,15 @@ export declare const QUERY_PARAMS_PARSED: {
9
9
  export declare const FACET_PARAMS_TYPE: {
10
10
  TERMS: string;
11
11
  RANGE: string;
12
+ PARTIAL_RANGE: string;
12
13
  HIERARCHY: string;
13
14
  };
14
15
  export declare const FACET_FILTER_MAP: {
15
16
  terms: string;
16
17
  range: string;
18
+ stats: string;
17
19
  hierarchy: string;
20
+ partialRange: string;
18
21
  };
19
22
  export declare const FACET_KEY_SEPARATOR = ".";
20
23
  export declare const FACET_RANGE_SEPARATOR = ":";
@@ -12258,12 +12258,15 @@ const QUERY_PARAMS_PARSED = {
12258
12258
  const FACET_PARAMS_TYPE = {
12259
12259
  TERMS: "f.",
12260
12260
  RANGE: "fr.",
12261
+ PARTIAL_RANGE: "fpr.",
12261
12262
  HIERARCHY: "fh."
12262
12263
  };
12263
12264
  const FACET_FILTER_MAP = {
12264
12265
  terms: FACET_PARAMS_TYPE.TERMS,
12265
12266
  range: FACET_PARAMS_TYPE.RANGE,
12266
- hierarchy: FACET_PARAMS_TYPE.HIERARCHY
12267
+ stats: FACET_PARAMS_TYPE.RANGE,
12268
+ hierarchy: FACET_PARAMS_TYPE.HIERARCHY,
12269
+ partialRange: FACET_PARAMS_TYPE.PARTIAL_RANGE
12267
12270
  };
12268
12271
  const FACET_KEY_SEPARATOR = ".";
12269
12272
  const FACET_RANGE_SEPARATOR = ":";
@@ -12417,7 +12420,7 @@ const getLabeledFilters = (filters, facets2, translations) => {
12417
12420
  });
12418
12421
  });
12419
12422
  };
12420
- const isFacetKey = (key) => key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.TERMS) || key.startsWith(FACET_PARAMS_TYPE.HIERARCHY);
12423
+ const isFacetKey = (key) => key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.TERMS) || key.startsWith(FACET_PARAMS_TYPE.HIERARCHY) || key.startsWith(FACET_PARAMS_TYPE.PARTIAL_RANGE);
12421
12424
  const getMostSpecificHierarchyTerms = (terms) => {
12422
12425
  const specificTerms = [];
12423
12426
  for (const term of terms) {
@@ -12505,8 +12508,7 @@ const parseFacetKey = (key, searchParams) => {
12505
12508
  if (key.startsWith(FACET_PARAMS_TYPE.TERMS)) {
12506
12509
  return (_b25 = (_a25 = searchParams.getAll(key)) == null ? void 0 : _a25.map((v) => decodeURIComponent(v))) != null ? _b25 : [];
12507
12510
  }
12508
- if (key.startsWith(FACET_PARAMS_TYPE.RANGE)) {
12509
- const isPrice = key == null ? void 0 : key.includes(CURRENCY_KEY_INDICATOR);
12511
+ if (key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.PARTIAL_RANGE)) {
12510
12512
  const range2 = searchParams.get(key);
12511
12513
  if (!range2) {
12512
12514
  return {};
@@ -12514,7 +12516,7 @@ const parseFacetKey = (key, searchParams) => {
12514
12516
  const [min, max] = range2.split(FACET_RANGE_SEPARATOR);
12515
12517
  return {
12516
12518
  gte: min || void 0,
12517
- [isPrice ? "lte" : "lt"]: max || void 0
12519
+ [key.startsWith(FACET_PARAMS_TYPE.PARTIAL_RANGE) ? "lt" : "lte"]: max || void 0
12518
12520
  };
12519
12521
  }
12520
12522
  if (key.startsWith(FACET_PARAMS_TYPE.HIERARCHY)) {
@@ -12716,6 +12718,7 @@ const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, cur
12716
12718
  };
12717
12719
  const toggleRangeFilter = (appendParams, removeParameters, facetAction, getQueryParamName, currentFilters) => {
12718
12720
  var _a25, _b25;
12721
+ const baseFacetQueryParamName = facetAction.type === "partialRange" ? FACET_PARAMS_TYPE.PARTIAL_RANGE : FACET_PARAMS_TYPE.RANGE;
12719
12722
  const currentFilter = rangeFilterToString(
12720
12723
  currentFilters == null ? void 0 : currentFilters[facetAction.key],
12721
12724
  FACET_RANGE_SEPARATOR
@@ -12726,14 +12729,14 @@ const toggleRangeFilter = (appendParams, removeParameters, facetAction, getQuery
12726
12729
  if (!facetValue) {
12727
12730
  removeParameters({
12728
12731
  paramsToRemove: [
12729
- getFacetParam(facetAction.key, "", FACET_PARAMS_TYPE.RANGE).name,
12732
+ getFacetParam(facetAction.key, "", baseFacetQueryParamName).name,
12730
12733
  ...paramsToRemove
12731
12734
  ]
12732
12735
  });
12733
12736
  return;
12734
12737
  }
12735
12738
  appendParams({
12736
- params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
12739
+ params: [getFacetParam(facetAction.key, facetValue, baseFacetQueryParamName)],
12737
12740
  paramsToRemove,
12738
12741
  encode: false
12739
12742
  });
@@ -26500,12 +26503,10 @@ const _sfc_main$14 = /* @__PURE__ */ vue.defineComponent({
26500
26503
  setup(__props) {
26501
26504
  const optionsStore = useOptionsStore();
26502
26505
  const { searchResultOptions } = storeToRefs(optionsStore);
26503
- const units = vue.computed(
26504
- () => {
26505
- var _a25, _b25, _c, _d, _e;
26506
- return (_e = (_d = (_c = (_b25 = (_a25 = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _a25.filters) == null ? void 0 : _b25.facets) == null ? void 0 : _c.stats) == null ? void 0 : _d.units) != null ? _e : {};
26507
- }
26508
- );
26506
+ const units = vue.computed(() => {
26507
+ var _a25, _b25, _c, _d, _e;
26508
+ return (_e = (_d = (_c = (_b25 = (_a25 = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _a25.filters) == null ? void 0 : _b25.facets) == null ? void 0 : _c.stats) == null ? void 0 : _d.units) != null ? _e : {};
26509
+ });
26509
26510
  const isOpen = vue.ref(false);
26510
26511
  const paramsStore = useParamsStore();
26511
26512
  const optionStore = useOptionsStore();
@@ -26555,7 +26556,8 @@ const _sfc_main$14 = /* @__PURE__ */ vue.defineComponent({
26555
26556
  paramsStore.removeParameters({
26556
26557
  paramsToRemove: [
26557
26558
  optionStore.getQueryParamName(QUERY_PARAMS.PAGE),
26558
- `${FACET_PARAMS_TYPE.RANGE}${filter.key}`
26559
+ `${FACET_PARAMS_TYPE.RANGE}${filter.key}`,
26560
+ `${FACET_PARAMS_TYPE.PARTIAL_RANGE}${filter.key}`
26559
26561
  ]
26560
26562
  });
26561
26563
  break;
@@ -26854,7 +26856,7 @@ const _sfc_main$11 = /* @__PURE__ */ vue.defineComponent({
26854
26856
  emit("select", {
26855
26857
  key: facet.value.key,
26856
26858
  value,
26857
- type: facet.value.type
26859
+ type: facet.value.type === "range" ? "partialRange" : facet.value.type
26858
26860
  });
26859
26861
  };
26860
26862
  const toggleShowAll = () => {
@@ -28842,6 +28844,15 @@ const _sfc_main$T = /* @__PURE__ */ vue.defineComponent({
28842
28844
  filters.value
28843
28845
  );
28844
28846
  break;
28847
+ case "partialRange":
28848
+ toggleRangeFilter(
28849
+ paramStore.appendParams,
28850
+ paramStore.removeParameters,
28851
+ facetAction,
28852
+ optionsStore.getQueryParamName,
28853
+ filters.value
28854
+ );
28855
+ break;
28845
28856
  case "hierarchy":
28846
28857
  toggleHierarchyFilter(
28847
28858
  paramStore.appendParams,
@@ -28859,8 +28870,14 @@ const _sfc_main$T = /* @__PURE__ */ vue.defineComponent({
28859
28870
  }
28860
28871
  };
28861
28872
  const clear = (facet) => {
28862
- const param = getFacetKey(facet.key, facet.type);
28863
- paramStore.removeParameters({ paramsToRemove: [param] });
28873
+ if (facet.type === "range") {
28874
+ paramStore.removeParameters({
28875
+ paramsToRemove: [getFacetKey(facet.key, "range"), getFacetKey(facet.key, "partialRange")]
28876
+ });
28877
+ } else {
28878
+ const param = getFacetKey(facet.key, facet.type);
28879
+ paramStore.removeParameters({ paramsToRemove: [param] });
28880
+ }
28864
28881
  };
28865
28882
  const clearAll = () => {
28866
28883
  paramStore.removeAllFilters();
@@ -30517,6 +30534,7 @@ const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
30517
30534
  itemId: id.value,
30518
30535
  searchQuery: query.value,
30519
30536
  type: item.type,
30537
+ options: props.lupaClickTrackingType === "recommendedItemClick" ? { allowEmptySearchQuery: true } : void 0,
30520
30538
  analytics: item.type === "addToCart" ? {
30521
30539
  type: "search_add_to_cart",
30522
30540
  label: title.value || id.value || link.value
@@ -12256,12 +12256,15 @@ const QUERY_PARAMS_PARSED = {
12256
12256
  const FACET_PARAMS_TYPE = {
12257
12257
  TERMS: "f.",
12258
12258
  RANGE: "fr.",
12259
+ PARTIAL_RANGE: "fpr.",
12259
12260
  HIERARCHY: "fh."
12260
12261
  };
12261
12262
  const FACET_FILTER_MAP = {
12262
12263
  terms: FACET_PARAMS_TYPE.TERMS,
12263
12264
  range: FACET_PARAMS_TYPE.RANGE,
12264
- hierarchy: FACET_PARAMS_TYPE.HIERARCHY
12265
+ stats: FACET_PARAMS_TYPE.RANGE,
12266
+ hierarchy: FACET_PARAMS_TYPE.HIERARCHY,
12267
+ partialRange: FACET_PARAMS_TYPE.PARTIAL_RANGE
12265
12268
  };
12266
12269
  const FACET_KEY_SEPARATOR = ".";
12267
12270
  const FACET_RANGE_SEPARATOR = ":";
@@ -12415,7 +12418,7 @@ const getLabeledFilters = (filters, facets2, translations) => {
12415
12418
  });
12416
12419
  });
12417
12420
  };
12418
- const isFacetKey = (key) => key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.TERMS) || key.startsWith(FACET_PARAMS_TYPE.HIERARCHY);
12421
+ const isFacetKey = (key) => key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.TERMS) || key.startsWith(FACET_PARAMS_TYPE.HIERARCHY) || key.startsWith(FACET_PARAMS_TYPE.PARTIAL_RANGE);
12419
12422
  const getMostSpecificHierarchyTerms = (terms) => {
12420
12423
  const specificTerms = [];
12421
12424
  for (const term of terms) {
@@ -12503,8 +12506,7 @@ const parseFacetKey = (key, searchParams) => {
12503
12506
  if (key.startsWith(FACET_PARAMS_TYPE.TERMS)) {
12504
12507
  return (_b25 = (_a25 = searchParams.getAll(key)) == null ? void 0 : _a25.map((v) => decodeURIComponent(v))) != null ? _b25 : [];
12505
12508
  }
12506
- if (key.startsWith(FACET_PARAMS_TYPE.RANGE)) {
12507
- const isPrice = key == null ? void 0 : key.includes(CURRENCY_KEY_INDICATOR);
12509
+ if (key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.PARTIAL_RANGE)) {
12508
12510
  const range2 = searchParams.get(key);
12509
12511
  if (!range2) {
12510
12512
  return {};
@@ -12512,7 +12514,7 @@ const parseFacetKey = (key, searchParams) => {
12512
12514
  const [min, max] = range2.split(FACET_RANGE_SEPARATOR);
12513
12515
  return {
12514
12516
  gte: min || void 0,
12515
- [isPrice ? "lte" : "lt"]: max || void 0
12517
+ [key.startsWith(FACET_PARAMS_TYPE.PARTIAL_RANGE) ? "lt" : "lte"]: max || void 0
12516
12518
  };
12517
12519
  }
12518
12520
  if (key.startsWith(FACET_PARAMS_TYPE.HIERARCHY)) {
@@ -12714,6 +12716,7 @@ const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, cur
12714
12716
  };
12715
12717
  const toggleRangeFilter = (appendParams, removeParameters, facetAction, getQueryParamName, currentFilters) => {
12716
12718
  var _a25, _b25;
12719
+ const baseFacetQueryParamName = facetAction.type === "partialRange" ? FACET_PARAMS_TYPE.PARTIAL_RANGE : FACET_PARAMS_TYPE.RANGE;
12717
12720
  const currentFilter = rangeFilterToString(
12718
12721
  currentFilters == null ? void 0 : currentFilters[facetAction.key],
12719
12722
  FACET_RANGE_SEPARATOR
@@ -12724,14 +12727,14 @@ const toggleRangeFilter = (appendParams, removeParameters, facetAction, getQuery
12724
12727
  if (!facetValue) {
12725
12728
  removeParameters({
12726
12729
  paramsToRemove: [
12727
- getFacetParam(facetAction.key, "", FACET_PARAMS_TYPE.RANGE).name,
12730
+ getFacetParam(facetAction.key, "", baseFacetQueryParamName).name,
12728
12731
  ...paramsToRemove
12729
12732
  ]
12730
12733
  });
12731
12734
  return;
12732
12735
  }
12733
12736
  appendParams({
12734
- params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
12737
+ params: [getFacetParam(facetAction.key, facetValue, baseFacetQueryParamName)],
12735
12738
  paramsToRemove,
12736
12739
  encode: false
12737
12740
  });
@@ -26498,12 +26501,10 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent({
26498
26501
  setup(__props) {
26499
26502
  const optionsStore = useOptionsStore();
26500
26503
  const { searchResultOptions } = storeToRefs(optionsStore);
26501
- const units = computed(
26502
- () => {
26503
- var _a25, _b25, _c, _d, _e;
26504
- return (_e = (_d = (_c = (_b25 = (_a25 = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _a25.filters) == null ? void 0 : _b25.facets) == null ? void 0 : _c.stats) == null ? void 0 : _d.units) != null ? _e : {};
26505
- }
26506
- );
26504
+ const units = computed(() => {
26505
+ var _a25, _b25, _c, _d, _e;
26506
+ return (_e = (_d = (_c = (_b25 = (_a25 = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _a25.filters) == null ? void 0 : _b25.facets) == null ? void 0 : _c.stats) == null ? void 0 : _d.units) != null ? _e : {};
26507
+ });
26507
26508
  const isOpen = ref(false);
26508
26509
  const paramsStore = useParamsStore();
26509
26510
  const optionStore = useOptionsStore();
@@ -26553,7 +26554,8 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent({
26553
26554
  paramsStore.removeParameters({
26554
26555
  paramsToRemove: [
26555
26556
  optionStore.getQueryParamName(QUERY_PARAMS.PAGE),
26556
- `${FACET_PARAMS_TYPE.RANGE}${filter.key}`
26557
+ `${FACET_PARAMS_TYPE.RANGE}${filter.key}`,
26558
+ `${FACET_PARAMS_TYPE.PARTIAL_RANGE}${filter.key}`
26557
26559
  ]
26558
26560
  });
26559
26561
  break;
@@ -26852,7 +26854,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
26852
26854
  emit("select", {
26853
26855
  key: facet.value.key,
26854
26856
  value,
26855
- type: facet.value.type
26857
+ type: facet.value.type === "range" ? "partialRange" : facet.value.type
26856
26858
  });
26857
26859
  };
26858
26860
  const toggleShowAll = () => {
@@ -28840,6 +28842,15 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
28840
28842
  filters.value
28841
28843
  );
28842
28844
  break;
28845
+ case "partialRange":
28846
+ toggleRangeFilter(
28847
+ paramStore.appendParams,
28848
+ paramStore.removeParameters,
28849
+ facetAction,
28850
+ optionsStore.getQueryParamName,
28851
+ filters.value
28852
+ );
28853
+ break;
28843
28854
  case "hierarchy":
28844
28855
  toggleHierarchyFilter(
28845
28856
  paramStore.appendParams,
@@ -28857,8 +28868,14 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
28857
28868
  }
28858
28869
  };
28859
28870
  const clear = (facet) => {
28860
- const param = getFacetKey(facet.key, facet.type);
28861
- paramStore.removeParameters({ paramsToRemove: [param] });
28871
+ if (facet.type === "range") {
28872
+ paramStore.removeParameters({
28873
+ paramsToRemove: [getFacetKey(facet.key, "range"), getFacetKey(facet.key, "partialRange")]
28874
+ });
28875
+ } else {
28876
+ const param = getFacetKey(facet.key, facet.type);
28877
+ paramStore.removeParameters({ paramsToRemove: [param] });
28878
+ }
28862
28879
  };
28863
28880
  const clearAll = () => {
28864
28881
  paramStore.removeAllFilters();
@@ -30515,6 +30532,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
30515
30532
  itemId: id.value,
30516
30533
  searchQuery: query.value,
30517
30534
  type: item.type,
30535
+ options: props.lupaClickTrackingType === "recommendedItemClick" ? { allowEmptySearchQuery: true } : void 0,
30518
30536
  analytics: item.type === "addToCart" ? {
30519
30537
  type: "search_add_to_cart",
30520
30538
  label: title.value || id.value || link.value
@@ -14,4 +14,9 @@ export type RangeFacetAction = {
14
14
  value: string[];
15
15
  key: string;
16
16
  };
17
- export type FacetAction = TermFacetAction | RangeFacetAction | HierarchyFacetAction;
17
+ export type PartialRangeFacetAction = {
18
+ type: 'partialRange';
19
+ value: string[];
20
+ key: string;
21
+ };
22
+ export type FacetAction = TermFacetAction | RangeFacetAction | HierarchyFacetAction | PartialRangeFacetAction;
@@ -1,5 +1,4 @@
1
- import { HierarchyFacetAction, RangeFacetAction, TermFacetAction } from '../types/search-results/FacetAction';
2
- import { FilterType } from '../types/search-results/Filters';
1
+ import { HierarchyFacetAction, RangeFacetAction, PartialRangeFacetAction, TermFacetAction } from '../types/search-results/FacetAction';
3
2
  import { FilterGroup } from '@getlupa/client-sdk/Types';
4
3
  import { LupaQueryParamValue } from '../types/General';
5
4
  type AppendParams = ({ params, paramsToRemove, encode }: {
@@ -10,14 +9,14 @@ type AppendParams = ({ params, paramsToRemove, encode }: {
10
9
  paramsToRemove?: string[];
11
10
  encode?: boolean;
12
11
  }) => unknown;
13
- export declare const getFacetKey: (key: string, type: FilterType) => string;
12
+ export declare const getFacetKey: (key: string, type: string) => string;
14
13
  export declare const getFacetParam: (key: string, value: string[] | string, type?: string) => {
15
14
  name: string;
16
15
  value: string[] | string;
17
16
  };
18
17
  export declare const toggleTermFilter: (appendParams: AppendParams, facetAction: TermFacetAction, getQueryParamName?: (param: LupaQueryParamValue) => string, currentFilters?: FilterGroup, paramsToRemove?: string[]) => void;
19
18
  export declare const toggleHierarchyFilter: (appendParams: AppendParams, facetAction: HierarchyFacetAction, getQueryParamName?: (param: LupaQueryParamValue) => string, currentFilters?: FilterGroup, removeAllLevels?: boolean) => void;
20
- export declare const toggleRangeFilter: (appendParams: AppendParams, removeParameters: AppendParams, facetAction: RangeFacetAction, getQueryParamName?: (param: LupaQueryParamValue) => string, currentFilters?: FilterGroup) => void;
19
+ export declare const toggleRangeFilter: (appendParams: AppendParams, removeParameters: AppendParams, facetAction: RangeFacetAction | PartialRangeFacetAction, getQueryParamName?: (param: LupaQueryParamValue) => string, currentFilters?: FilterGroup) => void;
21
20
  export declare const toggleTermParam: (params?: string[], param?: string) => string[];
22
21
  export declare const toggleLastPram: (params?: string[], param?: string) => string[];
23
22
  export declare const toggleHierarchyParam: (params?: string[], param?: string, removeAllLevels?: boolean) => string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.23.0",
3
+ "version": "0.23.2",
4
4
  "main": "dist/lupaSearch.mjs",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",