@sledge-app/react-instant-search 2.0.16 → 2.0.18

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.
@@ -4306,7 +4306,7 @@ ${selectedOption === item ? "sledge__product-variant-size-swatch-active" : ""} s
4306
4306
  const colorOptionClass = `${selectedOption === item ? "sledge__product-variant-color-swatch-active" : ""} sledge__product-variant-color-swatch`;
4307
4307
  const colorDataSettings = ((_a3 = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING))) == null ? void 0 : _a3.colors) || [];
4308
4308
  const getColorSwatch = (colorDataSettings == null ? void 0 : colorDataSettings.filter(({ name }) => name === item)[0]) || {};
4309
- const colorSwatch = (getColorSwatch == null ? void 0 : getColorSwatch.image) ? `url(${getColorSwatch == null ? void 0 : getColorSwatch.image})` : (getColorSwatch == null ? void 0 : getColorSwatch.rgb) || item;
4309
+ const colorSwatch = (getColorSwatch == null ? void 0 : getColorSwatch.image) ? `url('${getColorSwatch == null ? void 0 : getColorSwatch.image}')` : (getColorSwatch == null ? void 0 : getColorSwatch.rgb) || item;
4310
4310
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
4311
4311
  "button",
4312
4312
  {
@@ -7227,7 +7227,8 @@ const FilterItem = (props) => {
7227
7227
  allowedFilter = [],
7228
7228
  layoutType,
7229
7229
  collectionId,
7230
- isHorizontalGroup = false
7230
+ isHorizontalGroup = false,
7231
+ renderedCount = 0
7231
7232
  } = props;
7232
7233
  const { value, label } = filter;
7233
7234
  const filterItemId = `filter-${indexFilter}-${layoutType}-${collectionId || "all"}-${deviceType}-${stringToSlug(value)}`;
@@ -7255,7 +7256,7 @@ const FilterItem = (props) => {
7255
7256
  setClickedOpenFilterHorizontalId == null ? void 0 : setClickedOpenFilterHorizontalId(valueOpenFilterHorizontal);
7256
7257
  }
7257
7258
  },
7258
- className: isHorizontalGroup ? "sledge-instant-search__result-filter-trigger-horizontal-group" : `${isLastIndex ? (allowedFilter == null ? void 0 : allowedFilter.length) % 2 ? "sledge-instant-search__result-filter-trigger-odd" : "sledge-instant-search__result-filter-trigger-even" : ""}`,
7259
+ className: isHorizontalGroup ? "sledge-instant-search__result-filter-trigger-horizontal-group" : `${isLastIndex ? renderedCount % 2 ? "sledge-instant-search__result-filter-trigger-odd" : "sledge-instant-search__result-filter-trigger-even" : ""}`,
7259
7260
  style: filterTitleStyle,
7260
7261
  children: [
7261
7262
  label,
@@ -7351,9 +7352,21 @@ const FilterHorizontal = (props) => {
7351
7352
  isHorizontalGroup = false,
7352
7353
  allowedFilterSlider
7353
7354
  } = props;
7355
+ const [renderedCount, setRenderedCount] = React__default.useState(0);
7356
+ React__default.useEffect(() => {
7357
+ const countRenderedComponents = () => {
7358
+ const renderedComponents = document.querySelectorAll(".sledge-instant-search__result-filter-horizontal.sledge-instant-search__result-filter-horizontal-component .sledge__button");
7359
+ setRenderedCount(renderedComponents.length);
7360
+ };
7361
+ const timer = setTimeout(countRenderedComponents, 0);
7362
+ return () => clearTimeout(timer);
7363
+ }, [items]);
7354
7364
  const { sort = null, limit = null } = components;
7355
7365
  const wrapperAdditionalProps = {
7356
- ...isHorizontalGroup && { "horizontal-group": "" }
7366
+ ...isHorizontalGroup && { "horizontal-group": "" },
7367
+ ...{
7368
+ [renderedCount % 2 ? "odd-items" : "even-items"]: ""
7369
+ }
7357
7370
  };
7358
7371
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isSkeleton ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-skeleton", ...wrapperAdditionalProps, children: [1, 2, 3, 4, 5, 6, 7].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "106px", height: "42px", rounded: "md", color: "lighten" }, index)) }) : (items == null ? void 0 : items.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal-wrapper", ...wrapperAdditionalProps, children: [
7359
7372
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
@@ -7376,7 +7389,8 @@ const FilterHorizontal = (props) => {
7376
7389
  allowedFilter: items,
7377
7390
  layoutType,
7378
7391
  collectionId,
7379
- isHorizontalGroup
7392
+ isHorizontalGroup,
7393
+ renderedCount
7380
7394
  }
7381
7395
  )),
7382
7396
  sort ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-sort", children: sort }) : null,
@@ -8950,9 +8964,10 @@ const SearchResultWidget = (props) => {
8950
8964
  let valueAllowedFilterSlider = [];
8951
8965
  let valueHierarchicalFacetAliases = [];
8952
8966
  if (!isSetFilter) {
8967
+ let isSetFilterItems = false;
8953
8968
  allowedFilters == null ? void 0 : allowedFilters.map((filter) => {
8954
8969
  const { active, collections, items } = filter;
8955
- if (!active)
8970
+ if (!active || isSetFilterItems)
8956
8971
  return;
8957
8972
  const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => {
8958
8973
  return {
@@ -8962,10 +8977,12 @@ const SearchResultWidget = (props) => {
8962
8977
  });
8963
8978
  if (collectionId && (collections == null ? void 0 : collections.includes(String(collectionId)))) {
8964
8979
  isSetFilter = true;
8980
+ isSetFilterItems = true;
8965
8981
  valueAllowedFilter = newItems;
8966
8982
  } else {
8967
8983
  if (collections == null ? void 0 : collections.includes("all")) {
8968
8984
  isSetFilter = true;
8985
+ isSetFilterItems = true;
8969
8986
  valueAllowedFilter = newItems;
8970
8987
  }
8971
8988
  }
@@ -9109,22 +9126,26 @@ const SearchResultWidget = (props) => {
9109
9126
  const { index } = tab;
9110
9127
  let isSetFilter2 = false;
9111
9128
  let getFacets = [];
9112
- if (!isSetFilter2)
9129
+ if (!isSetFilter2) {
9130
+ let isSetFilterItems = false;
9113
9131
  filters == null ? void 0 : filters.map((filter) => {
9114
9132
  const { active, collections, items } = filter;
9115
- if (!active)
9133
+ if (!active || isSetFilterItems)
9116
9134
  return;
9117
9135
  const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => (otherItem == null ? void 0 : otherItem.display) === "tree" ? HIERARCHICAL_FACET_OBJECT_ALIASES[value] || value : value);
9118
9136
  if (collectionId && (collections == null ? void 0 : collections.includes(String(collectionId)))) {
9119
9137
  isSetFilter2 = true;
9138
+ isSetFilterItems = true;
9120
9139
  getFacets = newItems;
9121
9140
  } else {
9122
9141
  if (collections == null ? void 0 : collections.includes("all")) {
9123
9142
  isSetFilter2 = true;
9143
+ isSetFilterItems = true;
9124
9144
  getFacets = newItems;
9125
9145
  }
9126
9146
  }
9127
9147
  });
9148
+ }
9128
9149
  let isProductIndex = index.includes(index_product);
9129
9150
  let isHasProductFacets = isProductIndex && getFacets.length;
9130
9151
  if (isHasProductFacets)