@searchspring/snap-controller 0.65.0 → 0.65.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.
@@ -915,7 +915,7 @@ function getAutocompleteRedirectSchemaData(_a) {
915
915
  };
916
916
  }
917
917
  function getAutocompleteSchemaData(_a) {
918
- var _b, _c, _d, _e, _f, _g, _h, _j;
918
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
919
919
  var params = _a.params, store = _a.store, results = _a.results;
920
920
  var filters = (_b = params.filters) === null || _b === void 0 ? void 0 : _b.reduce(function (acc, filter) {
921
921
  var _a;
@@ -939,10 +939,10 @@ function getAutocompleteSchemaData(_a) {
939
939
  }
940
940
  return acc;
941
941
  }, {});
942
- return __assign(__assign({ q: ((_d = (_c = params.search) === null || _c === void 0 ? void 0 : _c.query) === null || _d === void 0 ? void 0 : _d.string) || '', correctedQuery: ((_e = params.search) === null || _e === void 0 ? void 0 : _e.originalQuery) || '' }, filters), { sort: [
942
+ return __assign(__assign({ q: ((_d = (_c = store.search) === null || _c === void 0 ? void 0 : _c.originalQuery) === null || _d === void 0 ? void 0 : _d.string) || ((_f = (_e = store.search) === null || _e === void 0 ? void 0 : _e.query) === null || _f === void 0 ? void 0 : _f.string) || '', correctedQuery: ((_h = (_g = store.search) === null || _g === void 0 ? void 0 : _g.originalQuery) === null || _h === void 0 ? void 0 : _h.string) ? (_k = (_j = store.search) === null || _j === void 0 ? void 0 : _j.query) === null || _k === void 0 ? void 0 : _k.string : undefined }, filters), { sort: [
943
943
  {
944
- field: (_f = store.sorting.current) === null || _f === void 0 ? void 0 : _f.field,
945
- dir: (_g = store.sorting.current) === null || _g === void 0 ? void 0 : _g.direction,
944
+ field: (_l = store.sorting.current) === null || _l === void 0 ? void 0 : _l.field,
945
+ dir: (_m = store.sorting.current) === null || _m === void 0 ? void 0 : _m.direction,
946
946
  },
947
947
  ], pagination: {
948
948
  totalResults: store.pagination.totalResults,
@@ -951,8 +951,8 @@ function getAutocompleteSchemaData(_a) {
951
951
  }, merchandising: {
952
952
  personalized: store.merchandising.personalized,
953
953
  redirect: store.merchandising.redirect,
954
- triggeredCampaigns: (((_h = store.merchandising.campaigns) === null || _h === void 0 ? void 0 : _h.length) &&
955
- ((_j = store.merchandising.campaigns) === null || _j === void 0 ? void 0 : _j.map(function (campaign) {
954
+ triggeredCampaigns: (((_o = store.merchandising.campaigns) === null || _o === void 0 ? void 0 : _o.length) &&
955
+ ((_p = store.merchandising.campaigns) === null || _p === void 0 ? void 0 : _p.map(function (campaign) {
956
956
  var experiement = store.merchandising.experiments.find(function (experiment) { return experiment.campaignId === campaign.id; });
957
957
  return {
958
958
  id: campaign.id,
@@ -217,8 +217,6 @@ var SearchController = /** @class */ (function (_super) {
217
217
  _o.label = 2;
218
218
  case 2:
219
219
  params_1 = this.params;
220
- // reset events for new search
221
- this.events = { product: {} };
222
220
  if (((_d = (_c = params_1.search) === null || _c === void 0 ? void 0 : _c.query) === null || _d === void 0 ? void 0 : _d.string) && ((_f = (_e = params_1.search) === null || _e === void 0 ? void 0 : _e.query) === null || _f === void 0 ? void 0 : _f.string.length)) {
223
221
  // save it to the history store
224
222
  this.store.history.save(params_1.search.query.string);
@@ -307,7 +305,9 @@ var SearchController = /** @class */ (function (_super) {
307
305
  _o.label = 10;
308
306
  case 10: return [3 /*break*/, 13];
309
307
  case 11:
310
- // normal request for next page
308
+ // normal request
309
+ // reset events for new search
310
+ this.events = { product: {} };
311
311
  // clear previousResults to prevent infinite scroll from using them
312
312
  this.previousResults = [];
313
313
  return [4 /*yield*/, this.client.search(params_1)];
@@ -756,7 +756,7 @@ function getSearchRedirectSchemaData(_a) {
756
756
  };
757
757
  }
758
758
  function getSearchSchemaData(_a) {
759
- var _b, _c, _d, _e, _f, _g, _h, _j;
759
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
760
760
  var params = _a.params, store = _a.store, results = _a.results;
761
761
  var filters = (_b = params.filters) === null || _b === void 0 ? void 0 : _b.reduce(function (acc, filter) {
762
762
  var _a;
@@ -780,10 +780,10 @@ function getSearchSchemaData(_a) {
780
780
  }
781
781
  return acc;
782
782
  }, {});
783
- return __assign(__assign({ q: ((_d = (_c = params.search) === null || _c === void 0 ? void 0 : _c.query) === null || _d === void 0 ? void 0 : _d.string) || '', correctedQuery: (_e = params.search) === null || _e === void 0 ? void 0 : _e.originalQuery }, filters), { sort: [
783
+ return __assign(__assign({ q: ((_d = (_c = params.search) === null || _c === void 0 ? void 0 : _c.query) === null || _d === void 0 ? void 0 : _d.string) || '', correctedQuery: ((_f = (_e = store.search) === null || _e === void 0 ? void 0 : _e.originalQuery) === null || _f === void 0 ? void 0 : _f.string) ? (_h = (_g = store.search) === null || _g === void 0 ? void 0 : _g.query) === null || _h === void 0 ? void 0 : _h.string : undefined }, filters), { sort: [
784
784
  {
785
- field: (_f = store.sorting.current) === null || _f === void 0 ? void 0 : _f.field,
786
- dir: (_g = store.sorting.current) === null || _g === void 0 ? void 0 : _g.direction,
785
+ field: (_j = store.sorting.current) === null || _j === void 0 ? void 0 : _j.field,
786
+ dir: (_k = store.sorting.current) === null || _k === void 0 ? void 0 : _k.direction,
787
787
  },
788
788
  ], pagination: {
789
789
  totalResults: store.pagination.totalResults,
@@ -792,8 +792,8 @@ function getSearchSchemaData(_a) {
792
792
  }, merchandising: {
793
793
  personalized: store.merchandising.personalized,
794
794
  redirect: store.merchandising.redirect,
795
- triggeredCampaigns: (((_h = store.merchandising.campaigns) === null || _h === void 0 ? void 0 : _h.length) &&
796
- ((_j = store.merchandising.campaigns) === null || _j === void 0 ? void 0 : _j.map(function (campaign) {
795
+ triggeredCampaigns: (((_l = store.merchandising.campaigns) === null || _l === void 0 ? void 0 : _l.length) &&
796
+ ((_m = store.merchandising.campaigns) === null || _m === void 0 ? void 0 : _m.map(function (campaign) {
797
797
  var experiement = store.merchandising.experiments.find(function (experiment) { return experiment.campaignId === campaign.id; });
798
798
  return {
799
799
  id: campaign.id,
@@ -714,8 +714,8 @@ function getAutocompleteSchemaData({ params, store, results, }) {
714
714
  return acc;
715
715
  }, {});
716
716
  return {
717
- q: params.search?.query?.string || '',
718
- correctedQuery: params.search?.originalQuery || '',
717
+ q: store.search?.originalQuery?.string || store.search?.query?.string || '',
718
+ correctedQuery: store.search?.originalQuery?.string ? store.search?.query?.string : undefined,
719
719
  ...filters,
720
720
  sort: [
721
721
  {
@@ -121,8 +121,6 @@ export class SearchController extends AbstractController {
121
121
  await this.init();
122
122
  }
123
123
  const params = this.params;
124
- // reset events for new search
125
- this.events = { product: {} };
126
124
  if (params.search?.query?.string && params.search?.query?.string.length) {
127
125
  // save it to the history store
128
126
  this.store.history.save(params.search.query.string);
@@ -205,7 +203,9 @@ export class SearchController extends AbstractController {
205
203
  }
206
204
  }
207
205
  else {
208
- // normal request for next page
206
+ // normal request
207
+ // reset events for new search
208
+ this.events = { product: {} };
209
209
  // clear previousResults to prevent infinite scroll from using them
210
210
  this.previousResults = [];
211
211
  [meta, response] = await this.client.search(params);
@@ -583,7 +583,7 @@ function getSearchSchemaData({ params, store, results, }) {
583
583
  }, {});
584
584
  return {
585
585
  q: params.search?.query?.string || '',
586
- correctedQuery: params.search?.originalQuery,
586
+ correctedQuery: store.search?.originalQuery?.string ? store.search?.query?.string : undefined,
587
587
  ...filters,
588
588
  sort: [
589
589
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@searchspring/snap-controller",
3
- "version": "0.65.0",
3
+ "version": "0.65.1",
4
4
  "description": "Snap Controllers",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -20,22 +20,22 @@
20
20
  "test:watch": "jest --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@searchspring/snap-toolbox": "^0.65.0",
23
+ "@searchspring/snap-toolbox": "^0.65.1",
24
24
  "css.escape": "1.5.1",
25
25
  "deepmerge": "4.3.1"
26
26
  },
27
27
  "devDependencies": {
28
- "@searchspring/snap-client": "^0.65.0",
29
- "@searchspring/snap-event-manager": "^0.65.0",
30
- "@searchspring/snap-logger": "^0.65.0",
31
- "@searchspring/snap-profiler": "^0.65.0",
32
- "@searchspring/snap-store-mobx": "^0.65.0",
33
- "@searchspring/snap-tracker": "^0.65.0",
34
- "@searchspring/snap-url-manager": "^0.65.0"
28
+ "@searchspring/snap-client": "^0.65.1",
29
+ "@searchspring/snap-event-manager": "^0.65.1",
30
+ "@searchspring/snap-logger": "^0.65.1",
31
+ "@searchspring/snap-profiler": "^0.65.1",
32
+ "@searchspring/snap-store-mobx": "^0.65.1",
33
+ "@searchspring/snap-tracker": "^0.65.1",
34
+ "@searchspring/snap-url-manager": "^0.65.1"
35
35
  },
36
36
  "sideEffects": false,
37
37
  "files": [
38
38
  "dist/**/*"
39
39
  ],
40
- "gitHead": "e96fc4426a64178a94a8ca603ec834bdca020fdb"
40
+ "gitHead": "cd33cd87ad8d51302000b31bce6aa90b4b25ba89"
41
41
  }