@zengenti/contensis-react-base 3.0.2-beta.2 → 3.0.2-beta.21

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-21a7d836.js} +120 -432
  2. package/cjs/App-21a7d836.js.map +1 -0
  3. package/cjs/ContensisDeliveryApi-c079b03a.js +231 -0
  4. package/cjs/ContensisDeliveryApi-c079b03a.js.map +1 -0
  5. package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-7f0d107a.js} +23 -37
  6. package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-7f0d107a.js.map} +1 -1
  7. package/cjs/{ToJs-a9a8522b.js → ToJs-6e9cfa69.js} +3 -4
  8. package/cjs/{ToJs-a9a8522b.js.map → ToJs-6e9cfa69.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 +1488 -272
  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-2a6b5be0.js} +64 -113
  18. package/cjs/login-2a6b5be0.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-8a20e424.js → sagas-e04b94c1.js} +225 -301
  26. package/cjs/sagas-e04b94c1.js.map +1 -0
  27. package/cjs/search.js +68 -94
  28. package/cjs/search.js.map +1 -1
  29. package/cjs/{selectors-656da4b7.js → selectors-bcca60f4.js} +89 -8
  30. package/cjs/selectors-bcca60f4.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-4077e706.js} +50 -159
  37. package/cjs/version-4077e706.js.map +1 -0
  38. package/cjs/version-fe28099e.js +98 -0
  39. package/cjs/version-fe28099e.js.map +1 -0
  40. package/esm/{App-640239d2.js → App-2af18a99.js} +102 -412
  41. package/esm/App-2af18a99.js.map +1 -0
  42. package/esm/ContensisDeliveryApi-5660ee0e.js +227 -0
  43. package/esm/ContensisDeliveryApi-5660ee0e.js.map +1 -0
  44. package/esm/{RouteLoader-5171c63f.js → RouteLoader-6eac364e.js} +22 -36
  45. package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-6eac364e.js.map} +1 -1
  46. package/esm/{ToJs-4e02a04d.js → ToJs-9b30636a.js} +3 -4
  47. package/esm/{ToJs-4e02a04d.js.map → ToJs-9b30636a.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 +1490 -274
  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-71ff3fcb.js} +63 -112
  57. package/esm/login-71ff3fcb.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-e576b6f6.js → sagas-933a8fc8.js} +177 -254
  65. package/esm/sagas-933a8fc8.js.map +1 -0
  66. package/esm/search.js +69 -95
  67. package/esm/search.js.map +1 -1
  68. package/esm/{selectors-a5e5835b.js → selectors-74de49a3.js} +75 -8
  69. package/esm/selectors-74de49a3.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-b15807c5.js +87 -0
  76. package/esm/version-b15807c5.js.map +1 -0
  77. package/esm/{version-e3a5ec66.js → version-ef107106.js} +37 -142
  78. package/esm/version-ef107106.js.map +1 -0
  79. package/models/redux/appstate.d.ts +1 -0
  80. package/models/routing/redux/selectors.d.ts +2 -1
  81. package/models/search/models/Queries.d.ts +2 -1
  82. package/models/search/models/Search.d.ts +2 -0
  83. package/models/search/models/SearchActions.d.ts +3 -3
  84. package/models/search/redux/actions.d.ts +6 -6
  85. package/models/search/redux/util.d.ts +1 -1
  86. package/models/search/search/expressions.d.ts +1 -1
  87. package/models/server/features/linkdepth-api/search.d.ts +1 -1
  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-8a20e424.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-e576b6f6.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
@@ -81,7 +81,8 @@ var types = /*#__PURE__*/Object.freeze({
81
81
  });
82
82
 
83
83
  const withMappers = (action, mappers) => {
84
- return { ...action,
84
+ return {
85
+ ...action,
85
86
  mappers
86
87
  };
87
88
  };
@@ -136,18 +137,18 @@ const clearFilters$1 = filterKey => {
136
137
  filterKey
137
138
  };
138
139
  };
139
- const updatePageIndex$1 = (pageIndex, scrollYPos) => {
140
+ const updatePageIndex$1 = (pageIndex, scrollToElement) => {
140
141
  return {
141
142
  type: UPDATE_PAGE_INDEX,
142
143
  pageIndex,
143
- scrollYPos
144
+ scrollToElement
144
145
  };
145
146
  };
146
- const updatePageSize$1 = (pageSize, scrollYPos) => {
147
+ const updatePageSize$1 = (pageSize, scrollToElement) => {
147
148
  return {
148
149
  type: UPDATE_PAGE_SIZE,
149
150
  pageSize,
150
- scrollYPos
151
+ scrollToElement
151
152
  };
152
153
  };
153
154
  const updateCurrentFacet$1 = facet => {
@@ -168,13 +169,13 @@ const updateSearchTerm$1 = term => {
168
169
  term
169
170
  };
170
171
  };
171
- const updateSelectedFilters = (filter, key, isUnknownItem = false, scrollYPos) => {
172
+ const updateSelectedFilters = (filter, key, isUnknownItem = false, scrollToElement) => {
172
173
  return {
173
174
  type: UPDATE_SELECTED_FILTERS,
174
175
  filter,
175
176
  key,
176
177
  isUnknownItem,
177
- scrollYPos
178
+ scrollToElement
178
179
  };
179
180
  };
180
181
  const updateSortOrder$1 = (orderBy, facet) => {
@@ -201,53 +202,47 @@ var actions = /*#__PURE__*/Object.freeze({
201
202
  updateSortOrder: updateSortOrder$1
202
203
  });
203
204
 
204
- exports.Context = void 0; // export type Context = 'facets' | 'listings' | 'minilist';
205
-
206
- (function (Context) {
205
+ let Context = /*#__PURE__*/function (Context) {
207
206
  Context["facets"] = "facets";
208
207
  Context["listings"] = "listings";
209
208
  Context["minilist"] = "minilist";
210
- })(exports.Context || (exports.Context = {}));
209
+ return Context;
210
+ }({});
211
+ // export type Context = 'facets' | 'listings' | 'minilist';
211
212
 
213
+ // Find a fromJS function from global that is dynamically loaded in createStore
212
214
  // or replace with a stub function for non-immutable gets
213
-
214
215
  const makeFromJS = (returnType = globalThis.STATE_TYPE || 'immutable') => {
215
216
  var _immutable, _immutable2;
216
-
217
217
  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;
218
218
  };
219
-
220
219
  const getImmutableOrJS = (state, stateKey, fallbackValue, returnType = globalThis.STATE_TYPE || 'immutable') => {
221
220
  // Find a fromJS function from global that is dynamically loaded in createStore
222
221
  // or replace with a stub function for non-immutable gets
223
222
  const fromJS = makeFromJS(returnType);
224
-
225
223
  if (state && 'get' in state && typeof state.get === 'function' && 'getIn' in state && typeof state.getIn === 'function' && 'toJS' in state && typeof state.toJS === 'function') {
226
224
  if (Array.isArray(stateKey)) return fromJS(state.getIn(stateKey, fallbackValue));
227
225
  return fromJS(state.get(stateKey, fallbackValue));
228
226
  }
229
-
230
227
  if (Array.isArray(stateKey) && state && typeof state === 'object') {
231
228
  const result = mapJson.jpath(stateKey.join('.'), state);
232
229
  if (typeof result === 'undefined') return fallbackValue;
233
230
  return result;
234
231
  }
235
-
236
232
  const result = state && typeof state === 'object' ? state[stateKey] : undefined;
237
233
  if (typeof result === 'undefined') return fallbackValue;
238
234
  return result;
239
235
  };
240
236
 
241
- const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], exports.Context.facets);
242
- const getCurrent = (state, context = exports.Context.facets) => context === exports.Context.facets ? getCurrentFacet(state) : getCurrentListing(state);
237
+ const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context.facets);
238
+ const getCurrent = (state, context = Context.facets) => context === Context.facets ? getCurrentFacet(state) : getCurrentListing(state);
243
239
  const getCurrentFacet = state => getImmutableOrJS(state, ['search', 'currentFacet']);
244
240
  const getCurrentListing = state => getImmutableOrJS(state, ['search', 'currentListing']);
245
- const getCurrentTab = state => getImmutableOrJS(state, ['search', exports.Context.facets, getCurrentFacet(state), 'tabId'], 0);
246
- const getFacets = (state, returnType) => getImmutableOrJS(state, ['search', exports.Context.facets], {}, returnType);
241
+ const getCurrentTab = state => getImmutableOrJS(state, ['search', Context.facets, getCurrentFacet(state), 'tabId'], 0);
242
+ const getFacets = (state, returnType) => getImmutableOrJS(state, ['search', Context.facets], {}, returnType);
247
243
  const getTabFacets = state => Object.fromEntries(Object.entries(getFacets(state, 'js')).filter(([key]) => getImmutableOrJS(getFacets(state), [key, 'tabId'], 0) === getCurrentTab(state)));
248
244
  const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key, facet = {}]) => {
249
245
  var _facet$pagingInfo;
250
-
251
246
  return {
252
247
  isSelected: getCurrentFacet(state) === key,
253
248
  key,
@@ -255,28 +250,29 @@ const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key
255
250
  totalCount: (_facet$pagingInfo = facet.pagingInfo) === null || _facet$pagingInfo === void 0 ? void 0 : _facet$pagingInfo.totalCount
256
251
  };
257
252
  });
258
- const getFacet = (state, facetName = '', context = exports.Context.facets, returnType) => {
253
+ const getFacet = (state, facetName = '', context = Context.facets, returnType) => {
259
254
  const currentFacet = facetName || getCurrentFacet(state);
260
255
  return getImmutableOrJS(state, ['search', context, currentFacet], {}, returnType);
261
256
  };
262
257
  const getListing = (state, listing = '') => {
263
258
  const currentListing = listing || getCurrentListing(state);
264
- return getImmutableOrJS(state, ['search', exports.Context.listings, currentListing], {});
259
+ return getImmutableOrJS(state, ['search', Context.listings, currentListing], {});
265
260
  };
266
- const getFilters = (state, facet, context = exports.Context.facets, returnType) => {
261
+ const getFilters = (state, facet, context = Context.facets, returnType) => {
267
262
  return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'filters'], {}, returnType);
268
263
  };
269
- const getRenderableFilters = (state, facet = '', context = exports.Context.facets) => Object.fromEntries(Object.entries(getFilters(state, facet, context, 'js')).filter(([, f = {}]) => typeof f.renderable !== 'boolean' ? true : f.renderable));
270
- const getFiltersToLoad = (state, facet, context = exports.Context.facets, returnType) => {
264
+ const getRenderableFilters = (state, facet = '', context = Context.facets) => Object.fromEntries(Object.entries(getFilters(state, facet, context, 'js')).filter(([, f = {}]) => typeof f.renderable !== 'boolean' ? true : f.renderable));
265
+ const getFiltersToLoad = (state, facet, context = Context.facets, returnType) => {
271
266
  const filters = getFilters(state, facet, context, returnType);
272
267
  const loadedFilters = Object.entries(filters).map(([key, f = {}]) => [key, (f.items || []).filter(i => {
273
268
  const title = i === null || i === void 0 ? void 0 : i.title;
274
269
  return typeof title !== 'undefined' && !!title;
275
270
  }).length > 0 && (f.isError || false) === false]);
276
271
  return loadedFilters.map(([filterKey, isLoaded]) => !isLoaded ? filterKey : null).filter(f => !!f);
277
- }; // We lowercase the filter key unless it's an ISO date string where the T must be uppercase
272
+ };
278
273
 
