@searchspring/snap-controller 0.43.0 → 0.43.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.
@@ -1 +1 @@
1
- {"version":3,"file":"AutocompleteController.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteController.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAA0B,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,4BAA4B,EAAkD,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEnJ,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAG1E,eAAO,MAAM,WAAW,MAAM,CAAC;AA0B/B,aAAK,wBAAwB,GAAG;IAC/B,OAAO,EAAE;QACR,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;KAC5C,CAAC;CACF,CAAC;AAEF,qBAAa,sBAAuB,SAAQ,kBAAkB;IACtD,IAAI,kBAAgC;IACnC,KAAK,EAAE,iBAAiB,CAAC;IACzB,MAAM,EAAE,4BAA4B,CAAC;IACtC,OAAO,EAAE,YAAY,CAAC;gBAG5B,MAAM,EAAE,4BAA4B,EACpC,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAC1F,OAAO,CAAC,EAAE,gBAAgB;IA6D3B,KAAK,EAAE,wBAAwB,CAO7B;IAEF,IAAI,MAAM,IAAI,wBAAwB,CA0CrC;IAEK,UAAU,CAAC,YAAY,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC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iB,CAAC;IACzB,MAAM,EAAE,4BAA4B,CAAC;IACtC,OAAO,EAAE,YAAY,CAAC;gBAG5B,MAAM,EAAE,4BAA4B,EACpC,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAC1F,OAAO,CAAC,EAAE,gBAAgB;IA6D3B,KAAK,EAAE,wBAAwB,CAO7B;IAEF,IAAI,MAAM,IAAI,wBAAwB,CA0CrC;IAEK,UAAU,CAAC,YAAY,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BhE,KAAK,IAAI,IAAI;IASb,QAAQ;;0BAEc,aAAa,KAAG,QAAQ,OAAO,GAAG,SAAS,CAAC;wBAkDpD,aAAa,KAAG,IAAI;uBAMrB,UAAU,KAAG,IAAI;4BAQN,MAAM,SAAS,CAAC,gBAAgB,CAAC,KAAG,QAAQ,IAAI,CAAC;mCAgDhD,MAAM,WAAW,CAAC,gBAAgB,CAAC,KAAG,IAAI;uBAqBtD,aAAa,KAAG,IAAI;;;;uBA8DpB,UAAU,KAAG,IAAI;;MAS5B;IAEF,MAAM,IAAI,IAAI;IAgBR,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA6E3B,cAAc,QAAa,QAAQ,IAAI,CAAC,CAwBtC;IAEF,MAAM,QAAa,QAAQ,IAAI,CAAC,CAkH9B;CACF"}
@@ -287,8 +287,8 @@ var AutocompleteController = /** @class */ (function (_super) {
287
287
  _this.setFocused(e.target);
288
288
  }
289
289
  var value = e.target.value;
290
- // prevent search when value is unchanged
291
- if (_this.store.state.input == value && _this.store.loaded) {
290
+ // prevent search when value is unchanged or empty
291
+ if (((!_this.store.state.input && !value) || _this.store.state.input == value) && _this.store.loaded) {
292
292
  return;
293
293
  }
294
294
  _this.store.state.input = value;
@@ -298,28 +298,32 @@ var AutocompleteController = /** @class */ (function (_super) {
298
298
  input.value = value;
299
299
  });
300
300
  }
301
+ // TODO cancel any current requests?
301
302
  clearTimeout(_this.handlers.input.timeoutDelay);
302
- // input is empty
303
+ var trendingResultsEnabled = ((_c = _this.store.trending) === null || _c === void 0 ? void 0 : _c.length) && ((_e = (_d = _this.config.settings) === null || _d === void 0 ? void 0 : _d.trending) === null || _e === void 0 ? void 0 : _e.showResults);
304
+ var historyResultsEnabled = ((_f = _this.store.history) === null || _f === void 0 ? void 0 : _f.length) && ((_h = (_g = _this.config.settings) === null || _g === void 0 ? void 0 : _g.history) === null || _h === void 0 ? void 0 : _h.showResults);
303
305
  if (!value) {
304
- // TODO cancel any current requests?
305
- // reset the store (in case input was just cleared)
306
+ // there is no input value - reset state of store and UrlManager
306
307
  _this.store.reset();
307
- if (((_c = _this.store.trending) === null || _c === void 0 ? void 0 : _c.length) && ((_e = (_d = _this.config.settings) === null || _d === void 0 ? void 0 : _d.trending) === null || _e === void 0 ? void 0 : _e.showResults)) {
308
+ _this.urlManager.reset().go();
309
+ // show results for trending or history (if configured) - trending has priority
310
+ if (trendingResultsEnabled) {
308
311
  _this.store.trending[0].preview();
309
312
  }
310
- else if (((_f = _this.store.history) === null || _f === void 0 ? void 0 : _f.length) && ((_h = (_g = _this.config.settings) === null || _g === void 0 ? void 0 : _g.history) === null || _h === void 0 ? void 0 : _h.showResults)) {
313
+ else if (historyResultsEnabled) {
311
314
  _this.store.history[0].preview();
312
315
  }
313
- else {
314
- // reset urlManager when a preview is not available to do so
315
- _this.urlManager.reset().go();
316
- }
317
316
  }
318
317
  else {
318
+ // new query in the input - trigger a new search via UrlManager
319
319
  _this.store.resetTerms();
320
320
  _this.handlers.input.timeoutDelay = setTimeout(function () {
321
321
  _this.store.state.locks.terms.unlock();
322
322
  _this.store.state.locks.facets.unlock();
323
+ // must reset query to ensure funcitonality when trending/history term is equal to the typed term
324
+ if (trendingResultsEnabled || historyResultsEnabled) {
325
+ _this.urlManager.set({ query: '' }).go();
326
+ }
323
327
  _this.urlManager.set({ query: _this.store.state.input }).go();
324
328
  }, exports.INPUT_DELAY);
325
329
  }
@@ -375,7 +379,12 @@ var AutocompleteController = /** @class */ (function (_super) {
375
379
  return __generator(this, function (_d) {
376
380
  switch (_d.label) {
377
381
  case 0:
382
+ // if urlManager has no query, there will be no need to get params and no query
383
+ if (!this.urlManager.state.query) {
384
+ return [2 /*return*/];
385
+ }
378
386
  params = this.params;
387
+ // if params have no query do not search
379
388
  if (!((_c = (_b = params === null || params === void 0 ? void 0 : params.search) === null || _b === void 0 ? void 0 : _b.query) === null || _c === void 0 ? void 0 : _c.string)) {
380
389
  return [2 /*return*/];
381
390
  }
@@ -727,6 +736,7 @@ var AutocompleteController = /** @class */ (function (_super) {
727
736
  else if (form) {
728
737
  form.addEventListener('submit', _this.handlers.input.formSubmit);
729
738
  formActionUrl = form.action || '';
739
+ // serializeForm will include additional form element in our urlManager as globals
730
740
  if ((_c = _this.config.settings) === null || _c === void 0 ? void 0 : _c.serializeForm) {
731
741
  bindFormParameters(form, _this.handlers.input.formElementChange, function (elem) {
732
742
  return elem != input;
@@ -744,10 +754,12 @@ var AutocompleteController = /** @class */ (function (_super) {
744
754
  return __assign(__assign({}, translatorConfig), { urlRoot: formActionUrl });
745
755
  }));
746
756
  }
747
- if (document.activeElement === input) {
757
+ // if the input is currently focused, trigger setFocues which will eventually trigger keyup - but not if loading
758
+ if (document.activeElement === input && !_this.store.loading) {
748
759
  _this.setFocused(input);
749
760
  }
750
761
  });
762
+ // get trending terms - this is at the bottom because urlManager changes need to be in place before creating the store
751
763
  if (((_b = (_a = this.config.settings) === null || _a === void 0 ? void 0 : _a.trending) === null || _b === void 0 ? void 0 : _b.limit) && ((_d = (_c = this.config.settings) === null || _c === void 0 ? void 0 : _c.trending) === null || _d === void 0 ? void 0 : _d.limit) > 0 && !((_e = this.store.trending) === null || _e === void 0 ? void 0 : _e.length)) {
752
764
  this.searchTrending();
753
765
  }
@@ -781,7 +793,7 @@ function timeout(time) {
781
793
  });
782
794
  }
783
795
  // for grabbing other parameters from the form and using them in UrlManager
784
- var INPUT_TYPE_BLACKLIST = ['file', 'reset', 'submit', 'button', 'image', 'password'];
796
+ var INPUT_TYPE_BLOCKLIST = ['file', 'reset', 'submit', 'button', 'image', 'password'];
785
797
  function getFormParameters(form, filterFn) {
786
798
  var parameters = {};
787
799
  if (typeof form == 'object' && form.nodeName == 'FORM') {
@@ -790,7 +802,7 @@ function getFormParameters(form, filterFn) {
790
802
  if (typeof filterFn == 'function' && !filterFn(elem)) {
791
803
  continue;
792
804
  }
793
- if (elem.name && !INPUT_TYPE_BLACKLIST.includes(elem.type)) {
805
+ if (elem.name && !INPUT_TYPE_BLOCKLIST.includes(elem.type)) {
794
806
  if ((elem.type != 'checkbox' && elem.type != 'radio') || elem.checked) {
795
807
  parameters[elem.name] = elem.value;
796
808
  }
@@ -799,6 +811,7 @@ function getFormParameters(form, filterFn) {
799
811
  }
800
812
  return parameters;
801
813
  }
814
+ // this picks up changes to the form
802
815
  function bindFormParameters(form, fn, filterFn) {
803
816
  if (typeof form == 'object' && form.nodeName == 'FORM') {
804
817
  for (var i = form.elements.length - 1; i >= 0; i--) {
@@ -806,7 +819,7 @@ function bindFormParameters(form, fn, filterFn) {
806
819
  if (typeof filterFn == 'function' && !filterFn(elem)) {
807
820
  continue;
808
821
  }
809
- if (elem.name && !INPUT_TYPE_BLACKLIST.includes(elem.type)) {
822
+ if (elem.name && !INPUT_TYPE_BLOCKLIST.includes(elem.type)) {
810
823
  elem.addEventListener('change', fn);
811
824
  }
812
825
  }
@@ -816,7 +829,7 @@ function unbindFormParameters(form, fn) {
816
829
  if (typeof form == 'object' && form.nodeName == 'FORM') {
817
830
  for (var i = form.elements.length - 1; i >= 0; i--) {
818
831
  var elem = form.elements[i];
819
- if (elem.name && !INPUT_TYPE_BLACKLIST.includes(elem.type)) {
832
+ if (elem.name && !INPUT_TYPE_BLOCKLIST.includes(elem.type)) {
820
833
  elem.removeEventListener('change', fn);
821
834
  }
822
835
  }
@@ -1 +1 @@
1
- {"version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,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAC1F,OAAO,CAAC,EAAE,gBAAgB;IA6D3B,KAAK,EAAE,wBAAwB,CAO7B;IAEF,IAAI,MAAM,IAAI,wBAAwB,CA0CrC;IAEK,UAAU,CAAC,YAAY,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BhE,KAAK,IAAI,IAAI;IASb,QAAQ;;0BAEc,aAAa,KAAG,QAAQ,OAAO,GAAG,SAAS,CAAC;wBAkDpD,aAAa,KAAG,IAAI;uBAMrB,UAAU,KAAG,IAAI;4BAQN,MAAM,SAAS,CAAC,gBAAgB,CAAC,KAAG,QAAQ,IAAI,CAAC;mCAgDhD,MAAM,WAAW,CAAC,gBAAgB,CAAC,KAAG,IAAI;uBAqBtD,aAAa,KAAG,IAAI;;;;uBA8DpB,UAAU,KAAG,IAAI;;MAS5B;IAEF,MAAM,IAAI,IAAI;IAgBR,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA6E3B,cAAc,QAAa,QAAQ,IAAI,CAAC,CAwBtC;IAEF,MAAM,QAAa,QAAQ,IAAI,CAAC,CAkH9B;CACF"}
@@ -173,8 +173,8 @@ export class AutocompleteController extends AbstractController {
173
173
  this.setFocused(e.target);
174
174
  }
175
175
  const value = e.target.value;
176
- // prevent search when value is unchanged
177
- if (this.store.state.input == value && this.store.loaded) {
176
+ // prevent search when value is unchanged or empty
177
+ if (((!this.store.state.input && !value) || this.store.state.input == value) && this.store.loaded) {
178
178
  return;
179
179
  }
180
180
  this.store.state.input = value;
@@ -184,28 +184,32 @@ export class AutocompleteController extends AbstractController {
184
184
  input.value = value;
185
185
  });
186
186
  }
187
+ // TODO cancel any current requests?
187
188
  clearTimeout(this.handlers.input.timeoutDelay);
188
- // input is empty
189
+ const trendingResultsEnabled = this.store.trending?.length && this.config.settings?.trending?.showResults;
190
+ const historyResultsEnabled = this.store.history?.length && this.config.settings?.history?.showResults;
189
191
  if (!value) {
190
- // TODO cancel any current requests?
191
- // reset the store (in case input was just cleared)
192
+ // there is no input value - reset state of store and UrlManager
192
193
  this.store.reset();
193
- if (this.store.trending?.length && this.config.settings?.trending?.showResults) {
194
+ this.urlManager.reset().go();
195
+ // show results for trending or history (if configured) - trending has priority
196
+ if (trendingResultsEnabled) {
194
197
  this.store.trending[0].preview();
195
198
  }
196
- else if (this.store.history?.length && this.config.settings?.history?.showResults) {
199
+ else if (historyResultsEnabled) {
197
200
  this.store.history[0].preview();
198
201
  }
199
- else {
200
- // reset urlManager when a preview is not available to do so
201
- this.urlManager.reset().go();
202
- }
203
202
  }
204
203
  else {
204
+ // new query in the input - trigger a new search via UrlManager
205
205
  this.store.resetTerms();
206
206
  this.handlers.input.timeoutDelay = setTimeout(() => {
207
207
  this.store.state.locks.terms.unlock();
208
208
  this.store.state.locks.facets.unlock();
209
+ // must reset query to ensure funcitonality when trending/history term is equal to the typed term
210
+ if (trendingResultsEnabled || historyResultsEnabled) {
211
+ this.urlManager.set({ query: '' }).go();
212
+ }
209
213
  this.urlManager.set({ query: this.store.state.input }).go();
210
214
  }, INPUT_DELAY);
211
215
  }
@@ -247,7 +251,12 @@ export class AutocompleteController extends AbstractController {
247
251
  this.store.updateTrendingTerms(terms);
248
252
  };
249
253
  this.search = async () => {
254
+ // if urlManager has no query, there will be no need to get params and no query
255
+ if (!this.urlManager.state.query) {
256
+ return;
257
+ }
250
258
  const params = this.params;
259
+ // if params have no query do not search
251
260
  if (!params?.search?.query?.string) {
252
261
  return;
253
262
  }
@@ -508,6 +517,7 @@ export class AutocompleteController extends AbstractController {
508
517
  else if (form) {
509
518
  form.addEventListener('submit', this.handlers.input.formSubmit);
510
519
  formActionUrl = form.action || '';
520
+ // serializeForm will include additional form element in our urlManager as globals
511
521
  if (this.config.settings?.serializeForm) {
512
522
  bindFormParameters(form, this.handlers.input.formElementChange, function (elem) {
513
523
  return elem != input;
@@ -528,10 +538,12 @@ export class AutocompleteController extends AbstractController {
528
538
  };
529
539
  }));
530
540
  }
531
- if (document.activeElement === input) {
541
+ // if the input is currently focused, trigger setFocues which will eventually trigger keyup - but not if loading
542
+ if (document.activeElement === input && !this.store.loading) {
532
543
  this.setFocused(input);
533
544
  }
534
545
  });
546
+ // get trending terms - this is at the bottom because urlManager changes need to be in place before creating the store
535
547
  if (this.config.settings?.trending?.limit && this.config.settings?.trending?.limit > 0 && !this.store.trending?.length) {
536
548
  this.searchTrending();
537
549
  }
@@ -554,7 +566,7 @@ async function timeout(time) {
554
566
  });
555
567
  }
556
568
  // for grabbing other parameters from the form and using them in UrlManager
557
- const INPUT_TYPE_BLACKLIST = ['file', 'reset', 'submit', 'button', 'image', 'password'];
569
+ const INPUT_TYPE_BLOCKLIST = ['file', 'reset', 'submit', 'button', 'image', 'password'];
558
570
  function getFormParameters(form, filterFn) {
559
571
  const parameters = {};
560
572
  if (typeof form == 'object' && form.nodeName == 'FORM') {
@@ -563,7 +575,7 @@ function getFormParameters(form, filterFn) {
563
575
  if (typeof filterFn == 'function' && !filterFn(elem)) {
564
576
  continue;
565
577
  }
566
- if (elem.name && !INPUT_TYPE_BLACKLIST.includes(elem.type)) {
578
+ if (elem.name && !INPUT_TYPE_BLOCKLIST.includes(elem.type)) {
567
579
  if ((elem.type != 'checkbox' && elem.type != 'radio') || elem.checked) {
568
580
  parameters[elem.name] = elem.value;
569
581
  }
@@ -572,6 +584,7 @@ function getFormParameters(form, filterFn) {
572
584
  }
573
585
  return parameters;
574
586
  }
587
+ // this picks up changes to the form
575
588
  function bindFormParameters(form, fn, filterFn) {
576
589
  if (typeof form == 'object' && form.nodeName == 'FORM') {
577
590
  for (let i = form.elements.length - 1; i >= 0; i--) {
@@ -579,7 +592,7 @@ function bindFormParameters(form, fn, filterFn) {
579
592
  if (typeof filterFn == 'function' && !filterFn(elem)) {
580
593
  continue;
581
594
  }
582
- if (elem.name && !INPUT_TYPE_BLACKLIST.includes(elem.type)) {
595
+ if (elem.name && !INPUT_TYPE_BLOCKLIST.includes(elem.type)) {
583
596
  elem.addEventListener('change', fn);
584
597
  }
585
598
  }
@@ -589,7 +602,7 @@ function unbindFormParameters(form, fn) {
589
602
  if (typeof form == 'object' && form.nodeName == 'FORM') {
590
603
  for (let i = form.elements.length - 1; i >= 0; i--) {
591
604
  const elem = form.elements[i];
592
- if (elem.name && !INPUT_TYPE_BLACKLIST.includes(elem.type)) {
605
+ if (elem.name && !INPUT_TYPE_BLOCKLIST.includes(elem.type)) {
593
606
  elem.removeEventListener('change', fn);
594
607
  }
595
608
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@searchspring/snap-controller",
3
- "version": "0.43.0",
3
+ "version": "0.43.1",
4
4
  "description": "Snap Controllers",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -20,21 +20,21 @@
20
20
  "test:watch": "jest --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@searchspring/snap-toolbox": "^0.43.0",
23
+ "@searchspring/snap-toolbox": "^0.43.1",
24
24
  "deepmerge": "4.3.1"
25
25
  },
26
26
  "devDependencies": {
27
- "@searchspring/snap-client": "^0.43.0",
28
- "@searchspring/snap-event-manager": "^0.43.0",
29
- "@searchspring/snap-logger": "^0.43.0",
30
- "@searchspring/snap-profiler": "^0.43.0",
31
- "@searchspring/snap-store-mobx": "^0.43.0",
32
- "@searchspring/snap-tracker": "^0.43.0",
33
- "@searchspring/snap-url-manager": "^0.43.0"
27
+ "@searchspring/snap-client": "^0.43.1",
28
+ "@searchspring/snap-event-manager": "^0.43.1",
29
+ "@searchspring/snap-logger": "^0.43.1",
30
+ "@searchspring/snap-profiler": "^0.43.1",
31
+ "@searchspring/snap-store-mobx": "^0.43.1",
32
+ "@searchspring/snap-tracker": "^0.43.1",
33
+ "@searchspring/snap-url-manager": "^0.43.1"
34
34
  },
35
35
  "sideEffects": false,
36
36
  "files": [
37
37
  "dist/**/*"
38
38
  ],
39
- "gitHead": "60b06644edb6f2f8258334321e15cafb5d7d4888"
39
+ "gitHead": "45b2fd3657b3d4dddf4256657d18baa4be0647f8"
40
40
  }