@sledge-app/react-instant-search 0.0.77 → 0.0.78

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.
@@ -2666,7 +2666,7 @@ const SearchIconWidgetPopup = () => {
2666
2666
  ] }) });
2667
2667
  };
2668
2668
  const SearchResultWidget = (props) => {
2669
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2669
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2670
2670
  const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
2671
2671
  const { layoutType = "default", query, params, children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct, data: propsData } = props;
2672
2672
  const { keyword: queryKeyword = "" } = query || {};
@@ -2679,10 +2679,11 @@ const SearchResultWidget = (props) => {
2679
2679
  productCardsComponent = productCard;
2680
2680
  }
2681
2681
  });
2682
- const [settings] = React__default.useState(typeof localStorage !== "undefined" ? (_a = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "{}")) == null ? void 0 : _a.data : {});
2682
+ const searchParams = typeof document !== "undefined" ? new URLSearchParams((_a = document == null ? void 0 : document.location) == null ? void 0 : _a.search) : null;
2683
+ const [settings] = React__default.useState(typeof localStorage !== "undefined" ? (_b = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "{}")) == null ? void 0 : _b.data : {});
2683
2684
  const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
2684
2685
  const [isLoading, setIsLoading] = React__default.useState(true);
2685
- const [keyword, setKeyword] = React__default.useState("");
2686
+ const [keyword, setKeyword] = React__default.useState(searchParams == null ? void 0 : searchParams.get(queryKeyword));
2686
2687
  const [clickedTabIndexId, setClickedTabIndexId] = React__default.useState(null);
2687
2688
  const [clickedTabIndexName, setClickedTabIndexName] = React__default.useState();
2688
2689
  const [resultComponent, setResultComponent] = React__default.useState(/* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}));
@@ -2749,7 +2750,6 @@ const SearchResultWidget = (props) => {
2749
2750
  if (propsData && initStatesFirstTime) {
2750
2751
  response = propsData.result;
2751
2752
  setInitStatesFirstTime(false);
2752
- response = await multiSearch(body);
2753
2753
  } else
2754
2754
  response = await multiSearch(body);
2755
2755
  if (!response)
@@ -2833,8 +2833,8 @@ const SearchResultWidget = (props) => {
2833
2833
  React__default.useEffect(() => {
2834
2834
  if (!(isRenderApp == null ? void 0 : isRenderApp.instantSearch))
2835
2835
  return;
2836
- const searchParams = new URLSearchParams(document.location.search);
2837
- setKeyword((searchParams == null ? void 0 : searchParams.get(queryKeyword)) || "");
2836
+ const searchParams2 = new URLSearchParams(document.location.search);
2837
+ setKeyword((searchParams2 == null ? void 0 : searchParams2.get(queryKeyword)) || "");
2838
2838
  handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
2839
2839
  }, [isRenderApp]);
2840
2840
  React__default.useEffect(() => {
@@ -2848,8 +2848,8 @@ const SearchResultWidget = (props) => {
2848
2848
  }
2849
2849
  }, [keyword]);
2850
2850
  const tabSkeleton = layoutType === "default" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-tab-list sledge-instant-search__result-tab-list-skeleton", children: [1, 2, 3, 4, 5].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "122px", height: "28px", rounded: "md", color: "grey-100", animationDuration: "15s" }, index)) }) : null;
2851
- const filterHorizontalSkeleton = ((_b = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b.enable_on_search) && ((_c = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _c.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-skeleton", children: [1, 2, 3, 4, 5, 6, 7].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "106px", height: "42px", rounded: "md", color: "grey-100", animationDuration: "13s" }, index)) }) : null;
2852
- const filterVerticalSkeleton = ((_d = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _d.enable_on_search) && ((_e = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _e.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2851
+ const filterHorizontalSkeleton = ((_c = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _c.enable_on_search) && ((_d = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _d.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-skeleton", children: [1, 2, 3, 4, 5, 6, 7].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "106px", height: "42px", rounded: "md", color: "grey-100", animationDuration: "13s" }, index)) }) : null;
2852
+ const filterVerticalSkeleton = ((_e = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _e.enable_on_search) && ((_f = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _f.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2853
2853
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
2854
2854
  "div",
2855
2855
  {
@@ -3065,7 +3065,7 @@ const SearchResultWidget = (props) => {
3065
3065
  )
3066
3066
  ] }) : null;
3067
3067
  const productGridSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3068
- ((_f = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _f.show_total_products) && ((_g = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _g.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
3068
+ ((_g = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _g.show_total_products) && ((_h = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _h.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
3069
3069
  SkeletonLoading.Item,
3070
3070
  {
3071
3071
  width: "117px",
@@ -3081,7 +3081,7 @@ const SearchResultWidget = (props) => {
3081
3081
  /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ProductGrid, { count: 12, type: "large" })
3082
3082
  ] });
3083
3083
  const searchAndSelectOptionSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-keyword", children: [
3084
- ((_h = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _h.show_total_products) && ((_i = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _i.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-horizontal", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "117px", height: "28px", color: "grey-100", rounded: "md", animationDuration: "13s" }) }) : null,
3084
+ ((_i = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _i.show_total_products) && ((_j = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _j.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-horizontal", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "117px", height: "28px", color: "grey-100", rounded: "md", animationDuration: "13s" }) }) : null,
3085
3085
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-keyword-form", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3086
3086
  SkeletonLoading.Item,
3087
3087
  {
@@ -3112,7 +3112,7 @@ const SearchResultWidget = (props) => {
3112
3112
  tabSkeleton,
3113
3113
  filterHorizontalSkeleton,
3114
3114
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-wrapper sledge-instant-search__result-wrapper-skeleton", children: [
3115
- ((_j = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _j.enable_on_search) && ((_k = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _k.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : null,
3115
+ ((_k = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _k.enable_on_search) && ((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : null,
3116
3116
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data", children: [
3117
3117
  searchAndSelectOptionSkeleton,
3118
3118
  productGridSkeleton