@sledge-app/react-instant-search 2.0.28 → 2.0.30

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.
@@ -185,7 +185,8 @@ const OBJECT_DATA_STRING_KEY = {
185
185
  ACCEPTED_FILETYPE_MEDIA: "{{ accepted_filetype_media }}",
186
186
  MAX_SIZE_MEDIA: "{{ max_size_media }}",
187
187
  FILTER_TITLE: "{{ filter_title }}",
188
- PRICE_MAX_MONEY_FORMAT: "{{ price_max_money_format }}"
188
+ PRICE_MAX_MONEY_FORMAT: "{{ price_max_money_format }}",
189
+ LANGUAGE_REVIEW_PLURAL_SINGULAR: "{{ language_review_plural_singular }}"
189
190
  };
190
191
  const ELEMENT_ID = {
191
192
  PRODUCT_REVIEW: {
@@ -4262,6 +4263,14 @@ const VariantSelector = (props) => {
4262
4263
  const inventoryQuantity = (_g = selectOption.attributes["data-inventory-quantity"]) == null ? void 0 : _g.value;
4263
4264
  const inventoryManagement = (_h = selectOption.attributes["data-inventory-management"]) == null ? void 0 : _h.value;
4264
4265
  const inventoryPolicy = (_i = selectOption.attributes["data-inventory-policy"]) == null ? void 0 : _i.value;
4266
+ const productLinks = parentCard.querySelectorAll('a[data-product-url="true"]');
4267
+ productLinks == null ? void 0 : productLinks.forEach((link) => {
4268
+ if (link == null ? void 0 : link.href) {
4269
+ const url2 = new URL(link.href);
4270
+ url2.searchParams.set("variant", variantId == null ? void 0 : variantId.replace(/^gid:\/\/shopify\/ProductVariant\/(\d+)$/, "$1"));
4271
+ link.href = url2.toString();
4272
+ }
4273
+ });
4265
4274
  const setOther = () => {
4266
4275
  var _a3, _b3;
4267
4276
  setElementAttribute({
@@ -4382,7 +4391,7 @@ ${selectedOption === item ? "sledge__product-variant-size-swatch-active" : ""} s
4382
4391
  ] }, optionParentIndex) : /* @__PURE__ */ jsxRuntimeExports.jsx(
4383
4392
  "select",
4384
4393
  {
4385
- className: "sledge__product-variant-size-swatch-select",
4394
+ className: `sledge__product-variant-size-swatch-select options-button-${stringToSlug(optionName)}`,
4386
4395
  onChange: (el) => {
4387
4396
  let { value } = el.target;
4388
4397
  setSelectedVariant(el, value, optionParentIndex + 1);
@@ -4396,7 +4405,7 @@ ${selectedOption === item ? "sledge__product-variant-size-swatch-active" : ""} s
4396
4405
  ] });
4397
4406
  };
4398
4407
  const ProductCard = React__default.memo((props) => {
4399
- var _a, _b, _c, _d, _e, _f, _g;
4408
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4400
4409
  const {
4401
4410
  item,
4402
4411
  handleAddToCart,
@@ -4441,6 +4450,7 @@ const ProductCard = React__default.memo((props) => {
4441
4450
  compare_at_price = "",
4442
4451
  sku = ""
4443
4452
  } = (variants == null ? void 0 : variants.length) ? variants[0] : {};
4453
+ const productUrl = `${url}?variant=${(_a = variants == null ? void 0 : variants[0]) == null ? void 0 : _a.id}`;
4444
4454
  const defaultSelectedVariantId = variant_admin_graphql_api_id ? variant_admin_graphql_api_id : "";
4445
4455
  const defaultSelectedVariantStock = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_quantity") ? variants[0].inventory_quantity : 0;
4446
4456
  const defaultSelectedVariantInventoryManagement = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_management") ? variants[0].inventory_management : null;
@@ -4483,8 +4493,8 @@ const ProductCard = React__default.memo((props) => {
4483
4493
  },
4484
4494
  ...dataReviews && Object.keys(dataReviews).length ? {
4485
4495
  review: {
4486
- total: ((_a = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _a.review_count) ? dataReviews == null ? void 0 : dataReviews[id].review_count : 0,
4487
- average: ((_c = (_b = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _b.rating) == null ? void 0 : _c.average) ? dataReviews == null ? void 0 : dataReviews[id].rating.average : 0
4496
+ total: ((_b = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _b.review_count) ? dataReviews == null ? void 0 : dataReviews[id].review_count : 0,
4497
+ average: ((_d = (_c = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _c.rating) == null ? void 0 : _d.average) ? dataReviews == null ? void 0 : dataReviews[id].rating.average : 0
4488
4498
  }
4489
4499
  } : {}
4490
4500
  },
@@ -4539,7 +4549,8 @@ const ProductCard = React__default.memo((props) => {
4539
4549
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-image-flyout", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4540
4550
  "a",
4541
4551
  {
4542
- href: url,
4552
+ href: productUrl,
4553
+ "data-product-url": "true",
4543
4554
  onClick: () => {
4544
4555
  if (sourceApp === "instant-search") {
4545
4556
  productClickTrigger$1({
@@ -4578,7 +4589,8 @@ const ProductCard = React__default.memo((props) => {
4578
4589
  title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4579
4590
  "a",
4580
4591
  {
4581
- href: url,
4592
+ href: productUrl,
4593
+ "data-product-url": "true",
4582
4594
  onClick: () => {
4583
4595
  if (sourceApp === "instant-search") {
4584
4596
  productClickTrigger$1({
@@ -4621,7 +4633,8 @@ const ProductCard = React__default.memo((props) => {
4621
4633
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
4622
4634
  "a",
4623
4635
  {
4624
- href: url,
4636
+ href: productUrl,
4637
+ "data-product-url": "true",
4625
4638
  onClick: () => {
4626
4639
  if (sourceApp === "instant-search") {
4627
4640
  productClickTrigger$1({
@@ -4656,7 +4669,7 @@ const ProductCard = React__default.memo((props) => {
4656
4669
  onAfterAddWishlist,
4657
4670
  onAfterRemoveWishlist,
4658
4671
  wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id],
4659
- ...objectPresent(previewSettings) && ((_e = (_d = previewSettings == null ? void 0 : previewSettings.settings) == null ? void 0 : _d.general) == null ? void 0 : _e.use_dummy_data) ? {
4672
+ ...objectPresent(previewSettings) && ((_f = (_e = previewSettings == null ? void 0 : previewSettings.settings) == null ? void 0 : _e.general) == null ? void 0 : _f.use_dummy_data) ? {
4660
4673
  previewSettings
4661
4674
  } : {}
4662
4675
  }
@@ -4692,7 +4705,7 @@ const ProductCard = React__default.memo((props) => {
4692
4705
  }
4693
4706
  )
4694
4707
  ] }),
4695
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: (_g = (_f = product == null ? void 0 : product.images) == null ? void 0 : _f.map) == null ? void 0 : _g.call(_f, (image2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
4708
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: (_h = (_g = product == null ? void 0 : product.images) == null ? void 0 : _g.map) == null ? void 0 : _h.call(_g, (image2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
4696
4709
  "img",
4697
4710
  {
4698
4711
  decoding: "async",
@@ -4743,7 +4756,8 @@ const ProductCard = React__default.memo((props) => {
4743
4756
  title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4744
4757
  "a",
4745
4758
  {
4746
- href: url,
4759
+ href: productUrl,
4760
+ "data-product-url": "true",
4747
4761
  onClick: () => {
4748
4762
  if (sourceApp === "instant-search") {
4749
4763
  productClickTrigger$1({
@@ -5510,7 +5524,7 @@ const DotButton = (props) => {
5510
5524
  };
5511
5525
  const FlyoutSidebar$1 = "";
5512
5526
  const FlyoutSidebar = ({ title, content, footer = null, open, setOpen, position = "left", className = "", withBlurEffect = false }) => {
5513
- const [isLoading, setIsLoading] = React__default.useState(true);
5527
+ const [isLoading, setIsLoading] = React__default.useState(false);
5514
5528
  const [isScrollAtBottom, setIsScrollAtBottom] = React__default.useState(false);
5515
5529
  const contentContainerRef = React__default.useRef(null);
5516
5530
  React__default.useLayoutEffect(() => {
@@ -7708,7 +7722,7 @@ const Facet = (props) => {
7708
7722
  ...filter_option_text_transform && { textTransform: filter_option_text_transform }
7709
7723
  };
7710
7724
  let { value, label, display, indexFilter, items, settings: filterSettings } = filter;
7711
- const { show_search, auto_select_search, hide_filter_list } = filterSettings || {};
7725
+ const { show_search, auto_select_search, hide_filter_list, show_all_children_items } = filterSettings || {};
7712
7726
  const show_filter_list_when_search = !hide_filter_list;
7713
7727
  if (isFirstLoading)
7714
7728
  return null;
@@ -7834,6 +7848,7 @@ const Facet = (props) => {
7834
7848
  const isFacetHierarchical = Object.hasOwn(facetValue, "children");
7835
7849
  const isHasChildren = isFacetHierarchical && (children == null ? void 0 : children.length);
7836
7850
  const isChecked = Boolean(clickedFacets && ((_a3 = clickedFacets[value]) == null ? void 0 : _a3.includes(itemValue)));
7851
+ const isShowAllChildrenItems = show_all_children_items ? isHasChildren : isHasChildren && isChecked;
7837
7852
  const { haveNextPage: haveNextPage2, currentItems: currentItems2 } = handleFacetLoadMore({
7838
7853
  facetItems: children
7839
7854
  });
@@ -7852,7 +7867,7 @@ const Facet = (props) => {
7852
7867
  motion.div,
7853
7868
  {
7854
7869
  initial: false,
7855
- animate: isChecked ? "open" : "closed",
7870
+ animate: isShowAllChildrenItems ? "open" : isChecked ? "open" : "closed",
7856
7871
  variants: ROTATE_FILTER_ARROW_ANIMATION,
7857
7872
  className: "sledge-instant-search__result-filter-checkbox-item-level-arrow",
7858
7873
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 15, height: 15, color: "#000000" })
@@ -7886,7 +7901,7 @@ const Facet = (props) => {
7886
7901
  },
7887
7902
  key
7888
7903
  ),
7889
- isHasChildren && isChecked ? haveNextPage2 ? React__default.cloneElement(
7904
+ isShowAllChildrenItems ? haveNextPage2 ? React__default.cloneElement(
7890
7905
  /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
7891
7906
  blockComponentChildren,
7892
7907
  loadMoreComponent
@@ -9043,6 +9058,8 @@ const SearchResultWidget = (props) => {
9043
9058
  const querySortBy = (query == null ? void 0 : query.sortBy) ? query.sortBy : DEFAULT_QUERY_PARAM.SORT_BY;
9044
9059
  const queryPage = (query == null ? void 0 : query.page) ? query.page : DEFAULT_QUERY_PARAM.PAGE;
9045
9060
  const queryLimit = (query == null ? void 0 : query.limit) ? query.limit : DEFAULT_QUERY_PARAM.LIMIT;
9061
+ const desktopColumns = localStorage.getItem(LOCAL_STORAGE_KEY.GRID_DESKTOP_COLUMN) || "column-3";
9062
+ const mobileColumns = localStorage.getItem(LOCAL_STORAGE_KEY.GRID_MOBILE_COLUMN) || "column-2";
9046
9063
  const { collectionId } = params || {};
9047
9064
  const searchParams = typeof document !== "undefined" ? new URLSearchParams((_a = document == null ? void 0 : document.location) == null ? void 0 : _a.search) : null;
9048
9065
  const { generalPreviewSettings, instantSearchPreviewSettings, previewSettings } = usePreviewSettings({
@@ -9100,7 +9117,10 @@ const SearchResultWidget = (props) => {
9100
9117
  const [valueFilterPriceChange, setValueFilterPriceChange] = React__default.useState([]);
9101
9118
  const [valueFilterOnSaleChange, setValueFilterOnSaleChange] = React__default.useState([]);
9102
9119
  const [valueFilterSliderOthers, setValueFilterSliderOthers] = React__default.useState({});
9103
- const [currentColumnGrid, setCurrentColumnGrid] = React__default.useState(null);
9120
+ const [currentColumnGrid, setCurrentColumnGrid] = React__default.useState({
9121
+ desktop: desktopColumns,
9122
+ mobile: mobileColumns
9123
+ });
9104
9124
  const debouncedKeyword = useDebounce(keyword, 500);
9105
9125
  let productCardsComponent = null;
9106
9126
  let collectionCardsComponent = null;