@zengenti/contensis-react-base 3.0.2-beta.0 → 3.0.2-beta.10

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.
Files changed (110) hide show
  1. package/cjs/{App-ee485b92.js → App-81a45001.js} +111 -427
  2. package/cjs/App-81a45001.js.map +1 -0
  3. package/cjs/ContensisDeliveryApi-de88df2a.js +231 -0
  4. package/cjs/ContensisDeliveryApi-de88df2a.js.map +1 -0
  5. package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-47d70a26.js} +23 -37
  6. package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-47d70a26.js.map} +1 -1
  7. package/cjs/{ToJs-a9a8522b.js → ToJs-61c03582.js} +3 -4
  8. package/cjs/{ToJs-a9a8522b.js.map → ToJs-61c03582.js.map} +1 -1
  9. package/cjs/client.js +20 -27
  10. package/cjs/client.js.map +1 -1
  11. package/cjs/contensis-react-base.js +124 -188
  12. package/cjs/contensis-react-base.js.map +1 -1
  13. package/cjs/forms.js +430 -545
  14. package/cjs/forms.js.map +1 -1
  15. package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-7c363211.js} +1 -4
  16. package/cjs/{fromJSLeaveImmer-e74c673c.js.map → fromJSLeaveImmer-7c363211.js.map} +1 -1
  17. package/cjs/{login-840860bc.js → login-51b66359.js} +64 -113
  18. package/cjs/login-51b66359.js.map +1 -0
  19. package/cjs/{reducers-3a4f8971.js → reducers-9afb5f89.js} +14 -31
  20. package/cjs/reducers-9afb5f89.js.map +1 -0
  21. package/cjs/redux.js +17 -17
  22. package/cjs/redux.js.map +1 -1
  23. package/cjs/routing.js +6 -7
  24. package/cjs/routing.js.map +1 -1
  25. package/cjs/{sagas-7c19ce8e.js → sagas-6d12e7ca.js} +224 -283
  26. package/cjs/sagas-6d12e7ca.js.map +1 -0
  27. package/cjs/search.js +74 -82
  28. package/cjs/search.js.map +1 -1
  29. package/cjs/{selectors-656da4b7.js → selectors-c76c2676.js} +84 -7
  30. package/cjs/selectors-c76c2676.js.map +1 -0
  31. package/cjs/urls-6fcaf4c6.js.map +1 -1
  32. package/cjs/user.js +4 -13
  33. package/cjs/user.js.map +1 -1
  34. package/cjs/util.js +45 -53
  35. package/cjs/util.js.map +1 -1
  36. package/cjs/{version-78dfc3bd.js → version-38afaf2a.js} +45 -158
  37. package/cjs/version-38afaf2a.js.map +1 -0
  38. package/cjs/version-886f49d8.js +98 -0
  39. package/cjs/version-886f49d8.js.map +1 -0
  40. package/esm/{App-640239d2.js → App-5f914483.js} +93 -407
  41. package/esm/App-5f914483.js.map +1 -0
  42. package/esm/ContensisDeliveryApi-ad06857d.js +227 -0
  43. package/esm/ContensisDeliveryApi-ad06857d.js.map +1 -0
  44. package/esm/{RouteLoader-5171c63f.js → RouteLoader-f5d5f733.js} +22 -36
  45. package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-f5d5f733.js.map} +1 -1
  46. package/esm/{ToJs-4e02a04d.js → ToJs-0066e629.js} +3 -4
  47. package/esm/{ToJs-4e02a04d.js.map → ToJs-0066e629.js.map} +1 -1
  48. package/esm/client.js +15 -22
  49. package/esm/client.js.map +1 -1
  50. package/esm/contensis-react-base.js +119 -183
  51. package/esm/contensis-react-base.js.map +1 -1
  52. package/esm/forms.js +432 -547
  53. package/esm/forms.js.map +1 -1
  54. package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-e2dacd63.js} +1 -4
  55. package/esm/{fromJSLeaveImmer-0114ffcf.js.map → fromJSLeaveImmer-e2dacd63.js.map} +1 -1
  56. package/esm/{login-57395c9c.js → login-4d07c2de.js} +63 -112
  57. package/esm/login-4d07c2de.js.map +1 -0
  58. package/esm/{reducers-8e5d6232.js → reducers-3d5c37d1.js} +14 -31
  59. package/esm/reducers-3d5c37d1.js.map +1 -0
  60. package/esm/redux.js +9 -8
  61. package/esm/redux.js.map +1 -1
  62. package/esm/routing.js +3 -4
  63. package/esm/routing.js.map +1 -1
  64. package/esm/{sagas-8d8945e6.js → sagas-53d2aefb.js} +176 -238
  65. package/esm/sagas-53d2aefb.js.map +1 -0
  66. package/esm/search.js +75 -83
  67. package/esm/search.js.map +1 -1
  68. package/esm/{selectors-a5e5835b.js → selectors-3f0d804d.js} +70 -7
  69. package/esm/selectors-3f0d804d.js.map +1 -0
  70. package/esm/urls-eac9a747.js.map +1 -1
  71. package/esm/user.js +6 -15
  72. package/esm/user.js.map +1 -1
  73. package/esm/util.js +42 -53
  74. package/esm/util.js.map +1 -1
  75. package/esm/{version-e3a5ec66.js → version-dd31c7f0.js} +32 -141
  76. package/esm/version-dd31c7f0.js.map +1 -0
  77. package/esm/version-f4629693.js +87 -0
  78. package/esm/version-f4629693.js.map +1 -0
  79. package/models/forms/index.d.ts +1 -3
  80. package/models/search/models/Search.d.ts +2 -1
  81. package/models/search/models/SearchActions.d.ts +5 -0
  82. package/models/search/models/SearchProps.d.ts +4 -1
  83. package/models/search/models/SearchState.d.ts +1 -0
  84. package/models/search/redux/actions.d.ts +5 -0
  85. package/models/search/redux/reducers.d.ts +3 -0
  86. package/models/search/redux/selectors.d.ts +1 -0
  87. package/models/search/redux/types.d.ts +1 -0
  88. package/models/util/ContensisDeliveryApi.d.ts +6 -0
  89. package/models/util/index.d.ts +1 -0
  90. package/package.json +1 -1
  91. package/cjs/App-ee485b92.js.map +0 -1
  92. package/cjs/actions-8dc9e8de.js +0 -87
  93. package/cjs/actions-8dc9e8de.js.map +0 -1
  94. package/cjs/login-840860bc.js.map +0 -1
  95. package/cjs/reducers-3a4f8971.js.map +0 -1
  96. package/cjs/sagas-7c19ce8e.js.map +0 -1
  97. package/cjs/selectors-656da4b7.js.map +0 -1
  98. package/cjs/version-78dfc3bd.js.map +0 -1
  99. package/cjs/version-eba6d09b.js +0 -20
  100. package/cjs/version-eba6d09b.js.map +0 -1
  101. package/esm/App-640239d2.js.map +0 -1
  102. package/esm/actions-180948dd.js +0 -72
  103. package/esm/actions-180948dd.js.map +0 -1
  104. package/esm/login-57395c9c.js.map +0 -1
  105. package/esm/reducers-8e5d6232.js.map +0 -1
  106. package/esm/sagas-8d8945e6.js.map +0 -1
  107. package/esm/selectors-a5e5835b.js.map +0 -1
  108. package/esm/version-2485e2fb.js +0 -15
  109. package/esm/version-2485e2fb.js.map +0 -1
  110. package/esm/version-e3a5ec66.js.map +0 -1
@@ -25,6 +25,7 @@ const UPDATE_CURRENT_FACET = `${ACTION_PREFIX}UPDATE_CURRENT_FACET`;
25
25
  const UPDATE_CURRENT_TAB = `${ACTION_PREFIX}UPDATE_CURRENT_TAB`;
26
26
  const UPDATE_SORT_ORDER = `${ACTION_PREFIX}UPDATE_SORT_ORDER`;
27
27
  const UPDATE_PAGE_INDEX = `${ACTION_PREFIX}UPDATE_PAGE_INDEX`;
28
+ const UPDATE_PAGE_SIZE = `${ACTION_PREFIX}UPDATE_PAGE_SIZE`;
28
29
  const UPDATE_SEARCH_TERM = `${ACTION_PREFIX}UPDATE_SEARCH_TERM`;
29
30
  const UPDATE_SELECTED_FILTERS = `${ACTION_PREFIX}UPDATE_SELECTED_FILTERS`;
30
31
 
@@ -48,12 +49,14 @@ var types = /*#__PURE__*/Object.freeze({
48
49
  UPDATE_CURRENT_TAB: UPDATE_CURRENT_TAB,
49
50
  UPDATE_SORT_ORDER: UPDATE_SORT_ORDER,
50
51
  UPDATE_PAGE_INDEX: UPDATE_PAGE_INDEX,
52
+ UPDATE_PAGE_SIZE: UPDATE_PAGE_SIZE,
51
53
  UPDATE_SEARCH_TERM: UPDATE_SEARCH_TERM,
52
54
  UPDATE_SELECTED_FILTERS: UPDATE_SELECTED_FILTERS
53
55
  });
54
56
 
55
57
  const withMappers = (action, mappers) => {
56
- return { ...action,
58
+ return {
59
+ ...action,
57
60
  mappers
58
61
  };
59
62
  };
@@ -115,6 +118,13 @@ const updatePageIndex$1 = (pageIndex, scrollYPos) => {
115
118
  scrollYPos
116
119
  };
117
120
  };
