@sledge-app/react-instant-search 1.0.93 → 1.0.95

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.
@@ -644,7 +644,8 @@ const Checkbox = ({ id, name, value, required, label, checked, labelStyle = {},
644
644
  };
645
645
  const Slider$1 = "";
646
646
  const Slider = (props) => {
647
- const { value, min, max, step = 1, setValueCommit, setValueChange } = props;
647
+ const { value, textValue = [], min, max, step = 1, setValueCommit, setValueChange } = props;
648
+ let content = (textValue == null ? void 0 : textValue.length) ? textValue : value;
648
649
  return /* @__PURE__ */ jsxRuntimeExports.jsx("form", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
649
650
  $faa2e61a3361514f$export$be92b6f5f03c0fe9,
650
651
  {
@@ -663,7 +664,11 @@ const Slider = (props) => {
663
664
  /* @__PURE__ */ jsxRuntimeExports.jsx(
664
665
  Tooltip,
665
666
  {
666
- content: value[0],
667
+ ...(textValue == null ? void 0 : textValue.length) ? {
668
+ innerHTMLContent: content[0]
669
+ } : {
670
+ content: content[0]
671
+ },
667
672
  customArrow: `<svg width="19" height="5" viewBox="0 0 19 5" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 4.99998C9 9.48298e-05 16.4996 1.99678e-05 18.4999 0L9 2.2985e-06L0.5 2.04891e-06C9 2.2985e-06 9 4.99998 9 4.99998Z" fill="#43c6ac"/></svg>`,
668
673
  wrapTrigger: false,
669
674
  children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$6521433ed15a34db, { className: "sledge__SliderThumb" })
@@ -672,7 +677,11 @@ const Slider = (props) => {
672
677
  !value[1] ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
673
678
  Tooltip,
674
679
  {
675
- content: value[1],
680
+ ...(textValue == null ? void 0 : textValue.length) ? {
681
+ innerHTMLContent: content[1]
682
+ } : {
683
+ content: content[1]
684
+ },
676
685
  customArrow: `<svg width="19" height="5" viewBox="0 0 19 5" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 4.99998C9 9.48298e-05 16.4996 1.99678e-05 18.4999 0L9 2.2985e-06L0.5 2.04891e-06C9 2.2985e-06 9 4.99998 9 4.99998Z" fill="#43c6ac"/></svg>`,
677
686
  wrapTrigger: false,
678
687
  children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$6521433ed15a34db, { className: "sledge__SliderThumb" })
@@ -1793,7 +1802,7 @@ const Trigger = (props) => {
1793
1802
  setTypeIcon(defaultTypeIcon);
1794
1803
  }
1795
1804
  }, [isWishlist]);
1796
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: rootRef, children: !isLoading && !hidden && /* @__PURE__ */ jsxRuntimeExports.jsx(
1805
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: rootRef, className: "sledge-wishlist__trigger-root", children: !isLoading && !hidden && /* @__PURE__ */ jsxRuntimeExports.jsx(
1797
1806
  "div",
1798
1807
  {
1799
1808
  className: "sledge-wishlist__trigger-block",
@@ -2918,6 +2927,16 @@ const ProductCard = (props) => {
2918
2927
  const [selectedVariantStock, setSelectedVariantStock] = React__default.useState(defaultSelectedVariantStock);
2919
2928
  const [selectedVariantInventoryManagement, setSelectedVariantInventoryManagement] = React__default.useState(defaultSelectedVariantInventoryManagement);
2920
2929
  const [selectedVariantInventoryPolicy, setSelectedVariantInventoryPolicy] = React__default.useState(defaultSelectedVariantInventoryPolicy);
2930
+ const [hasEntryImage, setHasEntryImage] = React__default.useState(false);
2931
+ const [imageRef, imageEntry] = useIntersectionObserver({
2932
+ threshold: 0.1,
2933
+ root: null,
2934
+ rootMargin: "0px"
2935
+ });
2936
+ React__default.useEffect(() => {
2937
+ if (!hasEntryImage && (imageEntry == null ? void 0 : imageEntry.isIntersecting))
2938
+ setHasEntryImage(imageEntry == null ? void 0 : imageEntry.isIntersecting);
2939
+ }, [imageEntry]);
2921
2940
  let isLoadingAddToCart = clickedAddToCartId == selectedVariantId;
2922
2941
  let isOutOfStock = showOptionOutOfStock ? !Boolean(selectedVariantStock > 0 || selectedVariantInventoryManagement === null || selectedVariantInventoryPolicy === "continue") : false;
2923
2942
  let isOnSale = parseFloat(String(compare_at_price)) ? parseFloat(String(compare_at_price)) > parseFloat(String(price)) : false;
@@ -3076,10 +3095,16 @@ const ProductCard = (props) => {
3076
3095
  wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id]
3077
3096
  }
3078
3097
  ),
3079
- /* @__PURE__ */ jsxRuntimeExports.jsx(
3098
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-featured-image-element", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3080
3099
  "img",
3081
3100
  {
3082
- src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
3101
+ ref: imageRef,
3102
+ ...hasEntryImage ? {
3103
+ src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
3104
+ ["loaded"]: ""
3105
+ } : {
3106
+ ["data-src"]: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`
3107
+ },
3083
3108
  alt: "sledge-card-image",
3084
3109
  loading: "lazy",
3085
3110
  className: "sledge__product-grid-card-image-featured-image",
@@ -3090,7 +3115,7 @@ const ProductCard = (props) => {
3090
3115
  currentTarget.src = `${CDN_URL}/images/blank-image.png`;
3091
3116
  }
3092
3117
  }
3093
- ),
3118
+ ) }),
3094
3119
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: images == null ? void 0 : images.map((image2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
3095
3120
  "img",
3096
3121
  {
@@ -3324,7 +3349,7 @@ const ProductGrid = (props) => {
3324
3349
  onAfterRenderProduct && onAfterRenderProduct("success");
3325
3350
  handleSettings();
3326
3351
  }, []);
3327
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { className: `sledge__product-grid ${className}`, ...carouselSourceProp, "data-grid-type": type, children: data == null ? void 0 : data.map((item, index) => {
3352
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { className: `sledge__product-grid ${className}`, ...carouselSourceProp, "data-grid-type": type, "data-custom-card": Boolean(props == null ? void 0 : props.cards), children: data == null ? void 0 : data.map((item, index) => {
3328
3353
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
3329
3354
  ProductCard,
3330
3355
  {
@@ -3450,7 +3475,7 @@ const ArticleGrid = ({ className = "", data, cards: CardsComponent, isComponentJ
3450
3475
  }) }) });
3451
3476
  };
3452
3477
  const Tooltip$1 = "";
3453
- const Tooltip = ({ children, content, withArrow = true, customArrow = "", sideOffset = 5, alignOffset = 0, wrapTrigger = true }) => {
3478
+ const Tooltip = ({ children, content = null, innerHTMLContent = "", withArrow = true, customArrow = "", sideOffset = 5, alignOffset = 0, wrapTrigger = true }) => {
3454
3479
  const [open, setOpen] = React__default.useState(false);
3455
3480
  React__default.useEffect(() => {
3456
3481
  var _a;
@@ -3464,6 +3489,7 @@ const Tooltip = ({ children, content, withArrow = true, customArrow = "", sideOf
3464
3489
  /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$41fb9f06171c75f4, { asChild: true, children: wrapTrigger ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children }) : children }),
3465
3490
  /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs($a093c7e1ec25a057$export$7c6e2c02157bb7d2, { className: "sledge__tooltip-content", sideOffset, alignOffset, children: [
3466
3491
  content,
3492
+ innerHTMLContent && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: innerHTMLContent } }),
3467
3493
  withArrow ? /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$21b07c8f274aebd5, { className: "sledge__tooltip-arrow" }) : null
3468
3494
  ] }) })
3469
3495
  ] }) });
@@ -4673,7 +4699,7 @@ const handleFacetValues = ({
4673
4699
  return facetValues;
4674
4700
  };
4675
4701
  const FacetComponent = (props) => {
4676
- var _a, _b, _c;
4702
+ var _a, _b, _c, _d;
4677
4703
  const {
4678
4704
  filter,
4679
4705
  isFirstLoading,
@@ -4706,6 +4732,7 @@ const FacetComponent = (props) => {
4706
4732
  const [showFacet, setShowFacet] = React__default.useState(false);
4707
4733
  const searchFacetRef = React__default.useRef(null);
4708
4734
  const previousState = usePrevious({ keywordFacet });
4735
+ const { money_format } = generalDataSettings || {};
4709
4736
  const { button_load_more } = (generalDataSettings == null ? void 0 : generalDataSettings.languages) || {};
4710
4737
  const { search_filter_placeholder, search_filter_show_more_result, search_filter_no_result } = languageSettings || {};
4711
4738
  const {
@@ -4867,10 +4894,6 @@ const FacetComponent = (props) => {
4867
4894
  }
4868
4895
  ) : null
4869
4896
  ] }),
4870
- onClick: (e) => handleFilterChange({
4871
- parentId: value,
4872
- value: e.currentTarget.value
4873
- }),
4874
4897
  checked: isChecked,
4875
4898
  labelStyle: filter_option_style
4876
4899
  }
@@ -4880,6 +4903,13 @@ const FacetComponent = (props) => {
4880
4903
  "li",
4881
4904
  {
4882
4905
  className: `sledge-instant-search__result-filter-checkbox-item ${isFacetHierarchical ? `sledge-instant-search__result-filter-checkbox-item-level sledge-instant-search__result-filter-checkbox-item-level-${level}` : ""}`,
4906
+ onClick: (e) => {
4907
+ e.preventDefault();
4908
+ handleFilterChange({
4909
+ parentId: value,
4910
+ value: itemValue
4911
+ });
4912
+ },
4883
4913
  children: content
4884
4914
  },
4885
4915
  key
@@ -4925,19 +4955,32 @@ const FacetComponent = (props) => {
4925
4955
  }
4926
4956
  if (isDisplaySlider) {
4927
4957
  items = (defaultFacetStats == null ? void 0 : defaultFacetStats[value]) && Object.keys(defaultFacetStats[value]).length ? defaultFacetStats[value] : {};
4958
+ if (items && ((_c = Object.keys(items)) == null ? void 0 : _c.length)) {
4959
+ items = {
4960
+ min: (items == null ? void 0 : items.min) < 0 ? 0 : items == null ? void 0 : items.min,
4961
+ max: items == null ? void 0 : items.max
4962
+ };
4963
+ }
4928
4964
  let valueFilterSliderChange = [];
4965
+ let isPriceValue = false;
4966
+ let isSalePercent = false;
4929
4967
  if (value === "variants.price") {
4930
4968
  valueFilterSliderChange = valueFilterPriceChange;
4969
+ isPriceValue = true;
4931
4970
  } else if (value === "variants.sale_percent") {
4932
4971
  valueFilterSliderChange = valueFilterOnSaleChange;
4972
+ isSalePercent = true;
4933
4973
  }
4934
4974
  let defaultValueMin = (valueFilterSliderChange == null ? void 0 : valueFilterSliderChange[0]) || (items == null ? void 0 : items.min);
4935
4975
  let defaultValueMax = (valueFilterSliderChange == null ? void 0 : valueFilterSliderChange[1]) || (items == null ? void 0 : items.max);
4976
+ let contentDefaultValueMin = isPriceValue ? shopifyFormatMoney(defaultValueMin * 100, money_format) : isSalePercent ? `${defaultValueMin}%` : defaultValueMin;
4977
+ let contentDefaultValueMax = isPriceValue ? shopifyFormatMoney(defaultValueMax * 100, money_format) : isSalePercent ? `${defaultValueMax}%` : defaultValueMax;
4936
4978
  blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-list-slider", children: [
4937
4979
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4938
4980
  Slider,
4939
4981
  {
4940
4982
  value: defaultValueMin === defaultValueMax ? [defaultValueMax] : [defaultValueMin, defaultValueMax],
4983
+ textValue: defaultValueMin === defaultValueMax ? [contentDefaultValueMax] : [contentDefaultValueMin, contentDefaultValueMax],
4941
4984
  ...(items == null ? void 0 : items.min) === (items == null ? void 0 : items.max) ? {} : {
4942
4985
  min: items == null ? void 0 : items.min
4943
4986
  },
@@ -4957,8 +5000,8 @@ const FacetComponent = (props) => {
4957
5000
  }
4958
5001
  ),
4959
5002
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-list-slider-minmax", children: [
4960
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", children: defaultValueMin }),
4961
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", children: defaultValueMax })
5003
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", dangerouslySetInnerHTML: { __html: contentDefaultValueMin } }),
5004
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", dangerouslySetInnerHTML: { __html: contentDefaultValueMax } })
4962
5005
  ] })
4963
5006
  ] });
4964
5007
  } else if ((display.toLowerCase() === "checkbox" || display.toLowerCase() === "tree") && (currentItems == null ? void 0 : currentItems.length)) {
@@ -4996,7 +5039,7 @@ const FacetComponent = (props) => {
4996
5039
  value: value2
4997
5040
  };
4998
5041
  }),
4999
- defaultValue: clickedFacets && ((_c = clickedFacets[value]) == null ? void 0 : _c.length) ? clickedFacets[value][0] : "",
5042
+ defaultValue: clickedFacets && ((_d = clickedFacets[value]) == null ? void 0 : _d.length) ? clickedFacets[value][0] : "",
5000
5043
  labelStyle: filter_option_style,
5001
5044
  useVirtualized: true,
5002
5045
  selector: scrollElementSelector,
@@ -5384,7 +5427,9 @@ const SearchResultWidget = (props) => {
5384
5427
  let valueAllowedFilter = [];
5385
5428
  if (!isSetFilter)
5386
5429
  allowedFilters == null ? void 0 : allowedFilters.map((filter) => {
5387
- const { collections, items } = filter;
5430
+ const { active, collections, items } = filter;
5431
+ if (!active)
5432
+ return;
5388
5433
  const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => {
5389
5434
  return {
5390
5435
  ...otherItem,
@@ -5414,7 +5459,7 @@ const SearchResultWidget = (props) => {
5414
5459
  let items = [];
5415
5460
  if (display2.toLowerCase() === "tree") {
5416
5461
  for (let level = 0; level < MAX_LIMIT_HIERARCHICAL; level++) {
5417
- items = [...items, ...valueSearchResultFacets[`${value}.lvl${level}`]];
5462
+ items = [...items, ...(valueSearchResultFacets == null ? void 0 : valueSearchResultFacets[`${value}.lvl${level}`]) || []];
5418
5463
  }
5419
5464
  } else {
5420
5465
  items = valueSearchResultFacets[value];
@@ -6002,6 +6047,7 @@ const ResultProduct = (props) => {
6002
6047
  } = languageSettings || {};
6003
6048
  const { separator: hierarchical_separator, hiddens: hierarchical_hiddens } = hierarchicalProductTypeSettings || {};
6004
6049
  const { separator: hierarchical_collections_separator, hiddens: hierarchical_collections_hiddens } = hierarchicalCollectionsSettings || {};
6050
+ const { money_format } = generalDataSettings || {};
6005
6051
  const { button_load_more, button_loading, mobile_sort_placeholder } = (generalDataSettings == null ? void 0 : generalDataSettings.languages) || {};
6006
6052
  const summaryTextGenerator = (totalResult) => {
6007
6053
  var _a2;
@@ -6332,10 +6378,17 @@ const ResultProduct = (props) => {
6332
6378
  });
6333
6379
  const facetBlockSelected = ({ label, name, value, index }) => {
6334
6380
  var _a2, _b2, _c2;
6335
- let valueText = value;
6381
+ let valueText = (languageSettings == null ? void 0 : languageSettings[value]) || value;
6336
6382
  let isRange = ["variants.price", "variants.sale_percent"].includes(name);
6337
6383
  let getLabel = label;
6338
6384
  let getSettings = {};
6385
+ let isPriceValue = false;
6386
+ let isSalePercent = false;
6387
+ if (name === "variants.price") {
6388
+ isPriceValue = true;
6389
+ } else if (name === "variants.sale_percent") {
6390
+ isSalePercent = true;
6391
+ }
6339
6392
  if (defaultFilterItems == null ? void 0 : defaultFilterItems.length) {
6340
6393
  defaultFilterItems.map((defaultFilterItem) => {
6341
6394
  const { label: defaultFilterItemLabel, items, settings: defaultFilterItemSettings } = defaultFilterItem;
@@ -6350,7 +6403,7 @@ const ResultProduct = (props) => {
6350
6403
  valueText = String(valueText).replace(deletePrefix, "");
6351
6404
  });
6352
6405
  if (isRange)
6353
- valueText = value == null ? void 0 : value.join(" - ");
6406
+ valueText = value == null ? void 0 : value.map((valueItem) => isPriceValue ? shopifyFormatMoney(valueItem * 100, money_format) : isSalePercent ? `${valueItem}%` : valueItem).join(" - ");
6354
6407
  else
6355
6408
  valueText = (_b2 = String(valueText)) == null ? void 0 : _b2.replaceAll(hierarchical_collections_separator, " > ");
6356
6409
  valueText = (_c2 = String(valueText)) == null ? void 0 : _c2.replaceAll("_", " ");
@@ -6374,11 +6427,7 @@ const ResultProduct = (props) => {
6374
6427
  aliasValue = newSplitedValues.join(" > ");
6375
6428
  }
6376
6429
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-refine-selected", style: filter_option_style, children: [
6377
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-instant-search__result-filter-item-title-refine-list", children: [
6378
- getLabel,
6379
- ": ",
6380
- aliasValue || valueText
6381
- ] }),
6430
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-item-title-refine-list", dangerouslySetInnerHTML: { __html: `${getLabel}: ${aliasValue || valueText}` } }),
6382
6431
  /* @__PURE__ */ jsxRuntimeExports.jsx(
6383
6432
  "span",
6384
6433
  {