@sledge-app/react-instant-search 1.0.124 → 1.0.126

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.
@@ -6578,6 +6578,7 @@ const SearchResultWidget = (props) => {
6578
6578
  const [allowedFilterSlider, setAllowedFilterSlider] = React__default.useState([]);
6579
6579
  const [hierarchicalFacetAliases, setHierarchicalFacetAliases] = React__default.useState([]);
6580
6580
  const [usePublishedFilter, setUsePublishedFilter] = React__default.useState(false);
6581
+ const [showOutOfStock, setShowOutOfStock] = React__default.useState(false);
6581
6582
  const debouncedKeyword = useDebounce(keyword, 500);
6582
6583
  let productCardsComponent = null;
6583
6584
  let collectionCardsComponent = null;
@@ -6857,6 +6858,7 @@ const SearchResultWidget = (props) => {
6857
6858
  setSoldProductAtEnd(sold_product_at_end);
6858
6859
  setAttributesToRetrieve(attributes_to_retrieve);
6859
6860
  setUsePublishedFilter(use_published_filter);
6861
+ setShowOutOfStock(show_out_of_stock);
6860
6862
  getFirstIndex = tabs.find(({ index }) => index.includes(index_product));
6861
6863
  if (Object.keys(getFirstIndex).length) {
6862
6864
  setClickedTabIndexId(getFirstIndex.index);
@@ -6872,11 +6874,25 @@ const SearchResultWidget = (props) => {
6872
6874
  window.history.pushState(null, "", `${document.location.pathname}?${searchParams2.toString()}`);
6873
6875
  };
6874
6876
  useEffectCallback(() => {
6877
+ var _a2, _b2, _c2, _d2;
6875
6878
  if (!isRenderAppInstantSearch)
6876
6879
  return;
6877
6880
  const searchParams2 = new URLSearchParams(document.location.search);
6878
6881
  setKeyword((searchParams2 == null ? void 0 : searchParams2.get(queryKeyword)) || "");
6879
6882
  handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
6883
+ if (typeof window !== "undefined") {
6884
+ if (layoutType === "default") {
6885
+ if ((_b2 = (_a2 = window == null ? void 0 : window.sledge) == null ? void 0 : _a2.instantSearch) == null ? void 0 : _b2.searchResult)
6886
+ window.sledge.instantSearch.searchResult.search = (keyword2 = "") => {
6887
+ handleChangeKeyword == null ? void 0 : handleChangeKeyword(keyword2);
6888
+ };
6889
+ } else {
6890
+ if ((_d2 = (_c2 = window == null ? void 0 : window.sledge) == null ? void 0 : _c2.instantSearch) == null ? void 0 : _d2.productFilter)
6891
+ window.sledge.instantSearch.productFilter.search = (keyword2 = "") => {
6892
+ handleChangeKeyword == null ? void 0 : handleChangeKeyword(keyword2);
6893
+ };
6894
+ }
6895
+ }
6880
6896
  }, [isRenderAppInstantSearch]);
6881
6897
  useEffectCallback(() => {
6882
6898
  if (!valueRenderInstantSearchResult)
@@ -7254,7 +7270,8 @@ const SearchResultWidget = (props) => {
7254
7270
  attributesToRetrieve,
7255
7271
  allowedFilterSlider,
7256
7272
  hierarchicalFacetAliases,
7257
- usePublishedFilter
7273
+ usePublishedFilter,
7274
+ showOutOfStock
7258
7275
  })
7259
7276
  ] });
7260
7277
  };
@@ -7318,7 +7335,8 @@ const ResultProduct = (props) => {
7318
7335
  soldProductAtEnd,
7319
7336
  attributesToRetrieve,
7320
7337
  allowedFilterSlider,
7321
- hierarchicalFacetAliases
7338
+ hierarchicalFacetAliases,
7339
+ showOutOfStock
7322
7340
  } = props || {};
7323
7341
  const querySortBy = (query == null ? void 0 : query.sortBy) ? query.sortBy : DEFAULT_QUERY_PARAM.SORT_BY;
7324
7342
  const queryPage = (query == null ? void 0 : query.page) ? query.page : DEFAULT_QUERY_PARAM.PAGE;
@@ -7605,7 +7623,11 @@ const ResultProduct = (props) => {
7605
7623
  },
7606
7624
  separator: hierarchical_separator,
7607
7625
  separatorCollection: hierarchical_collections_separator,
7608
- additional: [(hiddenTags == null ? void 0 : hiddenTags.length) ? `'tags' NOT IN ${JSON.stringify(hiddenTags)}` : null, collectionId ? `'collections.id' = '${collectionId}'` : null],
7626
+ additional: [
7627
+ (hiddenTags == null ? void 0 : hiddenTags.length) ? `'tags' NOT IN ${JSON.stringify(hiddenTags)}` : null,
7628
+ collectionId ? `'collections.id' = '${collectionId}'` : null,
7629
+ !showOutOfStock ? `'availability' IN ${JSON.stringify(["in stock"])}` : null
7630
+ ],
7609
7631
  allowedFilterSlider,
7610
7632
  hierarchicalFacetAliases,
7611
7633
  defaultFilterItems
@@ -7652,6 +7674,20 @@ const ResultProduct = (props) => {
7652
7674
  setIsReplaceWidgetList == null ? void 0 : setIsReplaceWidgetList(true);
7653
7675
  };
7654
7676
  React__default.useEffect(() => {
7677
+ var _a2, _b2, _c2, _d2;
7678
+ if (typeof window !== "undefined") {
7679
+ if (layoutType === "default") {
7680
+ if ((_b2 = (_a2 = window == null ? void 0 : window.sledge) == null ? void 0 : _a2.instantSearch) == null ? void 0 : _b2.searchResult)
7681
+ window.sledge.instantSearch.searchResult.filter = () => {
7682
+ setTriggerClickedFacets(!triggerClickedFacets);
7683
+ };
7684
+ } else {
7685
+ if ((_d2 = (_c2 = window == null ? void 0 : window.sledge) == null ? void 0 : _c2.instantSearch) == null ? void 0 : _d2.productFilter)
7686
+ window.sledge.instantSearch.productFilter.filter = () => {
7687
+ setTriggerClickedFacets(!triggerClickedFacets);
7688
+ };
7689
+ }
7690
+ }
7655
7691
  let isKeywordChanged = Boolean(parentPreviousState && parentPreviousState.keyword !== keyword);
7656
7692
  let isReplaceData = Boolean(
7657
7693
  previousState && ((previousState == null ? void 0 : previousState.clickedLimitId) !== clickedLimitId || (previousState == null ? void 0 : previousState.clickedSortId) !== clickedSortId || (previousState == null ? void 0 : previousState.clickedFacets) !== clickedFacets) || isKeywordChanged