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

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,51 @@ 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
- 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 }) });
4498
+ component = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4499
+ "div",
4500
+ {
4501
+ "data-for-loop-index": forLoopIndex,
4502
+ "data-for-loop-index-with-page": forLoopIndexWithPage,
4503
+ "data-product-id": id,
4504
+ "data-option-selected-value": encodeURIComponent(optionSelectedValue),
4505
+ dangerouslySetInnerHTML: { __html: CardsComponent({ ...CardsProps }) }
4506
+ }
4507
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(CardsComponent, { ...CardsProps }) });
4463
4508
  } 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",
4509
+ component = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFlyout ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
4510
+ "div",
4511
+ {
4512
+ className: "sledge__product-grid-card-flyout",
4513
+ "data-for-loop-index": forLoopIndex,
4514
+ "data-for-loop-index-with-page": forLoopIndexWithPage,
4515
+ "data-product-id": id,
4516
+ "data-option-selected-value": encodeURIComponent(optionSelectedValue),
4517
+ children: [
4518
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-flyout-wishlist-trigger", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4519
+ Trigger,
4505
4520
  {
4506
- ref: imageRef,
4507
- ...{
4508
- src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4509
- ["loaded"]: ""
4521
+ params: {
4522
+ productId: id,
4523
+ productVariantId: variant_id,
4524
+ productName: title,
4525
+ productVendor: vendor,
4526
+ productSku: sku,
4527
+ productVariantName: variant_title,
4528
+ productLink: url,
4529
+ productImage: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4530
+ productCurrency: currency,
4531
+ productPrice: price
4510
4532
  },
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) }
4533
+ ...triggerPropAdditional,
4534
+ onAfterAddWishlist,
4535
+ onAfterRemoveWishlist,
4536
+ wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id]
4551
4537
  }
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(
4538
+ ) }),
4539
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-image-flyout", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4559
4540
  "a",
4560
4541
  {
4561
4542
  href: url,
@@ -4571,186 +4552,273 @@ const ProductCard = React__default.memo((props) => {
4571
4552
  });
4572
4553
  }
4573
4554
  },
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 }
4555
+ className: "sledge__product-grid-card-image-link-flyout",
4556
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4557
+ "img",
4558
+ {
4559
+ ref: imageRef,
4560
+ ...{
4561
+ src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4562
+ ["loaded"]: ""
4643
4563
  },
4644
- image2 == null ? void 0 : image2.id
4645
- )) })
4646
- ]
4564
+ alt: "sledge-card-image",
4565
+ loading: "lazy",
4566
+ className: "sledge__product-grid-card-image-featured-image-flyout",
4567
+ onError: ({ currentTarget }) => {
4568
+ if (!currentTarget)
4569
+ return;
4570
+ currentTarget.onerror = null;
4571
+ currentTarget.src = `${CDN_URL}/images/blank-image.png`;
4572
+ }
4573
+ }
4574
+ )
4647
4575
  }
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: [
4576
+ ) }),
4577
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-desc-flyout", children: [
4578
+ title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4579
+ "a",
4580
+ {
4581
+ href: url,
4582
+ onClick: () => {
4583
+ if (sourceApp === "instant-search") {
4584
+ productClickTrigger$1({
4585
+ productId: id
4586
+ });
4587
+ } else if (productRecommendationSourceApps.includes(sourceApp)) {
4588
+ productClickTrigger({
4589
+ productId: id,
4590
+ sourceApp
4591
+ });
4592
+ }
4593
+ },
4594
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "sledge__product-grid-card-product-name-flyout", style: display_product_name_style, children: title })
4595
+ }
4596
+ ) : null,
4597
+ show_price ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-price-flyout", children: [
4654
4598
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: display_price_style, dangerouslySetInnerHTML: { __html: shopifyFormatMoney(price * 100, money_format) } }),
4655
4599
  isOnSale && /* @__PURE__ */ jsxRuntimeExports.jsx(
4656
4600
  "div",
4657
4601
  {
4658
- className: "sledge__product-grid-card-compare-at-price",
4602
+ className: "sledge__product-grid-card-compare-at-price-flyout",
4659
4603
  dangerouslySetInnerHTML: { __html: shopifyFormatMoney(compare_at_price * 100, money_format) }
4660
4604
  }
4661
4605
  )
4662
- ] }) : null,
4663
- show_vendor && vendor ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-badge-vendor", title: vendor, children: [
4664
- "Vendor: ",
4665
- vendor
4666
4606
  ] }) : null
