@getlupa/vue 0.6.0 → 0.6.1

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.
@@ -2705,6 +2705,14 @@ const useParamsStore = defineStore("params", () => {
2705
2705
  var _a;
2706
2706
  return (_a = params.value.filters) != null ? _a : {};
2707
2707
  });
2708
+ const navigate = (url) => {
2709
+ var _a, _b, _c;
2710
+ window.history.pushState("", "Append params", url.pathname + url.search);
2711
+ const params2 = parseParams(url.searchParams);
2712
+ (_c = (_b = (_a = optionsStore == null ? void 0 : optionsStore.searchBoxOptions) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onSearchResultsNavigate) == null ? void 0 : _c.call(_b, {
2713
+ params: params2
2714
+ });
2715
+ };
2708
2716
  const add = (newParams, ssr) => {
2709
2717
  if (!newParams) {
2710
2718
  return { params: params.value };
@@ -2717,7 +2725,7 @@ const useParamsStore = defineStore("params", () => {
2717
2725
  const url = getPageUrl();
2718
2726
  const paramsToRemove = Array.from(url.searchParams.keys()).filter(isFacetKey);
2719
2727
  removeParams(url, paramsToRemove);
2720
- window.history.pushState("", "Append params", url.pathname + url.search);
2728
+ navigate(url);
2721
2729
  params.value = parseParams(url.searchParams);
2722
2730
  searchString.value = url.search;
2723
2731
  };
@@ -2728,7 +2736,7 @@ const useParamsStore = defineStore("params", () => {
2728
2736
  const url = getPageUrl();
2729
2737
  paramsToRemove = getRemovableParams(url, paramsToRemove);
2730
2738
  removeParams(url, paramsToRemove);
2731
- window.history.pushState("", "Append params", url.pathname + url.search);
2739
+ navigate(url);
2732
2740
  if (!save) {
2733
2741
  return;
2734
2742
  }
@@ -2790,7 +2798,7 @@ const useParamsStore = defineStore("params", () => {
2790
2798
  paramsToRemove = getRemovableParams(url, paramsToRemove);
2791
2799
  removeParams(url, paramsToRemove);
2792
2800
  newParams.forEach((p2) => appendParam(url, p2, encode));
2793
- window.history.pushState("", "Append params", url.pathname + url.search);
2801
+ navigate(url);
2794
2802
  if (!save) {
2795
2803
  return;
2796
2804
  }
@@ -2703,6 +2703,14 @@ const useParamsStore = defineStore("params", () => {
2703
2703
  var _a;
2704
2704
  return (_a = params.value.filters) != null ? _a : {};
2705
2705
  });
2706
+ const navigate = (url) => {
2707
+ var _a, _b, _c;
2708
+ window.history.pushState("", "Append params", url.pathname + url.search);
2709
+ const params2 = parseParams(url.searchParams);
2710
+ (_c = (_b = (_a = optionsStore == null ? void 0 : optionsStore.searchBoxOptions) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onSearchResultsNavigate) == null ? void 0 : _c.call(_b, {
2711
+ params: params2
2712
+ });
2713
+ };
2706
2714
  const add = (newParams, ssr) => {
2707
2715
  if (!newParams) {
2708
2716
  return { params: params.value };
@@ -2715,7 +2723,7 @@ const useParamsStore = defineStore("params", () => {
2715
2723
  const url = getPageUrl();
2716
2724
  const paramsToRemove = Array.from(url.searchParams.keys()).filter(isFacetKey);
2717
2725
  removeParams(url, paramsToRemove);
2718
- window.history.pushState("", "Append params", url.pathname + url.search);
2726
+ navigate(url);
2719
2727
  params.value = parseParams(url.searchParams);
2720
2728
  searchString.value = url.search;
2721
2729
  };
@@ -2726,7 +2734,7 @@ const useParamsStore = defineStore("params", () => {
2726
2734
  const url = getPageUrl();
2727
2735
  paramsToRemove = getRemovableParams(url, paramsToRemove);
2728
2736
  removeParams(url, paramsToRemove);
2729
- window.history.pushState("", "Append params", url.pathname + url.search);
2737
+ navigate(url);
2730
2738
  if (!save) {
2731
2739
  return;
2732
2740
  }
@@ -2788,7 +2796,7 @@ const useParamsStore = defineStore("params", () => {
2788
2796
  paramsToRemove = getRemovableParams(url, paramsToRemove);
2789
2797
  removeParams(url, paramsToRemove);
2790
2798
  newParams.forEach((p2) => appendParam(url, p2, encode));
2791
- window.history.pushState("", "Append params", url.pathname + url.search);
2799
+ navigate(url);
2792
2800
  if (!save) {
2793
2801
  return;
2794
2802
  }
@@ -4,7 +4,7 @@ import { DocumentElementType } from './types/DocumentElement';
4
4
  import type { DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SingleStarRatingElement } from './types/DocumentElement';
5
5
  import type { ProductListOptions, CategoryFilterOptions } from './types/product-list/ProductListOptions';
6
6
  import type { ProductRecommendationOptions, RecommendationABTestingOptions } from './types/recommendations/RecommendationsOptions';
7
- import type { SearchBoxEventCallbacks, SearchBoxOptions, SearchBoxResultCallbackContext } from './types/search-box/SearchBoxOptions';
7
+ import type { SearchBoxEventCallbacks, SearchBoxOptions, SearchBoxResultCallbackContext, SearchBoxResultsNavigateContext } from './types/search-box/SearchBoxOptions';
8
8
  import { SearchBoxPanelType } from './types/search-box/SearchBoxPanel';
9
9
  import type { SearchContainerOptions, SearchContainerConfigOptions } from './types/search-container/SearchContainerOptions';
10
10
  import type { SearchResultBadgeType, SearchResultBadgeElement, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions } from './types/search-results/BadgeOptions';
@@ -21,10 +21,11 @@ import Recommendations from './components/recommendations/Recommendations.vue';
21
21
  import ChatContainer from './components/chat/ChatContainer.vue';
22
22
  import { getInitialSearchResults } from './utils/ssr.utils';
23
23
  import { ChatOptions, ChatSettings } from './types/chat/ChatOptions';
24
+ import { QueryParams } from './types/search-results/QueryParams';
24
25
  declare const initPinia: () => Pinia;
25
26
  declare const setupTracking: (options: TrackingOptions) => void;
26
27
  declare const LupaSearch: {
27
28
  install: (app: any, options: any) => void;
28
29
  };
29
30
  export { SearchBox, SearchResults, ProductList, Recommendations, SearchContainer, ChatContainer, DocumentElementType, SearchBoxPanelType, BadgeType, setupTracking, LupaSearch, initPinia, getInitialSearchResults };
30
- 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, ResultCallbackContext, FacetFilterQuery, CategoryFilterOptions, SearchResultsFilterOptions, SearchResultBadgeType, SearchResultBadgeElement, ResultFacetOptions, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions, SearchContainerOptions, SearchContainerConfigOptions, SingleStarRatingElement, DynamicData, ProductRecommendationOptions, RecommendationABTestingOptions, SsrOptions, ChatOptions, ChatSettings, SearchBoxEventCallbacks, SearchBoxResultCallbackContext };
31
+ 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, ResultCallbackContext, FacetFilterQuery, CategoryFilterOptions, SearchResultsFilterOptions, SearchResultBadgeType, SearchResultBadgeElement, ResultFacetOptions, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions, SearchContainerOptions, SearchContainerConfigOptions, SingleStarRatingElement, DynamicData, ProductRecommendationOptions, RecommendationABTestingOptions, SsrOptions, ChatOptions, ChatSettings, SearchBoxEventCallbacks, SearchBoxResultCallbackContext, QueryParams, SearchBoxResultsNavigateContext };
@@ -5,6 +5,7 @@ import type { DynamicData } from '../search-results/SearchResultsOptions';
5
5
  import type { SearchBoxHistory } from './SearchBoxHistory';
6
6
  import type { SearchBoxPanel } from './SearchBoxPanel';
7
7
  import { DisplaySuggestion } from './Common';
8
+ import { QueryParams } from '../search-results/QueryParams';
8
9
  export type SearchBoxOptions = SearchBoxPanelOptions & {
9
10
  inputSelector: string;
10
11
  searchTriggers?: string[];
@@ -41,8 +42,14 @@ export type SearchBoxResultCallbackContext = {
41
42
  }[];
42
43
  inputValue?: string;
43
44
  };
45
+ export type SearchBoxResultsNavigateContext = {
46
+ params: QueryParams & {
47
+ query: string;
48
+ };
49
+ };
44
50
  export type SearchBoxEventCallbacks = {
45
51
  onSearchBoxResults?: (context: SearchBoxResultCallbackContext) => unknown;
52
+ onSearchResultsNavigate?: (context: SearchBoxResultsNavigateContext) => unknown;
46
53
  };
47
54
  export type SearchBoxPanelOptions = SearchBoxInputOptions & {
48
55
  history: SearchBoxHistory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "main": "dist/lupaSearch.js",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",