121
+ const updatePageSize$1 = (pageSize, scrollYPos) => {
122
+ return {
123
+ type: UPDATE_PAGE_SIZE,
124
+ pageSize,
125
+ scrollYPos
126
+ };
127
+ };
118
128
  const updateCurrentFacet$1 = facet => {
119
129
  return {
120
130
  type: UPDATE_CURRENT_FACET,
@@ -158,6 +168,7 @@ var actions = /*#__PURE__*/Object.freeze({
158
168
  navigate: navigate,
159
169
  clearFilters: clearFilters$1,
160
170
  updatePageIndex: updatePageIndex$1,
171
+ updatePageSize: updatePageSize$1,
161
172
  updateCurrentFacet: updateCurrentFacet$1,
162
173
  updateCurrentTab: updateCurrentTab$1,
163
174
  updateSearchTerm: updateSearchTerm$1,
@@ -165,38 +176,33 @@ var actions = /*#__PURE__*/Object.freeze({
165
176
  updateSortOrder: updateSortOrder$1
166
177
  });
167
178
 
168
- let Context; // export type Context = 'facets' | 'listings' | 'minilist';
169
-
170
- (function (Context) {
179
+ let Context = /*#__PURE__*/function (Context) {
171
180
  Context["facets"] = "facets";
172
181
  Context["listings"] = "listings";
173
182
  Context["minilist"] = "minilist";
174
- })(Context || (Context = {}));
183
+ return Context;
184
+ }({});
185
+ // export type Context = 'facets' | 'listings' | 'minilist';
175
186
 
187
+ // Find a fromJS function from global that is dynamically loaded in createStore
176
188
  // or replace with a stub function for non-immutable gets
177
-
178
189
  const makeFromJS = (returnType = globalThis.STATE_TYPE || 'immutable') => {
179
190
  var _immutable, _immutable2;
180
-
181
191
  return returnType === 'immutable' ? ((_immutable = globalThis.immutable) === null || _immutable === void 0 ? void 0 : _immutable.fromJSOrdered) || ((_immutable2 = globalThis.immutable) === null || _immutable2 === void 0 ? void 0 : _immutable2.fromJS) || (v => v) : v => v;
182
192
  };
183
-
184
193
  const getImmutableOrJS = (state, stateKey, fallbackValue, returnType = globalThis.STATE_TYPE || 'immutable') => {
185
194
  // Find a fromJS function from global that is dynamically loaded in createStore
186
195
  // or replace with a stub function for non-immutable gets
187
196
  const fromJS = makeFromJS(returnType);
188
-
189
197
  if (state && 'get' in state && typeof state.get === 'function' && 'getIn' in state && typeof state.getIn === 'function' && 'toJS' in state && typeof state.toJS === 'function') {
190
198
  if (Array.isArray(stateKey)) return fromJS(state.getIn(stateKey, fallbackValue));
191
199
  return fromJS(state.get(stateKey, fallbackValue));
192
200
  }
193
-
194
201
  if (Array.isArray(stateKey) && state && typeof state === 'object') {
195
202
  const result = jpath(stateKey.join('.'), state);
196
203
  if (typeof result === 'undefined') return fallbackValue;
197
204
  return result;
198
205
  }
199
-
200
206
  const result = state && typeof state === 'object' ? state[stateKey] : undefined;
201
207
  if (typeof result === 'undefined') return fallbackValue;
202
208
  return result;
@@ -211,7 +217,6 @@ const getFacets = (state, returnType) => getImmutableOrJS(state, ['search', Cont
211
217
  const getTabFacets = state => Object.fromEntries(Object.entries(getFacets(state, 'js')).filter(([key]) => getImmutableOrJS(getFacets(state), [key, 'tabId'], 0) === getCurrentTab(state)));
212
218
  const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key, facet = {}]) => {
213
219
  var _facet$pagingInfo;
214
-
215
220
  return {
216
221
  isSelected: getCurrentFacet(state) === key,
217
222
  key,
@@ -238,8 +243,9 @@ const getFiltersToLoad = (state, facet, context = Context.facets, returnType) =>
238
243
  return typeof title !== 'undefined' && !!title;
239
244
  }).length > 0 && (f.isError || false) === false]);
240
245
  return loadedFilters.map(([filterKey, isLoaded]) => !isLoaded ? filterKey : null).filter(f => !!f);
241
- }; // We lowercase the filter key unless it's an ISO date string where the T must be uppercase
246
+ };
242
247
 
248
+ // We lowercase the filter key unless it's an ISO date string where the T must be uppercase
243
249
  const getSelectedFilters = (state, facet = '', context = Context.facets, returnType) => {
244
250
  const filters = getFilters(state, facet, context, 'js');
245
251
  const isoDateRegex = RegExp(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d/);
@@ -273,6 +279,11 @@ const getPaging = (state, current = '', context = Context.facets, returnType) =>
273
279
  const getPageIndex = (state, current = '', context = Context.facets) => {
274
280
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageIndex']);
275
281
  };
282
+ const getPageSize = (state, current = '', context = Context.facets) => {
283
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageSize'], 0 // Defaults to 0 because we want it to fall back to a query param if not defined
284
+ );
285
+ };
286
+
276
287
  const getPrevPageIndex = (state, current = '', context = Context.facets) => {
277
288
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'prevPageIndex']);
278
289
  };
@@ -315,7 +326,8 @@ const getTabsAndFacets = (state, returnType) => {
315
326
  if (!countFields || countFields.find((f = []) => (f === null || f === void 0 ? void 0 : f[0]) === facetName)) return getImmutableOrJS(facet, ['pagingInfo', 'totalCount']);
316
327
  return 0;
317
328
  }).reduce((a, b) => a + b, 0);
318
- return { ...tab,
329
+ return {
330
+ ...tab,
319
331
  [Context.facets]: Object.fromEntries(thisTabFacets),
320
332
  totalCount: thisTabTotal
321
333
  };
@@ -332,12 +344,12 @@ const getFacetsTotalCount = state => {
332
344
  const facets = getFacets(state);
333
345
  const wholeSearchTotal = Object.entries(facets).map(([, t = {}]) => {
334
346
  var _t$pagingInfo;
335
-
336
347
  return ((_t$pagingInfo = t.pagingInfo) === null || _t$pagingInfo === void 0 ? void 0 : _t$pagingInfo.totalCount) || 0;
337
348
  }).reduce((a, b) => a + b, 0);
338
349
  return wholeSearchTotal;
339
- }; // An exported copy of the relevant selectors scoped by default to a facets context
350
+ };
340
351
 
352
+ // An exported copy of the relevant selectors scoped by default to a facets context
341
353
  const selectFacets = {
342
354
  getCurrent: getCurrentFacet,
343
355
  getCurrentTab,
@@ -374,8 +386,9 @@ const selectFacets = {
374
386
  getSearchTerm,
375
387
  getSearchTotalCount,
376
388
  getSelectedFilters
377
- }; // An exported copy of the relevant selectors pre-scoped to a listing context
389
+ };
378
390
 
391
+ // An exported copy of the relevant selectors pre-scoped to a listing context
379
392
  const selectListing = {
380
393
  getCurrent: getCurrentListing,
381
394
  getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, Context.listings, 'js'),
