@sledge-app/react-instant-search 2.0.26 → 2.0.27

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.
@@ -4166,13 +4166,41 @@ const addToCartTrigger = async (data) => {
4166
4166
  });
4167
4167
  };
4168
4168
  const VariantSelector = (props) => {
4169
- var _a;
4170
- const { data, setSelectedVariantId, setSelectedVariantStock, setSelectedVariantInventoryManagement, setSelectedVariantInventoryPolicy, sourceApp } = props;
4169
+ var _a, _b, _c;
4170
+ const {
4171
+ data,
4172
+ setSelectedVariantId,
4173
+ setSelectedVariantStock,
4174
+ setSelectedVariantInventoryManagement,
4175
+ setSelectedVariantInventoryPolicy,
4176
+ sourceApp,
4177
+ instantSearchSettings,
4178
+ optionSelectedValue,
4179
+ hasEntryImage
4180
+ } = props;
4171
4181
  const { product } = data || {};
4172
4182
  const { variants } = product || {};
4173
4183
  const { id, handle, url } = product || {};
4174
4184
  const options = (product == null ? void 0 : product.options) ? Object.entries(product.options) : [];
4175
4185
  const images = (product == null ? void 0 : product.images) ?? [];
4186
+ const isSplitProducts = Boolean((_a = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _a.enable);
4187
+ const bySplitProducts = (_b = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _b.by;
4188
+ React__default.useEffect(() => {
4189
+ if (isSplitProducts && optionSelectedValue) {
4190
+ const productCardElement = document.querySelector(`.sledge__product-grid-card[data-product-id="${id}"][data-option-selected-value="${encodeURIComponent(optionSelectedValue)}"]`);
4191
+ if (productCardElement) {
4192
+ const variantColorSwatch = productCardElement.querySelector(`.sledge__product-variant-color-swatch[data-option-value="${encodeURIComponent(optionSelectedValue)}"]`);
4193
+ if (variantColorSwatch) {
4194
+ variantColorSwatch.dispatchEvent(new Event("click", { bubbles: true }));
4195
+ }
4196
+ const variantSelectOption = productCardElement.querySelector(`.sledge__product-variant-size-swatch-select[data-option-name="${bySplitProducts}"]`);
4197
+ if (variantSelectOption) {
4198
+ variantSelectOption.value = optionSelectedValue;
4199
+ variantSelectOption.dispatchEvent(new Event("change", { bubbles: true }));
4200
+ }
4201
+ }
4202
+ }
4203
+ }, [hasEntryImage]);
4176
4204
  const defaultSelected = {};
4177
4205
  function setDefaultFunction() {
4178
4206
  if (!(variants == null ? void 0 : variants.length))
@@ -4190,7 +4218,10 @@ const VariantSelector = (props) => {
4190
4218
  }
4191
4219
  setDefaultFunction();
4192
4220
  function setSelectedOption(element, optionName) {
4193
- const optionsButton = element.target.offsetParent.querySelector(`.options-button-${stringToSlug(optionName)}`).querySelectorAll(`button`);
4221
+ const optionsButtonElement = element.target.offsetParent.querySelector(`.options-button-${stringToSlug(optionName)}`);
4222
+ if (!optionsButtonElement)
4223
+ return;
4224
+ const optionsButton = optionsButtonElement.querySelectorAll(`button`);
4194
4225
  const defaultSelectedClassChanger = () => {
4195
4226
  optionsButton.forEach((button, index) => {
4196
4227
  button.classList.remove("sledge__product-variant-size-swatch-active");
@@ -4215,7 +4246,7 @@ const VariantSelector = (props) => {
4215
4246
  }
4216
4247
  }
4217
4248
  function setSelectedVariant(element, value, optionIndex) {
4218
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
4249
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i;
4219
4250
  const parentCard = element.target.offsetParent;
4220
4251
  const selectedInput = parentCard.querySelector(`.sledge__product-grid-card-selected-option[data-product-id='${id}']`);
4221
4252
  setElementAttribute({
@@ -4223,8 +4254,8 @@ const VariantSelector = (props) => {
4223
4254
  attributeName: `data-selected-option${optionIndex}`,
4224
4255
  value
4225
4256
  });
4226
- const option1 = `[data-option-1="${stringToSlug((_b = (_a2 = selectedInput == null ? void 0 : selectedInput.attributes) == null ? void 0 : _a2["data-selected-option1"]) == null ? void 0 : _b.value)}"]`;
4227
- const option2 = `${((_c = selectedInput == null ? void 0 : selectedInput.attributes) == null ? void 0 : _c["data-selected-option2"]) ? `[data-option-2="${stringToSlug((_e = (_d = selectedInput == null ? void 0 : selectedInput.attributes) == null ? void 0 : _d["data-selected-option2"]) == null ? void 0 : _e.value)}"]` : ""}`;
4257
+ const option1 = `[data-option-1="${stringToSlug((_b2 = (_a2 = selectedInput == null ? void 0 : selectedInput.attributes) == null ? void 0 : _a2["data-selected-option1"]) == null ? void 0 : _b2.value)}"]`;
4258
+ const option2 = `${((_c2 = selectedInput == null ? void 0 : selectedInput.attributes) == null ? void 0 : _c2["data-selected-option2"]) ? `[data-option-2="${stringToSlug((_e = (_d = selectedInput == null ? void 0 : selectedInput.attributes) == null ? void 0 : _d["data-selected-option2"]) == null ? void 0 : _e.value)}"]` : ""}`;
4228
4259
  const selectOption = parentCard.querySelector(`select option${option1}${option2}`);
4229
4260
  const variantId = selectOption.attributes["data-graphql-id"].value;
4230
4261
  const imageId = (_f = selectOption.attributes["data-image-id"]) == null ? void 0 : _f.value;
@@ -4232,11 +4263,11 @@ const VariantSelector = (props) => {
4232
4263
  const inventoryManagement = (_h = selectOption.attributes["data-inventory-management"]) == null ? void 0 : _h.value;
4233
4264
  const inventoryPolicy = (_i = selectOption.attributes["data-inventory-policy"]) == null ? void 0 : _i.value;
4234
4265
  const setOther = () => {
4235
- var _a3, _b2;
4266
+ var _a3, _b3;
4236
4267
  setElementAttribute({
4237
4268
  element: selectedInput,
4238
4269
  attributeName: "data-variant-id",
4239
- value: ((_b2 = (_a3 = selectOption == null ? void 0 : selectOption.attributes) == null ? void 0 : _a3["data-graphql-id"]) == null ? void 0 : _b2.value) || ""
4270
+ value: ((_b3 = (_a3 = selectOption == null ? void 0 : selectOption.attributes) == null ? void 0 : _a3["data-graphql-id"]) == null ? void 0 : _b3.value) || ""
4240
4271
  });
4241
4272
  setElementAttribute({
4242
4273
  element: selectedInput,
@@ -4289,7 +4320,7 @@ const VariantSelector = (props) => {
4289
4320
  return /* @__PURE__ */ jsxRuntimeExports.jsx("option", { ...optionAttributes, children: title }, id2);
4290
4321
  }) }),
4291
4322
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: images == null ? void 0 : images.map((image) => /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "hidden", id: image == null ? void 0 : image.id, value: image == null ? void 0 : image.src }, image == null ? void 0 : image.id)) }),
4292
- (_a = options == null ? void 0 : options.map) == null ? void 0 : _a.call(options, (option, optionParentIndex) => {
4323
+ (_c = options == null ? void 0 : options.map) == null ? void 0 : _c.call(options, (option, optionParentIndex) => {
4293
4324
  var _a2;
4294
4325
  const optionName = option[0];
4295
4326
  const optionValues = option[1];
@@ -4341,6 +4372,7 @@ ${selectedOption === item ? "sledge__product-variant-size-swatch-active" : ""} s
4341
4372
  setSelectedOption(el, optionName);
4342
4373
  },
4343
4374
  title: optionName === "Color" ? null : item,
4375
+ "data-option-value": encodeURIComponent(item),
4344
4376
  children: optionName === "Color" ? null : item
4345
4377
  },
4346
4378
  index
@@ -4356,6 +4388,7 @@ ${selectedOption === item ? "sledge__product-variant-size-swatch-active" : ""} s
4356
4388
  setSelectedVariant(el, value, optionParentIndex + 1);
4357
4389
  setSelectedOption(el, optionName);
4358
4390
  },
4391
+ "data-option-name": optionName,
4359
4392
  children: optionValues.map((item, index) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: item, children: item }, index))
4360
4393
  }
4361
4394
  ) : "" });
@@ -4383,6 +4416,8 @@ const ProductCard = React__default.memo((props) => {
4383
4416
  generalDataSettings,
4384
4417
  previewSettings,
4385
4418
  isFlyout,
4419
+ instantSearchSettings,
4420
+ optionSelectedValue,
4386
4421
  additionalCardProps
4387
4422
  } = props;
4388
4423
  const {
@@ -4457,105 +4492,42 @@ const ProductCard = React__default.memo((props) => {
4457
4492
  setShowPopupComponent,
4458
4493
  sourceApp,
4459
4494
  forLoopIndex,
4460
- forLoopIndexWithPage
4495
+ forLoopIndexWithPage,
4496
+ optionSelectedValue: optionSelectedValue || null
4461
4497
  };
4462
4498
  component = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-for-loop-index": forLoopIndex, "data-for-loop-index-with-page": forLoopIndexWithPage, dangerouslySetInnerHTML: { __html: CardsComponent({ ...CardsProps }) } }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CardsComponent, { ...CardsProps }) });
4463
4499
  } else {
4464
- component = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFlyout ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-flyout", "data-for-loop-index": forLoopIndex, "data-for-loop-index-with-page": forLoopIndexWithPage, children: [
4465
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-flyout-wishlist-trigger", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4466
- Trigger,
4467
- {
4468
- params: {
4469
- productId: id,
4470
- productVariantId: variant_id,
4471
- productName: title,
4472
- productVendor: vendor,
4473
- productSku: sku,
4474
- productVariantName: variant_title,
4475
- productLink: url,
4476
- productImage: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4477
- productCurrency: currency,
4478
- productPrice: price
4479
- },
4480
- ...triggerPropAdditional,
4481
- onAfterAddWishlist,
4482
- onAfterRemoveWishlist,
4483
- wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id]
4484
- }
4485
- ) }),
4486
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-image-flyout", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4487
- "a",
4488
- {
4489
- href: url,
4490
- onClick: () => {
4491
- if (sourceApp === "instant-search") {
4492
- productClickTrigger$1({
4493
- productId: id
4494
- });
4495
- } else if (productRecommendationSourceApps.includes(sourceApp)) {
4496
- productClickTrigger({
4497
- productId: id,
4498
- sourceApp
4499
- });
4500
- }
4501
- },
4502
- className: "sledge__product-grid-card-image-link-flyout",
4503
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4504
- "img",
4500
+ component = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFlyout ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
4501
+ "div",
4502
+ {
4503
+ className: "sledge__product-grid-card-flyout",
4504
+ "data-for-loop-index": forLoopIndex,
4505
+ "data-for-loop-index-with-page": forLoopIndexWithPage,
4506
+ "data-product-id": id,
4507
+ "data-option-selected-value": encodeURIComponent(optionSelectedValue),
4508
+ children: [
4509
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-flyout-wishlist-trigger", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4510
+ Trigger,
4505
4511
  {
4506
- ref: imageRef,
4507
- ...{
4508
- src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4509
- ["loaded"]: ""
4512
+ params: {
4513
+ productId: id,
4514
+ productVariantId: variant_id,
4515
+ productName: title,
4516
+ productVendor: vendor,
4517
+ productSku: sku,
4518
+ productVariantName: variant_title,
4519
+ productLink: url,
4520
+ productImage: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4521
+ productCurrency: currency,
4522
+ productPrice: price
4510
4523
  },
4511
- alt: "sledge-card-image",
4512
- loading: "lazy",
4513
- className: "sledge__product-grid-card-image-featured-image-flyout",
4514
- onError: ({ currentTarget }) => {
4515
- if (!currentTarget)
4516
- return;
4517
- currentTarget.onerror = null;
4518
- currentTarget.src = `${CDN_URL}/images/blank-image.png`;
4519
- }
4520
- }
4521
- )
4522
- }
4523
- ) }),
4524
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-desc-flyout", children: [
4525
- title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4526
- "a",
4527
- {
4528
- href: url,
4529
- onClick: () => {
4530
- if (sourceApp === "instant-search") {
4531
- productClickTrigger$1({
4532
- productId: id
4533
- });
4534
- } else if (productRecommendationSourceApps.includes(sourceApp)) {
4535
- productClickTrigger({
4536
- productId: id,
4537
- sourceApp
4538
- });
4539
- }
4540
- },
4541
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "sledge__product-grid-card-product-name-flyout", style: display_product_name_style, children: title })
4542
- }
4543
- ) : null,
4544
- show_price ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-price-flyout", children: [
4545
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: display_price_style, dangerouslySetInnerHTML: { __html: shopifyFormatMoney(price * 100, money_format) } }),
4546
- isOnSale && /* @__PURE__ */ jsxRuntimeExports.jsx(
4547
- "div",
4548
- {
4549
- className: "sledge__product-grid-card-compare-at-price-flyout",
4550
- dangerouslySetInnerHTML: { __html: shopifyFormatMoney(compare_at_price * 100, money_format) }
4524
+ ...triggerPropAdditional,
4525
+ onAfterAddWishlist,
4526
+ onAfterRemoveWishlist,
4527
+ wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id]
4551
4528
  }
