@sledge-app/react-instant-search 2.0.32 → 2.0.34

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.
@@ -4218,6 +4218,8 @@ const VariantSelector = (props) => {
4218
4218
  defaultSelected["data-inventory-quantity"] = variants[0].inventory_quantity;
4219
4219
  defaultSelected["data-inventory-management"] = variants[0].inventory_management;
4220
4220
  defaultSelected["data-inventory-policy"] = variants[0].inventory_policy;
4221
+ defaultSelected["data-price"] = variants[0].price;
4222
+ defaultSelected["data-compare-at-price"] = variants[0].compare_at_price;
4221
4223
  }
4222
4224
  setDefaultFunction();
4223
4225
  function setSelectedOption(element, optionName) {
@@ -4317,8 +4319,11 @@ const VariantSelector = (props) => {
4317
4319
  setSelectedVariantInventoryPolicy == null ? void 0 : setSelectedVariantInventoryPolicy(inventoryPolicy);
4318
4320
  if (price)
4319
4321
  setSelectedVariantPrice == null ? void 0 : setSelectedVariantPrice(price);
4320
- if (compareAtPrice)
4322
+ if (compareAtPrice) {
4321
4323
  setSelectedVariantCompareAtPrice == null ? void 0 : setSelectedVariantCompareAtPrice(compareAtPrice);
4324
+ } else {
4325
+ setSelectedVariantCompareAtPrice == null ? void 0 : setSelectedVariantCompareAtPrice(0);
4326
+ }
4322
4327
  if (imageId)
4323
4328
  parentCard.querySelector(`img.sledge__product-grid-card-image-featured-image`).src = parentCard.querySelector(`div.sledge__product-grid-card-variant-images img[id="${imageId}"]`).src;
4324
4329
  };
@@ -9449,7 +9454,7 @@ const SearchResultWidget = (props) => {
9449
9454
  return;
9450
9455
  };
9451
9456
  const handleSettings = ({ LOCAL_STORAGE_INSTANT_SEARCH_SETTING, isPreviewSettings = false }) => {
9452
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
9457
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
9453
9458
  setIsLoadingSetting(true);
9454
9459
  let response;
9455
9460
  let responseGeneral;
@@ -9499,9 +9504,11 @@ const SearchResultWidget = (props) => {
9499
9504
  setHiddenTags(hidden_tags);
9500
9505
  setDisplaySettings(display);
9501
9506
  setColorSwatches(colors);
9502
- setDefaultSort(
9503
- (searchParams == null ? void 0 : searchParams.get(querySortBy)) ? searchParams == null ? void 0 : searchParams.get(querySortBy) : collectionId ? String(default_sort).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collectionId)) : collections_all_id ? String(default_sort).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collections_all_id)) : String(default_sort).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID) ? (_a2 = valueAllowedSorts[0]) == null ? void 0 : _a2.value : default_sort
9504
- );
9507
+ let valueDefaultSort = (searchParams == null ? void 0 : searchParams.get(querySortBy)) ? searchParams == null ? void 0 : searchParams.get(querySortBy) : collectionId ? String(default_sort).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collectionId)) : collections_all_id ? String(default_sort).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collections_all_id)) : String(default_sort).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID) ? (_a2 = valueAllowedSorts[0]) == null ? void 0 : _a2.value : default_sort;
9508
+ if (!((_d2 = (_c2 = (_b2 = allowed_sorts == null ? void 0 : allowed_sorts.map) == null ? void 0 : _b2.call(allowed_sorts, (item) => item.value)) == null ? void 0 : _c2.includes) == null ? void 0 : _d2.call(_c2, default_sort))) {
9509
+ valueDefaultSort = (_e2 = valueAllowedSorts == null ? void 0 : valueAllowedSorts[0]) == null ? void 0 : _e2.value;
9510
+ }
9511
+ setDefaultSort(valueDefaultSort);
9505
9512
  setDefaultLimit(instantSearchPreviewSettings ? limit : (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.LIMIT_PRODUCT)) || limit);