@@ -431,6 +444,7 @@ var selectors = /*#__PURE__*/Object.freeze({
431
444
  getFeaturedResults: getFeaturedResults,
432
445
  getPaging: getPaging,
433
446
  getPageIndex: getPageIndex,
447
+ getPageSize: getPageSize,
434
448
  getPrevPageIndex: getPrevPageIndex,
435
449
  getPageIsLoading: getPageIsLoading,
436
450
  getPagesLoaded: getPagesLoaded,
@@ -455,31 +469,23 @@ const now = () => {
455
469
  if (typeof window == 'undefined') {
456
470
  return Date.now();
457
471
  }
458
-
459
472
  return window.performance.now();
460
473
  };
461
474
 
462
475
  const getClientConfig = (project, env) => {
463
- let config = DELIVERY_API_CONFIG;
464
- /* global DELIVERY_API_CONFIG */
465
-
476
+ let config = DELIVERY_API_CONFIG; /* global DELIVERY_API_CONFIG */
466
477
  if (project) {
467
478
  config.projectId = project;
468
479
  }
469
-
470
- if (typeof window != 'undefined' && PROXY_DELIVERY_API
471
- /* global PROXY_DELIVERY_API */
472
- ) {
480
+ if (typeof window != 'undefined' && PROXY_DELIVERY_API /* global PROXY_DELIVERY_API */) {
473
481
  // ensure a relative url is used to bypass the need for CORS (separate OPTIONS calls)
474
482
  config.rootUrl = env || '';
475
483
  config.responseHandler = {
476
484
  404: () => null
477
485
  };
478
486
  }
479
-
480
487
  return config;
481
488
  };
482
-
483
489
  class CacheNode {
484
490
  constructor(key, value) {
485
491
  this.key = key;
@@ -487,9 +493,7 @@ class CacheNode {
487
493
  this.next = null;
488
494
  this.prev = null;
489
495
  }
490
-
491
496
  }
492
-
493
497
  class LruCache {
494
498
  constructor(limit = 100) {
495
499
  this.map = {};
@@ -498,7 +502,6 @@ class LruCache {
498
502
  this.limit = limit || 100;
499
503
  this.size = 0;
500
504
  }
501
-
502
505
  get(key) {
503
506
  if (this.map[key]) {
504
507
  let value = this.map[key].value;
@@ -508,10 +511,8 @@ class LruCache {
508
511
  return value;
509
512
  }
510
513
  }
511
-
512
514
  set(key, value) {
513
515
  let node = new CacheNode(key, value);
514
-
515
516
  if (this.map[key]) {
516
517
  this.remove(key);
517
518
  } else {
@@ -522,60 +523,46 @@ class LruCache {
522
523
  this.tail.next = null;
523
524
  }
524
525
  }
525
-
526
526
  this.setHead(node);
527
527
  }
528
-
529
528
  setHead(node) {
530
529
  node.next = this.head;
531
530
  node.prev = null;
532
-
533
531
  if (this.head) {
534
532
  this.head.prev = node;
535
533
  }
536
-
537
534
  this.head = node;
538
-
539
535
  if (!this.tail) {
540
536
  this.tail = node;
541
537
  }
542
-
543
538
  this.size++;
544
539
  this.map[node.key] = node;
545
540
  }
546
-
547
541
  remove(key) {
548
542
  let node = this.map[key];
549
-
550
543
  if (node.prev) {
551
544
  node.prev.next = node.next;
552
545
  } else {
553
546
  this.head = node.next;
554
547
  }
555
-
556
548
  if (node.next) {
557
549
  node.next.prev = node.prev;
558
550
  } else {
559
551
  this.tail = node.prev;
560
552
  }
561
-
562
553
  delete this.map[key];
563
554
  this.size--;
564
555
  }
565
-
566
556
  }
567
-
568
557
  class CachedSearch {
569
558
  constructor() {
570
559
  this.cache = new LruCache();
571
560
  this.taxonomyLookup = {};
572
561
  }
573
-
574
562
  search(query, linkDepth, project, env) {
575
563
  const client = Client.create(getClientConfig(project, env));
576
564
  return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
577
565
  }
578
-
579
566
  getTaxonomyNodeByPath(path, project, env) {
580
567
  const client = Client.create(getClientConfig(project, env));
581
568
  return this.request(`[TAXONOMY NODE] ${path}`, () => client.taxonomy.getNodeByPath({
@@ -584,7 +571,6 @@ class CachedSearch {
584
571
  childDepth: 2
585
572
  }).then(node => this.extendTaxonomyNode(node)));
586
573
  }
587
-
588
574
  request(key, execute) {
589
575
  if (!this.cache.get(key) || typeof window == 'undefined') {
590
576
  let promise = execute();
@@ -593,41 +579,36 @@ class CachedSearch {
593
579
  this.cache.remove(key);
594
580
  });
595
581
  }
596
-
597
582
  return this.cache.get(key);
598
583
  }
599
-
600
584
  extendTaxonomyNode(node) {
601
585
  let id = this.getTaxonomyId(node);
602
586
  this.taxonomyLookup[id] = node.key;
603
- return { ...node,
587
+ return {
588
+ ...node,
604
589
  id,
605
590
  children: node.children ? node.children.map(n => this.extendTaxonomyNode(n)) : null
606
591
  };
607
592
  }
608
-
609
593
  getTaxonomyId(node) {
610
594
  if (node.key) {
611
595
  let parts = node.key.split('/');
612
596
  return parts[parts.length - 1];
613
597
  }
614
-
615
598
  return '';
616
599
  }
617
-
618
600
  fetch(uri, opts = {}) {
619
601
  return this.request(`[FETCH] ${uri} ${JSON.stringify(opts)}`, () => fetch(uri, opts));
620
602
  }
621
-
622
603
  }
623
-
624
604
  const cachedSearch = new CachedSearch();
625
605
 
626
606
  // eslint-disable-next-line import/default
627
607
  function fixFreeTextForElastic(s) {
628
608
  const illegalChars = ['>', '<', '=', '|', '!', '{', '}', '[', ']', '^', '~', '*', '?', ':', '\\', '/'];
629
609
  const illegalRegEx = new RegExp(illegalChars.map(c => '\\' + c).join('|'), 'g');
630
- s = s.replace(illegalRegEx, ''); // s = s.replace(encodedRegEx, ''); // (m) => '\\\\' + m);
610
+ s = s.replace(illegalRegEx, '');
611
+ // s = s.replace(encodedRegEx, ''); // (m) => '\\\\' + m);
631
612
 
632
613
  return s;
633
614
  }
@@ -647,13 +628,11 @@ const getItemsFromResult = result => {
647
628
  const {
648
629
  payload
649
630
  } = result || {};
650
-
651
631
  if (payload) {
652
632
  if (Array.isArray(payload)) return payload;
653
633
  if (Array.isArray(payload.items)) return payload.items;
654
634
  return payload;
655
635
  }
656
-
657
636
  return [];
658
637
  };
659
638
  const extractQuotedPhrases = searchTerm => {
@@ -665,6 +644,7 @@ const buildUrl = (route, params) => {
665
644
  const path = qs ? `${route}${route.includes('?') ? '&' : '?'}${qs}` : route;
666
645
  return path;
667
646
  };
647
+
668
648
  /**
669
649
  * Returns all params from the current route query string or static route
670
650
  * Supply static route argument if reading parameters from the route path
@@ -673,15 +653,14 @@ const buildUrl = (route, params) => {
673
653
  * @param location location object containing at least pathname and search
674
654
  * @returns Keyed params object
675
655
  */
676
-
677
656
  const routeParams = (staticRoute, location) => {
678
657
  var _staticRoute$match;
679
-
680
658
  // match.params is react-router-config/react-router@5 style
681
659
  // params is supplied with RouteObject in react-router@6
682
660
  const pathParams = (staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$match = staticRoute.match) === null || _staticRoute$match === void 0 ? void 0 : _staticRoute$match.params) || (staticRoute === null || staticRoute === void 0 ? void 0 : staticRoute.params) || {};
683
661
  const queryParams = parse(typeof window !== 'undefined' ? window.location.search : (location === null || location === void 0 ? void 0 : location.search) || '');
684
- return { ...pathParams,
662
+ return {
663
+ ...pathParams,
685
664
  ...queryParams
686
665
  };
687
666
  };
@@ -689,13 +668,11 @@ const callCustomApi = async (customApi, filters) => {
689
668
  const apiUri = customApi.uri || '';
690
669
  let uri = buildUrl(apiUri, filters);
691
670
  if (!uri) throw new Error('uri is required to use customApi');
692
-
693
671
  if (typeof window == 'undefined') {
694
672
  if (!uri.startsWith('http')) uri = `http://localhost:3001${uri}`;
695
673
  const response = await fetch(uri);
696
674
  return await response.json();
697
675
  }
698
-
699
676
  const response = await cachedSearch.fetch(uri);
700
677
  return await response.clone().json();
701
678
  };
@@ -703,32 +680,27 @@ const removeEmptyAttributes = obj => {
703
680
  Object.entries(obj).forEach(([key, val]) => val && typeof val === 'object' && removeEmptyAttributes(val) || (typeof val === 'undefined' || val === null || val === '') && delete obj[key]);
704
681
  return obj;
705
682
  };
706
- const toArray = (obj, seperator = ',') => typeof obj === 'undefined' || obj === null ? obj : Array.isArray(obj) ? obj : obj.split(seperator); // assumes array elements are primitive types
683
+ const toArray = (obj, seperator = ',') => typeof obj === 'undefined' || obj === null ? obj : Array.isArray(obj) ? obj : obj.split(seperator);
707
684
 
685
+ // assumes array elements are primitive types
708
686
  const areArraysEqualSets = (a1, a2) => {
709
687
  const superSet = {};
710
-
711
688
  for (const ai of a1) {
712
689
  const e = ai + typeof ai;
713
690
  superSet[e] = 1;
714
691
  }
715
-
716
692
  for (const ai of a2) {
717
693
  const e = ai + typeof ai;
718
-
719
694
  if (!superSet[e]) {
720
695
  return false;
721
696
  }
722
-
723
697
  superSet[e] = 2;
724
698
  }
725
-
726
699
  for (const e in superSet) {
727
700
  if (superSet[e] === 1) {
728
701
  return false;
729
702
  }
730
703
  }
731
-
732
704
  return true;
733
705
  };
734
706
 
@@ -739,12 +711,12 @@ const searchUriTemplate = {
739
711
  }) => {
740
712
  const context = getSearchContext(state);
741
713
  const currentPath = selectCurrentPath(state) || '/search';
742
-
743
714
  if (context !== 'listings') {
744
715
  const currentFacet = facet || getCurrentFacet(state);
745
716
  const filters = getSelectedFilters(state, facet, context);
746
- const currentFilter = filters.contentTypeId; // Check if we have a filter first
717
+ const currentFilter = filters.contentTypeId;
747
718
 
719
+ // Check if we have a filter first
748
720
  const newPath = (currentFilter === null || currentFilter === void 0 ? void 0 : currentFilter.length) > 0 && currentFacet ? `${currentPath}/${currentFacet}/${currentFilter}` : currentFacet ? `${currentPath}/${currentFacet}` : currentPath;
749
721
  return newPath;
750
722
  } else {
@@ -756,30 +728,32 @@ const searchUriTemplate = {
756
728
  facet,
757
729
  orderBy,
758
730
  term,
759
- pageIndex
731
+ pageIndex,
732
+ pageSize
760
733
  }) => {
761
- const searchContext = getSearchContext(state); // Lose stateFilters and currentSearch if a new
734
+ const searchContext = getSearchContext(state);
735
+ // Lose stateFilters and currentSearch if a new
762
736
  // term is passed via an argument
763
-
764
737
  const stateFilters = term ? {} : Object.fromEntries(Object.entries(getSelectedFilters(state, facet, searchContext, 'js')).map(([k, f]) => [k, f === null || f === void 0 ? void 0 : f.join(',')]));
765
738
  const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
766
739
  const currentQs = removeEmptyAttributes(parse(currentSearch));
767
740
  if (orderBy) currentQs.orderBy = orderBy;
768
- const searchTerm = getSearchTerm(state); // Use Immutable's merge to merge the stateFilters with any current Qs
741
+ const searchTerm = getSearchTerm(state);
742
+ // Use Immutable's merge to merge the stateFilters with any current Qs
769
743
  // to build the new Qs.
770
-
771
744
  const mergedSearch = removeEmptyAttributes(merge(currentQs, stateFilters));
772
745
  if (searchTerm) mergedSearch.term = searchTerm;
773
746
  if (pageIndex) mergedSearch.pageIndex = pageIndex + 1;
774
- if (pageIndex === 0) mergedSearch.pageIndex = undefined; // We don't want these as search params in the url, we just need the search package to see them
747
+ if (pageIndex === 0) mergedSearch.pageIndex = undefined;
748
+ if (pageSize) mergedSearch.pageSize = pageSize;
775
749
 
750
+ // We don't want these as search params in the url, we just need the search package to see them
776
751
  return stringify(mergedSearch);
777
752
  },
778
753
  hash: ({
779
754
  state
780
755
  }) => getImmutableOrJS(state, ['routing', 'location', 'hash'], '').replace('#', '')
781
756
  };
782
-
783
757
  const mapStateToSearchUri = state => mapJson(state, searchUriTemplate);
784
758
 
785
759
  const DataFormats = {
@@ -814,7 +788,8 @@ const Fields = {
814
788
 
815
789
  const fieldExpression = (field, value, operator = 'equalTo', weight, fuzzySearch = false) => {
816
790
  if (!field || !value || Array.isArray(value) && value.length === 0) return [];
817
- if (Array.isArray(field)) // If an array of fieldIds have been provided, call self for each fieldId
791
+ if (Array.isArray(field))
792
+ // If an array of fieldIds have been provided, call self for each fieldId
818
793
  // to generate expressions that are combined with an 'or' operator
819
794
  return [Op.or(...field.map(fieldId => fieldExpression(fieldId, value, operator, weight, fuzzySearch)).flat())];
820
795
  if (operator === 'between') return between(field, value);
@@ -823,19 +798,15 @@ const fieldExpression = (field, value, operator = 'equalTo', weight, fuzzySearch
823
798
  const contentTypeIdExpression = (contentTypeIds, webpageTemplates, assetTypes) => {
824
799
  const expressions = [];
825
800
  if (!contentTypeIds && !webpageTemplates && !assetTypes) return expressions;
826
-
827
801
  if (contentTypeIds && contentTypeIds.length > 0) {
828
802
  expressions.push(...dataFormatExpression(contentTypeIds, DataFormats.entry));
829
803
  }
830
-
831
804
  if (webpageTemplates && webpageTemplates.length > 0) {
832
805
  expressions.push(...dataFormatExpression(webpageTemplates, DataFormats.webpage));
833
806
  }
834
-
835
807
  if (assetTypes && assetTypes.length > 0) {
836
808
  expressions.push(...dataFormatExpression(assetTypes, DataFormats.asset));
837
809
  }
838
-
839
810
  if (expressions.length > 1) return [Op.or(...expressions)];
840
811
  return expressions;
841
812
  };
@@ -843,14 +814,16 @@ const filterExpressions = (filters, isOptional = false) => {
843
814
  if (!filters) return [];
844
815
  const expressions = [];
845
816
  filters.map(selectedFilter => {
846
- if (selectedFilter.logicOperator === 'and') // using 'and' logic operator we loop through each filter
817
+ if (selectedFilter.logicOperator === 'and')
818
+ // using 'and' logic operator we loop through each filter
847
819
  // and loop through all values to add an expression for each filter value
848
820
  selectedFilter.values.forEach(value => expressions.push(...fieldExpression(selectedFilter.key, value, selectedFilter.fieldOperator || 'equalTo')));else if (selectedFilter.logicOperator === 'not') {
849
821
  const fieldExpressions = fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in');
850
822
  fieldExpressions.forEach(expr => {
851
823
  expressions.push(Op.not(expr));
852
824
  });
853
- } // using 'or' logic operator we loop over each filter
825
+ }
826
+ // using 'or' logic operator we loop over each filter
854
827
  // and simply add the array of values to an expression with an 'in' operator
855
828
  else expressions.push(...fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in'));
856
829
  if (isOptional) expressions.push(Op.not(fieldExpression(selectedFilter.key, true, 'exists')[0]));
@@ -874,7 +847,6 @@ const dataFormatExpression = (contentTypeIds, dataFormat = DataFormats.entry) =>
874
847
  if (notContentTypeIds.length > 0 && notExpr) andExpr.add(notExpr);
875
848
  return [andExpr];
876
849
  }
877
-
878
850
  return [];
879
851
  };
880
852
  const featuredResultsExpression = ({
@@ -883,24 +855,22 @@ const featuredResultsExpression = ({
883
855
  fieldValue = true
884
856
  } = {}) => {
885
857
  const expressions = [];
886
-
887
858
  if (contentTypeId) {
888
859
  expressions.push(...contentTypeIdExpression(Array.isArray(contentTypeId) ? contentTypeId : [contentTypeId]));
889
860
  }
890
-
891
861
  if (fieldId && fieldValue) {
892
862
  expressions.push(...fieldExpression(fieldId, fieldValue));
893
863
  }
894
-
895
864
  return expressions;
896
865
  };
897
866
  const languagesExpression = languages => fieldExpression(Fields.sys.language, languages);
898
867
  const includeInSearchExpressions = (webpageTemplates, includeInSearchFields) => {
899
- const expressions = []; // Or include this expression if we have explicity specified non-default includeInSearch fields
868
+ const expressions = [];
869
+ // Or include this expression if we have explicity specified non-default includeInSearch fields
870
+ if (Array.isArray(includeInSearchFields)) expressions.push(...includeInSearchFields.map(includeInSearchField => Op.or(Op.and(Op.exists(includeInSearchField, true), Op.equalTo(includeInSearchField, true)), Op.exists(includeInSearchField, false))));
900
871
 
901
- if (Array.isArray(includeInSearchFields)) expressions.push(...includeInSearchFields.map(includeInSearchField => Op.or(Op.and(Op.exists(includeInSearchField, true), Op.equalTo(includeInSearchField, true)), Op.exists(includeInSearchField, false)))); // If webpageTemplates have been specified, include this expression
872
+ // If webpageTemplates have been specified, include this expression
902
873
  // with the default includeInSearch field from classic Contensis.
903
-
904
874
  if (Array.isArray(webpageTemplates) && webpageTemplates.length > 0) expressions.push(Op.or(Op.and(Op.exists(Fields.sys.includeInSearch, true), Op.equalTo(Fields.sys.includeInSearch, true)), Op.exists(Fields.sys.includeInSearch, false)));
905
875
  return expressions;
906
876
  };
@@ -920,69 +890,52 @@ const excludeIdsExpression = excludeIds => {
920
890
  };
921
891
  const orderByExpression = orderBy => {
922
892
  let expression;
923
-
924
893
  if (orderBy && orderBy.length > 0) {
925
894
  expression = OrderBy;
926
-
927
895
  for (const ob of orderBy) {
928
896
  var _expression, _expression2;
929
-
930
897
  expression = ob.startsWith('-') ? (_expression = expression) === null || _expression === void 0 ? void 0 : _expression.desc(ob.substring(1)) : (_expression2 = expression) === null || _expression2 === void 0 ? void 0 : _expression2.asc(ob);
931
898
  }
932
899
  }
933
-
934
900
  return expression;
935
901
  };
936
-
937
902
  const equalToOrIn = (field, value, operator = 'equalTo', fuzzySearch = false) => {
938
903
  if (value.length === 0) return [];
939
-
940
904
  if (Array.isArray(value)) {
941
905
  if (operator === 'equalTo' || operator === 'in') return [Op.in(field, ...value)];
942
906
  const expressions = value.map(innerValue => {
943
907
  var _between, _distanceWithin;
944
-
945
908
  switch (operator) {
946
909
  case 'between':
947
910
  return (_between = between(field, innerValue)) === null || _between === void 0 ? void 0 : _between[0];
948
-
949
911
  case 'distanceWithin':
950
912
  return (_distanceWithin = distanceWithin(field, innerValue)) === null || _distanceWithin === void 0 ? void 0 : _distanceWithin[0];
951
-
952
913
  case 'exists':
953
914
  return Op.exists(field, innerValue);
954
-
955
915
  case 'freeText':
956
916
  // TODO: Potentially needs further implementation of new options
957
917
  return Op[operator](field, innerValue, fuzzySearch, undefined);
958
-
959
918
  default:
960
919
  return Op[operator](field, innerValue);
961
920
  }
962
921
  });
963
922
  return (expressions === null || expressions === void 0 ? void 0 : expressions.length) > 1 ? [Op.or(...expressions)] : expressions || [];
964
923
  }
965
-
966
924
  switch (operator) {
967
925
  case 'between':
968
926
  return between(field, value);
969
-
970
927
  case 'distanceWithin':
971
928
  return distanceWithin(field, value);
972
-
973
929
  case 'freeText':
974
930
  // TODO: Potentially needs further implementation of new options
975
931
  return [Op.freeText(field, value, fuzzySearch, undefined)];
976
-
977
932
  default:
978
933
  return [Op[operator](field, value)];
979
934
  }
980
935
  };
981
-
982
936
  const between = (field, value) => {
983
937
  const handle = betweenValue => {
984
938
  const valArr = betweenValue.split('--');
985
-
986
939
  if (valArr.length > 1) {
987
940
  const [minimum, maximum] = valArr;
988
941
  return Op.between(field, minimum, maximum);
@@ -992,17 +945,14 @@ const between = (field, value) => {
992
945
  return false;
993
946
  }
994
947
  };
995
-
996
948
  if (value.length === 0) return [];
997
949
  if (Array.isArray(value)) return [Op.or(...value.map(handle).filter(bc => bc !== false))];
998
950
  const op = handle(value);
999
951
  return op ? [op] : [];
1000
952
  };
1001
-
1002
953
  const distanceWithin = (field, value) => {
1003
954
  const handle = distanceValue => {
1004
955
  const valArr = distanceValue.split(' ');
1005
-
1006
956
  if (valArr.length > 1) {
1007
957
  const [lat, lon] = valArr;
1008
958
  return Op.distanceWithin(field, Number(lat), Number(lon), (valArr === null || valArr === void 0 ? void 0 : valArr[2]) || '10mi');
@@ -1012,28 +962,27 @@ const distanceWithin = (field, value) => {
1012
962
  return false;
1013
963
  }
1014
964
  };
1015
-
1016
965
  if (value.length === 0) return [];
1017
966
  if (Array.isArray(value)) return [Op.or(...value.map(handle).filter(bc => bc !== false))];
1018
967
  const op = handle(value);
1019
968
  return op ? [op] : [];
1020
969
  };
970
+
1021
971
  /**
1022
972
  * Accept HTTP style objects and map them to
1023
973
  * their equivalent JS client "Op" expressions
1024
974
  * @param {array} where the where array as you'd provide it to the HTTP API
1025
975
  * @returns {array} array of constructed Delivery API Operators
1026
976
  */
1027
-
1028
-
1029
977
  const customWhereExpressions = where => {
1030
- if (!where || !Array.isArray(where)) return []; // Map each clause inside the where array
978
+ if (!where || !Array.isArray(where)) return [];
1031
979
 
980
+ // Map each clause inside the where array
1032
981
  return where.map(clause => {
1033
- let expression; // Map through each property in the clause so we can
982
+ let expression;
983
+ // Map through each property in the clause so we can
1034
984
  // capture the values required and reconstruct them as
1035
985
  // a Delivery API expression
1036
-
1037
986
  let operator;
1038
987
  Object.keys(clause).map((key, idx) => {
1039
988
  // The clause may contain only one key
@@ -1041,7 +990,6 @@ const customWhereExpressions = where => {
1041
990
  const field = clause.field;
1042
991
  const value = clause[Object.keys(clause).find(k => !['field', 'weight'].includes(k)) || ''];
1043
992
  const weight = clause.weight;
1044
-
1045
993
  if (idx === 0) {
1046
994
  if (operator === 'and' || operator === 'or') {
1047
995
  // These are array expressions so we can call ourself recursively
@@ -1049,24 +997,21 @@ const customWhereExpressions = where => {
1049
997
  const recurseExpr = customWhereExpressions(clause[operator]);
1050
998
  expression = Op[operator](...recurseExpr);
1051
999
  }
1052
-
1053
1000
  if (['not'].includes(operator)) {
1054
1001
  // A 'not' expression is an object with only one inner field and inner operator
1055
1002
  Object.keys(value).map((notKey, notIdx) => {
1056
1003
  const innerOperator = notKey;
1057
1004
  const innerValue = value[notKey];
1058
- const innerField = value.field; // Map the expression when we've looped and scoped to
1005
+ const innerField = value.field;
1006
+ // Map the expression when we've looped and scoped to
1059
1007
  // the second property inside the clause
1060
-
1061
1008
  if (notIdx === 1) expression = Op.not(makeJsExpression(innerOperator, innerField, innerValue));
1062
1009
  });
1063
1010
  }
1064
- } // Map the expression when we've looped and scoped to
1011
+ }
1012
+ // Map the expression when we've looped and scoped to
1065
1013
  // the second property inside the clause
1066
-
1067
-
1068
1014
  operator = Object.keys(clause).find(clauseKey => !['field', 'weight'].includes(clauseKey));
1069
-
1070
1015
  if (idx === 1) {
1071
1016
  expression = makeJsExpression(operator, field, value);
1072
1017
  if (typeof weight === 'number') expression = expression.weight(weight);
@@ -1075,28 +1020,29 @@ const customWhereExpressions = where => {
1075
1020
  return expression;
1076
1021
  });
1077
1022
  };
1078
-
1079
1023
  const makeJsExpression = (operator, field, value) => operator === 'freeText' || operator === 'contains' ? Op[operator](field, value) : operator === 'in' ? Op[operator](field, ...value) : operator === 'exists' ? Op[operator](field, value) : operator === 'between' ? Op[operator](field, value[0], value[1]) : operator === 'distanceWithin' ? Op[operator](field, value === null || value === void 0 ? void 0 : value.lat, value === null || value === void 0 ? void 0 : value.lon, value === null || value === void 0 ? void 0 : value.distance) : Op[operator](field, value);
1080
-
1081
1024
  const termExpressions = (searchTerm, weightedSearchFields, fuzzySearch) => {
1082
1025
  if (searchTerm && weightedSearchFields && weightedSearchFields.length > 0) {
1083
1026
  // Extract any phrases in quotes to array
1084
- const quotedPhrases = extractQuotedPhrases(searchTerm); // Modify the search term to remove any quoted phrases to leave any remaining terms
1027
+ const quotedPhrases = extractQuotedPhrases(searchTerm);
1085
1028
 
1029
+ // Modify the search term to remove any quoted phrases to leave any remaining terms
1086
1030
  let modifiedSearchTerm = searchTerm;
1087
- quotedPhrases.forEach(qp => modifiedSearchTerm = modifiedSearchTerm.replace(qp, '').replace('""', '').trim()); // Push to the operators array to include in the query
1031
+ quotedPhrases.forEach(qp => modifiedSearchTerm = modifiedSearchTerm.replace(qp, '').replace('""', '').trim());
1088
1032
 
1089
- const operators = []; // Helper functions to generate Op expressions
1033
+ // Push to the operators array to include in the query
1034
+ const operators = [];
1090
1035
 
1036
+ // Helper functions to generate Op expressions
1091
1037
  const containsOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'contains', f.weight);
1038
+ const freeTextOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'freeText', f.weight, fuzzySearch);
1092
1039
 
1093
- const freeTextOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'freeText', f.weight, fuzzySearch); // For each weighted search field
1094
-
1095
-
1040
+ // For each weighted search field
1096
1041
  weightedSearchFields.forEach(wsf => {
1097
1042
  // Push to field operators
1098
- const fieldOperators = []; // Add operator expressions for modified search term
1043
+ const fieldOperators = [];
1099
1044
 
1045
+ // Add operator expressions for modified search term
1100
1046
  if (modifiedSearchTerm) {
1101
1047
  if ([Fields.keywords, Fields.sys.filename, Fields.sys.uri].includes(wsf.fieldId)) {
1102
1048
  fieldOperators.push(...containsOp(wsf, modifiedSearchTerm));
@@ -1107,20 +1053,22 @@ const termExpressions = (searchTerm, weightedSearchFields, fuzzySearch) => {
1107
1053
  fieldOperators.push(...freeTextOp(wsf, modifiedSearchTerm));
1108
1054
  }
1109
1055
  }
1110
- } // Add operator expressions for any quoted phrases
1056
+ }
1111
1057
 
1058
+ // Add operator expressions for any quoted phrases
1059
+ quotedPhrases.forEach(qp => fieldOperators.push(...containsOp(wsf, qp)));
1112
1060
 
1113
- quotedPhrases.forEach(qp => fieldOperators.push(...containsOp(wsf, qp))); // If we are using multiple operators for a field we will
1061
+ // If we are using multiple operators for a field we will
1114
1062
  // wrap each field inside an And operator so we will match
1115
1063
  // all terms/phrases rather than any terms/phrases
1116
-
1117
1064
  if (fieldOperators.length > 1) {
1118
1065
  operators.push(Op.and(...fieldOperators));
1119
1066
  } else {
1120
1067
  operators.push(...fieldOperators);
1121
1068
  }
1122
- }); // Wrap operators in an Or operator
1069
+ });
1123
1070
 
1071
+ // Wrap operators in an Or operator
1124
1072
  return [Op.or().addRange(operators).add(Op.freeText(Fields.searchContent, searchTerm, fuzzySearch))];
1125
1073
  } else if (searchTerm) {
1126
1074
  // Searching without weightedSearchFields defined will fall back
@@ -1180,11 +1128,9 @@ const searchQuery = ({
1180
1128
  const query = new Query(...expressions);
1181
1129
  if (!searchTerm) query.orderBy = orderByExpression(orderBy);
1182
1130
  if (dynamicOrderBy && dynamicOrderBy.length) query.orderBy = orderByExpression(dynamicOrderBy);
1183
-
1184
1131
  if (fields && fields.length > 0 && !isFeatured) {
1185
1132
  query.fields = fields;
1186
1133
  }
1187
-
1188
1134
  query.pageIndex = isFeatured ? 0 : pageIndex;
1189
1135
  query.pageSize = isFeatured && typeof featuredResults.count === 'number' ? featuredResults.count : pageSize;
1190
1136
  return query;
@@ -1205,7 +1151,6 @@ const mapEntriesToSearchResults = ({
1205
1151
  const mapperFunc = mapper || mappers && mappers.results;
1206
1152
  return items && typeof mapperFunc === 'function' ? mapperFunc(items, facet, context, state) : [];
1207
1153
  };
1208
-
1209
1154
  const facetTemplate = {
1210
1155
  type: () => SET_SEARCH_ENTRIES,
1211
1156
  context: 'action.context',
@@ -1248,11 +1193,9 @@ const facetTemplate = {
1248
1193
  pagesLoaded
1249
1194
  }) => {
1250
1195
  const loaded = [...(pagesLoaded || [])];
1251
-
1252
1196
  if (isNaN(loaded.find(l => l === pageIndex))) {
1253
1197
  loaded.push(pageIndex);
1254
1198
  }
1255
-
1256
1199
  return loaded.sort((a, b) => a - b);
1257
1200
  }
1258
1201
  },
@@ -1275,18 +1218,21 @@ const facetTemplate = {
1275
1218
  prevPageIndex
1276
1219
  } = action.queryParams;
1277
1220
  const results = mapEntriesToSearchResults(action, getItemsFromResult(result), state);
1278
- if (!loadMorePaging) return results; // add a _pageIndex property to the returned results to help us later
1221
+ if (!loadMorePaging) return results;
1279
1222
 
1223
+ // add a _pageIndex property to the returned results to help us later
1280
1224
  const nextResults = results.map((r, idx) => ({
1281
1225
  _pageIndex: pageIndex,
1282
1226
  _pagePosition: idx,
1283
1227
  ...r
1284
1228
  }));
1285
- const loadedPages = pagesLoaded || []; // if pageIndex is found in loadedPages, we have already loaded this page
1229
+ const loadedPages = pagesLoaded || [];
1286
1230
 
1287
- if (!isNaN(loadedPages.find(l => l === pageIndex))) return prevResults; // Determine where we put the results depending on if we
1288
- // are paging forwards, backwards, or doing a new search
1231
+ // if pageIndex is found in loadedPages, we have already loaded this page
1232
+ if (!isNaN(loadedPages.find(l => l === pageIndex))) return prevResults;
1289
1233
 
1234
+ // Determine where we put the results depending on if we
1235
+ // are paging forwards, backwards, or doing a new search
1290
1236
  const firstResultSet = pageIndex > prevPageIndex ? prevResults || [] : nextResults;
1291
1237
  const secondResultSet = pageIndex > prevPageIndex ? nextResults : prevResults || [];
1292
1238
  const onlyResultSet = loadedPages.length === 0 ? nextResults : false;
@@ -1317,13 +1263,11 @@ const filterTemplate = {
1317
1263
  if (payload && (payload.items || payload.children)) {
1318
1264
  const items = (payload.items || payload.children).map(item => {
1319
1265
  var _item$sys;
1320
-
1321
1266
  item.isSelected = selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.includes((item === null || item === void 0 ? void 0 : (_item$sys = item.sys) === null || _item$sys === void 0 ? void 0 : _item$sys.id) || item.key);
1322
1267
  return item;
1323
1268
  });
1324
1269
  return mapper(items);
1325
1270
  }
1326
-
1327
1271
  return [];
1328
1272
  }
1329
1273
  },
@@ -1346,22 +1290,22 @@ const filterExpressionMapper = {
1346
1290
  fieldOperator: 'fieldOperator',
1347
1291
  logicOperator: 'logicOperator'
1348
1292
  };
1349
-
1350
1293
  const mapFilterToFilterExpression = filter => mapJson(filter, filterExpressionMapper);
1351
1294
 
1352
1295
  const mapFiltersToFilterExpression = (filters, selectedFilters) => {
1353
1296
  if (!selectedFilters || Object.keys(selectedFilters).length === 0) return [];
1354
- const filterExpressions = []; // Iterate through the keys in selectedFilters and locate
1355
- // the items that are selected and queryable
1297
+ const filterExpressions = [];
1356
1298
 
1299
+ // Iterate through the keys in selectedFilters and locate
1300
+ // the items that are selected and queryable
1357
1301
  Object.entries(selectedFilters).map(([fkey, selectedValues]) => {
1358
1302
  const filter = filters[fkey];
1359
-
1360
1303
  if (selectedValues && filter) {
1361
1304
  // Where we have a value for a selectedFilter
1362
1305
  // and a filter is found for the current key
1363
1306
  // map the filter to a filterExpression object
1364
- const expr = mapFilterToFilterExpression({ ...filter,
1307
+ const expr = mapFilterToFilterExpression({
1308
+ ...filter,
1365
1309
  selectedValues
1366
1310
  });
1367
1311
  filterExpressions.push(expr);
@@ -1397,8 +1341,8 @@ const queryParamsTemplate = {
1397
1341
  context
1398
1342
  }) => {
1399
1343
  const stateFilters = getFilters(state, facet, context, 'js');
1400
- const selectedFilters = getSelectedFilters(state, facet, context, 'js'); // Use another mapping function to map the filter parameters for the query
1401
-
1344
+ const selectedFilters = getSelectedFilters(state, facet, context, 'js');
1345
+ // Use another mapping function to map the filter parameters for the query
1402
1346
  const filterParams = mapFiltersToFilterExpression(stateFilters, selectedFilters);
1403
1347
  return filterParams;
1404
1348
  },
@@ -1424,7 +1368,13 @@ const queryParamsTemplate = {
1424
1368
  if (action.type === UPDATE_PAGE_INDEX) return action.params.pageIndex;
1425
1369
  return !action.preload ? getPageIndex(state, action.facet, action.context) : 0;
1426
1370
  },
1427
- pageSize: root => getQueryParameter(root, 'pageSize'),
1371
+ pageSize: root => {
1372
+ const {
1373
+ action,
1374
+ state
1375
+ } = root;
1376
+ return getPageSize(state, action.facet, action.context) || getQueryParameter(root, 'pageSize');
1377
+ },
1428
1378
  pagesLoaded: ({
1429
1379
  state,
1430
1380
  facet,
@@ -1441,7 +1391,6 @@ const queryParamsTemplate = {
1441
1391
  context
1442
1392
  }) => {
1443
1393
  var _getFacet;
1444
-
1445
1394
  return ((_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId) || selectCurrentProject(state);
1446
1395
  },
1447
1396
  searchTerm: root => root.context !== Context.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
@@ -1456,11 +1405,12 @@ const queryParamsTemplate = {
1456
1405
  weightedSearchFields: root => {
1457
1406
  const wsf = getQueryParameter(root, 'weightedSearchFields', []);
1458
1407
  const deduped = wsf.filter((v, i, a) => a.findIndex(t => t.fieldId === v.fieldId) === i);
1459
- return deduped; // return wsf;
1408
+ return deduped;
1409
+ // return wsf;
1460
1410
  },
1411
+
1461
1412
  webpageTemplates: root => getQueryParameter(root, 'webpageTemplates', [])
1462
1413
  };
1463
-
1464
1414
  const mapStateToQueryParams = sourceJson => mapJson(sourceJson, queryParamsTemplate);
1465
1415
 
1466
1416
  /**
@@ -1474,9 +1424,9 @@ const generateQueryParams = (action, state) => {
1474
1424
  const {
1475
1425
  context,
1476
1426
  facet
1477
- } = action; // Map parameters using state and some additional
1427
+ } = action;
1428
+ // Map parameters using state and some additional
1478
1429
  // inputs from the action
1479
-
1480
1430
  const queryParams = mapStateToQueryParams({
1481
1431
  context,
1482
1432
  facet,
@@ -1485,12 +1435,12 @@ const generateQueryParams = (action, state) => {
1485
1435
  });
1486
1436
  return [queryParams, runSearch(action, state, queryParams)];
1487
1437
  };
1438
+
1488
1439
  /**
1489
1440
  * Checks if we have already loaded everything we're asking for and tells us to run the search or not
1490
1441
  * @param action
1491
1442
  * @param state
1492
1443
  */
1493
-
1494
1444
  const runSearch = (action, state, queryParams) => {
1495
1445
  const {
1496
1446
  context,
@@ -1502,12 +1452,14 @@ const runSearch = (action, state, queryParams) => {
1502
1452
  } = action;
1503
1453
  let willRun = false;
1504
1454
  const facetIsLoaded = defaultLang ? false : getIsLoaded(state, context, facet);
1505
- const stateParams = { ...getQueryParams(ogState, facet, context)
1455
+ const stateParams = {
1456
+ ...getQueryParams(ogState, facet, context)
1506
1457
  };
1507
1458
  stateParams.pageIndex = getPageIndex(ogState, facet, context);
1508
1459
  stateParams.searchTerm = getSearchTerm(ogState);
1509
-
1510
- if (context === Context.facets && ssr || // context === Context.minilist ||
1460
+ stateParams.pageSize = getPageSize(ogState, facet, context);
1461
+ if (context === Context.facets && ssr ||
1462
+ // context === Context.minilist ||
1511
1463
  preload || !facetIsLoaded || filterParamsChanged(action) || defaultLang) {
1512
1464
  willRun = true;
1513
1465
  } else {
@@ -1515,28 +1467,24 @@ const runSearch = (action, state, queryParams) => {
1515
1467
  // are the same as what we already have in state
1516
1468
  Object.entries(stateParams).forEach(([param, value]) => {
1517
1469
  const queryParam = queryParams[param];
1518
-
1519
1470
  if (JSON.stringify(value) !== JSON.stringify(queryParam)) {
1520
1471
  willRun = true;
1521
1472
  }
1522
1473
  });
1523
1474
  }
1524
-
1525
1475
  const internalPaging = getIsInternalPaging(ogState, facet, context);
1526
-
1527
1476
  if (internalPaging && facetIsLoaded) {
1528
1477
  willRun = false;
1529
1478
  }
1530
-
1531
1479
  return willRun;
1532
1480
  };
1481
+
1533
1482
  /**
1534
1483
  * This will tell us if filter parameters have been
1535
1484
  * changed by some external event such as a route change
1536
1485
  * @param action
1537
1486
  * @returns true or false
1538
1487
  */
1539
-
1540
1488
  const filterParamsChanged = (action, state) => {
1541
1489
  const {
1542
1490
  context,
@@ -1551,12 +1499,13 @@ const filterParamsChanged = (action, state) => {
1551
1499
  });
1552
1500
  return paramsChanged.filter(f => f === true).length > 0;
1553
1501
  };
1554
- /* eslint-disable no-console */
1555
1502
 
1503
+ /* eslint-disable no-console */
1556
1504
  const debugExecuteSearch = (action, state) => {
1557
1505
  const [queryParams, runSearch] = generateQueryParams(action, state);
1558
1506
  console.log('runSearch', runSearch, 'action', action, 'filterParamsChanged', filterParamsChanged(action, state), 'getIsLoaded(state, context, facet)', getIsLoaded(state, action.context, action.facet));
1559
- const stateParams = { ...getQueryParams(action.ogState || state, action.facet, action.context),
1507
+ const stateParams = {
1508
+ ...getQueryParams(action.ogState || state, action.facet, action.context),
1560
1509
  pageIndex: getPageIndex(action.ogState || state, action.facet, action.context),
1561
1510
  searchTerm: getSearchTerm(action.ogState || state)
1562
1511
  };
@@ -1567,10 +1516,11 @@ const scrollTop = scrollYPos => {
1567
1516
  if (typeof window !== 'undefined') window.scrollTo(0, scrollYPos);
1568
1517
  };
1569
1518
 
1519
+ // *** FILTER ITEM MAPPING ***
1520
+
1570
1521
  // Base mapping, fields that are the same across all mappings
1571
1522
  // to save repeating these elements in every mapper, spread this
1572
1523
  // into your discrete mappings
1573
-
1574
1524
  const base = {
1575
1525
  contentTypeId: Fields.sys.contentTypeId,
1576
1526
  title: 'entryTitle',
@@ -1578,16 +1528,13 @@ const base = {
1578
1528
  path: 'sys.slug',
1579
1529
  isSelected: 'isSelected'
1580
1530
  };
1581
-
1582
1531
  const mapEntriesToFilterItems = entries => {
1583
1532
  if (!entries) return [];
1584
1533
  return entries.map(entry => {
1585
1534
  const template = base;
1586
-
1587
1535
  if (template) {
1588
1536
  return mapJson(entry, template);
1589
1537
  }
1590
-
1591
1538
  return entry;
1592
1539
  });
1593
1540
  };
@@ -1616,10 +1563,8 @@ const mapQueryParamsToCustomApi = queryParams => {
1616
1563
  return mapJson(queryParams, customApiMapping);
1617
1564
  };
1618
1565
 
1619
- const searchSagas = [takeEvery(CLEAR_FILTERS, clearFilters), takeEvery(DO_SEARCH, doSearch), takeEvery(SET_ROUTE_FILTERS, loadFilters), takeEvery(SET_SEARCH_ENTRIES, preloadOtherFacets), takeEvery(UPDATE_CURRENT_FACET, updateCurrentFacet), takeEvery(UPDATE_CURRENT_TAB, updateCurrentTab), takeEvery(UPDATE_PAGE_INDEX, updatePageIndex), takeEvery(UPDATE_SEARCH_TERM, updateSearchTerm), takeEvery(UPDATE_SORT_ORDER, updateSortOrder), takeEvery(UPDATE_SELECTED_FILTERS, applySearchFilter)];
1620
-
1566
+ const searchSagas = [takeEvery(CLEAR_FILTERS, clearFilters), takeEvery(DO_SEARCH, doSearch), takeEvery(SET_ROUTE_FILTERS, loadFilters), takeEvery(SET_SEARCH_ENTRIES, preloadOtherFacets), takeEvery(UPDATE_CURRENT_FACET, updateCurrentFacet), takeEvery(UPDATE_CURRENT_TAB, updateCurrentTab), takeEvery(UPDATE_PAGE_INDEX, updatePageIndex), takeEvery(UPDATE_PAGE_SIZE, updatePageSize), takeEvery(UPDATE_SEARCH_TERM, updateSearchTerm), takeEvery(UPDATE_SORT_ORDER, updateSortOrder), takeEvery(UPDATE_SELECTED_FILTERS, applySearchFilter)];
1621
1567
  const toJS = obj => obj && 'toJS' in obj && typeof obj.toJS === 'function' ? obj.toJS() : obj;
1622
-
1623
1568
  function* setRouteFilters(action) {
1624
1569
  const {
1625
1570
  mappers,
@@ -1630,17 +1575,17 @@ function* setRouteFilters(action) {
1630
1575
  } = action;
1631
1576
  const context = listingType ? Context.listings : Context.facets;
1632
1577
  const state = toJS(yield select());
1633
- const ssr = getIsSsr(state); // Get current facet from params or state
1578
+ const ssr = getIsSsr(state);
1634
1579
 
1635
- let currentFacet = params && params.facet || listingType; // Pick the default facet from initialState
1580
+ // Get current facet from params or state
1581
+ let currentFacet = params && params.facet || listingType;
1636
1582
 
1583
+ // Pick the default facet from initialState
1637
1584
  if (!currentFacet) {
1638
1585
  var _Object$keys;
1639
-
1640
1586
  const tabs = getSearchTabs(state, 'js');
1641
1587
  currentFacet = (tabs === null || tabs === void 0 ? void 0 : tabs[0].defaultFacet) || ((_Object$keys = Object.keys(getFacets(state, 'js'))) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0]) || '';
1642
1588
  }
1643
-
1644
1589
  const nextAction = {
1645
1590
  type: SET_ROUTE_FILTERS,
1646
1591
  context,
@@ -1651,48 +1596,50 @@ function* setRouteFilters(action) {
1651
1596
  ssr,
1652
1597
  debug
1653
1598
  };
1654
- yield put(nextAction); // keep track of this state ref for comparing changes to params later
1599
+ yield put(nextAction);
1655
1600
 
1601
+ // keep track of this state ref for comparing changes to params later
1656
1602
  const ogState = {
1657
1603
  search: state.search
1658
- }; // Using call instead of triggering from the put
1659
- // to allow this exported saga to continue during SSR
1604
+ };
1660
1605
 
1661
- yield call(ensureSearch, { ...nextAction,
1606
+ // Using call instead of triggering from the put
1607
+ // to allow this exported saga to continue during SSR
1608
+ yield call(ensureSearch, {
1609
+ ...nextAction,
1662
1610
  ogState
1663
1611
  });
1664
1612
  }
1665
1613
  function* doSearch(action) {
1666
1614
  var _action$params;
1667
-
1668
1615
  const state = toJS(yield select());
1669
-
1670
1616
  if (action.config) {
1671
1617
  // If the action contains a config object, we can add this to the
1672
1618
  // state at runtime
1673
- yield put({ ...action,
1619
+ yield put({
1620
+ ...action,
1674
1621
  type: APPLY_CONFIG
1675
1622
  });
1676
1623
  }
1677
-
1678
- const nextAction = { ...action,
1624
+ const nextAction = {
1625
+ ...action,
1679
1626
  type: SET_SEARCH_FILTERS,
1680
1627
  ssr: getIsSsr(state),
1681
1628
  facet: action.facet || ((_action$params = action.params) === null || _action$params === void 0 ? void 0 : _action$params.facet)
1682
1629
  };
1683
-
1684
1630
  if (nextAction.facet && (action.config || Object.keys(getFacet(state, nextAction.facet, action.context, 'js')).length > 0)) {
1685
- yield put(nextAction); // keep track of this state ref for comparing changes to params later
1631
+ yield put(nextAction);
1686
1632
 
1633
+ // keep track of this state ref for comparing changes to params later
1687
1634
  const ogState = {
1688
1635
  search: state.search
1689
1636
  };
1690
- yield call(ensureSearch, { ...nextAction,
1637
+ yield call(ensureSearch, {
1638
+ ...nextAction,
1691
1639
  ogState
1692
1640
  });
1693
1641
  }
1694
1642
  }
1695
-
1696
1643
  function* loadFilters(action) {
1697
1644
  const {
1698
1645
  facet: facetKey,
@@ -1700,7 +1647,6 @@ function* loadFilters(action) {
1700
1647
  mappers = {}
1701
1648
  } = action;
1702
1649
  const filtersToLoad = yield select(getFiltersToLoad, facetKey, context, 'js');
1703
-
1704
1650
  if (filtersToLoad.length > 0) {
1705
1651
  yield put({
1706
1652
  type: LOAD_FILTERS,
@@ -1726,7 +1672,6 @@ function* loadFilters(action) {
1726
1672
  if (filtersToLoadSagas) yield all(filtersToLoadSagas);
1727
1673
  }
1728
1674
  }
1729
-
1730
1675
  function* loadFilter(action) {
1731
1676
  const {
1732
1677
  facetKey,
@@ -1752,7 +1697,6 @@ function* loadFilter(action) {
1752
1697
  selectedKeys,
1753
1698
  mapper
1754
1699
  };
1755
-
1756
1700
  try {
1757
1701
  if (contentTypeId) {
1758
1702
  const versionStatus = yield select(selectVersionStatus);
@@ -1762,7 +1706,6 @@ function* loadFilter(action) {
1762
1706
  if (payload.type === 'error') throw payload;
1763
1707
  createStateFrom.payload = payload;
1764
1708
  }
1765
-
1766
1709
  if (path) {
1767
1710
  const payload = yield cachedSearch.getTaxonomyNodeByPath(path, projectId);
1768
1711
  if (!payload) throw new Error(`No payload returned for taxonomy path: '${path}'`);
@@ -1773,35 +1716,33 @@ function* loadFilter(action) {
1773
1716
  createStateFrom.type = LOAD_FILTERS_ERROR;
1774
1717
  createStateFrom.error = error;
1775
1718
  }
1776
-
1777
1719
  const nextAction = mapJson(createStateFrom, filterTemplate);
1778
1720
  yield put(nextAction);
1779
1721
  }
1780
-
1781
1722
  function* ensureSearch(action) {
1782
1723
  const {
1783
1724
  context,
1784
1725
  facet,
1785
1726
  debug
1786
1727
  } = action;
1787
-
1788
1728
  try {
1789
1729
  const state = yield select();
1790
- const nextAction = { ...action,
1730
+ const nextAction = {
1731
+ ...action,
1791
1732
  ogState: action.ogState || {
1792
1733
  search: state.search
1793
1734
  }
1794
1735
  };
1795
1736
  const [queryParams, runSearch] = generateQueryParams(nextAction, state);
1796
1737
  if (debug && (debug === true || debug.executeSearch)) debugExecuteSearch(nextAction, state);
1797
-
1798
1738
  if (runSearch) {
1799
1739
  yield put({
1800
1740
  type: EXECUTE_SEARCH,
1801
1741
  facet,
1802
1742
  context
1803
1743
  });
1804
- yield call(executeSearch, { ...nextAction,
1744
+ yield call(executeSearch, {
1745
+ ...nextAction,
1805
1746
  context,
1806
1747
  facet,
1807
1748
  queryParams,
@@ -1813,7 +1754,6 @@ function* ensureSearch(action) {
1813
1754
  log.error(...['Error running search saga:', error, error.stack]);
1814
1755
  }
1815
1756
  }
1816
-
1817
1757
  function* executeSearch(action) {
1818
1758
  const {
1819
1759
  context,
@@ -1821,14 +1761,12 @@ function* executeSearch(action) {
1821
1761
  queryParams,
1822
1762
  mappers
1823
1763
  } = action;
1824
-
1825
1764
  try {
1826
1765
  const state = yield select();
1827
1766
  let result = {};
1828
1767
  let featuredResult;
1829
1768
  let featuredQuery;
1830
1769
  const customApi = getCustomApi(state, facet, context, 'js');
1831
-
1832
1770
  if (customApi) {
1833
1771
  const apiParams = typeof mappers === 'object' && typeof mappers.customApi === 'function' && mappers.customApi(queryParams) || mapQueryParamsToCustomApi(queryParams);
1834
1772
  result.payload = yield callCustomApi(customApi, apiParams);
@@ -1836,19 +1774,16 @@ function* executeSearch(action) {
1836
1774
  } else {
1837
1775
  if (queryParams.featuredResults) {
1838
1776
  featuredQuery = searchQuery(queryParams, true);
1839
- featuredResult = yield timedSearch(featuredQuery, queryParams.linkDepth, queryParams.projectId, queryParams.env); // eslint-disable-next-line require-atomic-updates
1840
-
1777
+ featuredResult = yield timedSearch(featuredQuery, queryParams.linkDepth, queryParams.projectId, queryParams.env);
1778
+ // eslint-disable-next-line require-atomic-updates
1841
1779
  queryParams.excludeIds = getItemsFromResult(featuredResult).map(fi => {
1842
1780
  var _fi$sys;
1843
-
1844
1781
  return fi === null || fi === void 0 ? void 0 : (_fi$sys = fi.sys) === null || _fi$sys === void 0 ? void 0 : _fi$sys.id;
1845
1782
  }).filter(fi => typeof fi === 'string');
1846
1783
  }
1847
-
1848
1784
  const query = searchQuery(queryParams);
1849
1785
  result = yield timedSearch(query, queryParams.linkDepth, queryParams.projectId, queryParams.env);
1850
1786
  }
1851
-
1852
1787
  const createStateFrom = {
1853
1788
  action,
1854
1789
  featuredResult,
@@ -1864,7 +1799,6 @@ function* executeSearch(action) {
1864
1799
  log.error(...['Error running search saga:', error, error.stack]);
1865
1800
  }
1866
1801
  }
1867
-
1868
1802
  function* preloadOtherFacets(action) {
1869
1803
  const {
1870
1804
  preload,
@@ -1874,18 +1808,19 @@ function* preloadOtherFacets(action) {
1874
1808
  } = action;
1875
1809
  const state = yield select();
1876
1810
  const currentFacet = getCurrentFacet(state);
1877
-
1878
1811
  if (!preload && facet === currentFacet && context !== Context.listings) {
1879
1812
  const allFacets = getFacets(state, 'js');
1880
1813
  const otherFacets = Object.keys(allFacets).filter(f => f !== currentFacet);
1881
1814
  yield all(otherFacets.map((preloadFacet = '') => {
1882
- const preloadAction = { ...action,
1815
+ const preloadAction = {
1816
+ ...action,
1883
1817
  facet: preloadFacet,
1884
1818
  preload: true
1885
1819
  };
1886
1820
  const [queryParams, runSearch] = generateQueryParams(preloadAction, state);
1887
1821
  if (debug && (debug === true || debug.preloadOtherFacets)) debugExecuteSearch(preloadAction, state);
1888
- return runSearch && call(executeSearch, { ...action,
1822
+ return runSearch && call(executeSearch, {
1823
+ ...action,
1889
1824
  type: EXECUTE_SEARCH_PRELOAD,
1890
1825
  preload: true,
1891
1826
  facet: preloadFacet,
@@ -1894,7 +1829,6 @@ function* preloadOtherFacets(action) {
1894
1829
  }));
1895
1830
  }
1896
1831
  }
1897
-
1898
1832
  function* updateCurrentTab(action) {
1899
1833
  const {
1900
1834
  id,
@@ -1904,19 +1838,16 @@ function* updateCurrentTab(action) {
1904
1838
  const facets = getFacets(state, 'js');
1905
1839
  const tabs = getSearchTabs(state, 'js');
1906
1840
  let nextFacet = tabs === null || tabs === void 0 ? void 0 : tabs[id].currentFacet;
1907
-
1908
1841
  if (!nextFacet) {
1909
1842
  Object.entries(facets).map(([facetName, facet]) => {
1910
1843
  if (facet.tabId === id && (tabs === null || tabs === void 0 ? void 0 : tabs[id].defaultFacet) === facetName) nextFacet = facetName;
1911
1844
  });
1912
- } // If the next Tab does not have a defaultFacet,
1845
+ }
1846
+ // If the next Tab does not have a defaultFacet,
1913
1847
  // take the first facet for that tab
1914
-
1915
-
1916
1848
  if (!nextFacet) nextFacet = Object.entries(facets).filter(([, f]) => f.tabId === id)[0][0];
1917
1849
  yield put(withMappers(updateCurrentFacet$1(nextFacet), mappers));
1918
1850
  }
1919
-
1920
1851
  function* clearFilters(action) {
1921
1852
  const {
1922
1853
  mappers
@@ -1924,7 +1855,6 @@ function* clearFilters(action) {
1924
1855
  const uri = yield buildUri({}, mappers);
1925
1856
  yield put(navigate(uri));
1926
1857
  }
1927
-
1928
1858
  function* updateCurrentFacet(action) {
1929
1859
  const {
1930
1860
  facet,
@@ -1937,7 +1867,6 @@ function* updateCurrentFacet(action) {
1937
1867
  }, mappers);
1938
1868
  yield put(navigate(uri));
1939
1869
  }
1940
-
1941
1870
  function* updateSearchTerm(action) {
1942
1871
  const {
1943
1872
  term,
@@ -1948,7 +1877,6 @@ function* updateSearchTerm(action) {
1948
1877
  }, mappers);
1949
1878
  yield put(navigate(uri));
1950
1879
  }
1951
-
1952
1880
  function* updateSortOrder(action) {
1953
1881
  const {
1954
1882
  orderBy,
@@ -1961,7 +1889,6 @@ function* updateSortOrder(action) {
1961
1889
  }, mappers);
1962
1890
  yield put(navigate(uri));
1963
1891
  }
1964
-
1965
1892
  function* updatePageIndex(action) {
1966
1893
  const {
1967
1894
  pageIndex,
@@ -1974,7 +1901,18 @@ function* updatePageIndex(action) {
1974
1901
  yield put(navigate(uri));
1975
1902
  if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
1976
1903
  }
1977
-
1904
+ function* updatePageSize(action) {
1905
+ const {
1906
+ pageSize,
1907
+ mappers,
1908
+ scrollYPos
1909
+ } = action;
1910
+ const uri = yield buildUri({
1911
+ pageSize
1912
+ }, mappers);
1913
+ yield put(navigate(uri));
1914
+ if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
1915
+ }
1978
1916
  function* applySearchFilter(action) {
1979
1917
  const {
1980
1918
  mappers,
@@ -1984,11 +1922,11 @@ function* applySearchFilter(action) {
1984
1922
  yield put(navigate(uri));
1985
1923
  if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
1986
1924
  }
1987
-
1988
1925
  function* buildUri({
1989
1926
  facet,
1990
1927
  orderBy,
1991
1928
  pageIndex = 0,
1929
+ pageSize,
1992
1930
  term
1993
1931
  }, mappers) {
1994
1932
  const state = yield select();
@@ -1998,12 +1936,12 @@ function* buildUri({
1998
1936
  facet,
1999
1937
  orderBy,
2000
1938
  pageIndex,
1939
+ pageSize,
2001
1940
  term
2002
- }); // return uri;
2003
-
1941
+ });
1942
+ // return uri;
2004
1943
  return `${uri.path}${uri.search && `?${uri.search}` || ''}${uri.hash && `#${uri.hash}` || ''}`;
2005
1944
  }
2006
-
2007
1945
  function* triggerMinilistSsr(options) {
2008
1946
  yield call(doSearch, {
2009
1947
  type: DO_SEARCH,
@@ -2017,5 +1955,5 @@ function* triggerSearchSsr(options) {
2017
1955
  yield call(setRouteFilters, options);
2018
1956
  }
2019
1957
 
2020
- export { APPLY_CONFIG as $, clearFilters$1 as A, updateCurrentFacet$1 as B, updateCurrentTab$1 as C, updatePageIndex$1 as D, updateSearchTerm$1 as E, updateSelectedFilters as F, updateSortOrder$1 as G, selectListing as H, mapStateToSearchUri as I, Context as J, selectFacets as K, triggerSearch as L, getFilters as M, toArray as N, UPDATE_SELECTED_FILTERS as O, UPDATE_SEARCH_TERM as P, UPDATE_PAGE_INDEX as Q, SET_SEARCH_ENTRIES as R, SET_SEARCH_FILTERS as S, SET_ROUTE_FILTERS as T, UPDATE_SORT_ORDER as U, LOAD_FILTERS_COMPLETE as V, LOAD_FILTERS_ERROR as W, LOAD_FILTERS as X, EXECUTE_SEARCH_ERROR as Y, EXECUTE_SEARCH as Z, CLEAR_FILTERS as _, customWhereExpressions as a, actions as a0, selectors as a1, types as a2, expressions as a3, queries as a4, doSearch as a5, setRouteFilters as a6, searchSagas as a7, triggerListingSsr as a8, triggerMinilistSsr as a9, triggerSearchSsr as aa, routeParams as ab, getPageIndex as b, contentTypeIdExpression as c, defaultExpressions as d, getCurrentTab as e, filterExpressions as f, getCurrentFacet as g, getFacet as h, getTabFacets as i, getFacetsTotalCount as j, getFacetTitles as k, getFeaturedResults as l, getRenderableFilters as m, getIsLoading as n, orderByExpression as o, getPaging as p, getPageIsLoading as q, getResults as r, getSearchTerm as s, termExpressions as t, getSearchTotalCount as u, getSelectedFilters as v, getQueryParameter as w, getTabsAndFacets as x, getTotalCount as y, withMappers as z };
2021
- //# sourceMappingURL=sagas-8d8945e6.js.map
1958
+ export { EXECUTE_SEARCH as $, clearFilters$1 as A, updateCurrentFacet$1 as B, updateCurrentTab$1 as C, updatePageIndex$1 as D, updatePageSize$1 as E, updateSearchTerm$1 as F, updateSelectedFilters as G, updateSortOrder$1 as H, selectListing as I, mapStateToSearchUri as J, Context as K, selectFacets as L, triggerSearch as M, getFilters as N, toArray as O, UPDATE_SELECTED_FILTERS as P, UPDATE_SEARCH_TERM as Q, UPDATE_PAGE_SIZE as R, UPDATE_PAGE_INDEX as S, SET_SEARCH_FILTERS as T, UPDATE_SORT_ORDER as U, SET_SEARCH_ENTRIES as V, SET_ROUTE_FILTERS as W, LOAD_FILTERS_COMPLETE as X, LOAD_FILTERS_ERROR as Y, LOAD_FILTERS as Z, EXECUTE_SEARCH_ERROR as _, customWhereExpressions as a, CLEAR_FILTERS as a0, APPLY_CONFIG as a1, actions as a2, selectors as a3, types as a4, expressions as a5, queries as a6, doSearch as a7, setRouteFilters as a8, searchSagas as a9, triggerListingSsr as aa, triggerMinilistSsr as ab, triggerSearchSsr as ac, routeParams as ad, getPageIndex as b, contentTypeIdExpression as c, defaultExpressions as d, getCurrentTab as e, filterExpressions as f, getCurrentFacet as g, getFacet as h, getTabFacets as i, getFacetsTotalCount as j, getFacetTitles as k, getFeaturedResults as l, getRenderableFilters as m, getIsLoading as n, orderByExpression as o, getPaging as p, getPageIsLoading as q, getResults as r, getSearchTerm as s, termExpressions as t, getSearchTotalCount as u, getSelectedFilters as v, getQueryParameter as w, getTabsAndFacets as x, getTotalCount as y, withMappers as z };
1959
+ //# sourceMappingURL=sagas-53d2aefb.js.map