@getlupa/vue 0.12.7 → 0.12.8

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.
@@ -2688,6 +2688,14 @@ const encodeParam = (param) => {
2688
2688
  const encoded = encodeURIComponent(param);
2689
2689
  return encoded.replace(/%C4%85/g, "ą").replace(/%C4%8D/g, "č").replace(/%C4%99/g, "ę").replace(/%C4%97/g, "ė").replace(/%C4%AF/g, "į").replace(/%C5%A1/g, "š").replace(/%C5%B3/g, "ų").replace(/%C5%AB/g, "ū").replace(/%C5%BE/g, "ž").replace(/%20/g, " ");
2690
2690
  };
2691
+ const getQueryParam = (name) => {
2692
+ try {
2693
+ const urlParams = new URLSearchParams(window.location.search);
2694
+ return urlParams.get(name);
2695
+ } catch (e2) {
2696
+ return null;
2697
+ }
2698
+ };
2691
2699
  const PATH_REPLACE_REGEXP = /{(.*?)}/gm;
2692
2700
  const generateLink = (linkPattern, document2) => {
2693
2701
  const matches = linkPattern.match(PATH_REPLACE_REGEXP);
@@ -2979,7 +2987,7 @@ const useParamsStore = defineStore("params", () => {
2979
2987
  searchText,
2980
2988
  facet
2981
2989
  }) => {
2982
- var _a;
2990
+ var _a, _b;
2983
2991
  const redirectionApplied = redirectionStore.redirectOnKeywordIfConfigured(
2984
2992
  searchText,
2985
2993
  optionsStore.boxRoutingBehavior
@@ -2987,7 +2995,10 @@ const useParamsStore = defineStore("params", () => {
2987
2995
  if (redirectionApplied) {
2988
2996
  return;
2989
2997
  }
2990
- if (!searchResultsLink.value || linksMatch(searchResultsLink.value, window.location.pathname)) {
2998
+ const forceFullReload = (_a = optionsStore.searchBoxOptions.forceFullReloadOnParams) == null ? void 0 : _a.some(
2999
+ (p2) => getQueryParam(p2)
3000
+ );
3001
+ if ((!searchResultsLink.value || linksMatch(searchResultsLink.value, window.location.pathname)) && !forceFullReload) {
2991
3002
  const singleFacetParam = facet ? getFacetParam(facet.key, [facet.title]) : void 0;
2992
3003
  const facetParam = singleFacetParam ? [
2993
3004
  __spreadProps(__spreadValues({}, singleFacetParam), {
@@ -3003,7 +3014,7 @@ const useParamsStore = defineStore("params", () => {
3003
3014
  searchResultsLink: searchResultsLink.value
3004
3015
  });
3005
3016
  } else {
3006
- const routing = (_a = optionsStore.boxRoutingBehavior) != null ? _a : "direct-link";
3017
+ const routing = (_b = optionsStore.boxRoutingBehavior) != null ? _b : "direct-link";
3007
3018
  redirectToResultsPage(
3008
3019
  searchResultsLink.value,
3009
3020
  searchText,
@@ -2686,6 +2686,14 @@ const encodeParam = (param) => {
2686
2686
  const encoded = encodeURIComponent(param);
2687
2687
  return encoded.replace(/%C4%85/g, "ą").replace(/%C4%8D/g, "č").replace(/%C4%99/g, "ę").replace(/%C4%97/g, "ė").replace(/%C4%AF/g, "į").replace(/%C5%A1/g, "š").replace(/%C5%B3/g, "ų").replace(/%C5%AB/g, "ū").replace(/%C5%BE/g, "ž").replace(/%20/g, " ");
2688
2688
  };
2689
+ const getQueryParam = (name) => {
2690
+ try {
2691
+ const urlParams = new URLSearchParams(window.location.search);
2692
+ return urlParams.get(name);
2693
+ } catch (e2) {
2694
+ return null;
2695
+ }
2696
+ };
2689
2697
  const PATH_REPLACE_REGEXP = /{(.*?)}/gm;
2690
2698
  const generateLink = (linkPattern, document2) => {
2691
2699
  const matches = linkPattern.match(PATH_REPLACE_REGEXP);
@@ -2977,7 +2985,7 @@ const useParamsStore = defineStore("params", () => {
2977
2985
  searchText,
2978
2986
  facet
2979
2987
  }) => {
2980
- var _a;
2988
+ var _a, _b;
2981
2989
  const redirectionApplied = redirectionStore.redirectOnKeywordIfConfigured(
2982
2990
  searchText,
2983
2991
  optionsStore.boxRoutingBehavior
@@ -2985,7 +2993,10 @@ const useParamsStore = defineStore("params", () => {
2985
2993
  if (redirectionApplied) {
2986
2994
  return;
2987
2995
  }
2988
- if (!searchResultsLink.value || linksMatch(searchResultsLink.value, window.location.pathname)) {
2996
+ const forceFullReload = (_a = optionsStore.searchBoxOptions.forceFullReloadOnParams) == null ? void 0 : _a.some(
2997
+ (p2) => getQueryParam(p2)
2998
+ );
2999
+ if ((!searchResultsLink.value || linksMatch(searchResultsLink.value, window.location.pathname)) && !forceFullReload) {
2989
3000
  const singleFacetParam = facet ? getFacetParam(facet.key, [facet.title]) : void 0;
2990
3001
  const facetParam = singleFacetParam ? [
2991
3002
  __spreadProps(__spreadValues({}, singleFacetParam), {
@@ -3001,7 +3012,7 @@ const useParamsStore = defineStore("params", () => {
3001
3012
  searchResultsLink: searchResultsLink.value
3002
3013
  });
3003
3014
  } else {
3004
- const routing = (_a = optionsStore.boxRoutingBehavior) != null ? _a : "direct-link";
3015
+ const routing = (_b = optionsStore.boxRoutingBehavior) != null ? _b : "direct-link";
3005
3016
  redirectToResultsPage(
3006
3017
  searchResultsLink.value,
3007
3018
  searchText,
@@ -15,7 +15,7 @@ export type ProductRecommendationOptions = SearchResultsProductOptions & {
15
15
  itemId: string[] | string;
16
16
  abTesting?: RecommendationABTestingOptions;
17
17
  carousel?: RecommenderCarouselOptions;
18
- filters?: FilterGroup;
18
+ recommendationFilters?: FilterGroup;
19
19
  layoutType?: 'carousel' | 'grid';
20
20
  recommendationLabels?: {
21
21
  title?: string;
@@ -66,4 +66,5 @@ export type SearchBoxPanelOptions = SearchBoxInputOptions & {
66
66
  showNoResultsPanel?: boolean;
67
67
  hideMoreResultsButtonOnNoResults?: boolean;
68
68
  expandOnSinglePanel?: boolean;
69
+ forceFullReloadOnParams?: string[];
69
70
  };
@@ -8,3 +8,4 @@ export declare const appendParam: (url: URL, { name, value }: {
8
8
  export declare const getRemovableParams: (url: URL, getQueryParamName?: (param: LupaQueryParamValue) => string, paramsToRemove?: 'all' | string[]) => string[] | undefined;
9
9
  export declare const removeParams: (url: URL, params?: string[]) => void;
10
10
  export declare const encodeParam: (param: string) => string;
11
+ export declare const getQueryParam: (name: string) => string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.12.7",
3
+ "version": "0.12.8",
4
4
  "main": "dist/lupaSearch.mjs",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",