4552
- )
4553
- ] }) : null
4554
- ] })
4555
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card", "data-for-loop-index": forLoopIndex, "data-for-loop-index-with-page": forLoopIndexWithPage, children: [
4556
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-content", children: [
4557
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-image", children: [
4558
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
4529
+ ) }),
4530
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-image-flyout", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4559
4531
  "a",
4560
4532
  {
4561
4533
  href: url,
@@ -4571,186 +4543,273 @@ const ProductCard = React__default.memo((props) => {
4571
4543
  });
4572
4544
  }
4573
4545
  },
4574
- className: "sledge__product-grid-card-image-link",
4575
- children: [
4576
- isOnSale && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-badge-on-sale", children: "ON SALE" }),
4577
- /* @__PURE__ */ jsxRuntimeExports.jsx(
4578
- Trigger,
4579
- {
4580
- params: {
4581
- productId: id,
4582
- productVariantId: variant_id,
4583
- productName: title,
4584
- productVendor: vendor,
4585
- productSku: sku,
4586
- productVariantName: variant_title,
4587
- productLink: url,
4588
- productImage: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4589
- productCurrency: currency,
4590
- productPrice: price
4591
- },
4592
- ...triggerPropAdditional,
4593
- onAfterAddWishlist,
4594
- onAfterRemoveWishlist,
4595
- wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id],
4596
- ...objectPresent(previewSettings) && ((_e = (_d = previewSettings == null ? void 0 : previewSettings.settings) == null ? void 0 : _d.general) == null ? void 0 : _e.use_dummy_data) ? {
4597
- previewSettings
4598
- } : {}
4599
- }
4600
- ),
4601
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-featured-image-element", children: [
4602
- /* @__PURE__ */ jsxRuntimeExports.jsx(
4603
- "img",
4604
- {
4605
- ref: imageRef,
4606
- ...hasEntryImage ? {
4607
- src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4608
- ["loaded"]: ""
4609
- } : {
4610
- ["data-src"]: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`
4611
- },
4612
- alt: "sledge-card-image",
4613
- loading: "lazy",
4614
- className: "sledge__product-grid-card-image-featured-image",
4615
- onError: ({ currentTarget }) => {
4616
- if (!currentTarget)
4617
- return;
4618
- currentTarget.onerror = null;
4619
- currentTarget.src = `${CDN_URL}/images/blank-image.png`;
4620
- }
4621
- }
4622
- ),
4623
- secondaryImage && /* @__PURE__ */ jsxRuntimeExports.jsx(
4624
- "img",
4625
- {
4626
- src: secondaryImage == null ? void 0 : secondaryImage.src,
4627
- alt: "sledge-card-image",
4628
- className: "sledge__product-grid-card-image-featured-image sledge__product-grid-card-image-featured-image--secondary"
4629
- }
4630
- )
4631
- ] }),
4632
- /* @__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(
4633
- "img",
4634
- {
4635
- decoding: "async",
4636
- id: image2 == null ? void 0 : image2.id,
4637
- height: "270",
4638
- loading: "lazy",
4639
- src: image2 == null ? void 0 : image2.src,
4640
- alt: product == null ? void 0 : product.title,
4641
- width: 269.92,
4642
- style: { aspectRatio: 269.92 / 270 }
4546
+ className: "sledge__product-grid-card-image-link-flyout",
4547
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4548
+ "img",
4549
+ {
4550
+ ref: imageRef,
4551
+ ...{
4552
+ src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4553
+ ["loaded"]: ""
4643
4554
  },
4644
- image2 == null ? void 0 : image2.id
4645
- )) })
4646
- ]
4555
+ alt: "sledge-card-image",
4556
+ loading: "lazy",
4557
+ className: "sledge__product-grid-card-image-featured-image-flyout",
4558
+ onError: ({ currentTarget }) => {
4559
+ if (!currentTarget)
4560
+ return;
4561
+ currentTarget.onerror = null;
4562
+ currentTarget.src = `${CDN_URL}/images/blank-image.png`;
4563
+ }
4564
+ }
4565
+ )
4647
4566
  }
4648
- ),
4649
- isOutOfStock ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-out-of-stock", children: language_button_out_of_stock || "Sold out" }) : null
4650
- ] }),
4651
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-desc", children: [
4652
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-title", children: [
4653
- show_price ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-price", children: [
4567
+ ) }),
4568
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-desc-flyout", children: [
4569
+ title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4570
+ "a",
4571
+ {
4572
+ href: url,
4573
+ onClick: () => {
4574
+ if (sourceApp === "instant-search") {
4575
+ productClickTrigger$1({
4576
+ productId: id
4577
+ });
4578
+ } else if (productRecommendationSourceApps.includes(sourceApp)) {
4579
+ productClickTrigger({
4580
+ productId: id,
4581
+ sourceApp
4582
+ });
4583
+ }
4584
+ },
4585
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "sledge__product-grid-card-product-name-flyout", style: display_product_name_style, children: title })
4586
+ }
4587
+ ) : null,
4588
+ show_price ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-price-flyout", children: [
4654
4589
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: display_price_style, dangerouslySetInnerHTML: { __html: shopifyFormatMoney(price * 100, money_format) } }),
4655
4590
  isOnSale && /* @__PURE__ */ jsxRuntimeExports.jsx(
4656
4591
  "div",
4657
4592
  {
4658
- className: "sledge__product-grid-card-compare-at-price",
4593
+ className: "sledge__product-grid-card-compare-at-price-flyout",
4659
4594
  dangerouslySetInnerHTML: { __html: shopifyFormatMoney(compare_at_price * 100, money_format) }
4660
4595
  }
4661
4596
  )
4662
- ] }) : null,
4663
- show_vendor && vendor ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-badge-vendor", title: vendor, children: [
4664
- "Vendor: ",
4665
- vendor
4666
4597
  ] }) : null
4598
+ ] })
4599
+ ]
4600
+ }
4601
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
4602
+ "div",
4603
+ {
4604
+ className: "sledge__product-grid-card",
4605
+ "data-for-loop-index": forLoopIndex,
4606
+ "data-for-loop-index-with-page": forLoopIndexWithPage,
4607
+ "data-product-id": id,
4608
+ "data-option-selected-value": encodeURIComponent(optionSelectedValue),
4609
+ children: [
4610
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-content", children: [
4611
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-image", children: [
4612
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
4613
+ "a",
4614
+ {
4615
+ href: url,
4616
+ onClick: () => {
4617
+ if (sourceApp === "instant-search") {
4618
+ productClickTrigger$1({
4619
+ productId: id
4620
+ });
4621
+ } else if (productRecommendationSourceApps.includes(sourceApp)) {
4622
+ productClickTrigger({
4623
+ productId: id,
4624
+ sourceApp
4625
+ });
4626
+ }
4627
+ },
4628
+ className: "sledge__product-grid-card-image-link",
4629
+ children: [
4630
+ isOnSale && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-badge-on-sale", children: "ON SALE" }),
4631
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
4632
+ Trigger,
4633
+ {
4634
+ params: {
4635
+ productId: id,
4636
+ productVariantId: variant_id,
4637
+ productName: title,
4638
+ productVendor: vendor,
4639
+ productSku: sku,
4640
+ productVariantName: variant_title,
4641
+ productLink: url,
4642
+ productImage: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4643
+ productCurrency: currency,
4644
+ productPrice: price
4645
+ },
4646
+ ...triggerPropAdditional,
4647
+ onAfterAddWishlist,
4648
+ onAfterRemoveWishlist,
4649
+ wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id],
4650
+ ...objectPresent(previewSettings) && ((_e = (_d = previewSettings == null ? void 0 : previewSettings.settings) == null ? void 0 : _d.general) == null ? void 0 : _e.use_dummy_data) ? {
4651
+ previewSettings
4652
+ } : {}
4653
+ }
4654
+ ),
4655
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-featured-image-element", children: [
4656
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
4657
+ "img",
4658
+ {
4659
+ ref: imageRef,
4660
+ ...hasEntryImage ? {
4661
+ src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4662
+ ["loaded"]: ""
4663
+ } : {
4664
+ ["data-src"]: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`
4665
+ },
4666
+ alt: "sledge-card-image",
4667
+ loading: "lazy",
4668
+ className: "sledge__product-grid-card-image-featured-image",
4669
+ onError: ({ currentTarget }) => {
4670
+ if (!currentTarget)
4671
+ return;
4672
+ currentTarget.onerror = null;
4673
+ currentTarget.src = `${CDN_URL}/images/blank-image.png`;
4674
+ }
4675
+ }
4676
+ ),
4677
+ secondaryImage && /* @__PURE__ */ jsxRuntimeExports.jsx(
4678
+ "img",
4679
+ {
4680
+ src: secondaryImage == null ? void 0 : secondaryImage.src,
4681
+ alt: "sledge-card-image",
4682
+ className: "sledge__product-grid-card-image-featured-image sledge__product-grid-card-image-featured-image--secondary"
4683
+ }
4684
+ )
4685
+ ] }),
4686
+ /* @__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(
4687
+ "img",
4688
+ {
4689
+ decoding: "async",
4690
+ id: image2 == null ? void 0 : image2.id,
4691
+ height: "270",
4692
+ loading: "lazy",
4693
+ src: image2 == null ? void 0 : image2.src,
4694
+ alt: product == null ? void 0 : product.title,
4695
+ width: 269.92,
4696
+ style: { aspectRatio: 269.92 / 270 }
4697
+ },
4698
+ image2 == null ? void 0 : image2.id
4699
+ )) })
4700
+ ]
4701
+ }
4702
+ ),
4703
+ isOutOfStock ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-out-of-stock", children: language_button_out_of_stock || "Sold out" }) : null
4704
+ ] }),
4705
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-desc", children: [
4706
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-title", children: [
4707
+ show_price ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-price", children: [
4708
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: display_price_style, dangerouslySetInnerHTML: { __html: shopifyFormatMoney(price * 100, money_format) } }),
4709
+ isOnSale && /* @__PURE__ */ jsxRuntimeExports.jsx(
4710
+ "div",
4711
+ {
4712
+ className: "sledge__product-grid-card-compare-at-price",
4713
+ dangerouslySetInnerHTML: { __html: shopifyFormatMoney(compare_at_price * 100, money_format) }
4714
+ }
4715
+ )
4716
+ ] }) : null,
4717
+ show_vendor && vendor ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-badge-vendor", title: vendor, children: [
4718
+ "Vendor: ",
4719
+ vendor
4720
+ ] }) : null
4721
+ ] }),
4722
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-rating", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4723
+ Rating,
4724
+ {
4725
+ params: {
4726
+ productId: id
4727
+ },
4728
+ size: "xs",
4729
+ withSkeletonLoading: false,
4730
+ isScrollToElementWidget: false,
4731
+ data: dataReviews == null ? void 0 : dataReviews[id]
4732
+ }
4733
+ ) }),
4734
+ title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4735
+ "a",
4736
+ {
4737
+ href: url,
4738
+ onClick: () => {
4739
+ if (sourceApp === "instant-search") {
4740
+ productClickTrigger$1({
4741
+ productId: id
4742
+ });
4743
+ } else if (productRecommendationSourceApps.includes(sourceApp)) {
4744
+ productClickTrigger({
4745
+ productId: id,
4746
+ sourceApp
4747
+ });
4748
+ }
4749
+ },
4750
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "sledge__product-grid-card-product-name", style: display_product_name_style, children: title })
4751
+ }
4752
+ ) : null,
4753
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-text", children: show_sku && sku ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
4754
+ "SKU: ",
4755
+ sku
4756
+ ] }) : null }),
4757
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
4758
+ VariantSelector,
4759
+ {
4760
+ data: {
4761
+ product: {
4762
+ ...product,
4763
+ variants
4764
+ }
4765
+ },
4766
+ setSelectedVariantId,
4767
+ setSelectedVariantStock,
4768
+ setSelectedVariantInventoryManagement,
4769
+ setSelectedVariantInventoryPolicy,
4770
+ sourceApp,
4771
+ instantSearchSettings,
4772
+ optionSelectedValue,
4773
+ hasEntryImage
4774
+ }
4775
+ )
4776
+ ] })
4667
4777
  ] }),