4607
+ ] })
4608
+ ]
4609
+ }
4610
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
4611
+ "div",
4612
+ {
4613
+ className: "sledge__product-grid-card",
4614
+ "data-for-loop-index": forLoopIndex,
4615
+ "data-for-loop-index-with-page": forLoopIndexWithPage,
4616
+ "data-product-id": id,
4617
+ "data-option-selected-value": encodeURIComponent(optionSelectedValue),
4618
+ children: [
4619
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-content", children: [
4620
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-image", children: [
4621
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
4622
+ "a",
4623
+ {
4624
+ href: url,
4625
+ onClick: () => {
4626
+ if (sourceApp === "instant-search") {
4627
+ productClickTrigger$1({
4628
+ productId: id
4629
+ });
4630
+ } else if (productRecommendationSourceApps.includes(sourceApp)) {
4631
+ productClickTrigger({
4632
+ productId: id,
4633
+ sourceApp
4634
+ });
4635
+ }
4636
+ },
4637
+ className: "sledge__product-grid-card-image-link",
4638
+ children: [
4639
+ isOnSale && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-badge-on-sale", children: "ON SALE" }),
4640
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
4641
+ Trigger,
4642
+ {
4643
+ params: {
4644
+ productId: id,
4645
+ productVariantId: variant_id,
4646
+ productName: title,
4647
+ productVendor: vendor,
4648
+ productSku: sku,
4649
+ productVariantName: variant_title,
4650
+ productLink: url,
4651
+ productImage: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4652
+ productCurrency: currency,
4653
+ productPrice: price
4654
+ },
4655
+ ...triggerPropAdditional,
4656
+ onAfterAddWishlist,
4657
+ onAfterRemoveWishlist,
4658
+ 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) ? {
4660
+ previewSettings
4661
+ } : {}
4662
+ }
4663
+ ),
4664
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-featured-image-element", children: [
4665
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
4666
+ "img",
4667
+ {
4668
+ ref: imageRef,
4669
+ ...hasEntryImage ? {
4670
+ src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
4671
+ ["loaded"]: ""
4672
+ } : {
4673
+ ["data-src"]: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`
4674
+ },
4675
+ alt: "sledge-card-image",
4676
+ loading: "lazy",
4677
+ className: "sledge__product-grid-card-image-featured-image",
4678
+ onError: ({ currentTarget }) => {
4679
+ if (!currentTarget)
4680
+ return;
4681
+ currentTarget.onerror = null;
4682
+ currentTarget.src = `${CDN_URL}/images/blank-image.png`;
4683
+ }
4684
+ }
4685
+ ),
4686
+ secondaryImage && /* @__PURE__ */ jsxRuntimeExports.jsx(
4687
+ "img",
4688
+ {
4689
+ src: secondaryImage == null ? void 0 : secondaryImage.src,
4690
+ alt: "sledge-card-image",
4691
+ className: "sledge__product-grid-card-image-featured-image sledge__product-grid-card-image-featured-image--secondary"
4692
+ }
4693
+ )
4694
+ ] }),
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(
4696
+ "img",
4697
+ {
4698
+ decoding: "async",
4699
+ id: image2 == null ? void 0 : image2.id,
4700
+ height: "270",
4701
+ loading: "lazy",
4702
+ src: image2 == null ? void 0 : image2.src,
4703
+ alt: product == null ? void 0 : product.title,
4704
+ width: 269.92,
4705
+ style: { aspectRatio: 269.92 / 270 }
4706
+ },
4707
+ image2 == null ? void 0 : image2.id
4708
+ )) })
4709
+ ]
4710
+ }
4711
+ ),
4712
+ isOutOfStock ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-out-of-stock", children: language_button_out_of_stock || "Sold out" }) : null
4713
+ ] }),
4714
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-desc", children: [
4715
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-title", children: [
4716
+ show_price ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-price", children: [
4717
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: display_price_style, dangerouslySetInnerHTML: { __html: shopifyFormatMoney(price * 100, money_format) } }),
4718
+ isOnSale && /* @__PURE__ */ jsxRuntimeExports.jsx(
4719
+ "div",
4720
+ {
4721
+ className: "sledge__product-grid-card-compare-at-price",
4722
+ dangerouslySetInnerHTML: { __html: shopifyFormatMoney(compare_at_price * 100, money_format) }
4723
+ }
4724
+ )
4725
+ ] }) : null,
4726
+ show_vendor && vendor ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-badge-vendor", title: vendor, children: [
4727
+ "Vendor: ",
4728
+ vendor
4729
+ ] }) : null
4730
+ ] }),
4731
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-rating", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4732
+ Rating,
4733
+ {
4734
+ params: {
4735
+ productId: id
4736
+ },
4737
+ size: "xs",
4738
+ withSkeletonLoading: false,
4739
+ isScrollToElementWidget: false,
4740
+ data: dataReviews == null ? void 0 : dataReviews[id]
4741
+ }
4742
+ ) }),
4743
+ title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4744
+ "a",
4745
+ {
4746
+ href: url,
4747
+ onClick: () => {
4748
+ if (sourceApp === "instant-search") {
4749
+ productClickTrigger$1({
4750
+ productId: id
4751
+ });
4752
+ } else if (productRecommendationSourceApps.includes(sourceApp)) {
4753
+ productClickTrigger({
4754
+ productId: id,
4755
+ sourceApp
4756
+ });
4757
+ }
4758
+ },
4759
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "sledge__product-grid-card-product-name", style: display_product_name_style, children: title })
4760
+ }
4761
+ ) : null,
4762
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-text", children: show_sku && sku ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
4763
+ "SKU: ",
4764
+ sku
4765
+ ] }) : null }),
4766
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
4767
+ VariantSelector,
4768
+ {
4769
+ data: {
4770
+ product: {
4771
+ ...product,
4772
+ variants
4773
+ }
4774
+ },
4775
+ setSelectedVariantId,
4776
+ setSelectedVariantStock,
4777
+ setSelectedVariantInventoryManagement,
4778
+ setSelectedVariantInventoryPolicy,
4779
+ sourceApp,
4780
+ instantSearchSettings,
4781
+ optionSelectedValue,
4782
+ hasEntryImage
4783
+ }
4784
+ )
4785
+ ] })
4667
4786
  ] }),
4668
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-rating", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4669
- Rating,
4670
- {
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",
4787
+ show_add_to_cart ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4788
+ Button,
4682
4789
  {
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
- });
4790
+ type: "button",
4791
+ colorType: "light",
4792
+ className: "sledge__product-grid-button-add-to-cart",
4793
+ style: {
4794
+ ...display_button_add_to_cart_style,
4795
+ ...isLoadingAddToCart && {
4796
+ cursor: "wait"
4694
4797
  }
4695
4798
  },
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
4799
+ ...isLoadingAddToCart || isOutOfStock ? {
4800
+ disabled: true
4801
+ } : {
4802
+ onClick: () => {
4803
+ handleAddToCart && handleAddToCart({
4804
+ id: selectedVariantId,
4805
+ quantity: 1
4806
+ });
4710
4807
  }
4711
4808
  },
4712
- setSelectedVariantId,
4713
- setSelectedVariantStock,
4714
- setSelectedVariantInventoryManagement,
4715
- setSelectedVariantInventoryPolicy,
4716
- sourceApp
4809
+ children: isOutOfStock ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4810
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BagIcon, { width: 15, height: 15, color: "currentColor" }),
4811
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: language_button_out_of_stock || "Sold out" })
4812
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4813
+ isLoadingAddToCart ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingDots, {}) : null,
4814
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BagIcon, { width: 15, height: 15, color: "currentColor" }),
4815
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: language_button_add_to_cart || "Add To Cart" })
4816
+ ] })
4717
4817
  }
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
- });
4741
- }
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
- ] }) });
4818
+ ) }) : null
4819
+ ]
4820
+ }
4821
+ ) });
4754
4822
  }
4755
4823
  return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: component }, id);
4756
4824
  });
@@ -4767,6 +4835,7 @@ const ProductGrid = React__default.memo((props) => {
4767
4835
  onAfterRenderProduct,
4768
4836
  currentColumnGrid,
4769
4837
  previewSettings,
4838
+ instantSearchSettings,
4770
4839
  hitsPerPage,
4771
4840
  currentPage
4772
4841
  } = props;
@@ -4864,21 +4933,23 @@ const ProductGrid = React__default.memo((props) => {
4864
4933
  "data-custom-card": Boolean(props == null ? void 0 : props.cards),
4865
4934
  "data-flyout": isFlyout,
4866
4935
  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
4936
+ var _a, _b, _c, _d, _e;
4937
+ const isSplitProducts = Boolean((_a = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _a.enable);
4938
+ 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] : [];
4939
+ const optionFirstValues = (optionFirst == null ? void 0 : optionFirst.length) ? optionFirst : [];
4940
+ const productCardProps = {
4941
+ item,
4942
+ handleAddToCart,
4943
+ clickedAddToCartId,
4944
+ generalDataSettings,
4945
+ additionalCardProps: {
4946
+ forLoopIndex: index,
4947
+ forLoopIndexWithPage: Number(currentPage) && Number(hitsPerPage) ? index + (Number(currentPage) - 1) * Number(hitsPerPage) : index
4879
4948
  },
4880
- `sledge-product-card_${index}`
4881
- );
4949
+ instantSearchSettings,
4950
+ ...props
4951
+ };
4952
+ 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
4953
  })
4883
4954
  }
4884
4955
  );
@@ -9840,6 +9911,7 @@ const SearchResultWidget = (props) => {
9840
9911
  setAllowedTabs,
9841
9912
  isDesktopLayout,
9842
9913
  previewSettings,
9914
+ instantSearchSettings,
9843
9915
  currentColumnGrid,
9844
9916
  setCurrentColumnGrid
9845
9917
  })
@@ -9926,6 +9998,7 @@ const ResultProduct = React__default.memo((props) => {
9926
9998
  setAllowedTabs,
9927
9999
  isDesktopLayout,
9928
10000
  previewSettings,
10001
+ instantSearchSettings,
9929
10002
  currentColumnGrid,
9930
10003
  setCurrentColumnGrid
9931
10004
  } = props || {};
@@ -10686,6 +10759,7 @@ const ResultProduct = React__default.memo((props) => {
10686
10759
  dataReviews: propsData == null ? void 0 : propsData.reviews,
10687
10760
  currentColumnGrid,
10688
10761
  previewSettings,
10762
+ instantSearchSettings,
10689
10763
  hitsPerPage: hitsPerPageResult,
10690
10764
  currentPage
10691
10765
  }