9506
9513
  setLanguageSettings(languages);
9507
9514
  setHierarchicalProductTypeSettings(hierarchical_product_type);
@@ -9513,7 +9520,7 @@ const SearchResultWidget = (props) => {
9513
9520
  setShowOutOfStock(show_out_of_stock);
9514
9521
  setTabs(tabs2);
9515
9522
  if (!clickedTabIndexId) {
9516
- getFirstIndex = (_b2 = tabs2 == null ? void 0 : tabs2.find) == null ? void 0 : _b2.call(tabs2, ({ index }) => index.includes(index_product));
9523
+ getFirstIndex = (_f2 = tabs2 == null ? void 0 : tabs2.find) == null ? void 0 : _f2.call(tabs2, ({ index }) => index.includes(index_product));
9517
9524
  if (Object.keys(getFirstIndex).length) {
9518
9525
  setClickedTabIndexId(getFirstIndex.index);
9519
9526
  setClickedTabIndexName(getFirstIndex.name);
@@ -9522,12 +9529,12 @@ const SearchResultWidget = (props) => {
9522
9529
  }
9523
9530
  setIsLoadingSetting(false);
9524
9531
  if (isPreviewSettings) {
9525
- let valueHideFilterWhenOneValue = ((_c2 = display == null ? void 0 : display.filter) == null ? void 0 : _c2.hide_when_one_value) && totalHitsProduct <= 1;
9532
+ let valueHideFilterWhenOneValue = ((_g2 = display == null ? void 0 : display.filter) == null ? void 0 : _g2.hide_when_one_value) && totalHitsProduct <= 1;
9526
9533
  const { isSetFilter, valueAllowedFilter, valueDefaultFilterItems, valueAllowedFilterSlider, valueHierarchicalFacetAliases } = handleFilterStates({
9527
9534
  data: response,
9528
9535
  valueSearchResultFacets: searchResultFacets
9529
9536
  });
9530
- if (!(!((_d2 = display == null ? void 0 : display.filter) == null ? void 0 : _d2.enable_on_search) || valueHideFilterWhenOneValue)) {
9537
+ if (!(!((_h2 = display == null ? void 0 : display.filter) == null ? void 0 : _h2.enable_on_search) || valueHideFilterWhenOneValue)) {
9531
9538
  if (isSetFilter)
9532
9539
  setAllowedFilter(valueAllowedFilter);
9533
9540
  if (valueAllowedFilter == null ? void 0 : valueAllowedFilter.length) {
@@ -9537,7 +9544,7 @@ const SearchResultWidget = (props) => {
9537
9544
  }
9538
9545
  }
9539
9546
  setAllowedTabs(
9540
- (_g2 = (_f2 = (_e2 = tabs2 == null ? void 0 : tabs2.map) == null ? void 0 : _e2.call(tabs2, (allowedTab) => {
9547
+ (_k2 = (_j2 = (_i2 = tabs2 == null ? void 0 : tabs2.map) == null ? void 0 : _i2.call(tabs2, (allowedTab) => {
9541
9548
  var _a3, _b3;
9542
9549
  const { type } = allowedTab;
9543
9550
  const total = ((_b3 = (_a3 = allowedTabs == null ? void 0 : allowedTabs.find) == null ? void 0 : _a3.call(allowedTabs, (tab) => (tab == null ? void 0 : tab.type) === type)) == null ? void 0 : _b3.total) || 0;
@@ -9547,7 +9554,7 @@ const SearchResultWidget = (props) => {
9547
9554
  total
9548
9555
  }
9549
9556
  };
9550
- })) == null ? void 0 : _f2.filter) == null ? void 0 : _g2.call(_f2, (item) => item)
9557
+ })) == null ? void 0 : _j2.filter) == null ? void 0 : _k2.call(_j2, (item) => item)
9551
9558
  );
9552
9559
  }
9553
9560
  };