4668
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-rating", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4669
- Rating,
4778
+ show_add_to_cart ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4779
+ Button,
4670
4780
  {
4671
- params: {
4672
- productId: id
4673
- },
4674
- size: "xs",
4675
- withSkeletonLoading: false,
4676
- isScrollToElementWidget: false,
4677
- data: dataReviews == null ? void 0 : dataReviews[id]
4678
- }
4679
- ) }),
4680
- title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4681
- "a",
4682
- {
4683
- href: url,
4684
- onClick: () => {
4685
- if (sourceApp === "instant-search") {
4686
- productClickTrigger$1({
4687
- productId: id
4688
- });
4689
- } else if (productRecommendationSourceApps.includes(sourceApp)) {
4690
- productClickTrigger({
4691
- productId: id,
4692
- sourceApp
4693
- });
4781
+ type: "button",
4782
+ colorType: "light",
4783
+ className: "sledge__product-grid-button-add-to-cart",
4784
+ style: {
4785
+ ...display_button_add_to_cart_style,
4786
+ ...isLoadingAddToCart && {
4787
+ cursor: "wait"
4694
4788
  }
4695
4789
  },
4696
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "sledge__product-grid-card-product-name", style: display_product_name_style, children: title })
4697
- }
4698
- ) : null,
4699
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-text", children: show_sku && sku ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
4700
- "SKU: ",
4701
- sku
4702
- ] }) : null }),
4703
- /* @__PURE__ */ jsxRuntimeExports.jsx(
4704
- VariantSelector,
4705
- {
4706
- data: {
4707
- product: {
4708
- ...product,
4709
- variants
4790
+ ...isLoadingAddToCart || isOutOfStock ? {
4791
+ disabled: true
4792
+ } : {
4793
+ onClick: () => {
4794
+ handleAddToCart && handleAddToCart({
4795
+ id: selectedVariantId,
4796
+ quantity: 1
4797
+ });
4710
4798
  }
4711
4799
  },
4712
- setSelectedVariantId,
4713
- setSelectedVariantStock,
4714
- setSelectedVariantInventoryManagement,
4715
- setSelectedVariantInventoryPolicy,
4716
- sourceApp
4717
- }
4718
- )
4719
- ] })
4720
- ] }),
4721
- show_add_to_cart ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4722
- Button,
4723
- {
4724
- type: "button",
4725
- colorType: "light",
4726
- className: "sledge__product-grid-button-add-to-cart",
4727
- style: {
4728
- ...display_button_add_to_cart_style,
4729
- ...isLoadingAddToCart && {
4730
- cursor: "wait"
4731
- }
4732
- },
4733
- ...isLoadingAddToCart || isOutOfStock ? {
4734
- disabled: true
4735
- } : {
4736
- onClick: () => {
4737
- handleAddToCart && handleAddToCart({
4738
- id: selectedVariantId,
4739
- quantity: 1
4740
- });
4800
+ children: isOutOfStock ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4801
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BagIcon, { width: 15, height: 15, color: "currentColor" }),
4802
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: language_button_out_of_stock || "Sold out" })
4803
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4804
+ isLoadingAddToCart ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingDots, {}) : null,
4805
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BagIcon, { width: 15, height: 15, color: "currentColor" }),
4806
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: language_button_add_to_cart || "Add To Cart" })
4807
+ ] })
4741
4808
  }
