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

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.
@@ -4262,6 +4262,14 @@ const VariantSelector = (props) => {
4262
4262
  const inventoryQuantity = (_g = selectOption.attributes["data-inventory-quantity"]) == null ? void 0 : _g.value;
4263
4263
  const inventoryManagement = (_h = selectOption.attributes["data-inventory-management"]) == null ? void 0 : _h.value;
4264
4264
  const inventoryPolicy = (_i = selectOption.attributes["data-inventory-policy"]) == null ? void 0 : _i.value;
4265
+ const productLinks = parentCard.querySelectorAll('a[data-product-url="true"]');
4266
+ productLinks == null ? void 0 : productLinks.forEach((link) => {
4267
+ if (link == null ? void 0 : link.href) {
4268
+ const url2 = new URL(link.href);
4269
+ url2.searchParams.set("variant", variantId == null ? void 0 : variantId.replace(/^gid:\/\/shopify\/ProductVariant\/(\d+)$/, "$1"));
4270
+ link.href = url2.toString();
4271
+ }
4272
+ });
4265
4273
  const setOther = () => {
4266
4274
  var _a3, _b3;
4267
4275
  setElementAttribute({
@@ -4382,7 +4390,7 @@ ${selectedOption === item ? "sledge__product-variant-size-swatch-active" : ""} s
4382
4390
  ] }, optionParentIndex) : /* @__PURE__ */ jsxRuntimeExports.jsx(
4383
4391
  "select",
4384
4392
  {
4385
- className: "sledge__product-variant-size-swatch-select",
4393
+ className: `sledge__product-variant-size-swatch-select options-button-${stringToSlug(optionName)}`,
4386
4394
  onChange: (el) => {
4387
4395
  let { value } = el.target;
4388
4396
  setSelectedVariant(el, value, optionParentIndex + 1);
@@ -4396,7 +4404,7 @@ ${selectedOption === item ? "sledge__product-variant-size-swatch-active" : ""} s
4396
4404
  ] });
4397
4405
  };
