@sledge-app/react-instant-search 2.0.74 → 2.0.76

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.
@@ -709,7 +709,8 @@ const getSortMap = ({
709
709
  }) => {
710
710
  activeCollectionId = activeCollectionId || "default";
711
711
  collectionAllId = collectionAllId || activeCollectionId || "all";
712
- return {
712
+ const fallbackValue = `featuredSort.${activeCollectionId}:asc`;
713
+ const sortMap = {
713
714
  "best-selling": `bestSellingSort.${collectionAllId}:asc`,
714
715
  "manual": `featuredSort.${activeCollectionId}:asc`,
715
716
  "created-ascending": "created_at:asc",
@@ -719,6 +720,14 @@ const getSortMap = ({
719
720
  "title-ascending": "title:asc",
720
721
  "title-descending": "title:desc"
721
722
  };
723
+ return new Proxy(sortMap, {
724
+ get(target, prop, receiver) {
725
+ if (typeof prop === "string" && !(prop in target)) {
726
+ return fallbackValue;
727
+ }
728
+ return Reflect.get(target, prop, receiver);
729
+ }
730
+ });
722
731
  };
723
732
  let onStorageFallback;
724
733
  const getWindowStore = () => {
@@ -6220,7 +6229,7 @@ const SearchIconWidgetPopup = () => {
6220
6229
  let response;
6221
6230
  let body = {
6222
6231
  queries: tabs.map((tab) => {
6223
- var _a3, _b3, _c3;
6232
+ var _a3, _b3, _c3, _d3;
6224
6233
  const { index } = tab;
6225
6234
  let isProductIndex = index.includes(index_product);
6226
6235
  let additionalFilter = DEFAULT_QUERY_PRODUCT_MEILISEARCH;
@@ -6255,12 +6264,13 @@ const SearchIconWidgetPopup = () => {
6255
6264
  let filterProduct = additionalFilter;
6256
6265
  if (containsFilter)
6257
6266
  filterProduct = filterProduct.concat(containsFilter);
6267
+ let hiddenCollectionsFilter = index === (instantSearchSettings == null ? void 0 : instantSearchSettings.index_collection) && ((_d3 = instantSearchSettings == null ? void 0 : instantSearchSettings.hidden_collections) == null ? void 0 : _d3.length) ? `'id' NOT IN ${JSON.stringify(instantSearchSettings.hidden_collections)}` : null;
6258
6268
  return {
6259
6269
  indexUid: index,
6260
6270
  q: valueKeyword,
6261
6271
  sort,
6262
6272
  hitsPerPage: isProductIndex ? instantSearchLimit : 4,
6263
- filter: isProductIndex ? [...new Set(filterProduct)].join(" AND ") : "",
6273
+ filter: isProductIndex ? [...new Set(filterProduct)].join(" AND ") : [hiddenCollectionsFilter].filter(Boolean).join(" AND "),
6264
6274
  attributesToRetrieve: attributes_to_retrieve
6265
6275
  };
6266
6276
  })
@@ -7023,7 +7033,7 @@ const keyOpenFilters = ({ items = [] }) => {
7023
7033
  }).filter((item) => item) : [];
7024
7034
  };
7025
7035
  const handleSearchResponse = async (props) => {
7026
- var _a, _b, _c, _d;
7036
+ var _a, _b, _c, _d, _e;
7027
7037
  let {
7028
7038
  layoutType = "default",
7029
7039
  clickedTabIndexId,
@@ -7113,6 +7123,10 @@ const handleSearchResponse = async (props) => {
7113
7123
  if (isTypeCategoryHasPublished({ usePublishedFilter, type: clickedTabIndexType })) {
7114
7124
  filterCategory = DEFAULT_QUERY_PUBLISHED_FILTER;
7115
7125
  }
7126
+ let hiddenCollectionsCategoryFilter = String(clickedTabIndexId) === (instantSearchSettings == null ? void 0 : instantSearchSettings.index_collection) && ((_e = instantSearchSettings == null ? void 0 : instantSearchSettings.hidden_collections) == null ? void 0 : _e.length) ? `'id' NOT IN ${JSON.stringify(instantSearchSettings.hidden_collections)}` : null;
7127
+ if (hiddenCollectionsCategoryFilter) {
7128
+ filterCategory = [filterCategory, hiddenCollectionsCategoryFilter].filter(Boolean).join(" AND ");
7129
+ }
7116
7130
  let bodyProductOrCategory = isResultForProduct ? {
7117
7131
  q: keyword,
7118
7132
  sort,
@@ -7137,15 +7151,20 @@ const handleSearchResponse = async (props) => {
7137
7151
  let getTabs = isUseMultiSearch ? tabs : tabs.filter(({ index }) => index == null ? void 0 : index.includes(clickedTabIndexId));
7138
7152
  let body = {
7139
7153
  queries: getTabs.map((tab) => {
7154
+ var _a2;
7140
7155
  const { index, type } = tab;
7141
7156
  let isCurrentIndex = index.includes(clickedTabIndexId);
7142
7157
  let isProductIndex = type === "product";
7158
+ let hiddenCollectionsFilter = index === (instantSearchSettings == null ? void 0 : instantSearchSettings.index_collection) && ((_a2 = instantSearchSettings == null ? void 0 : instantSearchSettings.hidden_collections) == null ? void 0 : _a2.length) ? `'id' NOT IN ${JSON.stringify(instantSearchSettings.hidden_collections)}` : null;
7143
7159
  return {
7144
7160
  indexUid: index,
7145
7161
  ...isCurrentIndex ? bodyProductOrCategory : {
7146
7162
  q: keyword || "",
7147
7163
  hitsPerPage: 1,
7148
- filter: isTypeCategoryHasPublished({ usePublishedFilter, type }) ? DEFAULT_QUERY_PUBLISHED_FILTER : isProductIndex ? filterProduct : "",
7164
+ filter: [
7165
+ isTypeCategoryHasPublished({ usePublishedFilter, type }) ? DEFAULT_QUERY_PUBLISHED_FILTER : isProductIndex ? filterProduct : "",
7166
+ hiddenCollectionsFilter
7167
+ ].filter(Boolean).join(" AND "),
7149
7168
  attributesToRetrieve: [],
7150
7169
  limit: 0,
7151
7170
  page: 0,
@@ -11703,7 +11722,7 @@ const SearchWidget = (props) => {
11703
11722
  let response;
11704
11723
  let body = {
11705
11724
  queries: tabs.map((tab) => {
11706
- var _a3, _b3, _c3;
11725
+ var _a3, _b3, _c3, _d3;
11707
11726
  const { index } = tab;
11708
11727
  let isProductIndex = index.includes(index_product);
11709
11728
  let additionalFilter = DEFAULT_QUERY_PRODUCT_MEILISEARCH;
@@ -11738,12 +11757,13 @@ const SearchWidget = (props) => {
11738
11757
  let filterProduct = additionalFilter;
11739
11758
  if (containsFilter)
11740
11759
  filterProduct = filterProduct.concat(containsFilter);
11760
+ let hiddenCollectionsFilter = index === (instantSearchSettings == null ? void 0 : instantSearchSettings.index_collection) && ((_d3 = instantSearchSettings == null ? void 0 : instantSearchSettings.hidden_collections) == null ? void 0 : _d3.length) ? `'id' NOT IN ${JSON.stringify(instantSearchSettings.hidden_collections)}` : null;
11741
11761
  return {
11742
11762
  indexUid: index,
11743
11763
  q: valueKeyword,
11744
11764
  sort,
11745
11765
  hitsPerPage: isProductIndex ? instantSearchLimit : 4,
11746
- filter: isProductIndex ? [...new Set(filterProduct)].join(" AND ") : "",
11766
+ filter: isProductIndex ? [...new Set(filterProduct)].join(" AND ") : [hiddenCollectionsFilter].filter(Boolean).join(" AND "),
11747
11767
  attributesToRetrieve: attributes_to_retrieve
11748
11768
  };
11749
11769
  })