4742
- },
4743
- children: isOutOfStock ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4744
- /* @__PURE__ */ jsxRuntimeExports.jsx(BagIcon, { width: 15, height: 15, color: "currentColor" }),
4745
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: language_button_out_of_stock || "Sold out" })
4746
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4747
- isLoadingAddToCart ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingDots, {}) : null,
4748
- /* @__PURE__ */ jsxRuntimeExports.jsx(BagIcon, { width: 15, height: 15, color: "currentColor" }),
4749
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: language_button_add_to_cart || "Add To Cart" })
4750
- ] })
4751
- }
4752
- ) }) : null
4753
- ] }) });
4809
+ ) }) : null
4810
+ ]
4811
+ }
4812
+ ) });
4754
4813
  }
4755
4814
  return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: component }, id);
4756
4815
  });
@@ -4767,6 +4826,7 @@ const ProductGrid = React__default.memo((props) => {
4767
4826
  onAfterRenderProduct,
4768
4827
  currentColumnGrid,
4769
4828
  previewSettings,
4829
+ instantSearchSettings,
4770
4830
  hitsPerPage,
4771
4831
  currentPage
4772
4832
  } = props;
@@ -4864,21 +4924,23 @@ const ProductGrid = React__default.memo((props) => {
4864
4924
  "data-custom-card": Boolean(props == null ? void 0 : props.cards),
4865
4925
  "data-flyout": isFlyout,
4866
4926
  children: data == null ? void 0 : data.map((item, index) => {
4867
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
4868
- ProductCard,
4869
- {
4870
- item,
4871
- handleAddToCart,
4872
- clickedAddToCartId,
4873
- generalDataSettings,
4874
- additionalCardProps: {
4875
- forLoopIndex: index,
4876
- forLoopIndexWithPage: Number(currentPage) && Number(hitsPerPage) ? index + (Number(currentPage) - 1) * Number(hitsPerPage) : index
4877
- },
4878
- ...props
4927
+ var _a, _b, _c, _d, _e;
4928
+ const isSplitProducts = Boolean((_a = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _a.enable);
4929
+ const optionFirst = isSplitProducts && ((_b = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _b.by) ? (_e = (_c = item == null ? void 0 : item.product) == null ? void 0 : _c.options) == null ? void 0 : _e[(_d = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _d.by] : [];
4930
+ const optionFirstValues = (optionFirst == null ? void 0 : optionFirst.length) ? optionFirst : [];
4931
+ const productCardProps = {
4932
+ item,
4933
+ handleAddToCart,
4934
+ clickedAddToCartId,
4935
+ generalDataSettings,
4936
+ additionalCardProps: {
4937
+ forLoopIndex: index,
4938
+ forLoopIndexWithPage: Number(currentPage) && Number(hitsPerPage) ? index + (Number(currentPage) - 1) * Number(hitsPerPage) : index
4879
4939
  },
4880
- `sledge-product-card_${index}`
4881
- );
4940
+ instantSearchSettings,
4941
+ ...props
4942
+ };
4943
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isSplitProducts && (optionFirstValues == null ? void 0 : optionFirstValues.length) ? optionFirstValues.map((optionFirstValue, indexFirstValue) => /* @__PURE__ */ jsxRuntimeExports.jsx(ProductCard, { optionSelectedValue: optionFirstValue, ...productCardProps }, `sledge-product-card_${index}_${indexFirstValue}`)) : /* @__PURE__ */ jsxRuntimeExports.jsx(ProductCard, { ...productCardProps }, `sledge-product-card_${index}`) });
4882
4944
  })
4883
4945
  }
4884
4946
  );
@@ -9840,6 +9902,7 @@ const SearchResultWidget = (props) => {
9840
9902
  setAllowedTabs,
9841
9903
  isDesktopLayout,
9842
9904
  previewSettings,
9905
+ instantSearchSettings,
9843
9906
  currentColumnGrid,
9844
9907
  setCurrentColumnGrid
9845
9908
  })
@@ -9926,6 +9989,7 @@ const ResultProduct = React__default.memo((props) => {
9926
9989
  setAllowedTabs,
9927
9990
  isDesktopLayout,
9928
9991
  previewSettings,
9992
+ instantSearchSettings,
9929
9993
  currentColumnGrid,
9930
9994
  setCurrentColumnGrid
9931
9995
  } = props || {};
@@ -10686,6 +10750,7 @@ const ResultProduct = React__default.memo((props) => {
10686
10750
  dataReviews: propsData == null ? void 0 : propsData.reviews,
10687
10751
  currentColumnGrid,
10688
10752
  previewSettings,
10753
+ instantSearchSettings,
10689
10754
  hitsPerPage: hitsPerPageResult,
10690
10755
  currentPage
10691
10756
  }