4398
4406
  const ProductCard = React__default.memo((props) => {
4399
- var _a, _b, _c, _d, _e, _f, _g;
4407
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4400
4408
  const {
4401
4409
  item,
4402
4410
  handleAddToCart,
@@ -4441,6 +4449,7 @@ const ProductCard = React__default.memo((props) => {
4441
4449
  compare_at_price = "",
4442
4450
  sku = ""
4443
4451
  } = (variants == null ? void 0 : variants.length) ? variants[0] : {};
4452
+ const productUrl = `${url}?variant=${(_a = variants == null ? void 0 : variants[0]) == null ? void 0 : _a.id}`;
4444
4453
  const defaultSelectedVariantId = variant_admin_graphql_api_id ? variant_admin_graphql_api_id : "";
4445
4454
  const defaultSelectedVariantStock = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_quantity") ? variants[0].inventory_quantity : 0;
4446
4455
  const defaultSelectedVariantInventoryManagement = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_management") ? variants[0].inventory_management : null;
@@ -4483,8 +4492,8 @@ const ProductCard = React__default.memo((props) => {
4483
4492
  },
4484
4493
  ...dataReviews && Object.keys(dataReviews).length ? {
4485
4494
  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
4495
+ total: ((_b = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _b.review_count) ? dataReviews == null ? void 0 : dataReviews[id].review_count : 0,
4496
+ 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
4497
  }
4489
4498
  } : {}
4490
4499
  },
@@ -4539,7 +4548,8 @@ const ProductCard = React__default.memo((props) => {
4539
4548
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-image-flyout", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4540
4549
  "a",
4541
4550
  {
4542
- href: url,
4551
+ href: productUrl,
4552
+ "data-product-url": "true",
4543
4553
  onClick: () => {
4544
4554
  if (sourceApp === "instant-search") {
4545
4555
  productClickTrigger$1({
@@ -4578,7 +4588,8 @@ const ProductCard = React__default.memo((props) => {
4578
4588
  title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4579
4589
  "a",
4580
4590
  {
4581
- href: url,
4591
+ href: productUrl,
4592
+ "data-product-url": "true",
4582
4593
  onClick: () => {
4583
4594
  if (sourceApp === "instant-search") {
4584
4595
  productClickTrigger$1({
@@ -4621,7 +4632,8 @@ const ProductCard = React__default.memo((props) => {
4621
4632
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
4622
4633
  "a",
4623
4634
  {
4624
- href: url,
4635
+ href: productUrl,
4636
+ "data-product-url": "true",
4625
4637
  onClick: () => {
4626
4638
  if (sourceApp === "instant-search") {
4627
4639
  productClickTrigger$1({
@@ -4656,7 +4668,7 @@ const ProductCard = React__default.memo((props) => {
4656
4668
  onAfterAddWishlist,
4657
4669
  onAfterRemoveWishlist,
4658
4670
  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) ? {
4671
+ ...objectPresent(previewSettings) && ((_f = (_e = previewSettings == null ? void 0 : previewSettings.settings) == null ? void 0 : _e.general) == null ? void 0 : _f.use_dummy_data) ? {
4660
4672
  previewSettings
4661
4673
  } : {}
4662
4674
  }
@@ -4692,7 +4704,7 @@ const ProductCard = React__default.memo((props) => {
4692
4704
  }
4693
4705
  )
4694
4706
  ] }),
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(
4707
+ /* @__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
4708
  "img",
4697
4709
  {
4698
4710
  decoding: "async",
@@ -4743,7 +4755,8 @@ const ProductCard = React__default.memo((props) => {
4743
4755
  title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4744
4756
  "a",
4745
4757
  {
4746
- href: url,
4758
+ href: productUrl,
4759
+ "data-product-url": "true",
4747
4760
  onClick: () => {
4748
4761
  if (sourceApp === "instant-search") {
4749
4762
  productClickTrigger$1({
@@ -5510,7 +5523,7 @@ const DotButton = (props) => {
5510
5523
  };
5511
5524
  const FlyoutSidebar$1 = "";
5512
5525
  const FlyoutSidebar = ({ title, content, footer = null, open, setOpen, position = "left", className = "", withBlurEffect = false }) => {
5513
- const [isLoading, setIsLoading] = React__default.useState(true);
5526
+ const [isLoading, setIsLoading] = React__default.useState(false);
5514
5527
  const [isScrollAtBottom, setIsScrollAtBottom] = React__default.useState(false);
5515
5528
  const contentContainerRef = React__default.useRef(null);
5516
5529
  React__default.useLayoutEffect(() => {
@@ -9043,6 +9056,8 @@ const SearchResultWidget = (props) => {
9043
9056
  const querySortBy = (query == null ? void 0 : query.sortBy) ? query.sortBy : DEFAULT_QUERY_PARAM.SORT_BY;
9044
9057
  const queryPage = (query == null ? void 0 : query.page) ? query.page : DEFAULT_QUERY_PARAM.PAGE;
9045
9058
  const queryLimit = (query == null ? void 0 : query.limit) ? query.limit : DEFAULT_QUERY_PARAM.LIMIT;
9059
+ const desktopColumns = localStorage.getItem(LOCAL_STORAGE_KEY.GRID_DESKTOP_COLUMN) || "column-3";
9060
+ const mobileColumns = localStorage.getItem(LOCAL_STORAGE_KEY.GRID_MOBILE_COLUMN) || "column-2";
9046
9061
  const { collectionId } = params || {};
9047
9062
  const searchParams = typeof document !== "undefined" ? new URLSearchParams((_a = document == null ? void 0 : document.location) == null ? void 0 : _a.search) : null;
9048
9063
  const { generalPreviewSettings, instantSearchPreviewSettings, previewSettings } = usePreviewSettings({
@@ -9100,7 +9115,10 @@ const SearchResultWidget = (props) => {
9100
9115
  const [valueFilterPriceChange, setValueFilterPriceChange] = React__default.useState([]);
9101
9116
  const [valueFilterOnSaleChange, setValueFilterOnSaleChange] = React__default.useState([]);
9102
9117
  const [valueFilterSliderOthers, setValueFilterSliderOthers] = React__default.useState({});
9103
- const [currentColumnGrid, setCurrentColumnGrid] = React__default.useState(null);
9118
+ const [currentColumnGrid, setCurrentColumnGrid] = React__default.useState({
9119
+ desktop: desktopColumns,
9120
+ mobile: mobileColumns
9121
+ });
9104
9122
  const debouncedKeyword = useDebounce(keyword, 500);
9105
9123
  let productCardsComponent = null;
9106
9124
  let collectionCardsComponent = null;