@sledge-app/react-instant-search 1.0.4 → 1.0.6

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.
@@ -1,4 +1,4 @@
1
- import { j as jsxRuntimeExports, $ as $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, a as $cb5cc270b50c6fcd$export$41fb9f06171c75f4, b as $cb5cc270b50c6fcd$export$602eac185826482c, c as $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, d as $cb5cc270b50c6fcd$export$f39c2d165cd861fe, e as $cb5cc270b50c6fcd$export$21b07c8f274aebd5, f as $67824d98245208a0$export$be92b6f5f03c0fe9, g as $67824d98245208a0$export$adb584737d712b70, h as $e698a72e93240346$export$be92b6f5f03c0fe9, i as $e698a72e93240346$export$adb584737d712b70, k as $faa2e61a3361514f$export$be92b6f5f03c0fe9, l as $faa2e61a3361514f$export$13921ac0cc260818, m as $faa2e61a3361514f$export$9a58ef0d7ad3278c, n as $faa2e61a3361514f$export$6521433ed15a34db, o as $f99a8c78507165f7$export$be92b6f5f03c0fe9, p as $f99a8c78507165f7$export$6d08773d2e66f8f2, q as $f99a8c78507165f7$export$adb584737d712b70, r as $cc7e05a45900e73f$export$6d08773d2e66f8f2, s as $cc7e05a45900e73f$export$d6e5bf9c43ea9319, t as $cc7e05a45900e73f$export$c3468e2714d175fa, u as $cc7e05a45900e73f$export$be92b6f5f03c0fe9, v as $cc7e05a45900e73f$export$41fb9f06171c75f4, w as $cc7e05a45900e73f$export$4c8d1a57a761ef94, x as $cc7e05a45900e73f$export$f04a61298a47a40f, y as $cc7e05a45900e73f$export$602eac185826482c, z as $cc7e05a45900e73f$export$7c6e2c02157bb7d2, A as $cc7e05a45900e73f$export$2f60d3ec9ad468f2, B as $cc7e05a45900e73f$export$d5c6c08dc2d3ca7, C as $cc7e05a45900e73f$export$bf1aedc3039c8d63, D as motion, E as client, F as $a093c7e1ec25a057$export$2881499e37b75b9a, G as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, H as $a093c7e1ec25a057$export$41fb9f06171c75f4, I as $a093c7e1ec25a057$export$602eac185826482c, J as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, K as $a093c7e1ec25a057$export$21b07c8f274aebd5, L as $57acba87d6e25586$export$be92b6f5f03c0fe9, M as $57acba87d6e25586$export$d5c6c08dc2d3ca7, N as $57acba87d6e25586$export$9a4e88b92edfce6b, O as $57acba87d6e25586$export$6521433ed15a34db, P as MasonryResponsive, Q as Masonry, R as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, S as $5d3850c4d0b4e6c7$export$602eac185826482c, T as $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, U as $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 } from "./vendor-af52d0f5.js";
1
+ import { j as jsxRuntimeExports, $ as $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, a as $cb5cc270b50c6fcd$export$41fb9f06171c75f4, b as $cb5cc270b50c6fcd$export$602eac185826482c, c as $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, d as $cb5cc270b50c6fcd$export$f39c2d165cd861fe, e as $cb5cc270b50c6fcd$export$21b07c8f274aebd5, f as $67824d98245208a0$export$be92b6f5f03c0fe9, g as $67824d98245208a0$export$adb584737d712b70, h as $e698a72e93240346$export$be92b6f5f03c0fe9, i as $e698a72e93240346$export$adb584737d712b70, k as $faa2e61a3361514f$export$be92b6f5f03c0fe9, l as $faa2e61a3361514f$export$13921ac0cc260818, m as $faa2e61a3361514f$export$9a58ef0d7ad3278c, n as $faa2e61a3361514f$export$6521433ed15a34db, o as $f99a8c78507165f7$export$be92b6f5f03c0fe9, p as $f99a8c78507165f7$export$6d08773d2e66f8f2, q as $f99a8c78507165f7$export$adb584737d712b70, r as $cc7e05a45900e73f$export$6d08773d2e66f8f2, s as $cc7e05a45900e73f$export$d6e5bf9c43ea9319, t as $cc7e05a45900e73f$export$c3468e2714d175fa, u as $cc7e05a45900e73f$export$be92b6f5f03c0fe9, v as $cc7e05a45900e73f$export$41fb9f06171c75f4, w as $cc7e05a45900e73f$export$4c8d1a57a761ef94, x as $cc7e05a45900e73f$export$f04a61298a47a40f, y as $cc7e05a45900e73f$export$602eac185826482c, z as $cc7e05a45900e73f$export$7c6e2c02157bb7d2, A as $cc7e05a45900e73f$export$2f60d3ec9ad468f2, B as $cc7e05a45900e73f$export$d5c6c08dc2d3ca7, C as $cc7e05a45900e73f$export$bf1aedc3039c8d63, D as motion, E as client, F as $a093c7e1ec25a057$export$2881499e37b75b9a, G as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, H as $a093c7e1ec25a057$export$41fb9f06171c75f4, I as $a093c7e1ec25a057$export$602eac185826482c, J as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, K as $a093c7e1ec25a057$export$21b07c8f274aebd5, L as $57acba87d6e25586$export$be92b6f5f03c0fe9, M as $57acba87d6e25586$export$d5c6c08dc2d3ca7, N as $57acba87d6e25586$export$9a4e88b92edfce6b, O as $57acba87d6e25586$export$6521433ed15a34db, P as MasonryResponsive, Q as Masonry, R as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, S as $5d3850c4d0b4e6c7$export$602eac185826482c, T as $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, U as $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 } from "./vendor-efe38901.js";
2
2
  import React__default, { createElement } from "react";