279
- const getSelectedFilters = (state, facet = '', context = exports.Context.facets, returnType) => {
274
+ // We lowercase the filter key unless it's an ISO date string where the T must be uppercase
275
+ const getSelectedFilters = (state, facet = '', context = Context.facets, returnType) => {
280
276
  const filters = getFilters(state, facet, context, 'js');
281
277
  const isoDateRegex = RegExp(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d/);
282
278
  const selectedFilters = Object.fromEntries(Object.entries(filters).map(([key, filter = {}]) => [key, (filter.items || []).filter(item => !!(item.isSelected || false)).map(item => {
@@ -287,60 +283,61 @@ const getSelectedFilters = (state, facet = '', context = exports.Context.facets,
287
283
  const fromJS = makeFromJS(returnType);
288
284
  return fromJS(selectedFilters);
289
285
  };
290
- const getResults = (state, current = '', context = exports.Context.facets, returnType) => {
286
+ const getResults = (state, current = '', context = Context.facets, returnType) => {
291
287
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'results'], [], returnType);
292
288
  };
293
- const getIsInternalPaging = (state, current, context = exports.Context.facets) => {
289
+ const getIsInternalPaging = (state, current, context = Context.facets) => {
294
290
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams', 'internalPaging'], false);
295
291
  };
296
- const getIsLoaded = (state, context = exports.Context.facets, facet) => {
292
+ const getIsLoaded = (state, context = Context.facets, facet) => {
297
293
  return !!getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'queryDuration'], 0);
298
294
  };
299
- const getIsLoading = (state, context = exports.Context.facets, facet) => {
295
+ const getIsLoading = (state, context = Context.facets, facet) => {
300
296
  return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'entries', 'isLoading']);
301
297
  };
302
298
  const getIsSsr = state => getImmutableOrJS(state, ['search', 'config', 'ssr'], false);
303
- const getFeaturedResults = (state, current = '', context = exports.Context.facets, returnType) => {
299
+ const getFeaturedResults = (state, current = '', context = Context.facets, returnType) => {
304
300
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'featuredResults'], [], returnType);
305
301
  };
306
- const getPaging = (state, current = '', context = exports.Context.facets, returnType) => {
302
+ const getPaging = (state, current = '', context = Context.facets, returnType) => {
307
303
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo'], {}, returnType);
308
304
  };
309
- const getPageIndex = (state, current = '', context = exports.Context.facets) => {
305
+ const getPageIndex = (state, current = '', context = Context.facets) => {
310
306
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageIndex']);
311
307
  };
312
- const getPageSize = (state, current = '', context = exports.Context.facets) => {
308
+ const getPageSize = (state, current = '', context = Context.facets) => {
313
309
  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
314
310
  );
315
311
  };
316
- const getPrevPageIndex = (state, current = '', context = exports.Context.facets) => {
312
+
313
+ const getPrevPageIndex = (state, current = '', context = Context.facets) => {
317
314
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'prevPageIndex']);
318
315
  };
319
- const getPageIsLoading = (state, current = '', context = exports.Context.facets) => {
316
+ const getPageIsLoading = (state, current = '', context = Context.facets) => {
320
317
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'isLoading']);
321
318
  };
322
- const getPagesLoaded = (state, current = '', context = exports.Context.facets) => {
319
+ const getPagesLoaded = (state, current = '', context = Context.facets) => {
323
320
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
324
321
  };
325
- const getTotalCount = (state, current = '', context = exports.Context.facets) => {
322
+ const getTotalCount = (state, current = '', context = Context.facets) => {
326
323
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'totalCount']);
327
324
  };
328
325
  const getSearchTerm = state => getImmutableOrJS(state, ['search', 'term']);
329
326
  const getSearchTabs = (state, returnType) => getImmutableOrJS(state, ['search', 'tabs'], [], returnType);
330
- const getQueryParams = (state, current = '', context = exports.Context.facets) => {
327
+ const getQueryParams = (state, current = '', context = Context.facets) => {
331
328
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams'], {}, 'js');
332
329
  };
333
330
  const getQueryParameter = ({
334
331
  state,
335
332
  facet,
336
- context = exports.Context.facets
333
+ context = Context.facets
337
334
  }, key, ifnull = null) => {
338
335
  return getImmutableOrJS(getQueryParams(state, facet, context), key, ifnull, 'js');
339
336
  };
340
- const getCustomApi = (state, current, context = exports.Context.facets, returnType) => {
337
+ const getCustomApi = (state, current, context = Context.facets, returnType) => {
341
338
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'customApi'], null, returnType);
342
339
  };
343
- const getCustomEnv = (state, current, context = exports.Context.facets) => {
340
+ const getCustomEnv = (state, current, context = Context.facets) => {
344
341
  return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'env']);
345
342
  };
346
343
  const getTabsAndFacets = (state, returnType) => {
@@ -355,8 +352,9 @@ const getTabsAndFacets = (state, returnType) => {
355
352
  if (!countFields || countFields.find((f = []) => (f === null || f === void 0 ? void 0 : f[0]) === facetName)) return getImmutableOrJS(facet, ['pagingInfo', 'totalCount']);
356
353
  return 0;
357
354
  }).reduce((a, b) => a + b, 0);
358
- return { ...tab,
359
- [exports.Context.facets]: Object.fromEntries(thisTabFacets),
355
+ return {
356
+ ...tab,
357
+ [Context.facets]: Object.fromEntries(thisTabFacets),
360
358
  totalCount: thisTabTotal
361
359
  };
362
360
  });
@@ -372,12 +370,12 @@ const getFacetsTotalCount = state => {
372
370
  const facets = getFacets(state);
373
371
  const wholeSearchTotal = Object.entries(facets).map(([, t = {}]) => {
374
372
  var _t$pagingInfo;
375
-
376
373
  return ((_t$pagingInfo = t.pagingInfo) === null || _t$pagingInfo === void 0 ? void 0 : _t$pagingInfo.totalCount) || 0;
377
374
  }).reduce((a, b) => a + b, 0);
378
375
  return wholeSearchTotal;
379
- }; // An exported copy of the relevant selectors scoped by default to a facets context
376
+ };
380
377
 
378
+ // An exported copy of the relevant selectors scoped by default to a facets context
381
379
  const selectFacets = {
382
380
  getCurrent: getCurrentFacet,
383
381
  getCurrentTab,
@@ -396,14 +394,14 @@ const selectFacets = {
396
394
  getPageIsLoading,
397
395
  getPagesLoaded,
398
396
  getPaging,
399
- getQueryParams: (state, facet) => getQueryParams(state, facet, exports.Context.facets),
397
+ getQueryParams: (state, facet) => getQueryParams(state, facet, Context.facets),
400
398
  getQueryParameter: ({
401
399
  state,
402
400
  facet
403
401
  }, key, ifnull) => getQueryParameter({
404
402
  state,
405
403
  facet,
406
- context: exports.Context.facets
404
+ context: Context.facets
407
405
  }, key, ifnull),
408
406
  getRenderableFilters,
409
407
  getResults,
@@ -414,34 +412,35 @@ const selectFacets = {
414
412
  getSearchTerm,
415
413
  getSearchTotalCount,
416
414
  getSelectedFilters
417
- }; // An exported copy of the relevant selectors pre-scoped to a listing context
415
+ };
418
416
 
417
+ // An exported copy of the relevant selectors pre-scoped to a listing context
419
418
  const selectListing = {
420
419
  getCurrent: getCurrentListing,
421
- getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, exports.Context.listings, 'js'),
422
- getFilters: (state, listing = '') => getFilters(state, listing, exports.Context.listings, 'js'),
423
- getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, exports.Context.listings),
420
+ getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, Context.listings, 'js'),
421
+ getFilters: (state, listing = '') => getFilters(state, listing, Context.listings, 'js'),
422
+ getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, Context.listings),
424
423
  getListing,
425
- getIsLoaded: state => getIsLoaded(state, exports.Context.listings),
426
- getIsLoading: state => getIsLoading(state, exports.Context.listings),
427
- getPageIndex: (state, listing = '') => getPageIndex(state, listing, exports.Context.listings),
428
- getPaging: (state, listing = '') => getPaging(state, listing, exports.Context.listings, 'js'),
429
- getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing, exports.Context.listings),
430
- getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, exports.Context.listings),
431
- getQueryParams: (state, listing = '') => getQueryParams(state, listing, exports.Context.listings),
424
+ getIsLoaded: state => getIsLoaded(state, Context.listings),
425
+ getIsLoading: state => getIsLoading(state, Context.listings),
426
+ getPageIndex: (state, listing = '') => getPageIndex(state, listing, Context.listings),
427
+ getPaging: (state, listing = '') => getPaging(state, listing, Context.listings, 'js'),
428
+ getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing, Context.listings),
429
+ getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, Context.listings),
430
+ getQueryParams: (state, listing = '') => getQueryParams(state, listing, Context.listings),
432
431
  getQueryParameter: ({
433
432
  state,
434
433
  facet
435
434
  }, key, ifnull) => getQueryParameter({
436
435
  state,
437
436
  facet,
438
- context: exports.Context.listings
437
+ context: Context.listings
439
438
  }, key, ifnull),
440
- getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, exports.Context.listings),
441
- getResults: (state, listing = '') => getResults(state, listing, exports.Context.listings, 'js'),
439
+ getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, Context.listings),
440
+ getResults: (state, listing = '') => getResults(state, listing, Context.listings, 'js'),
442
441
  getSearchTerm,
443
- getTotalCount: (state, listing = '') => getTotalCount(state, listing, exports.Context.listings),
444
- getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, exports.Context.listings, 'js')
442
+ getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context.listings),
443
+ getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context.listings, 'js')
445
444
  };
446
445
  const selectCurrentPath = state => getImmutableOrJS(state, ['routing', 'currentPath']);
447
446
  const selectCurrentProject = state => getImmutableOrJS(state, ['routing', 'currentProject']);
@@ -496,31 +495,23 @@ const now = () => {
496
495
  if (typeof window == 'undefined') {
497
496
  return Date.now();
498
497
  }
499
-
500
498
  return window.performance.now();
501
499
  };
502
500
 
