@sledge-app/react-instant-search 1.0.49 → 1.0.51

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.
@@ -3942,8 +3942,10 @@ const ButtonLoadMore = ({ text, onClick, isInfiniteScroll, currentPage, totalPag
3942
3942
  };
3943
3943
  React__default.useEffect(() => {
3944
3944
  handlePageInfo();
3945
- if (isInfiniteScroll && isVisibleLoadMore && (entry == null ? void 0 : entry.isIntersecting))
3946
- onClick == null ? void 0 : onClick();
3945
+ if (isInfiniteScroll && isVisibleLoadMore && (entry == null ? void 0 : entry.isIntersecting)) {
3946
+ const delay = setTimeout(() => onClick == null ? void 0 : onClick(), 500);
3947
+ return () => clearTimeout(delay);
3948
+ }
3947
3949
  }, [entry]);
3948
3950
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__pagination", ref, children: (entry == null ? void 0 : entry.isIntersecting) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__load-more", children: [
3949
3951
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: pageInfo }),
@@ -4699,27 +4701,31 @@ const ResultProduct = (props) => {
4699
4701
  ...filter_button_text_transform && { textTransform: filter_button_text_transform }
4700
4702
  });
4701
4703
  let hierarchicalFacetAliases = Object.entries(HIERARCHICAL_FACET_OBJECT_ALIASES).map((hierarchicalFacetAlias) => hierarchicalFacetAlias[1]);
4702
- let facetHierarchical = hierarchicalFacetAliases.reduce((item, key) => {
4703
- let defaultLevelHierarchical = {};
4704
- for (let iLevel = 0; iLevel < MAX_LIMIT_HIERARCHICAL; iLevel++) {
4705
- defaultLevelHierarchical[`lvl${iLevel}`] = [];
4706
- }
4707
- return { ...item, [key]: defaultLevelHierarchical };
4708
- }, {});
4709
- Object.entries(clickedFacets).map((facet) => {
4710
- var _a2;
4711
- if ((facet == null ? void 0 : facet.length) && facet[1].length) {
4712
- let isHierarchical = hierarchicalFacetAliases.includes(facet[0]);
4713
- if (isHierarchical)
4714
- (_a2 = facet[1]) == null ? void 0 : _a2.map((item) => {
4715
- const arrItem = String(item).split(hierarchical_separator);
4716
- if ((arrItem == null ? void 0 : arrItem.length) && Object.hasOwn(facetHierarchical[facet[0]], `lvl${arrItem.length - 1}`))
4717
- facetHierarchical[facet[0]][`lvl${arrItem.length - 1}`].push(item);
4718
- });
4719
- }
4720
- });
4721
4704
  const isLoadMore = ["load_more", "infinite_scroll"].includes((_j = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _j.pagination_type);
4722
4705
  const isVisibleLoadMore = totalPage === currentPage && !isLoadingButtonLoadMore ? false : totalPage >= currentPage;
4706
+ const detectArrFacetHierarchical = (clickedFacetsObject) => {
4707
+ let facetHierarchical = hierarchicalFacetAliases.reduce((item, key) => {
4708
+ let defaultLevelHierarchical = {};
4709
+ for (let iLevel = 0; iLevel < MAX_LIMIT_HIERARCHICAL; iLevel++) {
4710
+ defaultLevelHierarchical[`lvl${iLevel}`] = [];
4711
+ }
4712
+ return { ...item, [key]: defaultLevelHierarchical };
4713
+ }, {});
4714
+ Object.entries(clickedFacetsObject).map((facet) => {
4715
+ var _a2;
4716
+ if ((facet == null ? void 0 : facet.length) && facet[1].length) {
4717
+ let isHierarchical = hierarchicalFacetAliases.includes(facet[0]);
4718
+ if (isHierarchical)
4719
+ (_a2 = facet[1]) == null ? void 0 : _a2.map((item) => {
4720
+ const arrItem = String(item).split(hierarchical_separator);
4721
+ if ((arrItem == null ? void 0 : arrItem.length) && Object.hasOwn(facetHierarchical[facet[0]], `lvl${arrItem.length - 1}`))
4722
+ facetHierarchical[facet[0]][`lvl${arrItem.length - 1}`].push(item);
4723
+ });
4724
+ }
4725
+ });
4726
+ return facetHierarchical;
4727
+ };
4728
+ let arrSelectedFacetHierarchical = detectArrFacetHierarchical(clickedFacets);
4723
4729
  const detectQueryStringFilter = (facetsQueryStringObject) => {
4724
4730
  const searchParams = new URLSearchParams(document.location.search);
4725
4731
  const searchParamsObject = Object.fromEntries(searchParams);
@@ -4785,12 +4791,15 @@ const ResultProduct = (props) => {
4785
4791
  var _a2;
4786
4792
  let facets2 = [value];
4787
4793
  let isRange = ["variants.price"].includes(parentId);
4794
+ let isHierarchical = hierarchicalFacetAliases.includes(parentId);
4788
4795
  if (clickedFacets) {
4789
4796
  if (force) {
4790
4797
  facets2 = [value];
4791
4798
  } else {
4792
4799
  if ((_a2 = clickedFacets[parentId]) == null ? void 0 : _a2.includes(value)) {
4793
4800
  facets2 = clickedFacets[parentId].filter((facet) => facet !== value);
4801
+ if (isHierarchical)
4802
+ facets2 = facets2.filter((facet) => !facet.startsWith(value));
4794
4803
  } else {
4795
4804
  if (isRange) {
4796
4805
  if (clickedFacets[parentId], clickedFacets[parentId] === value) {
@@ -4848,6 +4857,7 @@ const ResultProduct = (props) => {
4848
4857
  }
4849
4858
  setIsLoading(isReplaceData ? true : !isLoadMore2);
4850
4859
  let detectClickedFacets = detectQueryStringFilter(clickedFacets);
4860
+ let facetHierarchical = detectArrFacetHierarchical(detectClickedFacets);
4851
4861
  let response;
4852
4862
  let filters = Object.entries(detectClickedFacets).map((facet) => {
4853
4863
  var _a3, _b3;
@@ -5229,7 +5239,7 @@ const ResultProduct = (props) => {
5229
5239
  let parent = hierarchicalFacets;
5230
5240
  for (let facet of facets2) {
5231
5241
  const names = facet.name.split(hierarchical_separator);
5232
- const selectedFacetHierarchical = facetHierarchical[indexValue][`lvl${level}`];
5242
+ const selectedFacetHierarchical = arrSelectedFacetHierarchical[indexValue][`lvl${level}`];
5233
5243
  const isWhenSelectedHideSiblings = hide_unrelated && (selectedFacetHierarchical == null ? void 0 : selectedFacetHierarchical.length) && !selectedFacetHierarchical.includes(facet.value);
5234
5244
  const isHidden = hierarchical_hiddens == null ? void 0 : hierarchical_hiddens.find((hierarchical_hidden) => {
5235
5245
  var _a3;