@sledge-app/react-instant-search 2.0.20 → 2.0.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.
@@ -8968,7 +8968,7 @@ const SearchResultWidget = (props) => {
8968
8968
  [indexProduct]
8969
8969
  );
8970
8970
  const handleFilterStates = ({ data = {}, valueSearchResultFacets = {} }) => {
8971
- var _a2, _b2, _c2;
8971
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
8972
8972
  const { filters } = data;
8973
8973
  let allowedFilters = ((_b2 = (_a2 = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _a2.filters) == null ? void 0 : _b2.length) ? (_c2 = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _c2.filters : (filters == null ? void 0 : filters.length) ? filters : [];
8974
8974
  let isSetFilter = false;
@@ -8977,10 +8977,9 @@ const SearchResultWidget = (props) => {
8977
8977
  let valueAllowedFilterSlider = [];
8978
8978
  let valueHierarchicalFacetAliases = [];
8979
8979
  if (!isSetFilter) {
8980
- let isSetFilterItems = false;
8981
- allowedFilters == null ? void 0 : allowedFilters.map((filter) => {
8980
+ let allowedFiltersCollectionId = (_f2 = (_e2 = (_d2 = allowedFilters == null ? void 0 : allowedFilters.map) == null ? void 0 : _d2.call(allowedFilters, (filter) => {
8982
8981
  const { active, collections, items } = filter;
8983
- if (!active || isSetFilterItems)
8982
+ if (!active)
8984
8983
  return;
8985
8984
  const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => {
8986
8985
  return {
@@ -8989,17 +8988,36 @@ const SearchResultWidget = (props) => {
8989
8988
  };
8990
8989
  });
8991
8990
  if (collectionId && (collections == null ? void 0 : collections.includes(String(collectionId)))) {
8992
- isSetFilter = true;
8993
- isSetFilterItems = true;
8994
- valueAllowedFilter = newItems;
8991
+ return newItems;
8995
8992
  } else {
8996
- if (collections == null ? void 0 : collections.includes("all")) {
8997
- isSetFilter = true;
8998
- isSetFilterItems = true;
8999
- valueAllowedFilter = newItems;
9000
- }
8993
+ return;
9001
8994
  }
9002
- });
8995
+ })) == null ? void 0 : _e2.filter) == null ? void 0 : _f2.call(_e2, (item) => item);
8996
+ let allowedFiltersCollectionAll = (_i2 = (_h2 = (_g2 = allowedFilters == null ? void 0 : allowedFilters.map) == null ? void 0 : _g2.call(allowedFilters, (filter) => {
8997
+ const { active, collections, items } = filter;
8998
+ if (!active)
8999
+ return;
9000
+ const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => {
9001
+ return {
9002
+ ...otherItem,
9003
+ value: (otherItem == null ? void 0 : otherItem.display) === "tree" ? HIERARCHICAL_FACET_OBJECT_ALIASES[value] || value : value
9004
+ };
9005
+ });
9006
+ if (collections == null ? void 0 : collections.includes("all")) {
9007
+ return newItems;
9008
+ } else {
9009
+ return;
9010
+ }
9011
+ })) == null ? void 0 : _h2.filter) == null ? void 0 : _i2.call(_h2, (item) => item);
9012
+ if (collectionId && (allowedFiltersCollectionId == null ? void 0 : allowedFiltersCollectionId.length)) {
9013
+ isSetFilter = true;
9014
+ valueAllowedFilter = allowedFiltersCollectionId == null ? void 0 : allowedFiltersCollectionId[0];
9015
+ } else {
9016
+ if (allowedFiltersCollectionAll == null ? void 0 : allowedFiltersCollectionAll.length) {
9017
+ isSetFilter = true;
9018
+ valueAllowedFilter = allowedFiltersCollectionAll == null ? void 0 : allowedFiltersCollectionAll[0];
9019
+ }
9020
+ }
9003
9021
  }
9004
9022
  if (valueAllowedFilter == null ? void 0 : valueAllowedFilter.length) {
9005
9023
  valueDefaultFilterItems = valueAllowedFilter.map((filter) => {
@@ -9136,28 +9154,42 @@ const SearchResultWidget = (props) => {
9136
9154
  const { filters, index_product, tabs: tabs2, hidden_tags, show_out_of_stock, display, use_published_filter } = data;
9137
9155
  let getTabs = layoutType === "product-filter" ? tabs2.filter(({ index }) => index == null ? void 0 : index.includes(index_product)) : tabs2;
9138
9156
  getTabs.map((tab) => {
9157
+ var _a2, _b2, _c2, _d2, _e2, _f2;
9139
9158
  const { index } = tab;
9140
9159
  let isSetFilter2 = false;
9141
9160
  let getFacets = [];
9142
9161
  if (!isSetFilter2) {
9143
- let isSetFilterItems = false;
9144
- filters == null ? void 0 : filters.map((filter) => {
9162
+ let allowedFiltersCollectionId = (_c2 = (_b2 = (_a2 = filters == null ? void 0 : filters.map) == null ? void 0 : _a2.call(filters, (filter) => {
9145
9163
  const { active, collections, items } = filter;
9146
- if (!active || isSetFilterItems)
9164
+ if (!active)
9147
9165
  return;
9148
9166
  const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => (otherItem == null ? void 0 : otherItem.display) === "tree" ? HIERARCHICAL_FACET_OBJECT_ALIASES[value] || value : value);
9149
9167
  if (collectionId && (collections == null ? void 0 : collections.includes(String(collectionId)))) {
9150
- isSetFilter2 = true;
9151
- isSetFilterItems = true;
9152
- getFacets = newItems;
9168
+ return newItems;
9153
9169
  } else {
9154
- if (collections == null ? void 0 : collections.includes("all")) {
9155
- isSetFilter2 = true;
9156
- isSetFilterItems = true;
9157
- getFacets = newItems;
9158
- }
9170
+ return;
9159
9171
  }
9160
- });
9172
+ })) == null ? void 0 : _b2.filter) == null ? void 0 : _c2.call(_b2, (item) => item);
9173
+ let allowedFiltersCollectionAll = (_f2 = (_e2 = (_d2 = filters == null ? void 0 : filters.map) == null ? void 0 : _d2.call(filters, (filter) => {
9174
+ const { active, collections, items } = filter;
9175
+ if (!active)
9176
+ return;
9177
+ const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => (otherItem == null ? void 0 : otherItem.display) === "tree" ? HIERARCHICAL_FACET_OBJECT_ALIASES[value] || value : value);
9178
+ if (collections == null ? void 0 : collections.includes("all")) {
9179
+ return newItems;
9180
+ } else {
9181
+ return;
9182
+ }
9183
+ })) == null ? void 0 : _e2.filter) == null ? void 0 : _f2.call(_e2, (item) => item);
9184
+ if (collectionId && (allowedFiltersCollectionId == null ? void 0 : allowedFiltersCollectionId.length)) {
9185
+ isSetFilter2 = true;
9186
+ getFacets = allowedFiltersCollectionId == null ? void 0 : allowedFiltersCollectionId[0];
9187
+ } else {
9188
+ if (allowedFiltersCollectionAll == null ? void 0 : allowedFiltersCollectionAll.length) {
9189
+ isSetFilter2 = true;
9190
+ getFacets = allowedFiltersCollectionAll == null ? void 0 : allowedFiltersCollectionAll[0];
9191
+ }
9192
+ }
9161
9193
  }
9162
9194
  let isProductIndex = index.includes(index_product);
9163
9195
  let isHasProductFacets = isProductIndex && getFacets.length;