3
3
  import { SledgeContext } from "@sledge-app/core";
4
4
  import "react-dom";
@@ -2347,6 +2347,51 @@ const ProductGrid = ({
2347
2347
  const { id: variant_id = "", title: variant_title = "", price = "", sku = "" } = (variants == null ? void 0 : variants.length) ? variants[0] : {};
2348
2348
  let isLoadingAddToCart = clickedAddToCartId == variant_id;
2349
2349
  let isOutOfStock = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_quantity") ? !variants[0].inventory_quantity && showOptionOutOfStock : false;
2350
+ const options = (product == null ? void 0 : product.options) ? Object.entries(product.options) : [];
2351
+ const images = (product == null ? void 0 : product.images) ?? [];
2352
+ const defaultSelected = {};
2353
+ function setDefaultFunction() {
2354
+ if (!(variants == null ? void 0 : variants.length))
2355
+ return;
2356
+ defaultSelected["data-product-handle"] = product.handle;
2357
+ defaultSelected["data-selected-option1"] = variants[0].option1;
2358
+ if (variants[0].option2) {
2359
+ defaultSelected["data-selected-option2"] = variants[0].option2;
2360
+ }
2361
+ defaultSelected["data-variant-id"] = variants[0].admin_graphql_api_id;
2362
+ }
2363
+ setDefaultFunction();
2364
+ const defaultSelectedVariantId = (variants == null ? void 0 : variants.length) ? variants[0].admin_graphql_api_id : "";
2365
+ const [selectedVariantId, setSelectedVariantId] = React__default.useState(defaultSelectedVariantId);
2366
+ function setSelectedVariant(element, value, optionIndex) {
2367
+ var _a2;
2368
+ const selectedInput = element.target.parentNode.parentNode.firstChild;
2369
+ const parentCard = element.target.offsetParent;
2370
+ const setOptionAttribute = () => {
2371
+ selectedInput.attributes[`data-selected-option${optionIndex}`].value = value;
2372
+ };
2373
+ setOptionAttribute();
2374
+ const option1 = `[data-option-1="${selectedInput.attributes["data-selected-option1"].value}"]`;
2375
+ const option2 = `${selectedInput.attributes["data-selected-option2"] ? `[data-option-2="${selectedInput.attributes["data-selected-option2"].value}"]` : ""}`;
2376
+ const selectOption = parentCard.querySelector(`select option${option1}${option2}`);
2377
+ const variantId = selectOption.attributes["data-graphql-id"].value;
2378
+ const imageId = (_a2 = selectOption.attributes["data-image-id"]) == null ? void 0 : _a2.value;
2379
+ const setOther = () => {
2380
+ selectedInput.attributes[`data-variant-id`].value = selectOption.attributes["data-graphql-id"].value;
2381
+ if (variantId)
2382
+ setSelectedVariantId(variantId);
2383
+ if (imageId)
2384
+ parentCard.querySelector(`img.sledge__product-grid-card-image-featured-image`).src = parentCard.querySelector(
2385
+ `div.sledge__product-grid-card-variant-images img[id="${imageId}"]`
2386
+ ).src;
2387
+ };
2388
+ setOther();
2389
+ const result = {
2390
+ variantId,
2391
+ imageId
2392
+ };
2393
+ return result;
2394
+ }
2350
2395
  const getCards = cards ? cards({
2351
2396
  product: {
2352
2397
  ...product,
@@ -2402,7 +2447,21 @@ const ProductGrid = ({
2402
2447
  wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id]
2403
2448
  }
2404
2449
  ),
2405
- /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${API_URL}/img/blank-image.png`, alt: "sledge-card-image", loading: "lazy" })
2450
+ /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${API_URL}/img/blank-image.png`, alt: "sledge-card-image", loading: "lazy", className: "sledge__product-grid-card-image-featured-image" }),
2451
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: images == null ? void 0 : images.map((image2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
2452
+ "img",
2453
+ {
2454
+ decoding: "async",
2455
+ id: image2 == null ? void 0 : image2.id,
2456
+ height: "270",
2457
+ loading: "lazy",
2458
+ src: image2 == null ? void 0 : image2.src,
2459
+ alt: product == null ? void 0 : product.title,
2460
+ width: 269.92,
2461
+ style: { aspectRatio: 269.92 / 270 }
2462
+ },
2463
+ image2 == null ? void 0 : image2.id
2464
+ )) })
2406
2465
  ]
