@sledge-app/react-instant-search 2.0.19 → 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.
@@ -7726,8 +7726,11 @@ const Facet = (props) => {
7726
7726
  });
7727
7727
  };
7728
7728
  const colorSwatchComponent = ({ item = {}, index }) => {
7729
- var _a2;
7730
- let getColorSwatch = (colorSwatches == null ? void 0 : colorSwatches.filter(({ name }) => name == null ? void 0 : name.includes(item == null ? void 0 : item.value))[0]) || {};
7729
+ var _a2, _b2;
7730
+ let getColorSwatch = ((_a2 = colorSwatches == null ? void 0 : colorSwatches.filter(({ name }) => {
7731
+ var _a3;
7732
+ return (name == null ? void 0 : name.toLowerCase()) === ((_a3 = item == null ? void 0 : item.value) == null ? void 0 : _a3.toLowerCase());
7733
+ })) == null ? void 0 : _a2[0]) || {};
7731
7734
  return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
7732
7735
  ColorSwatch,
7733
7736
  {
@@ -7740,7 +7743,7 @@ const Facet = (props) => {
7740
7743
  parentId: value,
7741
7744
  value: e.currentTarget.value
7742
7745
  }),
7743
- checked: Boolean(clickedFacets && ((_a2 = clickedFacets[value]) == null ? void 0 : _a2.includes(item == null ? void 0 : item.value))),
7746
+ checked: Boolean(clickedFacets && ((_b2 = clickedFacets[value]) == null ? void 0 : _b2.includes(item == null ? void 0 : item.value))),
7744
7747
  ...display.toLowerCase() === "swatch_with_label" ? {
7745
7748
  labelType: "text",
7746
7749
  label: `${item == null ? void 0 : item.labelName} ${(item == null ? void 0 : item.counter) !== void 0 && isShowNumberMatchingProduct ? ` (${item == null ? void 0 : item.counter})` : ""}`,
@@ -8965,7 +8968,7 @@ const SearchResultWidget = (props) => {
8965
8968
  [indexProduct]
8966
8969
  );
8967
8970
  const handleFilterStates = ({ data = {}, valueSearchResultFacets = {} }) => {
8968
- var _a2, _b2, _c2;
8971
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
8969
8972
  const { filters } = data;
8970
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 : [];
8971
8974
  let isSetFilter = false;
@@ -8974,10 +8977,9 @@ const SearchResultWidget = (props) => {
8974
8977
  let valueAllowedFilterSlider = [];
8975
8978
  let valueHierarchicalFacetAliases = [];
8976
8979
  if (!isSetFilter) {
8977
- let isSetFilterItems = false;
8978
- 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) => {
8979
8981
  const { active, collections, items } = filter;
8980
- if (!active || isSetFilterItems)
8982
+ if (!active)
8981
8983
  return;
8982
8984
  const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => {
8983
8985
  return {
@@ -8986,17 +8988,36 @@ const SearchResultWidget = (props) => {
8986
8988
  };
8987
8989
  });
8988
8990
  if (collectionId && (collections == null ? void 0 : collections.includes(String(collectionId)))) {
8989
- isSetFilter = true;
8990
- isSetFilterItems = true;
8991
- valueAllowedFilter = newItems;
8991
+ return newItems;
8992
8992
  } else {
8993
- if (collections == null ? void 0 : collections.includes("all")) {
8994
- isSetFilter = true;
8995
- isSetFilterItems = true;
8996
- valueAllowedFilter = newItems;
8997
- }
8993
+ return;
8998
8994
  }
8999
- });
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
+ }
9000
9021
  }
9001
9022
  if (valueAllowedFilter == null ? void 0 : valueAllowedFilter.length) {
9002
9023
  valueDefaultFilterItems = valueAllowedFilter.map((filter) => {
@@ -9133,28 +9154,42 @@ const SearchResultWidget = (props) => {
9133
9154
  const { filters, index_product, tabs: tabs2, hidden_tags, show_out_of_stock, display, use_published_filter } = data;
9134
9155
  let getTabs = layoutType === "product-filter" ? tabs2.filter(({ index }) => index == null ? void 0 : index.includes(index_product)) : tabs2;
9135
9156
  getTabs.map((tab) => {
9157
+ var _a2, _b2, _c2, _d2, _e2, _f2;
9136
9158
  const { index } = tab;
9137
9159
  let isSetFilter2 = false;
9138
9160
  let getFacets = [];
9139
9161
  if (!isSetFilter2) {
9140
- let isSetFilterItems = false;
9141
- 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) => {
9142
9163
  const { active, collections, items } = filter;
9143
- if (!active || isSetFilterItems)
9164
+ if (!active)
9144
9165
  return;
9145
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);
9146
9167
  if (collectionId && (collections == null ? void 0 : collections.includes(String(collectionId)))) {
9147
- isSetFilter2 = true;
9148
- isSetFilterItems = true;
9149
- getFacets = newItems;
9168
+ return newItems;
9150
9169
  } else {
9151
- if (collections == null ? void 0 : collections.includes("all")) {
9152
- isSetFilter2 = true;
9153
- isSetFilterItems = true;
9154
- getFacets = newItems;
9155
- }
9170
+ return;
9156
9171
  }
9157
- });
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
+ }
9158
9193
  }
9159
9194
  let isProductIndex = index.includes(index_product);
9160
9195
  let isHasProductFacets = isProductIndex && getFacets.length;