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

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.
@@ -2716,7 +2716,7 @@ const WidgetRoot = (props) => {
2716
2716
  }
2717
2717
  };
2718
2718
  const handleSetWishlistData = async (isLoadMore = false, init = false) => {
2719
- var _a2, _b2, _c2;
2719
+ var _a2, _b2;
2720
2720
  const searchParams = new URLSearchParams(document.location.search);
2721
2721
  const getShareId = (params == null ? void 0 : params.shareId) ? params.shareId : (searchParams == null ? void 0 : searchParams.get(queryShareId)) || "";
2722
2722
  setIsLoading(isRefreshWidgetList ? true : !isLoadMore);
@@ -2743,15 +2743,16 @@ const WidgetRoot = (props) => {
2743
2743
  response = propsData;
2744
2744
  } else
2745
2745
  response = await getWishlist(queryParam);
2746
+ const responseData = (response == null ? void 0 : response.data) ?? [];
2746
2747
  run = ((_a2 = response == null ? void 0 : response.status) == null ? void 0 : _a2.code) === 200 || false;
2747
- valueWishlistData = !((_b2 = response.data) == null ? void 0 : _b2.length) ? [] : (prevState) => (wishlistData == null ? void 0 : wishlistData.length) && isLoadMore ? [...prevState, ...response.data] : response.data;
2748
- valueTotalPage = ((_c2 = response == null ? void 0 : response.page) == null ? void 0 : _c2.total_page) || 1;
2748
+ valueWishlistData = !responseData.length ? [] : (prevState) => (wishlistData == null ? void 0 : wishlistData.length) && isLoadMore ? [...prevState, ...responseData] : responseData;
2749
+ valueTotalPage = ((_b2 = response == null ? void 0 : response.page) == null ? void 0 : _b2.total_page) || 1;
2749
2750
  if (run) {
2750
2751
  setWishlistData(valueWishlistData);
2751
2752
  setTotalPage(valueTotalPage);
2752
- setIsLoading(false);
2753
- setIsRefreshWidgetList(false);
2754
2753
  }
2754
+ setIsLoading(false);
2755
+ setIsRefreshWidgetList(false);
2755
2756
  };
2756
2757
  const handleShareData = async () => {
2757
2758
  var _a2, _b2, _c2, _d;
@@ -3184,7 +3185,8 @@ const Badge = (props) => {
3184
3185
  setOpen: setOpenFlyoutWishlistWidget,
3185
3186
  position: "right",
3186
3187
  className: "sledge-flyout-widget__wishlist",
3187
- withBlurEffect: true
3188
+ withBlurEffect: true,
3189
+ unmountContentOnLoading: false
3188
3190
  }
3189
3191
  ) : null,
3190
3192
  isFirstLoading ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: position === "none" ? /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderMenu, {}) : String(position).includes("bottom") ? /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingIcon, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingFull, {}) })
@@ -5866,7 +5868,18 @@ const DotButton = (props) => {
5866
5868
  return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", ...restProps, children });
5867
5869
  };
5868
5870
  const FlyoutSidebar$1 = "";
5869
- const FlyoutSidebar = ({ title, content, footer = null, open, setOpen, position = "left", className = "", withBlurEffect = false, flyoutInfoContent = null }) => {
5871
+ const FlyoutSidebar = ({
5872
+ title,
5873
+ content,
5874
+ footer = null,
5875
+ open,
5876
+ setOpen,
5877
+ position = "left",
5878
+ className = "",
5879
+ withBlurEffect = false,
5880
+ flyoutInfoContent = null,
5881
+ unmountContentOnLoading = true
5882
+ }) => {
5870
5883
  const [isLoading, setIsLoading] = React__default.useState(false);
5871
5884
  const [isScrollAtBottom, setIsScrollAtBottom] = React__default.useState(false);
5872
5885
  const contentContainerRef = React__default.useRef(null);
@@ -5915,11 +5928,11 @@ const FlyoutSidebar = ({ title, content, footer = null, open, setOpen, position
5915
5928
  {
5916
5929
  ref: contentContainerRef,
5917
5930
  className: `sledge__flyout-mobile-content ${showBlurEffect ? "sledge__flyout-mobile-content-blur-effect" : ""}`,
5918
- style: isLoading ? { display: "none" } : void 0,
5919
- children: content
5931
+ style: unmountContentOnLoading && isLoading ? { display: "none" } : void 0,
5932
+ children: unmountContentOnLoading && isLoading ? null : content
5920
5933
  }
5921
5934
  ),
5922
- footer ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__flyout-mobile-footer", style: isLoading ? { display: "none" } : void 0, children: footer }) : null
5935
+ footer ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__flyout-mobile-footer", style: unmountContentOnLoading && isLoading ? { display: "none" } : void 0, children: unmountContentOnLoading && isLoading ? null : footer }) : null
5923
5936
  ] })
