@getlupa/vue 0.3.5 → 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
  }
@@ -16087,7 +16090,7 @@ const getApiUrl = (environment, customBaseUrl) => {
16087
16090
  return Env[environment] || Env["production"];
16088
16091
  };
16089
16092
  const suggestSearchChatPhrases = (options, request) => __async(exports, null, function* () {
16090
- var _a, _b;
16093
+ var _a, _b, _c;
16091
16094
  const { environment, customBaseUrl } = options;
16092
16095
  try {
16093
16096
  const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps(__spreadValues({}, defaultConfig), {
@@ -16099,14 +16102,15 @@ const suggestSearchChatPhrases = (options, request) => __async(exports, null, fu
16099
16102
  return __spreadProps(__spreadValues({}, data), { success: true });
16100
16103
  }
16101
16104
  const errors = yield res.json();
16105
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16102
16106
  return { success: false, errors };
16103
16107
  } catch (e) {
16104
- (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
16108
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16105
16109
  return { success: false, errors: [e] };
16106
16110
  }
16107
16111
  });
16108
16112
  const suggestPhraseAlternatives = (_0, _1) => __async(exports, [_0, _1], function* (options, { phrases }) {
16109
- var _a, _b;
16113
+ var _a, _b, _c;
16110
16114
  const { environment, customBaseUrl } = options;
16111
16115
  try {
16112
16116
  const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps(__spreadValues({}, defaultConfig), {
@@ -16118,14 +16122,15 @@ const suggestPhraseAlternatives = (_0, _1) => __async(exports, [_0, _1], functio
16118
16122
  return __spreadProps(__spreadValues({}, data), { success: true });
16119
16123
  }
16120
16124
  const errors = yield res.json();
16125
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16121
16126
  return { success: false, errors };
16122
16127
  } catch (e) {
16123
- (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
16128
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16124
16129
  return { success: false, errors: [e] };
16125
16130
  }
16126
16131
  });
16127
16132
  const suggestSimplifiedPhrases = (_0, _1) => __async(exports, [_0, _1], function* (options, { phrases }) {
16128
- var _a, _b;
16133
+ var _a, _b, _c;
16129
16134
  const { environment, customBaseUrl } = options;
16130
16135
  try {
16131
16136
  const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps(__spreadValues({}, defaultConfig), {
@@ -16137,9 +16142,10 @@ const suggestSimplifiedPhrases = (_0, _1) => __async(exports, [_0, _1], function
16137
16142
  return __spreadProps(__spreadValues({}, data), { success: true });
16138
16143
  }
16139
16144
  const errors = yield res.json();
16145
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16140
16146
  return { success: false, errors };
16141
16147
  } catch (e) {
16142
- (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
16148
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16143
16149
  return { success: false, errors: [e] };
16144
16150
  }
16145
16151
  });
@@ -16148,7 +16154,7 @@ const suggestBestProductMatches = (_0, _1) => __async(exports, [_0, _1], functio
16148
16154
  productStrings,
16149
16155
  messageHistory
16150
16156
  }) {
16151
- var _a, _b;
16157
+ var _a, _b, _c;
16152
16158
  const { environment, customBaseUrl } = options;
16153
16159
  try {
16154
16160
  const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps(__spreadValues({}, defaultConfig), {
@@ -16160,9 +16166,10 @@ const suggestBestProductMatches = (_0, _1) => __async(exports, [_0, _1], functio
16160
16166
  return __spreadProps(__spreadValues({}, data), { success: true });
16161
16167
  }
16162
16168
  const errors = yield res.json();
16169
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16163
16170
  return { success: false, errors };
16164
16171
  } catch (e) {
16165
- (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
16172
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16166
16173
  return { success: false, errors: [e] };
16167
16174
  }
16168
16175
  });
@@ -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
  }
@@ -16085,7 +16088,7 @@ const getApiUrl = (environment, customBaseUrl) => {
16085
16088
  return Env[environment] || Env["production"];
16086
16089
  };
16087
16090
  const suggestSearchChatPhrases = (options, request) => __async(void 0, null, function* () {
16088
- var _a, _b;
16091
+ var _a, _b, _c;
16089
16092
  const { environment, customBaseUrl } = options;
16090
16093
  try {
16091
16094
  const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps(__spreadValues({}, defaultConfig), {
@@ -16097,14 +16100,15 @@ const suggestSearchChatPhrases = (options, request) => __async(void 0, null, fun
16097
16100
  return __spreadProps(__spreadValues({}, data), { success: true });
16098
16101
  }
16099
16102
  const errors = yield res.json();
16103
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16100
16104
  return { success: false, errors };
16101
16105
  } catch (e) {
16102
- (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
16106
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16103
16107
  return { success: false, errors: [e] };
16104
16108
  }
16105
16109
  });
16106
16110
  const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
16107
- var _a, _b;
16111
+ var _a, _b, _c;
16108
16112
  const { environment, customBaseUrl } = options;
16109
16113
  try {
16110
16114
  const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps(__spreadValues({}, defaultConfig), {
@@ -16116,14 +16120,15 @@ const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function
16116
16120
  return __spreadProps(__spreadValues({}, data), { success: true });
16117
16121
  }
16118
16122
  const errors = yield res.json();
16123
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16119
16124
  return { success: false, errors };
16120
16125
  } catch (e) {
16121
- (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
16126
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16122
16127
  return { success: false, errors: [e] };
16123
16128
  }
16124
16129
  });
16125
16130
  const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
16126
- var _a, _b;
16131
+ var _a, _b, _c;
16127
16132
  const { environment, customBaseUrl } = options;
16128
16133
  try {
16129
16134
  const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps(__spreadValues({}, defaultConfig), {
@@ -16135,9 +16140,10 @@ const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function*
16135
16140
  return __spreadProps(__spreadValues({}, data), { success: true });
16136
16141
  }
16137
16142
  const errors = yield res.json();
16143
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16138
16144
  return { success: false, errors };
16139
16145
  } catch (e) {
16140
- (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
16146
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16141
16147
  return { success: false, errors: [e] };
16142
16148
  }
16143
16149
  });
@@ -16146,7 +16152,7 @@ const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function
16146
16152
  productStrings,
16147
16153
  messageHistory
16148
16154
  }) {
16149
- var _a, _b;
16155
+ var _a, _b, _c;
16150
16156
  const { environment, customBaseUrl } = options;
16151
16157
  try {
16152
16158
  const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps(__spreadValues({}, defaultConfig), {
@@ -16158,9 +16164,10 @@ const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function
16158
16164
  return __spreadProps(__spreadValues({}, data), { success: true });
16159
16165
  }
16160
16166
  const errors = yield res.json();
16167
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16161
16168
  return { success: false, errors };
16162
16169
  } catch (e) {
16163
- (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
16170
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16164
16171
  return { success: false, errors: [e] };
16165
16172
  }
16166
16173
  });
@@ -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.5",
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",