2407
2466
  }
2408
2467
  ),
@@ -2414,9 +2473,9 @@ const ProductGrid = ({
2414
2473
  currency,
2415
2474
  price
2416
2475
  ] }) }) : null,
2417
- show_vendor && vendor ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-badge-vendor", children: [
2476
+ show_vendor && vendor ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-badge-vendor", title: vendor, children: [
2418
2477
  "Vendor: ",
2419
- (vendor == null ? void 0 : vendor.length) > 5 ? `${String(vendor).substring(0, 5)}...` : vendor
2478
+ vendor
2420
2479
  ] }) : null
2421
2480
  ] }),
2422
2481
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-rating", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -2444,7 +2503,49 @@ const ProductGrid = ({
2444
2503
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-text", children: show_sku && sku ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2445
2504
  "SKU: ",
2446
2505
  sku
2447
- ] }) : null })
2506
+ ] }) : null }),
2507
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-variant-swatch", children: [
2508
+ /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "hidden", ...defaultSelected, className: "selected-option" }),
2509
+ /* @__PURE__ */ jsxRuntimeExports.jsx("select", { className: "variant-picker sledge__product-grid-card-variant-picker", children: variants == null ? void 0 : variants.map((variant) => {
2510
+ const { title: title2, option1, option2, position, id: id2, admin_graphql_api_id, image_id } = variant;
2511
+ let optionAttributes = {
2512
+ "data-option-1": option1,
2513
+ "data-option-2": option2,
2514
+ "data-position": position,
2515
+ "data-id": id2,
2516
+ "data-graphql-id": admin_graphql_api_id,
2517
+ "data-image-id": image_id
2518
+ };
2519
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("option", { ...optionAttributes, children: title2 }, id2);
2520
+ }) }),
2521
+ options == null ? void 0 : options.map((option, optionParentIndex) => {
2522
+ const optionName = option[0];
2523
+ const optionValues = option[1];
2524
+ const [selectedOption, setSelectedOption] = React__default.useState(optionValues[0]);
2525
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: optionValues[0] !== "Default Title" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-variant-size-swatch-flex", children: optionValues.map((item2, index2) => {
2526
+ const defaultOptionClass = `
2527
+ ${selectedOption === item2 ? "sledge__product-variant-size-swatch-active" : ""} sledge__product-variant-size-swatch`;
2528
+ const colorOptionClass = `${selectedOption === item2 ? "sledge__product-variant-color-swatch-active" : ""} sledge__product-variant-color-swatch`;
2529
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
2530
+ "button",
2531
+ {
2532
+ type: "button",
2533
+ className: optionName === "Color" ? colorOptionClass : defaultOptionClass,
2534
+ style: {
2535
+ backgroundColor: optionName === "Color" ? item2 : null
2536
+ },
2537
+ onClick: (el) => {
2538
+ setSelectedVariant(el, item2, optionParentIndex + 1);
2539
+ setSelectedOption(item2);
2540
+ },
2541
+ title: optionName === "Color" ? null : item2,
2542
+ children: optionName === "Color" ? null : item2
2543
+ },
2544
+ index2
2545
+ );
2546
+ }) }, optionParentIndex) });
2547
+ })
2548
+ ] })
2448
2549
  ] })
2449
2550
  ] }),
2450
2551
  show_add_to_cart ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -2462,7 +2563,7 @@ const ProductGrid = ({
2462
2563
  disabled: true
2463
2564
  } : {
2464
2565
  onClick: () => handleAddToCart({
2465
- id: variant_id,
2566
+ id: selectedVariantId,
2466
2567
  quantity: 1
2467
2568
  })
2468
2569
  },
@@ -3293,7 +3394,7 @@ const SearchResultWidget = (props) => {
3293
3394
  data: propsData,
3294
3395
  sledgeSettings
3295
3396
  } = props;
3296
- const { keyword: queryKeyword = "" } = query || {};
3397
+ const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : "q";
3297
3398
  const { collectionId } = params || {};
3298
3399
  let productCardsComponent = null;
3299
3400
  let collectionCardsComponent = null;
@@ -3852,7 +3953,7 @@ const ResultProduct = (props) => {
3852
3953
  data: propsData,
3853
3954
  settings
3854
3955
  } = props || {};
3855
- const { keyword: queryKeyword = "" } = query || {};
3956
+ const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : "q";
3856
3957
  const { collectionId } = params || {};
3857
3958
  const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
3858
3959
  const [isLoading, setIsLoading] = React__default.useState(!propsData);