@getlupa/vue 0.3.6 → 0.3.7

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.
@@ -7637,6 +7637,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
7637
7637
  const paramStore = useParamsStore();
7638
7638
  const { sort } = storeToRefs(paramStore);
7639
7639
  const selectedKey = vue.ref("");
7640
+ const previousKey = vue.ref("");
7640
7641
  const sortItems = vue.computed(() => {
7641
7642
  if (props.options.options && props.options.options.length) {
7642
7643
  return props.options.options;
@@ -7652,6 +7653,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
7652
7653
  var _a, _b;
7653
7654
  const optionToSelect = (_a = sortItems.value.find((x) => x.key === sort.value)) == null ? void 0 : _a.key;
7654
7655
  selectedKey.value = optionToSelect != null ? optionToSelect : (_b = defaultSortValue.value) == null ? void 0 : _b.key;
7656
+ previousKey.value = selectedKey.value;
7655
7657
  };
7656
7658
  vue.watch(sort, () => setSortValue());
7657
7659
  vue.onMounted(() => {
@@ -7663,11 +7665,12 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
7663
7665
  if (!value) {
7664
7666
  return;
7665
7667
  }
7666
- (_c = (_b = props.callbacks) == null ? void 0 : _b.onSortChange) == null ? void 0 : _c.call(_b, { selectedSortKey: value });
7668
+ (_c = (_b = props.callbacks) == null ? void 0 : _b.onSortChange) == null ? void 0 : _c.call(_b, { selectedSortKey: value, previousSortKey: previousKey.value });
7667
7669
  paramStore.appendParams({
7668
7670
  params: [{ name: QUERY_PARAMS.SORT, value }],
7669
7671
  paramsToRemove: [QUERY_PARAMS.PAGE]
7670
7672
  });
7673
+ previousKey.value = selectedKey.value;
7671
7674
  };
7672
7675
  return (_ctx, _cache) => {
7673
7676
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$y, [
@@ -9362,7 +9365,7 @@ const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
9362
9365
  const hasResults2 = Boolean(
9363
9366
  results.total > 0 || ((_a = results.similarQueries) == null ? void 0 : _a.length) || ((_b = results.didYouMean) == null ? void 0 : _b.options)
9364
9367
  );
9365
- (_d = (_c = props.options.callbacks) == null ? void 0 : _c.onSearchResults) == null ? void 0 : _d.call(_c, { queryKey, hasResults: hasResults2 });
9368
+ (_d = (_c = props.options.callbacks) == null ? void 0 : _c.onSearchResults) == null ? void 0 : _d.call(_c, { queryKey, hasResults: hasResults2, params: paramStore.params });
9366
9369
  if (!hasResults2) {
9367
9370
  return;
9368
9371
  }
@@ -7635,6 +7635,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
7635
7635
  const paramStore = useParamsStore();
7636
7636
  const { sort } = storeToRefs(paramStore);
7637
7637
  const selectedKey = ref("");
7638
+ const previousKey = ref("");
7638
7639
  const sortItems = computed(() => {
7639
7640
  if (props.options.options && props.options.options.length) {
7640
7641
  return props.options.options;
@@ -7650,6 +7651,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
7650
7651
  var _a, _b;
7651
7652
  const optionToSelect = (_a = sortItems.value.find((x) => x.key === sort.value)) == null ? void 0 : _a.key;
7652
7653
  selectedKey.value = optionToSelect != null ? optionToSelect : (_b = defaultSortValue.value) == null ? void 0 : _b.key;
7654
+ previousKey.value = selectedKey.value;
7653
7655
  };
7654
7656
  watch(sort, () => setSortValue());
7655
7657
  onMounted(() => {
@@ -7661,11 +7663,12 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
7661
7663
  if (!value) {
7662
7664
  return;
7663
7665
  }
7664
- (_c = (_b = props.callbacks) == null ? void 0 : _b.onSortChange) == null ? void 0 : _c.call(_b, { selectedSortKey: value });
7666
+ (_c = (_b = props.callbacks) == null ? void 0 : _b.onSortChange) == null ? void 0 : _c.call(_b, { selectedSortKey: value, previousSortKey: previousKey.value });
7665
7667
  paramStore.appendParams({
7666
7668
  params: [{ name: QUERY_PARAMS.SORT, value }],
7667
7669
  paramsToRemove: [QUERY_PARAMS.PAGE]
7668
7670
  });
7671
+ previousKey.value = selectedKey.value;
7669
7672
  };
7670
7673
  return (_ctx, _cache) => {
7671
7674
  return openBlock(), createElementBlock("div", _hoisted_1$y, [
@@ -9360,7 +9363,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
9360
9363
  const hasResults2 = Boolean(
9361
9364
  results.total > 0 || ((_a = results.similarQueries) == null ? void 0 : _a.length) || ((_b = results.didYouMean) == null ? void 0 : _b.options)
9362
9365
  );
9363
- (_d = (_c = props.options.callbacks) == null ? void 0 : _c.onSearchResults) == null ? void 0 : _d.call(_c, { queryKey, hasResults: hasResults2 });
9366
+ (_d = (_c = props.options.callbacks) == null ? void 0 : _c.onSearchResults) == null ? void 0 : _d.call(_c, { queryKey, hasResults: hasResults2, params: paramStore.params });
9364
9367
  if (!hasResults2) {
9365
9368
  return;
9366
9369
  }
@@ -10,7 +10,7 @@ import type { SearchContainerOptions, SearchContainerConfigOptions } from './typ
10
10
  import type { SearchResultBadgeType, SearchResultBadgeElement, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions } from './types/search-results/BadgeOptions';
11
11
  import { BadgeType } from './types/search-results/BadgeOptions';
12
12
  import type { RoutingBehavior } from './types/search-results/RoutingBehavior';
13
- import type { SearchResultsOptions, FacetStyle, SearchResultEventCallbacks, CallbackContext, SortCallbackContext, FacetFilterQuery, SearchResultsFilterOptions, ResultFacetOptions, DynamicData, SsrOptions } from './types/search-results/SearchResultsOptions';
13
+ import type { SearchResultsOptions, FacetStyle, SearchResultEventCallbacks, CallbackContext, SortCallbackContext, ResultCallbackContext, FacetFilterQuery, SearchResultsFilterOptions, ResultFacetOptions, DynamicData, SsrOptions } from './types/search-results/SearchResultsOptions';
14
14
  import type { AnchorPosition } from './types/search-results/SearchResultsProductCardOptions';
15
15
  import type { SortOptions, SearchResultsSortOptions } from './types/search-results/SearchResultsSort';
16
16
  import SearchBox from './components/search-box/SearchBox.vue';
@@ -27,4 +27,4 @@ declare const LupaSearch: {
27
27
  install: (app: any, options: any) => void;
28
28
  };
29
29
  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, FacetFilterQuery, CategoryFilterOptions, SearchResultsFilterOptions, SearchResultBadgeType, SearchResultBadgeElement, ResultFacetOptions, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions, SearchContainerOptions, SearchContainerConfigOptions, SingleStarRatingElement, DynamicData, ProductRecommendationOptions, RecommendationABTestingOptions, SsrOptions, ChatOptions };
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 };
@@ -35,9 +35,13 @@ export type CallbackContext = {
35
35
  };
36
36
  export type SortCallbackContext = {
37
37
  selectedSortKey: string;
38
+ previousSortKey?: string;
39
+ };
40
+ export type ResultCallbackContext = CallbackContext & {
41
+ params: Record<string, any>;
38
42
  };
39
43
  export type SearchResultEventCallbacks = {
40
- onSearchResults?: (context: CallbackContext) => unknown;
44
+ onSearchResults?: (context: ResultCallbackContext) => unknown;
41
45
  onAdditionalPanelResults?: (context: CallbackContext) => unknown;
42
46
  onCategoryFilterResults?: (context: CallbackContext) => unknown;
43
47
  onProductClick?: (context: CallbackContext) => unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "main": "dist/lupaSearch.js",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",