@sledge-app/react-instant-search 0.0.113 → 0.0.115

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.
@@ -72,8 +72,7 @@ const LOCAL_STORAGE_KEY = {
72
72
  PRODUCT_REVIEW_SETTING: "sledge-product-review-setting",
73
73
  INSTANT_SEARCH_SETTING: "sledge-instant-search-setting",
74
74
  ISSUED_AUTH_APP: "sledge-issued-auth-app",
75
- EXPIRED_AUTH_APP: "sledge-expired-auth-app",
76
- EXPIRED_SETTING: "sledge-expired-setting"
75
+ EXPIRED_AUTH_APP: "sledge-expired-auth-app"
77
76
  };
78
77
  const INTERNAL_SELECTOR_VALUE = {
79
78
  ELEMENT_TOAST_NOTIFICATION: "toast-notification",
@@ -1207,7 +1206,7 @@ const Trigger = (props) => {
1207
1206
  const { status, data: response_data } = resAddWishlist || {};
1208
1207
  const { code } = status || {};
1209
1208
  if (code === 200) {
1210
- if (((_b2 = (_a2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a2.badge) == null ? void 0 : _b2.trigger) && typeof wishlistChecked !== "boolean")
1209
+ if ((_b2 = (_a2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a2.badge) == null ? void 0 : _b2.trigger)
1211
1210
  (_f = (_c2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _c2.badge) == null ? void 0 : _f.trigger(!((_e = (_d = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _d.badge) == null ? void 0 : _e.value));
1212
1211
  BadgeInitSelector(true);
1213
1212
  if (typeof window !== "undefined") {
@@ -2944,13 +2943,13 @@ const SearchIconWidgetPopup = () => {
2944
2943
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2;
2945
2944
  const { data, onSearch = false, withFetchReviewInfo = false } = params;
2946
2945
  setIsLoading(true);
2947
- const { tabs, suffix_index_product, hidden_tags, display, show_out_of_stock } = data;
2946
+ const { index_product, tabs, hidden_tags, display, show_out_of_stock } = data;
2948
2947
  const suggestion = ((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion) || {};
2949
2948
  let response;
2950
2949
  let body = {
2951
2950
  queries: tabs.map((tab) => {
2952
2951
  const { index } = tab;
2953
- let isProductIndex = index.includes(suffix_index_product);
2952
+ let isProductIndex = index.includes(index_product);
2954
2953
  let additionalFilter = [];
2955
2954
  if (hidden_tags == null ? void 0 : hidden_tags.length)
2956
2955
  additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
@@ -2968,14 +2967,14 @@ const SearchIconWidgetPopup = () => {
2968
2967
  if (!response)
2969
2968
  return;
2970
2969
  const { results } = response;
2971
- let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(suffix_index_product));
2970
+ let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(index_product));
2972
2971
  if (onSearch && (keyword == null ? void 0 : keyword.length)) {
2973
2972
  searchTrigger({
2974
2973
  keyword,
2975
2974
  resultCount: ((_b2 = valueSearchResultProduct[0]) == null ? void 0 : _b2.totalHits) || 0
2976
2975
  });
2977
2976
  }
2978
- let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(suffix_index_product)))) == null ? void 0 : _c2.map((result) => {
2977
+ let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(index_product)))) == null ? void 0 : _c2.map((result) => {
2979
2978
  const { indexUid } = result;
2980
2979
  const { name } = tabs == null ? void 0 : tabs.find(({ index }) => index.includes(indexUid));
2981
2980
  return {
@@ -3296,7 +3295,7 @@ const SearchResultWidget = (props) => {
3296
3295
  const [allowedFilters, setAllowedFilters] = React__default.useState(((_c = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _c.filters) || []);
3297
3296
  const [allowedTabs, setAllowedTabs] = React__default.useState([]);
3298
3297
  const [facets, setFacets] = React__default.useState([]);
3299
- const [suffixIndexProduct, setSuffixIndexProduct] = React__default.useState(((_d = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _d.suffix_index_product) || "");
3298
+ const [indexProduct, setIndexProduct] = React__default.useState(((_d = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _d.index_product) || "");
3300
3299
  const [searchResultFacets, setSearchResultFacets] = React__default.useState({});
3301
3300
  const [hiddenTags, setHiddenTags] = React__default.useState(((_e = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _e.hidden_tags) || []);
3302
3301
  const [displaySettings, setDisplaySettings] = React__default.useState(((_f = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _f.display) || {});
@@ -3309,11 +3308,11 @@ const SearchResultWidget = (props) => {
3309
3308
  const handleChangeTabIndex = (id, name, e) => {
3310
3309
  setClickedTabIndexId(id);
3311
3310
  setClickedTabIndexName(name);
3312
- setResultComponent(id.includes(suffixIndexProduct) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResultCategory, {}));
3311
+ setResultComponent(id.includes(indexProduct) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResultCategory, {}));
3313
3312
  };
3314
3313
  const handleInitStates = async (data, type) => {
3315
- const { filters, tabs, suffix_index_product, hidden_tags, show_out_of_stock } = data;
3316
- let getTabs = layoutType === "product-filter" ? tabs.filter(({ index }) => index == null ? void 0 : index.includes(suffix_index_product)) : tabs;
3314
+ const { filters, index_product, tabs, hidden_tags, show_out_of_stock } = data;
3315
+ let getTabs = layoutType === "product-filter" ? tabs.filter(({ index }) => index == null ? void 0 : index.includes(index_product)) : tabs;
3317
3316
  let response;
3318
3317
  let body = {
3319
3318
  queries: getTabs.map((tab) => {
@@ -3331,7 +3330,7 @@ const SearchResultWidget = (props) => {
3331
3330
  }
3332
3331
  }
3333
3332
  }) : [];
3334
- let isProductIndex = index.includes(suffix_index_product);
3333
+ let isProductIndex = index.includes(index_product);
3335
3334
  let isHasProductFacets = isProductIndex && getFacets.length;
3336
3335
  let additionalFilter = [];
3337
3336
  if (hidden_tags == null ? void 0 : hidden_tags.length)
@@ -3376,7 +3375,7 @@ const SearchResultWidget = (props) => {
3376
3375
  })
3377
3376
  );
3378
3377
  } else {
3379
- const { facetDistribution, facetStats } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid.includes(suffix_index_product))) || {};
3378
+ const { facetDistribution, facetStats } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid.includes(index_product))) || {};
3380
3379
  setSearchResultFacets(
3381
3380
  facetDistribution ? Object.fromEntries(
3382
3381
  Object.entries(facetDistribution).map((facet) => {
@@ -3416,16 +3415,16 @@ const SearchResultWidget = (props) => {
3416
3415
  response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
3417
3416
  if (!response)
3418
3417
  return;
3419
- const { allowed_sorts, default_sort, filters, tabs, suffix_index_product, hidden_tags, display, colors, show_out_of_stock } = response;
3418
+ const { allowed_sorts, default_sort, filters, index_product, tabs, hidden_tags, display, colors, show_out_of_stock } = response;
3420
3419
  setAllowedSorts((allowed_sorts == null ? void 0 : allowed_sorts.length) ? allowed_sorts : []);
3421
3420
  setAllowedFilters((filters == null ? void 0 : filters.length) ? filters : []);
3422
- setSuffixIndexProduct(suffix_index_product);
3421
+ setIndexProduct(index_product);
3423
3422
  setHiddenTags(hidden_tags);
3424
3423
  setDisplaySettings(display);
3425
3424
  setColorSwatches(colors);
3426
3425
  setDefaultSort(default_sort);
3427
3426
  setShowOutOfStock(show_out_of_stock);
3428
- getFirstIndex = tabs.find(({ index }) => index.includes(suffix_index_product));
3427
+ getFirstIndex = tabs.find(({ index }) => index.includes(index_product));
3429
3428
  if (Object.keys(getFirstIndex).length) {
3430
3429
  setClickedTabIndexId(getFirstIndex.index);
3431
3430
  setClickedTabIndexName(getFirstIndex.name);
@@ -3440,6 +3439,9 @@ const SearchResultWidget = (props) => {
3440
3439
  const searchParams2 = new URLSearchParams(document.location.search);
3441
3440
  setKeyword((searchParams2 == null ? void 0 : searchParams2.get(queryKeyword)) || "");
3442
3441
  handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
3442
+ window.addEventListener("popstate", (event) => {
3443
+ console.log(`location: ${document.location}, state: ${JSON.stringify(event.state)}`);
3444
+ });
3443
3445
  }, [isRenderAppInstantSearch]);
3444
3446
  React__default.useEffect(() => {
3445
3447
  if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword) && layoutType === "default") {
@@ -4613,13 +4615,13 @@ const SearchWidget = (props) => {
4613
4615
  if (!keyword.length)
4614
4616
  return;
4615
4617
  setIsLoading(true);
4616
- const { tabs, suffix_index_product, hidden_tags, display, show_out_of_stock } = data;
4618
+ const { index_product, tabs, hidden_tags, display, show_out_of_stock } = data;
4617
4619
  const suggestion = ((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion) || {};
4618
4620
  let response;
4619
4621
  let body = {
4620
4622
  queries: tabs.map((tab) => {
4621
4623
  const { index } = tab;
4622
- let isProductIndex = index.includes(suffix_index_product);
4624
+ let isProductIndex = index.includes(index_product);
4623
4625
  let additionalFilter = [];
4624
4626
  if (hidden_tags == null ? void 0 : hidden_tags.length)
4625
4627
  additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
@@ -4637,14 +4639,14 @@ const SearchWidget = (props) => {
4637
4639
  if (!response)
4638
4640
  return;
4639
4641
  const { results } = response;
4640
- let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(suffix_index_product));
4642
+ let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(index_product));
4641
4643
  if (onSearch && (keyword == null ? void 0 : keyword.length)) {
4642
4644
  searchTrigger({
4643
4645
  keyword,
4644
4646
  resultCount: ((_b2 = valueSearchResultProduct[0]) == null ? void 0 : _b2.totalHits) || 0
4645
4647
  });
4646
4648
  }
4647
- let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(suffix_index_product)))) == null ? void 0 : _c2.map((result) => {
4649
+ let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(index_product)))) == null ? void 0 : _c2.map((result) => {
4648
4650
  const { indexUid } = result;
4649
4651
  const { name } = tabs == null ? void 0 : tabs.find(({ index }) => index.includes(indexUid));
4650
4652
  return {