503
501
  const getClientConfig = (project, env) => {
504
- let config = DELIVERY_API_CONFIG;
505
- /* global DELIVERY_API_CONFIG */
506
-
502
+ let config = DELIVERY_API_CONFIG; /* global DELIVERY_API_CONFIG */
507
503
  if (project) {
508
504
  config.projectId = project;
509
505
  }
510
-
511
- if (typeof window != 'undefined' && PROXY_DELIVERY_API
512
- /* global PROXY_DELIVERY_API */
513
- ) {
506
+ if (typeof window != 'undefined' && PROXY_DELIVERY_API /* global PROXY_DELIVERY_API */) {
514
507
  // ensure a relative url is used to bypass the need for CORS (separate OPTIONS calls)
515
508
  config.rootUrl = env || '';
516
509
  config.responseHandler = {
517
510
  404: () => null
518
511
  };
519
512
  }
520
-
521
513
  return config;
522
514
  };
523
-
524
515
  class CacheNode {
525
516
  constructor(key, value) {
526
517
  this.key = key;
@@ -528,9 +519,7 @@ class CacheNode {
528
519
  this.next = null;
529
520
  this.prev = null;
530
521
  }
531
-
532
522
  }
533
-
534
523
  class LruCache {
535
524
  constructor(limit = 100) {
536
525
  this.map = {};
@@ -539,7 +528,6 @@ class LruCache {
539
528
  this.limit = limit || 100;
540
529
  this.size = 0;
541
530
  }
542
-
543
531
  get(key) {
544
532
  if (this.map[key]) {
545
533
  let value = this.map[key].value;
@@ -549,10 +537,8 @@ class LruCache {
549
537
  return value;
550
538
  }
551
539
  }
552
-
553
540
  set(key, value) {
554
541
  let node = new CacheNode(key, value);
555
-
556
542
  if (this.map[key]) {
557
543
  this.remove(key);
558
544
  } else {
@@ -563,60 +549,46 @@ class LruCache {
563
549
  this.tail.next = null;
564
550
  }
565
551
  }
566
-
567
552
  this.setHead(node);
568
553
  }
569
-
570
554
  setHead(node) {
571
555
  node.next = this.head;
572
556
  node.prev = null;
573
-
574
557
  if (this.head) {
575
558
  this.head.prev = node;
576
559
  }
577
-
578
560
  this.head = node;
579
-
580
561
  if (!this.tail) {
581
562
  this.tail = node;
582
563
  }
583
-
584
564
  this.size++;
585
565
  this.map[node.key] = node;
586
566
  }
587
-
588
567
  remove(key) {
589
568
  let node = this.map[key];
590
-
591
569
  if (node.prev) {
592
570
  node.prev.next = node.next;
593
571
  } else {
594
572
  this.head = node.next;
595
573
  }
596
-
597
574
  if (node.next) {
598
575
  node.next.prev = node.prev;
599
576
  } else {
600
577
  this.tail = node.prev;
601
578
  }
602
-
603
579
  delete this.map[key];
604
580
  this.size--;
605
581
  }
606
-
607
582
  }
608
-
609
583
  class CachedSearch {
610
584
  constructor() {
611
585
  this.cache = new LruCache();
612
586
  this.taxonomyLookup = {};
613
587
  }
614
-
615
588
  search(query, linkDepth, project, env) {
616
589
  const client = contensisDeliveryApi.Client.create(getClientConfig(project, env));
617
590
  return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
618
591
  }
619
-
620
592
  getTaxonomyNodeByPath(path, project, env) {
621
593
  const client = contensisDeliveryApi.Client.create(getClientConfig(project, env));
622
594
  return this.request(`[TAXONOMY NODE] ${path}`, () => client.taxonomy.getNodeByPath({
@@ -625,7 +597,6 @@ class CachedSearch {
625
597
  childDepth: 2
626
598
  }).then(node => this.extendTaxonomyNode(node)));
627
599
  }
628
-
629
600
  request(key, execute) {
630
601
  if (!this.cache.get(key) || typeof window == 'undefined') {
631
602
  let promise = execute();
@@ -634,41 +605,36 @@ class CachedSearch {
634
605
  this.cache.remove(key);
635
606
  });
636
607
  }
637
-
638
608
  return this.cache.get(key);
639
609
  }
640
-
641
610
  extendTaxonomyNode(node) {
642
611
  let id = this.getTaxonomyId(node);
643
612
  this.taxonomyLookup[id] = node.key;
644
- return { ...node,
613
+ return {
614
+ ...node,
645
615
  id,
646
616
  children: node.children ? node.children.map(n => this.extendTaxonomyNode(n)) : null
647
617
  };
648
618
  }
649
-
650
619
  getTaxonomyId(node) {
651
620
  if (node.key) {
652
621
  let parts = node.key.split('/');
653
622
  return parts[parts.length - 1];
654
623
  }
655
-
656
624
  return '';
657
625
  }
658
-
659
626
  fetch(uri, opts = {}) {
660
627
  return this.request(`[FETCH] ${uri} ${JSON.stringify(opts)}`, () => fetch(uri, opts));
661
628
  }
662
-
663
629
  }
664
-
665
630
  const cachedSearch = new CachedSearch();
666
631
 
667
632
  // eslint-disable-next-line import/default
668
633
  function fixFreeTextForElastic(s) {
669
634
  const illegalChars = ['>', '<', '=', '|', '!', '{', '}', '[', ']', '^', '~', '*', '?', ':', '\\', '/'];
670
635
  const illegalRegEx = new RegExp(illegalChars.map(c => '\\' + c).join('|'), 'g');
671
- s = s.replace(illegalRegEx, ''); // s = s.replace(encodedRegEx, ''); // (m) => '\\\\' + m);
636
+ s = s.replace(illegalRegEx, '');
637
+ // s = s.replace(encodedRegEx, ''); // (m) => '\\\\' + m);
672
638
 
673
639
  return s;
674
640
  }
@@ -688,13 +654,11 @@ const getItemsFromResult = result => {
688
654
  const {
689
655
  payload
690
656
  } = result || {};
691
-
692
657
  if (payload) {
693
658
  if (Array.isArray(payload)) return payload;
694
659
  if (Array.isArray(payload.items)) return payload.items;
695
660
  return payload;
696
661
  }
697
-
698
662
  return [];
699
663
  };
700
664
  const extractQuotedPhrases = searchTerm => {
@@ -706,6 +670,7 @@ const buildUrl = (route, params) => {
706
670
  const path = qs ? `${route}${route.includes('?') ? '&' : '?'}${qs}` : route;
707
671
  return path;
708
672
  };
673
+
709
674
  /**
710
675
  * Returns all params from the current route query string or static route
711
676
  * Supply static route argument if reading parameters from the route path
@@ -714,15 +679,14 @@ const buildUrl = (route, params) => {
714
679
  * @param location location object containing at least pathname and search
715
680
  * @returns Keyed params object
716
681
  */
717
-
718
682
  const routeParams = (staticRoute, location) => {
719
683
  var _staticRoute$match;
720
-
721
684
  // match.params is react-router-config/react-router@5 style
722
685
  // params is supplied with RouteObject in react-router@6
723
686
  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) || {};
724
687
  const queryParams = queryString.parse(typeof window !== 'undefined' ? window.location.search : (location === null || location === void 0 ? void 0 : location.search) || '');
725
- return { ...pathParams,
688
+ return {
689
+ ...pathParams,
726
690
  ...queryParams
727
691
  };
728
692
  };
@@ -730,13 +694,11 @@ const callCustomApi = async (customApi, filters) => {
730
694
  const apiUri = customApi.uri || '';
731
695
  let uri = buildUrl(apiUri, filters);
732
696
  if (!uri) throw new Error('uri is required to use customApi');
733
-
734
697
  if (typeof window == 'undefined') {
735
698
  if (!uri.startsWith('http')) uri = `http://localhost:3001${uri}`;
736
699
  const response = await fetch(uri);
737
700
  return await response.json();
738
701
  }
739
-
740
702
  const response = await cachedSearch.fetch(uri);
741
703
  return await response.clone().json();
742
704
  };
@@ -744,32 +706,27 @@ const removeEmptyAttributes = obj => {
744
706
  Object.entries(obj).forEach(([key, val]) => val && typeof val === 'object' && removeEmptyAttributes(val) || (typeof val === 'undefined' || val === null || val === '') && delete obj[key]);
745
707
  return obj;
746
708
  };
747
- const toArray = (obj, seperator = ',') => typeof obj === 'undefined' || obj === null ? obj : Array.isArray(obj) ? obj : obj.split(seperator); // assumes array elements are primitive types
709
+ const toArray = (obj, seperator = ',') => typeof obj === 'undefined' || obj === null ? obj : Array.isArray(obj) ? obj : obj.split(seperator);
748
710
 
711
+ // assumes array elements are primitive types
749
712
  const areArraysEqualSets = (a1, a2) => {
750
713
  const superSet = {};
751
-
752
714
  for (const ai of a1) {
753
715
  const e = ai + typeof ai;
754
716
  superSet[e] = 1;
755
717
  }
756
-
757
718
  for (const ai of a2) {
758
719
  const e = ai + typeof ai;
759
-
760
720
  if (!superSet[e]) {
761
721
  return false;
762
722
  }
763
-
764
723
  superSet[e] = 2;
765
724
  }
766
-
767
725
  for (const e in superSet) {
768
726
  if (superSet[e] === 1) {
769
727
  return false;
770
728
  }
771
729
  }
772
-
773
730
  return true;
774
731
  };
775
732
 
@@ -780,12 +737,12 @@ const searchUriTemplate = {
780
737
  }) => {
781
738
  const context = getSearchContext(state);
782
739
  const currentPath = selectCurrentPath(state) || '/search';
783
-
784
740
  if (context !== 'listings') {
785
741
  const currentFacet = facet || getCurrentFacet(state);
786
742
  const filters = getSelectedFilters(state, facet, context);
787
- const currentFilter = filters.contentTypeId; // Check if we have a filter first
743
+ const currentFilter = filters.contentTypeId;
788
744
 
745
+ // Check if we have a filter first
789
746
  const newPath = (currentFilter === null || currentFilter === void 0 ? void 0 : currentFilter.length) > 0 && currentFacet ? `${currentPath}/${currentFacet}/${currentFilter}` : currentFacet ? `${currentPath}/${currentFacet}` : currentPath;
790
747
  return newPath;
791
748
  } else {
@@ -800,29 +757,29 @@ const searchUriTemplate = {
800
757
  pageIndex,
801
758
  pageSize
802
759
  }) => {
803
- const searchContext = getSearchContext(state); // Lose stateFilters and currentSearch if a new
760
+ const searchContext = getSearchContext(state);
761
+ // Lose stateFilters and currentSearch if a new
804
762
  // term is passed via an argument
805
-
806
763
  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(',')]));
807
764
  const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
808
765
  const currentQs = removeEmptyAttributes(queryString.parse(currentSearch));
809
766
  if (orderBy) currentQs.orderBy = orderBy;
810
- const searchTerm = getSearchTerm(state); // Use Immutable's merge to merge the stateFilters with any current Qs
767
+ const searchTerm = getSearchTerm(state);
768
+ // Use Immutable's merge to merge the stateFilters with any current Qs
811
769
  // to build the new Qs.
812
-
813
770
  const mergedSearch = removeEmptyAttributes(merge__default["default"](currentQs, stateFilters));
814
771
  if (searchTerm) mergedSearch.term = searchTerm;
815
772
  if (pageIndex) mergedSearch.pageIndex = pageIndex + 1;
816
773
  if (pageIndex === 0) mergedSearch.pageIndex = undefined;
817
- if (pageSize) mergedSearch.pageSize = pageSize; // We don't want these as search params in the url, we just need the search package to see them
774
+ if (pageSize) mergedSearch.pageSize = pageSize;
818
775
 
776
+ // We don't want these as search params in the url, we just need the search package to see them
819
777
  return queryString.stringify(mergedSearch);
820
778
  },
821
779
  hash: ({
822
780
  state
823
781
  }) => getImmutableOrJS(state, ['routing', 'location', 'hash'], '').replace('#', '')
824
782
  };
825
-
826
783
  const mapStateToSearchUri = state => mapJson__default["default"](state, searchUriTemplate);
827
784
 
828
785
  const DataFormats = {
@@ -857,7 +814,8 @@ const Fields = {
857
814
 
858
815
  const fieldExpression = (field, value, operator = 'equalTo', weight, fuzzySearch = false) => {
859
816
  if (!field || !value || Array.isArray(value) && value.length === 0) return [];
860
- if (Array.isArray(field)) // If an array of fieldIds have been provided, call self for each fieldId
817
+ if (Array.isArray(field))
818
+ // If an array of fieldIds have been provided, call self for each fieldId
861
819
  // to generate expressions that are combined with an 'or' operator
862
820
  return [contensisCoreApi.Op.or(...field.map(fieldId => fieldExpression(fieldId, value, operator, weight, fuzzySearch)).flat())];
863
821
  if (operator === 'between') return between(field, value);
@@ -866,19 +824,15 @@ const fieldExpression = (field, value, operator = 'equalTo', weight, fuzzySearch
866
824
  const contentTypeIdExpression = (contentTypeIds, webpageTemplates, assetTypes) => {
867
825
  const expressions = [];
868
826
  if (!contentTypeIds && !webpageTemplates && !assetTypes) return expressions;
869
-
870
827
  if (contentTypeIds && contentTypeIds.length > 0) {
871
828
  expressions.push(...dataFormatExpression(contentTypeIds, DataFormats.entry));
872
829
  }
873
-
874
830
  if (webpageTemplates && webpageTemplates.length > 0) {
875
831
  expressions.push(...dataFormatExpression(webpageTemplates, DataFormats.webpage));
876
832
  }
877
-
878
833
  if (assetTypes && assetTypes.length > 0) {
879
834
  expressions.push(...dataFormatExpression(assetTypes, DataFormats.asset));
880
835
  }
881
-
882
836
  if (expressions.length > 1) return [contensisCoreApi.Op.or(...expressions)];
883
837
  return expressions;
884
838
  };
@@ -886,14 +840,16 @@ const filterExpressions = (filters, isOptional = false) => {
886
840
  if (!filters) return [];
887
841
  const expressions = [];
888
842
  filters.map(selectedFilter => {
889
- if (selectedFilter.logicOperator === 'and') // using 'and' logic operator we loop through each filter
843
+ if (selectedFilter.logicOperator === 'and')
844
+ // using 'and' logic operator we loop through each filter
890
845
  // and loop through all values to add an expression for each filter value
891
846
  selectedFilter.values.forEach(value => expressions.push(...fieldExpression(selectedFilter.key, value, selectedFilter.fieldOperator || 'equalTo')));else if (selectedFilter.logicOperator === 'not') {
892
847
  const fieldExpressions = fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in');
893
848
  fieldExpressions.forEach(expr => {
894
849
  expressions.push(contensisCoreApi.Op.not(expr));
895
850
  });
896
- } // using 'or' logic operator we loop over each filter
851
+ }
852
+ // using 'or' logic operator we loop over each filter
897
853
  // and simply add the array of values to an expression with an 'in' operator
898
854
  else expressions.push(...fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in'));
899
855
  if (isOptional) expressions.push(contensisCoreApi.Op.not(fieldExpression(selectedFilter.key, true, 'exists')[0]));
@@ -917,7 +873,6 @@ const dataFormatExpression = (contentTypeIds, dataFormat = DataFormats.entry) =>
917
873
  if (notContentTypeIds.length > 0 && notExpr) andExpr.add(notExpr);
918
874
  return [andExpr];
919
875
  }
920
-
921
876
  return [];
922
877
  };
923
878
  const featuredResultsExpression = ({
@@ -926,24 +881,22 @@ const featuredResultsExpression = ({
926
881
  fieldValue = true
927
882
  } = {}) => {
928
883
  const expressions = [];
929
-
930
884
  if (contentTypeId) {
931
885
  expressions.push(...contentTypeIdExpression(Array.isArray(contentTypeId) ? contentTypeId : [contentTypeId]));
932
886
  }
933
-
934
887
  if (fieldId && fieldValue) {
935
888
  expressions.push(...fieldExpression(fieldId, fieldValue));
936
889
  }
937
-
938
890
  return expressions;
939
891
  };
940
892
  const languagesExpression = languages => fieldExpression(Fields.sys.language, languages);
941
893
  const includeInSearchExpressions = (webpageTemplates, includeInSearchFields) => {
942
- const expressions = []; // Or include this expression if we have explicity specified non-default includeInSearch fields
894
+ const expressions = [];
895
+ // Or include this expression if we have explicity specified non-default includeInSearch fields
896
+ if (Array.isArray(includeInSearchFields)) expressions.push(...includeInSearchFields.map(includeInSearchField => contensisCoreApi.Op.or(contensisCoreApi.Op.and(contensisCoreApi.Op.exists(includeInSearchField, true), contensisCoreApi.Op.equalTo(includeInSearchField, true)), contensisCoreApi.Op.exists(includeInSearchField, false))));
943
897
 
944
- if (Array.isArray(includeInSearchFields)) expressions.push(...includeInSearchFields.map(includeInSearchField => contensisCoreApi.Op.or(contensisCoreApi.Op.and(contensisCoreApi.Op.exists(includeInSearchField, true), contensisCoreApi.Op.equalTo(includeInSearchField, true)), contensisCoreApi.Op.exists(includeInSearchField, false)))); // If webpageTemplates have been specified, include this expression
898
+ // If webpageTemplates have been specified, include this expression
945
899
  // with the default includeInSearch field from classic Contensis.
946
-
947
900
  if (Array.isArray(webpageTemplates) && webpageTemplates.length > 0) expressions.push(contensisCoreApi.Op.or(contensisCoreApi.Op.and(contensisCoreApi.Op.exists(Fields.sys.includeInSearch, true), contensisCoreApi.Op.equalTo(Fields.sys.includeInSearch, true)), contensisCoreApi.Op.exists(Fields.sys.includeInSearch, false)));
948
901
  return expressions;
949
902
  };
@@ -963,69 +916,52 @@ const excludeIdsExpression = excludeIds => {
963
916
  };
964
917
  const orderByExpression = orderBy => {
965
918
  let expression;
966
-
967
919
  if (orderBy && orderBy.length > 0) {
968
920
  expression = contensisCoreApi.OrderBy;
969
-
970
921
  for (const ob of orderBy) {
971
922
  var _expression, _expression2;
972
-
973
923
  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);
974
924
  }
975
925
  }
976
-
977
926
  return expression;
978
927
  };
979
-
980
928
  const equalToOrIn = (field, value, operator = 'equalTo', fuzzySearch = false) => {
981
929
  if (value.length === 0) return [];
982
-
983
930
  if (Array.isArray(value)) {
984
931
  if (operator === 'equalTo' || operator === 'in') return [contensisCoreApi.Op.in(field, ...value)];
985
932
  const expressions = value.map(innerValue => {
986
933
  var _between, _distanceWithin;
987
-
988
934
  switch (operator) {
989
935
  case 'between':
990
936
  return (_between = between(field, innerValue)) === null || _between === void 0 ? void 0 : _between[0];
991
-
992
937
  case 'distanceWithin':
993
938
  return (_distanceWithin = distanceWithin(field, innerValue)) === null || _distanceWithin === void 0 ? void 0 : _distanceWithin[0];
994
-
995
939
  case 'exists':
996
940
  return contensisCoreApi.Op.exists(field, innerValue);
997
-
998
941
  case 'freeText':
999
942
  // TODO: Potentially needs further implementation of new options
1000
943
  return contensisCoreApi.Op[operator](field, innerValue, fuzzySearch, undefined);
1001
-
1002
944
  default:
1003
945
  return contensisCoreApi.Op[operator](field, innerValue);
1004
946
  }
1005
947
  });
1006
948
  return (expressions === null || expressions === void 0 ? void 0 : expressions.length) > 1 ? [contensisCoreApi.Op.or(...expressions)] : expressions || [];
1007
949
  }
1008
-
1009
950
  switch (operator) {
1010
951
  case 'between':
1011
952
  return between(field, value);
1012
-
1013
953
  case 'distanceWithin':
1014
954
  return distanceWithin(field, value);
1015
-
1016
955
  case 'freeText':
1017
956
  // TODO: Potentially needs further implementation of new options
1018
957
  return [contensisCoreApi.Op.freeText(field, value, fuzzySearch, undefined)];
1019
-
1020
958
  default:
1021
959
  return [contensisCoreApi.Op[operator](field, value)];
1022
960
  }
1023
961
  };
1024
-
1025
962
  const between = (field, value) => {
1026
963
  const handle = betweenValue => {
1027
964
  const valArr = betweenValue.split('--');
1028
-
1029
965
  if (valArr.length > 1) {
1030
966
  const [minimum, maximum] = valArr;
1031
967
  return contensisCoreApi.Op.between(field, minimum, maximum);
@@ -1035,17 +971,14 @@ const between = (field, value) => {
1035
971
  return false;
1036
972
  }
1037
973
  };
1038
-
1039
974
  if (value.length === 0) return [];
1040
975
  if (Array.isArray(value)) return [contensisCoreApi.Op.or(...value.map(handle).filter(bc => bc !== false))];
1041
976
  const op = handle(value);
1042
977
  return op ? [op] : [];
1043
978
  };
1044
-
1045
979
  const distanceWithin = (field, value) => {
1046
980
  const handle = distanceValue => {
1047
981
  const valArr = distanceValue.split(' ');
1048
-
1049
982
  if (valArr.length > 1) {
1050
983
  const [lat, lon] = valArr;
1051
984
  return contensisCoreApi.Op.distanceWithin(field, Number(lat), Number(lon), (valArr === null || valArr === void 0 ? void 0 : valArr[2]) || '10mi');
@@ -1055,28 +988,27 @@ const distanceWithin = (field, value) => {
1055
988
  return false;
1056
989
  }
1057
990
  };
1058
-
1059
991
  if (value.length === 0) return [];
1060
992
  if (Array.isArray(value)) return [contensisCoreApi.Op.or(...value.map(handle).filter(bc => bc !== false))];
1061
993
  const op = handle(value);
1062
994
  return op ? [op] : [];
1063
995
  };
996
+
1064
997
  /**
1065
998
  * Accept HTTP style objects and map them to
1066
999
  * their equivalent JS client "Op" expressions
1067
1000
  * @param {array} where the where array as you'd provide it to the HTTP API
1068
1001
  * @returns {array} array of constructed Delivery API Operators
1069
1002
  */
1070
-
1071
-
1072
1003
  const customWhereExpressions = where => {
1073
- if (!where || !Array.isArray(where)) return []; // Map each clause inside the where array
1004
+ if (!where || !Array.isArray(where)) return [];
1074
1005
 
1006
+ // Map each clause inside the where array
1075
1007
  return where.map(clause => {
1076
- let expression; // Map through each property in the clause so we can
1008
+ let expression;
1009
+ // Map through each property in the clause so we can
1077
1010
  // capture the values required and reconstruct them as
1078
1011
  // a Delivery API expression
1079
-
1080
1012
  let operator;
1081
1013
  Object.keys(clause).map((key, idx) => {
1082
1014
  // The clause may contain only one key
@@ -1084,7 +1016,6 @@ const customWhereExpressions = where => {
1084
1016
  const field = clause.field;
1085
1017
  const value = clause[Object.keys(clause).find(k => !['field', 'weight'].includes(k)) || ''];
1086
1018
  const weight = clause.weight;
1087
-
1088
1019
  if (idx === 0) {
1089
1020
  if (operator === 'and' || operator === 'or') {
1090
1021
  // These are array expressions so we can call ourself recursively
@@ -1092,24 +1023,21 @@ const customWhereExpressions = where => {
1092
1023
  const recurseExpr = customWhereExpressions(clause[operator]);
1093
1024
  expression = contensisCoreApi.Op[operator](...recurseExpr);
1094
1025
  }
1095
-
1096
1026
  if (['not'].includes(operator)) {
1097
1027
  // A 'not' expression is an object with only one inner field and inner operator
1098
1028
  Object.keys(value).map((notKey, notIdx) => {
1099
1029
  const innerOperator = notKey;
1100
1030
  const innerValue = value[notKey];
1101
- const innerField = value.field; // Map the expression when we've looped and scoped to
1031
+ const innerField = value.field;
1032
+ // Map the expression when we've looped and scoped to
1102
1033
  // the second property inside the clause
1103
-
1104
1034
  if (notIdx === 1) expression = contensisCoreApi.Op.not(makeJsExpression(innerOperator, innerField, innerValue));
1105
1035
  });
1106
1036
  }
1107
- } // Map the expression when we've looped and scoped to
1037
+ }
1038
+ // Map the expression when we've looped and scoped to
1108
1039
  // the second property inside the clause
1109
-
1110
-
1111
1040
  operator = Object.keys(clause).find(clauseKey => !['field', 'weight'].includes(clauseKey));
1112
-
1113
1041
  if (idx === 1) {
1114
1042
  expression = makeJsExpression(operator, field, value);
1115
1043
  if (typeof weight === 'number') expression = expression.weight(weight);
@@ -1118,28 +1046,29 @@ const customWhereExpressions = where => {
1118
1046
  return expression;
1119
1047
  });
1120
1048
  };
1121
-
1122
1049
  const makeJsExpression = (operator, field, value) => operator === 'freeText' || operator === 'contains' ? contensisCoreApi.Op[operator](field, value) : operator === 'in' ? contensisCoreApi.Op[operator](field, ...value) : operator === 'exists' ? contensisCoreApi.Op[operator](field, value) : operator === 'between' ? contensisCoreApi.Op[operator](field, value[0], value[1]) : operator === 'distanceWithin' ? contensisCoreApi.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) : contensisCoreApi.Op[operator](field, value);
1123
-
1124
- const termExpressions = (searchTerm, weightedSearchFields, fuzzySearch) => {
1050
+ const termExpressions = (searchTerm, weightedSearchFields, fuzzySearch, omitSearchFields = []) => {
1125
1051
  if (searchTerm && weightedSearchFields && weightedSearchFields.length > 0) {
1126
1052
  // Extract any phrases in quotes to array
1127
- const quotedPhrases = extractQuotedPhrases(searchTerm); // Modify the search term to remove any quoted phrases to leave any remaining terms
1053
+ const quotedPhrases = extractQuotedPhrases(searchTerm);
1128
1054
 
1055
+ // Modify the search term to remove any quoted phrases to leave any remaining terms
1129
1056
  let modifiedSearchTerm = searchTerm;
1130
- quotedPhrases.forEach(qp => modifiedSearchTerm = modifiedSearchTerm.replace(qp, '').replace('""', '').trim()); // Push to the operators array to include in the query
1057
+ quotedPhrases.forEach(qp => modifiedSearchTerm = modifiedSearchTerm.replace(qp, '').replace('""', '').trim());
1131
1058
 
1132
- const operators = []; // Helper functions to generate Op expressions
1059
+ // Push to the operators array to include in the query
1060
+ const operators = [];
1133
1061
 
1062
+ // Helper functions to generate Op expressions
1134
1063
  const containsOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'contains', f.weight);
1064
+ const freeTextOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'freeText', f.weight, fuzzySearch);
1135
1065
 
1136
- const freeTextOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'freeText', f.weight, fuzzySearch); // For each weighted search field
1137
-
1138
-
1066
+ // For each weighted search field
1139
1067
  weightedSearchFields.forEach(wsf => {
1140
1068
  // Push to field operators
1141
- const fieldOperators = []; // Add operator expressions for modified search term
1069
+ const fieldOperators = [];
1142
1070
 
1071
+ // Add operator expressions for modified search term
1143
1072
  if (modifiedSearchTerm) {
1144
1073
  if ([Fields.keywords, Fields.sys.filename, Fields.sys.uri].includes(wsf.fieldId)) {
1145
1074
  fieldOperators.push(...containsOp(wsf, modifiedSearchTerm));
@@ -1150,25 +1079,41 @@ const termExpressions = (searchTerm, weightedSearchFields, fuzzySearch) => {
1150
1079
  fieldOperators.push(...freeTextOp(wsf, modifiedSearchTerm));
1151
1080
  }
1152
1081
  }
1153
- } // Add operator expressions for any quoted phrases
1082
+ }
1154
1083
 
1084
+ // Add operator expressions for any quoted phrases
1085
+ quotedPhrases.forEach(qp => fieldOperators.push(...containsOp(wsf, qp)));
1155
1086
 
1156
- quotedPhrases.forEach(qp => fieldOperators.push(...containsOp(wsf, qp))); // If we are using multiple operators for a field we will
1087
+ // If we are using multiple operators for a field we will
1157
1088
  // wrap each field inside an And operator so we will match
1158
1089
  // all terms/phrases rather than any terms/phrases
1159
-
1160
1090
  if (fieldOperators.length > 1) {
1161
1091
  operators.push(contensisCoreApi.Op.and(...fieldOperators));
1162
1092
  } else {
1163
1093
  operators.push(...fieldOperators);
1164
1094
  }
1165
- }); // Wrap operators in an Or operator
1095
+ });
1166
1096
 
1167
- return [contensisCoreApi.Op.or().addRange(operators).add(contensisCoreApi.Op.freeText(Fields.searchContent, searchTerm, fuzzySearch))];
1097
+ // Wrap operators in an Or operator
1098
+ const expressions = contensisCoreApi.Op.or().addRange(operators);
1099
+ if (!omitSearchFields.find(sf => sf === Fields.searchContent))
1100
+ // include "searchContent" field by default unless omitted
1101
+ return [expressions.add(contensisCoreApi.Op.freeText(Fields.searchContent, searchTerm, fuzzySearch))];else return [expressions];
1168
1102
  } else if (searchTerm) {
1169
1103
  // Searching without weightedSearchFields defined will fall back
1170
1104
  // to a default set of search fields with arbritary weights set.
1171
- return [contensisCoreApi.Op.or(contensisCoreApi.Op.equalTo(Fields.entryTitle, searchTerm).weight(10), contensisCoreApi.Op.freeText(Fields.entryTitle, searchTerm, fuzzySearch).weight(2), contensisCoreApi.Op.freeText(Fields.entryDescription, searchTerm, fuzzySearch).weight(2), contensisCoreApi.Op.contains(Fields.keywords, searchTerm).weight(2), contensisCoreApi.Op.contains(Fields.sys.uri, searchTerm).weight(2), contensisCoreApi.Op.contains(Fields.sys.allUris, searchTerm), contensisCoreApi.Op.freeText(Fields.searchContent, searchTerm, fuzzySearch))];
1105
+
1106
+ const exp = [];
1107
+ if (!omitSearchFields.find(sf => sf === Fields.entryTitle)) {
1108
+ exp.push(contensisCoreApi.Op.equalTo(Fields.entryTitle, searchTerm).weight(10));
1109
+ exp.push(contensisCoreApi.Op.freeText(Fields.entryTitle, searchTerm, fuzzySearch).weight(2));
1110
+ }
1111
+ if (!omitSearchFields.find(sf => sf === Fields.entryDescription)) exp.push(contensisCoreApi.Op.freeText(Fields.entryDescription, searchTerm, fuzzySearch).weight(2));
1112
+ if (!omitSearchFields.find(sf => sf === Fields.keywords)) exp.push(contensisCoreApi.Op.contains(Fields.keywords, searchTerm).weight(2));
1113
+ if (!omitSearchFields.find(sf => sf === Fields.sys.uri)) exp.push(contensisCoreApi.Op.contains(Fields.sys.uri, searchTerm).weight(2));
1114
+ if (!omitSearchFields.find(sf => sf === Fields.sys.allUris)) exp.push(contensisCoreApi.Op.contains(Fields.sys.allUris, searchTerm));
1115
+ if (!omitSearchFields.find(sf => sf === Fields.searchContent)) exp.push(contensisCoreApi.Op.freeText(Fields.searchContent, searchTerm, fuzzySearch));
1116
+ return [contensisCoreApi.Op.or(...exp)];
1172
1117
  } else {
1173
1118
  return [];
1174
1119
  }
@@ -1211,23 +1156,22 @@ const searchQuery = ({
1211
1156
  languages,
1212
1157
  pageSize,
1213
1158
  pageIndex,
1159
+ omitDefaultSearchFields,
1214
1160
  orderBy,
1215
1161
  searchTerm,
1216
1162
  versionStatus,
1217
1163
  webpageTemplates,
1218
1164
  weightedSearchFields
1219
1165
  }, isFeatured = false) => {
1220
- let expressions = [...termExpressions(searchTerm, weightedSearchFields, fuzzySearch), ...defaultExpressions(versionStatus), ...includeInSearchExpressions(webpageTemplates, includeInSearchFields), ...languagesExpression(languages), ...customWhereExpressions(customWhere), ...excludeIdsExpression(excludeIds)];
1166
+ let expressions = [...termExpressions(searchTerm, weightedSearchFields, fuzzySearch, omitDefaultSearchFields), ...defaultExpressions(versionStatus), ...includeInSearchExpressions(webpageTemplates, includeInSearchFields), ...languagesExpression(languages), ...customWhereExpressions(customWhere), ...excludeIdsExpression(excludeIds)];
1221
1167
  if (isFeatured) expressions = [...expressions, ...featuredResultsExpression(featuredResults)];
1222
1168
  if (!isFeatured || featuredResults && !featuredResults.contentTypeId) expressions = [...expressions, ...filterExpressions(filters), ...contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes)];
1223
1169
  const query = new contensisCoreApi.Query(...expressions);
1224
1170
  if (!searchTerm) query.orderBy = orderByExpression(orderBy);
1225
1171
  if (dynamicOrderBy && dynamicOrderBy.length) query.orderBy = orderByExpression(dynamicOrderBy);
1226
-
1227
1172
  if (fields && fields.length > 0 && !isFeatured) {
1228
1173
  query.fields = fields;
1229
1174
  }
1230
-
1231
1175
  query.pageIndex = isFeatured ? 0 : pageIndex;
1232
1176
  query.pageSize = isFeatured && typeof featuredResults.count === 'number' ? featuredResults.count : pageSize;
1233
1177
  return query;
@@ -1248,7 +1192,6 @@ const mapEntriesToSearchResults = ({
1248
1192
  const mapperFunc = mapper || mappers && mappers.results;
1249
1193
  return items && typeof mapperFunc === 'function' ? mapperFunc(items, facet, context, state) : [];
1250
1194
  };
1251
-
1252
1195
  const facetTemplate = {
1253
1196
  type: () => SET_SEARCH_ENTRIES,
1254
1197
  context: 'action.context',
@@ -1291,11 +1234,9 @@ const facetTemplate = {
1291
1234
  pagesLoaded
1292
1235
  }) => {
1293
1236
  const loaded = [...(pagesLoaded || [])];
1294
-
1295
1237
  if (isNaN(loaded.find(l => l === pageIndex))) {
1296
1238
  loaded.push(pageIndex);
1297
1239
  }
1298
-
1299
1240
  return loaded.sort((a, b) => a - b);
1300
1241
  }
1301
1242
  },
@@ -1318,18 +1259,21 @@ const facetTemplate = {
1318
1259
  prevPageIndex
1319
1260
  } = action.queryParams;
1320
1261
  const results = mapEntriesToSearchResults(action, getItemsFromResult(result), state);
1321
- if (!loadMorePaging) return results; // add a _pageIndex property to the returned results to help us later
1262
+ if (!loadMorePaging) return results;
1322
1263
 
1264
+ // add a _pageIndex property to the returned results to help us later
1323
1265
  const nextResults = results.map((r, idx) => ({
1324
1266
  _pageIndex: pageIndex,
1325
1267
  _pagePosition: idx,
1326
1268
  ...r
1327
1269
  }));
1328
- const loadedPages = pagesLoaded || []; // if pageIndex is found in loadedPages, we have already loaded this page
1270
+ const loadedPages = pagesLoaded || [];
1329
1271
 
1330
- if (!isNaN(loadedPages.find(l => l === pageIndex))) return prevResults; // Determine where we put the results depending on if we
1331
- // are paging forwards, backwards, or doing a new search
1272
+ // if pageIndex is found in loadedPages, we have already loaded this page
1273
+ if (!isNaN(loadedPages.find(l => l === pageIndex))) return prevResults;
1332
1274
 
1275
+ // Determine where we put the results depending on if we
1276
+ // are paging forwards, backwards, or doing a new search
1333
1277
  const firstResultSet = pageIndex > prevPageIndex ? prevResults || [] : nextResults;
1334
1278
  const secondResultSet = pageIndex > prevPageIndex ? nextResults : prevResults || [];
1335
1279
  const onlyResultSet = loadedPages.length === 0 ? nextResults : false;
@@ -1360,13 +1304,11 @@ const filterTemplate = {
1360
1304
  if (payload && (payload.items || payload.children)) {
1361
1305
  const items = (payload.items || payload.children).map(item => {
1362
1306
  var _item$sys;
1363
-
1364
1307
  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);
1365
1308
  return item;
1366
1309
  });
1367
1310
  return mapper(items);
1368
1311
  }
1369
-
1370
1312
  return [];
1371
1313
  }
1372
1314
  },
@@ -1389,22 +1331,22 @@ const filterExpressionMapper = {
1389
1331
  fieldOperator: 'fieldOperator',
1390
1332
  logicOperator: 'logicOperator'
1391
1333
  };
1392
-
1393
1334
  const mapFilterToFilterExpression = filter => mapJson__default["default"](filter, filterExpressionMapper);
1394
1335
 
1395
1336
  const mapFiltersToFilterExpression = (filters, selectedFilters) => {
1396
1337
  if (!selectedFilters || Object.keys(selectedFilters).length === 0) return [];
1397
- const filterExpressions = []; // Iterate through the keys in selectedFilters and locate
1398
- // the items that are selected and queryable
1338
+ const filterExpressions = [];
1399
1339
 
1340
+ // Iterate through the keys in selectedFilters and locate
1341
+ // the items that are selected and queryable
1400
1342
  Object.entries(selectedFilters).map(([fkey, selectedValues]) => {
1401
1343
  const filter = filters[fkey];
1402
-
1403
1344
  if (selectedValues && filter) {
1404
1345
  // Where we have a value for a selectedFilter
1405
1346
  // and a filter is found for the current key
1406
1347
  // map the filter to a filterExpression object
1407
- const expr = mapFilterToFilterExpression({ ...filter,
1348
+ const expr = mapFilterToFilterExpression({
1349
+ ...filter,
1408
1350
  selectedValues
1409
1351
  });
1410
1352
  filterExpressions.push(expr);
@@ -1440,8 +1382,8 @@ const queryParamsTemplate = {
1440
1382
  context
1441
1383
  }) => {
1442
1384
  const stateFilters = getFilters(state, facet, context, 'js');
1443
- const selectedFilters = getSelectedFilters(state, facet, context, 'js'); // Use another mapping function to map the filter parameters for the query
1444
-
1385
+ const selectedFilters = getSelectedFilters(state, facet, context, 'js');
1386
+ // Use another mapping function to map the filter parameters for the query
1445
1387
  const filterParams = mapFiltersToFilterExpression(stateFilters, selectedFilters);
1446
1388
  return filterParams;
1447
1389
  },
@@ -1457,6 +1399,7 @@ const queryParamsTemplate = {
1457
1399
  }) => action.defaultLang ? [action.defaultLang] : [],
1458
1400
  linkDepth: root => getQueryParameter(root, 'linkDepth', 0),
1459
1401
  loadMorePaging: root => getQueryParameter(root, 'loadMorePaging', false),
1402
+ omitDefaultSearchFields: root => getQueryParameter(root, 'omitDefaultSearchFields', []),
1460
1403
  orderBy: root => getQueryParameter(root, 'orderBy', []),
1461
1404
  pageIndex: root => {
1462
1405
  const {
@@ -1490,10 +1433,9 @@ const queryParamsTemplate = {
1490
1433
  context
1491
1434
  }) => {
1492
1435
  var _getFacet;
1493
-
1494
- return ((_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId) || selectCurrentProject(state);
1436
+ return ((_getFacet = getFacet(state, facet, context, 'js')) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId) || selectCurrentProject(state);
1495
1437
  },
1496
- searchTerm: root => root.context !== exports.Context.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
1438
+ searchTerm: root => root.context !== Context.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
1497
1439
  selectedFilters: ({
1498
1440
  state,
1499
1441
  facet,
@@ -1505,11 +1447,12 @@ const queryParamsTemplate = {
1505
1447
  weightedSearchFields: root => {
1506
1448
  const wsf = getQueryParameter(root, 'weightedSearchFields', []);
1507
1449
  const deduped = wsf.filter((v, i, a) => a.findIndex(t => t.fieldId === v.fieldId) === i);
1508
- return deduped; // return wsf;
1450
+ return deduped;
1451
+ // return wsf;
1509
1452
  },
1453
+
1510
1454
  webpageTemplates: root => getQueryParameter(root, 'webpageTemplates', [])
1511
1455
  };
1512
-
1513
1456
  const mapStateToQueryParams = sourceJson => mapJson__default["default"](sourceJson, queryParamsTemplate);
1514
1457
 
1515
1458
  /**
@@ -1523,9 +1466,9 @@ const generateQueryParams = (action, state) => {
1523
1466
  const {
1524
1467
  context,
1525
1468
  facet
1526
- } = action; // Map parameters using state and some additional
1469
+ } = action;
1470
+ // Map parameters using state and some additional
1527
1471
  // inputs from the action
1528
-
1529
1472
  const queryParams = mapStateToQueryParams({
1530
1473
  context,
1531
1474
  facet,
@@ -1534,12 +1477,12 @@ const generateQueryParams = (action, state) => {
1534
1477
  });
1535
1478
  return [queryParams, runSearch(action, state, queryParams)];
1536
1479
  };
1480
+
1537
1481
  /**
1538
1482
  * Checks if we have already loaded everything we're asking for and tells us to run the search or not
1539
1483
  * @param action
1540
1484
  * @param state
1541
1485
  */
1542
-
1543
1486
  const runSearch = (action, state, queryParams) => {
1544
1487
  const {
1545
1488
  context,
@@ -1551,13 +1494,14 @@ const runSearch = (action, state, queryParams) => {
1551
1494
  } = action;
1552
1495
  let willRun = false;
1553
1496
  const facetIsLoaded = defaultLang ? false : getIsLoaded(state, context, facet);
1554
- const stateParams = { ...getQueryParams(ogState, facet, context)
1497
+ const stateParams = {
1498
+ ...getQueryParams(ogState, facet, context)
1555
1499
  };
1556
1500
  stateParams.pageIndex = getPageIndex(ogState, facet, context);
1557
1501
  stateParams.searchTerm = getSearchTerm(ogState);
1558
1502
  stateParams.pageSize = getPageSize(ogState, facet, context);
1559
-
1560
- if (context === exports.Context.facets && ssr || // context === Context.minilist ||
1503
+ if (context === Context.facets && ssr ||
1504
+ // context === Context.minilist ||
1561
1505
  preload || !facetIsLoaded || filterParamsChanged(action) || defaultLang) {
1562
1506
  willRun = true;
1563
1507
  } else {
@@ -1565,28 +1509,24 @@ const runSearch = (action, state, queryParams) => {
1565
1509
  // are the same as what we already have in state
1566
1510
  Object.entries(stateParams).forEach(([param, value]) => {
1567
1511
  const queryParam = queryParams[param];
1568
-
1569
1512
  if (JSON.stringify(value) !== JSON.stringify(queryParam)) {
1570
1513
  willRun = true;
1571
1514
  }
1572
1515
  });
1573
1516
  }
1574
-
1575
1517
  const internalPaging = getIsInternalPaging(ogState, facet, context);
1576
-
1577
1518
  if (internalPaging && facetIsLoaded) {
1578
1519
  willRun = false;
1579
1520
  }
1580
-
1581
1521
  return willRun;
1582
1522
  };
1523
+
1583
1524
  /**
1584
1525
  * This will tell us if filter parameters have been
1585
1526
  * changed by some external event such as a route change
1586
1527
  * @param action
1587
1528
  * @returns true or false
1588
1529
  */
1589
-
1590
1530
  const filterParamsChanged = (action, state) => {
1591
1531
  const {
1592
1532
  context,
@@ -1601,26 +1541,36 @@ const filterParamsChanged = (action, state) => {
1601
1541
  });
1602
1542
  return paramsChanged.filter(f => f === true).length > 0;
1603
1543
  };
1604
- /* eslint-disable no-console */
1605
1544
 
1545
+ /* eslint-disable no-console */
1606
1546
  const debugExecuteSearch = (action, state) => {
1607
1547
  const [queryParams, runSearch] = generateQueryParams(action, state);
1608
1548
  console.log('runSearch', runSearch, 'action', action, 'filterParamsChanged', filterParamsChanged(action, state), 'getIsLoaded(state, context, facet)', getIsLoaded(state, action.context, action.facet));
1609
- const stateParams = { ...getQueryParams(action.ogState || state, action.facet, action.context),
1549
+ const stateParams = {
1550
+ ...getQueryParams(action.ogState || state, action.facet, action.context),
1610
1551
  pageIndex: getPageIndex(action.ogState || state, action.facet, action.context),
1611
1552
  searchTerm: getSearchTerm(action.ogState || state)
1612
1553
  };
1613
1554
  console.log(stateParams, queryParams);
1614
1555
  console.log('getSelectedFilters', getSelectedFilters(action.ogState || state, action.facet, action.context, 'js'), 'params', action.params);
1615
1556
  };
1616
- const scrollTop = scrollYPos => {
1617
- if (typeof window !== 'undefined') window.scrollTo(0, scrollYPos);
1557
+ const scrollTo = scrollToElement => {
1558
+ if (typeof window !== 'undefined') {
1559
+ if (typeof scrollToElement === 'number')
1560
+ // Used to be Y coordinate, deprecated, because it's not accessible
1561
+ console.warn('updatePageIndex arg2 needs string');else if (typeof scrollToElement === 'string') {
1562
+ /* Effectively simulates an anchor link. Needed for accessibility, as window.scrollTo
1563
+ does not change focus, only scrolls the screen */
1564
+ window.location.href = `${location.pathname}${location.search}#${scrollToElement}`;
1565
+ }
1566
+ }
1618
1567
  };
1619
1568
 
1569
+ // *** FILTER ITEM MAPPING ***
1570
+
1620
1571
  // Base mapping, fields that are the same across all mappings
1621
1572
  // to save repeating these elements in every mapper, spread this
1622
1573
  // into your discrete mappings
1623
-
1624
1574
  const base = {
1625
1575
  contentTypeId: Fields.sys.contentTypeId,
1626
1576
  title: 'entryTitle',
@@ -1628,16 +1578,13 @@ const base = {
1628
1578
  path: 'sys.slug',
1629
1579
  isSelected: 'isSelected'
1630
1580
  };
1631
-
1632
1581
  const mapEntriesToFilterItems = entries => {
1633
1582
  if (!entries) return [];
1634
1583
  return entries.map(entry => {
1635
1584
  const template = base;
1636
-
1637
1585
  if (template) {
1638
1586
  return mapJson__default["default"](entry, template);
1639
1587
  }
1640
-
1641
1588
  return entry;
1642
1589
  });
1643
1590
  };
@@ -1667,9 +1614,7 @@ const mapQueryParamsToCustomApi = queryParams => {
1667
1614
  };
1668
1615
 
1669
1616
  const searchSagas = [effects.takeEvery(CLEAR_FILTERS, clearFilters), effects.takeEvery(DO_SEARCH, doSearch), effects.takeEvery(SET_ROUTE_FILTERS, loadFilters), effects.takeEvery(SET_SEARCH_ENTRIES, preloadOtherFacets), effects.takeEvery(UPDATE_CURRENT_FACET, updateCurrentFacet), effects.takeEvery(UPDATE_CURRENT_TAB, updateCurrentTab), effects.takeEvery(UPDATE_PAGE_INDEX, updatePageIndex), effects.takeEvery(UPDATE_PAGE_SIZE, updatePageSize), effects.takeEvery(UPDATE_SEARCH_TERM, updateSearchTerm), effects.takeEvery(UPDATE_SORT_ORDER, updateSortOrder), effects.takeEvery(UPDATE_SELECTED_FILTERS, applySearchFilter)];
1670
-
1671
1617
  const toJS = obj => obj && 'toJS' in obj && typeof obj.toJS === 'function' ? obj.toJS() : obj;
1672
-
1673
1618
  function* setRouteFilters(action) {
1674
1619
  const {
1675
1620
  mappers,
@@ -1678,19 +1623,19 @@ function* setRouteFilters(action) {
1678
1623
  defaultLang,
1679
1624
  debug
1680
1625
  } = action;
1681
- const context = listingType ? exports.Context.listings : exports.Context.facets;
1626
+ const context = listingType ? Context.listings : Context.facets;
1682
1627
  const state = toJS(yield effects.select());
1683
- const ssr = getIsSsr(state); // Get current facet from params or state
1628
+ const ssr = getIsSsr(state);
1684
1629
 
1685
- let currentFacet = params && params.facet || listingType; // Pick the default facet from initialState
1630
+ // Get current facet from params or state
1631
+ let currentFacet = params && params.facet || listingType;
1686
1632
 
1633
+ // Pick the default facet from initialState
1687
1634
  if (!currentFacet) {
1688
1635
  var _Object$keys;
1689
-
1690
1636
  const tabs = getSearchTabs(state, 'js');
1691
1637
  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]) || '';
1692
1638
  }
1693
-
1694
1639
  const nextAction = {
1695
1640
  type: SET_ROUTE_FILTERS,
1696
1641
  context,
@@ -1701,48 +1646,50 @@ function* setRouteFilters(action) {
1701
1646
  ssr,
1702
1647
  debug
1703
1648
  };
1704
- yield effects.put(nextAction); // keep track of this state ref for comparing changes to params later
1649
+ yield effects.put(nextAction);
1705
1650
 
1651
+ // keep track of this state ref for comparing changes to params later
1706
1652
  const ogState = {
1707
1653
  search: state.search
1708
- }; // Using call instead of triggering from the put
1709
- // to allow this exported saga to continue during SSR
1654
+ };
1710
1655
 
1711
- yield effects.call(ensureSearch, { ...nextAction,
1656
+ // Using call instead of triggering from the put
1657
+ // to allow this exported saga to continue during SSR
1658
+ yield effects.call(ensureSearch, {
1659
+ ...nextAction,
1712
1660
  ogState
1713
1661
  });
1714
1662
  }
1715
1663
  function* doSearch(action) {
1716
1664
  var _action$params;
1717
-
1718
1665
  const state = toJS(yield effects.select());
1719
-
1720
1666
  if (action.config) {
1721
1667
  // If the action contains a config object, we can add this to the
1722
1668
  // state at runtime
1723
- yield effects.put({ ...action,
1669
+ yield effects.put({
1670
+ ...action,
1724
1671
  type: APPLY_CONFIG
1725
1672
  });
1726
1673
  }
1727
-
1728
- const nextAction = { ...action,
1674
+ const nextAction = {
1675
+ ...action,
1729
1676
  type: SET_SEARCH_FILTERS,
1730
1677
  ssr: getIsSsr(state),
1731
1678
  facet: action.facet || ((_action$params = action.params) === null || _action$params === void 0 ? void 0 : _action$params.facet)
1732
1679
  };
1733
-
1734
1680
  if (nextAction.facet && (action.config || Object.keys(getFacet(state, nextAction.facet, action.context, 'js')).length > 0)) {
1735
- yield effects.put(nextAction); // keep track of this state ref for comparing changes to params later
1681
+ yield effects.put(nextAction);
1736
1682
 
1683
+ // keep track of this state ref for comparing changes to params later
1737
1684
  const ogState = {
1738
1685
  search: state.search
1739
1686
  };
1740
- yield effects.call(ensureSearch, { ...nextAction,
1687
+ yield effects.call(ensureSearch, {
1688
+ ...nextAction,
1741
1689
  ogState
1742
1690
  });
1743
1691
  }
1744
1692
  }
1745
-
1746
1693
  function* loadFilters(action) {
1747
1694
  const {
1748
1695
  facet: facetKey,
@@ -1750,7 +1697,6 @@ function* loadFilters(action) {
1750
1697
  mappers = {}
1751
1698
  } = action;
1752
1699
  const filtersToLoad = yield effects.select(getFiltersToLoad, facetKey, context, 'js');
1753
-
1754
1700
  if (filtersToLoad.length > 0) {
1755
1701
  yield effects.put({
1756
1702
  type: LOAD_FILTERS,
@@ -1776,7 +1722,6 @@ function* loadFilters(action) {
1776
1722
  if (filtersToLoadSagas) yield effects.all(filtersToLoadSagas);
1777
1723
  }
1778
1724
  }
1779
-
1780
1725
  function* loadFilter(action) {
1781
1726
  const {
1782
1727
  facetKey,
@@ -1802,7 +1747,6 @@ function* loadFilter(action) {
1802
1747
  selectedKeys,
1803
1748
  mapper
1804
1749
  };
1805
-
1806
1750
  try {
1807
1751
  if (contentTypeId) {
1808
1752
  const versionStatus = yield effects.select(selectVersionStatus);
@@ -1812,7 +1756,6 @@ function* loadFilter(action) {
1812
1756
  if (payload.type === 'error') throw payload;
1813
1757
  createStateFrom.payload = payload;
1814
1758
  }
1815
-
1816
1759
  if (path) {
1817
1760
  const payload = yield cachedSearch.getTaxonomyNodeByPath(path, projectId);
1818
1761
  if (!payload) throw new Error(`No payload returned for taxonomy path: '${path}'`);
@@ -1823,35 +1766,33 @@ function* loadFilter(action) {
1823
1766
  createStateFrom.type = LOAD_FILTERS_ERROR;
1824
1767
  createStateFrom.error = error;
1825
1768
  }
1826
-
1827
1769
  const nextAction = mapJson__default["default"](createStateFrom, filterTemplate);
1828
1770
  yield effects.put(nextAction);
1829
1771
  }
1830
-
1831
1772
  function* ensureSearch(action) {
1832
1773
  const {
1833
1774
  context,
1834
1775
  facet,
1835
1776
  debug
1836
1777
  } = action;
1837
-
1838
1778
  try {
1839
1779
  const state = yield effects.select();
1840
- const nextAction = { ...action,
1780
+ const nextAction = {
1781
+ ...action,
1841
1782
  ogState: action.ogState || {
1842
1783
  search: state.search
1843
1784
  }
1844
1785
  };
1845
1786
  const [queryParams, runSearch] = generateQueryParams(nextAction, state);
1846
1787
  if (debug && (debug === true || debug.executeSearch)) debugExecuteSearch(nextAction, state);
1847
-
1848
1788
  if (runSearch) {
1849
1789
  yield effects.put({
1850
1790
  type: EXECUTE_SEARCH,
1851
1791
  facet,
1852
1792
  context
1853
1793
  });
1854
- yield effects.call(executeSearch, { ...nextAction,
1794
+ yield effects.call(executeSearch, {
1795
+ ...nextAction,
1855
1796
  context,
1856
1797
  facet,
1857
1798
  queryParams,
@@ -1863,7 +1804,6 @@ function* ensureSearch(action) {
1863
1804
  log__namespace.error(...['Error running search saga:', error, error.stack]);
1864
1805
  }
1865
1806
  }
1866
-
1867
1807
  function* executeSearch(action) {
1868
1808
  const {
1869
1809
  context,
@@ -1871,14 +1811,12 @@ function* executeSearch(action) {
1871
1811
  queryParams,
1872
1812
  mappers
1873
1813
  } = action;
1874
-
1875
1814
  try {
1876
1815
  const state = yield effects.select();
1877
1816
  let result = {};
1878
1817
  let featuredResult;
1879
1818
  let featuredQuery;
1880
1819
  const customApi = getCustomApi(state, facet, context, 'js');
1881
-
1882
1820
  if (customApi) {
1883
1821
  const apiParams = typeof mappers === 'object' && typeof mappers.customApi === 'function' && mappers.customApi(queryParams) || mapQueryParamsToCustomApi(queryParams);
1884
1822
  result.payload = yield callCustomApi(customApi, apiParams);
@@ -1886,19 +1824,16 @@ function* executeSearch(action) {
1886
1824
  } else {
1887
1825
  if (queryParams.featuredResults) {
1888
1826
  featuredQuery = searchQuery(queryParams, true);
1889
- featuredResult = yield timedSearch(featuredQuery, queryParams.linkDepth, queryParams.projectId, queryParams.env); // eslint-disable-next-line require-atomic-updates
1890
-
1827
+ featuredResult = yield timedSearch(featuredQuery, queryParams.linkDepth, queryParams.projectId, queryParams.env);
1828
+ // eslint-disable-next-line require-atomic-updates
1891
1829
  queryParams.excludeIds = getItemsFromResult(featuredResult).map(fi => {
1892
1830
  var _fi$sys;
1893
-
1894
1831
  return fi === null || fi === void 0 ? void 0 : (_fi$sys = fi.sys) === null || _fi$sys === void 0 ? void 0 : _fi$sys.id;
1895
1832
  }).filter(fi => typeof fi === 'string');
1896
1833
  }
1897
-
1898
1834
  const query = searchQuery(queryParams);
1899
1835
  result = yield timedSearch(query, queryParams.linkDepth, queryParams.projectId, queryParams.env);
1900
1836
  }
1901
-
1902
1837
  const createStateFrom = {
1903
1838
  action,
1904
1839
  featuredResult,
@@ -1914,7 +1849,6 @@ function* executeSearch(action) {
1914
1849
  log__namespace.error(...['Error running search saga:', error, error.stack]);
1915
1850
  }
1916
1851
  }
1917
-
1918
1852
  function* preloadOtherFacets(action) {
1919
1853
  const {
1920
1854
  preload,
@@ -1924,18 +1858,19 @@ function* preloadOtherFacets(action) {
1924
1858
  } = action;
1925
1859
  const state = yield effects.select();
1926
1860
  const currentFacet = getCurrentFacet(state);
1927
-
1928
- if (!preload && facet === currentFacet && context !== exports.Context.listings) {
1861
+ if (!preload && facet === currentFacet && context !== Context.listings) {
1929
1862
  const allFacets = getFacets(state, 'js');
1930
1863
  const otherFacets = Object.keys(allFacets).filter(f => f !== currentFacet);
1931
1864
  yield effects.all(otherFacets.map((preloadFacet = '') => {
1932
- const preloadAction = { ...action,
1865
+ const preloadAction = {
1866
+ ...action,
1933
1867
  facet: preloadFacet,
1934
1868
  preload: true
1935
1869
  };
1936
1870
  const [queryParams, runSearch] = generateQueryParams(preloadAction, state);
1937
1871
  if (debug && (debug === true || debug.preloadOtherFacets)) debugExecuteSearch(preloadAction, state);
1938
- return runSearch && effects.call(executeSearch, { ...action,
1872
+ return runSearch && effects.call(executeSearch, {
1873
+ ...action,
1939
1874
  type: EXECUTE_SEARCH_PRELOAD,
1940
1875
  preload: true,
1941
1876
  facet: preloadFacet,
@@ -1944,7 +1879,6 @@ function* preloadOtherFacets(action) {
1944
1879
  }));
1945
1880
  }
1946
1881
  }
1947
-
1948
1882
  function* updateCurrentTab(action) {
1949
1883
  const {
1950
1884
  id,
@@ -1954,19 +1888,16 @@ function* updateCurrentTab(action) {
1954
1888
  const facets = getFacets(state, 'js');
1955
1889
  const tabs = getSearchTabs(state, 'js');
1956
1890
  let nextFacet = tabs === null || tabs === void 0 ? void 0 : tabs[id].currentFacet;
1957
-
1958
1891
  if (!nextFacet) {
1959
1892
  Object.entries(facets).map(([facetName, facet]) => {
1960
1893
  if (facet.tabId === id && (tabs === null || tabs === void 0 ? void 0 : tabs[id].defaultFacet) === facetName) nextFacet = facetName;
1961
1894
  });
1962
- } // If the next Tab does not have a defaultFacet,
1895
+ }
1896
+ // If the next Tab does not have a defaultFacet,
1963
1897
  // take the first facet for that tab
1964
-
1965
-
1966
1898
  if (!nextFacet) nextFacet = Object.entries(facets).filter(([, f]) => f.tabId === id)[0][0];
1967
1899
  yield effects.put(withMappers(updateCurrentFacet$1(nextFacet), mappers));
1968
1900
  }
1969
-
1970
1901
  function* clearFilters(action) {
1971
1902
  const {
1972
1903
  mappers
@@ -1974,7 +1905,6 @@ function* clearFilters(action) {
1974
1905
  const uri = yield buildUri({}, mappers);
1975
1906
  yield effects.put(navigate(uri));
1976
1907
  }
1977
-
1978
1908
  function* updateCurrentFacet(action) {
1979
1909
  const {
1980
1910
  facet,
@@ -1987,7 +1917,6 @@ function* updateCurrentFacet(action) {
1987
1917
  }, mappers);
1988
1918
  yield effects.put(navigate(uri));
1989
1919
  }
1990
-
1991
1920
  function* updateSearchTerm(action) {
1992
1921
  const {
1993
1922
  term,
@@ -1998,7 +1927,6 @@ function* updateSearchTerm(action) {
1998
1927
  }, mappers);
1999
1928
  yield effects.put(navigate(uri));
2000
1929
  }
2001
-
2002
1930
  function* updateSortOrder(action) {
2003
1931
  const {
2004
1932
  orderBy,
@@ -2011,43 +1939,39 @@ function* updateSortOrder(action) {
2011
1939
  }, mappers);
2012
1940
  yield effects.put(navigate(uri));
2013
1941
  }
2014
-
2015
1942
  function* updatePageIndex(action) {
2016
1943
  const {
2017
1944
  pageIndex,
2018
1945
  mappers,
2019
- scrollYPos
1946
+ scrollToElement
2020
1947
  } = action;
2021
1948
  const uri = yield buildUri({
2022
1949
  pageIndex
2023
1950
  }, mappers);
2024
1951
  yield effects.put(navigate(uri));
2025
- if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
1952
+ if (typeof scrollToElement !== 'undefined') scrollTo(scrollToElement);
2026
1953
  }
2027
-
2028
1954
  function* updatePageSize(action) {
2029
1955
  const {
2030
1956
  pageSize,
2031
1957
  mappers,
2032
- scrollYPos
1958
+ scrollToElement
2033
1959
  } = action;
2034
1960
  const uri = yield buildUri({
2035
1961
  pageSize
2036
1962
  }, mappers);
2037
1963
  yield effects.put(navigate(uri));
2038
- if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
1964
+ if (typeof scrollToElement !== 'undefined') scrollTo(scrollToElement);
2039
1965
  }
2040
-
2041
1966
  function* applySearchFilter(action) {
2042
1967
  const {
2043
1968
  mappers,
2044
- scrollYPos
1969
+ scrollToElement
2045
1970
  } = action;
2046
1971
  const uri = yield buildUri({}, mappers);
2047
1972
  yield effects.put(navigate(uri));
2048
- if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
1973
+ if (typeof scrollToElement !== 'undefined') scrollTo(scrollToElement);
2049
1974
  }
2050
-
2051
1975
  function* buildUri({
2052
1976
  facet,
2053
1977
  orderBy,
@@ -2064,11 +1988,10 @@ function* buildUri({
2064
1988
  pageIndex,
2065
1989
  pageSize,
2066
1990
  term
2067
- }); // return uri;
2068
-
1991
+ });
1992
+ // return uri;
2069
1993
  return `${uri.path}${uri.search && `?${uri.search}` || ''}${uri.hash && `#${uri.hash}` || ''}`;
2070
1994
  }
2071
-
2072
1995
  function* triggerMinilistSsr(options) {
2073
1996
  yield effects.call(doSearch, {
2074
1997
  type: DO_SEARCH,
@@ -2084,6 +2007,7 @@ function* triggerSearchSsr(options) {
2084
2007
 
2085
2008
  exports.APPLY_CONFIG = APPLY_CONFIG;
2086
2009
  exports.CLEAR_FILTERS = CLEAR_FILTERS;
2010
+ exports.Context = Context;
2087
2011
  exports.EXECUTE_SEARCH = EXECUTE_SEARCH;
2088
2012
  exports.EXECUTE_SEARCH_ERROR = EXECUTE_SEARCH_ERROR;
2089
2013
  exports.LOAD_FILTERS = LOAD_FILTERS;
@@ -2149,4 +2073,4 @@ exports.updateSearchTerm = updateSearchTerm$1;
2149
2073
  exports.updateSelectedFilters = updateSelectedFilters;
2150
2074
  exports.updateSortOrder = updateSortOrder$1;
2151
2075
  exports.withMappers = withMappers;
2152
- //# sourceMappingURL=sagas-8a20e424.js.map
2076
+ //# sourceMappingURL=sagas-e04b94c1.js.map