5924
5937
  ] }),
5925
5938
  document.body
@@ -9701,9 +9714,9 @@ const SearchResultWidget = (props) => {
9701
9714
  valueHierarchicalFacetAliases
9702
9715
  };
9703
9716
  };
9704
- const handleSetInitStates = ({ results = {}, data = {}, callback, isUpdateFilter = false }) => {
9717
+ const handleSetInitStates = ({ results = {}, data, callback, isUpdateFilter = false }) => {
9705
9718
  var _a2, _b2, _c2;
9706
- const { filters, index_product, tabs: tabs2, hidden_tags, show_out_of_stock, display, use_published_filter } = data;
9719
+ const { filters, index_product, tabs: tabs2, hidden_tags, show_out_of_stock, display, use_published_filter } = data ?? {};
9707
9720
  const {
9708
9721
  facetStats,
9709
9722
  totalHits: totalHitsResult,
@@ -9778,15 +9791,16 @@ const SearchResultWidget = (props) => {
9778
9791
  });
9779
9792
  };
9780
9793
  const handleInitStates = async (data) => {
9781
- const { filters, index_product, tabs: tabs2, hidden_tags, show_out_of_stock, display, use_published_filter } = data;
9782
- let getTabs = layoutType === "product-filter" ? tabs2.filter(({ index }) => index == null ? void 0 : index.includes(index_product)) : tabs2;
9783
- getTabs.map((tab) => {
9784
- var _a2, _b2, _c2, _d2, _e2, _f2;
9794
+ var _a2, _b2;
9795
+ const { filters, index_product, tabs: tabs2, hidden_tags, show_out_of_stock, display, use_published_filter } = data ?? {};
9796
+ const getTabs = layoutType === "product-filter" ? (_a2 = tabs2 == null ? void 0 : tabs2.filter) == null ? void 0 : _a2.call(tabs2, ({ index }) => index == null ? void 0 : index.includes(index_product)) : tabs2;
9797
+ (_b2 = getTabs == null ? void 0 : getTabs.map) == null ? void 0 : _b2.call(getTabs, (tab) => {
9798
+ var _a3, _b3, _c2, _d2, _e2, _f2;
9785
9799
  const { index } = tab;
9786
9800
  let isSetFilter2 = false;
9787
9801
  let getFacets = [];
9788
9802
  if (!isSetFilter2) {
9789
- let allowedFiltersCollectionId = (_c2 = (_b2 = (_a2 = filters == null ? void 0 : filters.map) == null ? void 0 : _a2.call(filters, (filter) => {
9803
+ let allowedFiltersCollectionId = (_c2 = (_b3 = (_a3 = filters == null ? void 0 : filters.map) == null ? void 0 : _a3.call(filters, (filter) => {
9790
9804
  const { active, collections, items } = filter;
9791
9805
  if (!active)
9792
9806
  return;
@@ -9796,7 +9810,7 @@ const SearchResultWidget = (props) => {
9796
9810
  } else {
9797
9811
  return;
9798
9812
  }
9799
- })) == null ? void 0 : _b2.filter) == null ? void 0 : _c2.call(_b2, (item) => item);
9813
+ })) == null ? void 0 : _b3.filter) == null ? void 0 : _c2.call(_b3, (item) => item);
9800
9814
  let allowedFiltersCollectionAll = (_f2 = (_e2 = (_d2 = filters == null ? void 0 : filters.map) == null ? void 0 : _d2.call(filters, (filter) => {
9801
9815
  const { active, collections, items } = filter;
9802
9816
  if (!active)
@@ -10754,8 +10768,8 @@ const ResultProduct = React__default.memo((props) => {
10754
10768
  let isCurrentIndex = index.includes(clickedTabIndexId);
10755
10769
  let tabTotal = isCurrentIndex ? totalHits : total;
10756
10770
  if (layoutType === "default" && ((_a3 = resultProp == null ? void 0 : resultProp.results) == null ? void 0 : _a3.length)) {
10757
- const { totalHits: totalHits2 } = (_c2 = (_b3 = resultProp == null ? void 0 : resultProp.results) == null ? void 0 : _b3.find) == null ? void 0 : _c2.call(_b3, ({ indexUid }) => indexUid.includes(index));
10758
- tabTotal = totalHits2 || tabTotal;
10771
+ const { totalHits: totalHitsFromIndex } = ((_c2 = (_b3 = resultProp == null ? void 0 : resultProp.results) == null ? void 0 : _b3.find) == null ? void 0 : _c2.call(_b3, ({ indexUid }) => indexUid.includes(index))) || {};
10772
+ tabTotal = totalHitsFromIndex ?? tabTotal;
10759
10773
  }
10760
10774
  return {
10761
10775
  ...tab,