@zengenti/contensis-react-base 4.0.0-beta.52 → 4.0.0-beta.54

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.
@@ -1305,10 +1305,10 @@ var expressions = /*#__PURE__*/Object.freeze({
1305
1305
  termExpressions: termExpressions
1306
1306
  });
1307
1307
 
1308
- const filterQuery = (contentTypeIds, languages, versionStatus, customWhere) => {
1308
+ const filterQuery = (contentTypeIds, languages, versionStatus, customWhere, pageSize = 100) => {
1309
1309
  const query = new Query(...[...contentTypeIdExpression(contentTypeIds), ...languagesExpression(languages), ...defaultExpressions(versionStatus), ...customWhereExpressions(customWhere)]);
1310
1310
  query.orderBy = OrderBy.asc(Fields.entryTitle);
1311
- query.pageSize = 100;
1311
+ query.pageSize = pageSize;
1312
1312
  return query;
1313
1313
  };
1314
1314
  const searchQuery = ({
@@ -5090,6 +5090,9 @@ const facetTemplate = {
5090
5090
  }
5091
5091
 
5092
5092
  // Update aggregation counts on existing filter items
5093
+ // In the context of a pre-loaded facet, the filter items will
5094
+ // not have been loaded yet, so we need to check again when
5095
+ // the filter items load and populate the aggregate counts then as well
5093
5096
  for (const filterItem of filter.items || []) {
5094
5097
  if (!aggregation) delete filterItem.aggregate;else {
5095
5098
  const aggregate = aggregation[filterItem.key.toLowerCase()];
@@ -5190,7 +5193,7 @@ const filterTemplate = {
5190
5193
  selectedKeys,
5191
5194
  mapper,
5192
5195
  facet,
5193
- filterKey
5196
+ filter
5194
5197
  }) => {
5195
5198
  // Handle taxonomy filter items
5196
5199
  if (payload && 'children' in payload) {
@@ -5203,10 +5206,18 @@ const filterTemplate = {
5203
5206
  }
5204
5207
 
5205
5208
  // Handle entries-based filter items
5206
- if (payload && 'items' in payload) {
5207
- var _facet$aggregations;
5209
+ if (payload && 'items' in payload && filter.fieldId) {
5210
+ var _facet$aggregations2;
5208
5211
  // Handle aggregations from SSR where the results containing the aggregations have loaded before the filter items
5209
- const aggregation = (_facet$aggregations = facet.aggregations) === null || _facet$aggregations === void 0 ? void 0 : _facet$aggregations[convertKeyForAggregation(filterKey)];
5212
+ const aggregation = Array.isArray(filter.fieldId) ? filter.fieldId.reduce((agg, fieldId) => {
5213
+ var _facet$aggregations;
5214
+ const fieldAggregations = ((_facet$aggregations = facet.aggregations) === null || _facet$aggregations === void 0 ? void 0 : _facet$aggregations[convertKeyForAggregation(fieldId)]) || {};
5215
+ // Accumulate numeric values for matching keys from previous counted fields
5216
+ for (const [key, value] of Object.entries(fieldAggregations)) {
5217
+ agg[key] = (agg[key] || 0) + value;
5218
+ }
5219
+ return agg;
5220
+ }, {}) : (_facet$aggregations2 = facet.aggregations) === null || _facet$aggregations2 === void 0 ? void 0 : _facet$aggregations2[convertKeyForAggregation(filter.fieldId)];
5210
5221
  const items = payload.items.map(item => {
5211
5222
  var _item$sys, _item$sys2;
5212
5223
  item.isSelected = selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.includes(item === null || item === void 0 || (_item$sys = item.sys) === null || _item$sys === void 0 ? void 0 : _item$sys.id);
@@ -5214,7 +5225,7 @@ const filterTemplate = {
5214
5225
  if (typeof aggregate === 'number') item.aggregate = aggregate;
5215
5226
  return item;
5216
5227
  });
5217
- return mapper === null || mapper === void 0 ? void 0 : mapper(items);
5228
+ return (mapper === null || mapper === void 0 ? void 0 : mapper(items)) || [];
5218
5229
  }
5219
5230
  return [];
5220
5231
  }
@@ -5779,6 +5790,7 @@ function* loadFilter(action) {
5779
5790
  const {
5780
5791
  contentTypeId,
5781
5792
  customWhere,
5793
+ pageSize,
5782
5794
  path
5783
5795
  } = filter;
5784
5796
  const createStateFrom = {
@@ -5786,6 +5798,7 @@ function* loadFilter(action) {
5786
5798
  context,
5787
5799
  error: undefined,
5788
5800
  facetKey,
5801
+ filter,
5789
5802
  filterKey,
5790
5803
  payload: {},
5791
5804
  selectedKeys,
@@ -5794,7 +5807,7 @@ function* loadFilter(action) {
5794
5807
  try {
5795
5808
  if (contentTypeId) {
5796
5809
  const versionStatus = yield select(selectVersionStatus);
5797
- const query = filterQuery(Array.isArray(contentTypeId) ? contentTypeId : [contentTypeId], languages, versionStatus, customWhere);
5810
+ const query = filterQuery(Array.isArray(contentTypeId) ? contentTypeId : [contentTypeId], languages, versionStatus, customWhere, pageSize);
5798
5811
  const payload = yield api.search(query, 0, projectId);
5799
5812
  if (!payload) throw new Error('No payload returned by search');
5800
5813
  if (payload.type === 'error') throw payload;
@@ -6054,4 +6067,4 @@ function* triggerSearchSsr(options) {
6054
6067
  }
6055
6068
 
6056
6069
  export { useFacets as $, updateCurrentTab$1 as A, updateCurrentFacet$1 as B, clearFilters$1 as C, selectListing as D, triggerSearch as E, Context as F, getFilters as G, UPDATE_SELECTED_FILTERS as H, UPDATE_SEARCH_TERM as I, UPDATE_PAGE_SIZE as J, UPDATE_PAGE_INDEX as K, SET_SEARCH_ENTRIES as L, SET_ROUTE_FILTERS as M, LOAD_FILTERS_COMPLETE as N, LOAD_FILTERS_ERROR as O, LOAD_FILTERS as P, EXECUTE_SEARCH_ERROR as Q, EXECUTE_SEARCH as R, SET_SEARCH_FILTERS as S, CLEAR_FILTERS as T, UPDATE_SORT_ORDER as U, APPLY_CONFIG as V, actions as W, selectors as X, types as Y, expressions as Z, queries as _, getTabsAndFacets$1 as a, useListing as a0, doSearch as a1, setRouteFilters as a2, searchSagas as a3, triggerListingSsr as a4, triggerMinilistSsr as a5, triggerSearchSsr as a6, defaultExpressions as a7, termExpressions as a8, contentTypeIdExpression as a9, filterExpressions as aa, orderByExpression as ab, customWhereExpressions as ac, cloneDeep as ad, getQueryParameter$2 as b, getSelectedFilters as c, getSearchTotalCount$1 as d, getSearchTerm$2 as e, getResultsInfo as f, getTotalCount$1 as g, getResults as h, getPageIsLoading$2 as i, getPaging as j, getIsLoading$2 as k, getRenderableFilters$2 as l, getFeaturedResults$2 as m, getFacetTitles$1 as n, getFacetsTotalCount$1 as o, getTabFacets$1 as p, getFacet$1 as q, getCurrentTab$1 as r, getPageIndex$2 as s, getCurrentFacet as t, updateSortOrder$1 as u, updateSelectedFilters as v, withMappers as w, updateSearchTerm$1 as x, updatePageSize$1 as y, updatePageIndex$1 as z };
6057
- //# sourceMappingURL=sagas-tSMLm-l5.js.map
6070
+ //# sourceMappingURL=sagas-Dl7xqU8K.js.map