@sledge-app/react-instant-search 0.0.15 → 0.0.17

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.
@@ -21,6 +21,9 @@ const SEPARATE_COMPONENT_DISPLAY_NAME = {
21
21
  CARDS: "ProductCards"
22
22
  }
23
23
  };
24
+ const SHOPIFY_GID = "gid://shopify/";
25
+ const SHOPIFY_GID_PRODUCT_ID = `${SHOPIFY_GID}Product/`;
26
+ const SHOPIFY_GID_PRODUCT_VARIANT_ID = `${SHOPIFY_GID}ProductVariant/`;
24
27
  const sanitizeDataId = (id) => {
25
28
  if (!id)
26
29
  return "";
@@ -612,7 +615,7 @@ const ButtonDetail = "";
612
615
  const Trigger$1 = "";
613
616
  const Trigger = (props) => {
614
617
  var _a, _b, _c;
615
- const { data, forceActive, hidden, onAfterAddWishlist, onAfterRemoveWishlist } = props;
618
+ const { data, forceActive = false, hidden = false, onAfterAddWishlist, onAfterRemoveWishlist } = props;
616
619
  const { productId, productVariantId } = data || {};
617
620
  const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId } = React__default.useContext(SledgeContext);
618
621
  const defaultColorIcon = "#767676";
@@ -635,7 +638,7 @@ const Trigger = (props) => {
635
638
  const handleCheckWishlist = async () => {
636
639
  let response;
637
640
  response = await checkWishlist(productId, productVariantId);
638
- setIsWishlist(response);
641
+ setIsWishlist(forceActive ? forceActive : response);
639
642
  };
640
643
  const handleClick = async (e) => {
641
644
  var _a2, _b2, _c2, _d, _e, _f;
@@ -1710,16 +1713,28 @@ const ProductGrid = ({
1710
1713
  const { product, variants } = item || {};
1711
1714
  const { id, title, image, url, vendor = "", currency } = product || {};
1712
1715
  const { id: variant_id = "", title: variant_title = "", price = "", sku = "" } = (variants == null ? void 0 : variants.length) ? variants[0] : {};
1716
+ const productUrl = new URL(product.url);
1717
+ const arrProductUrlPathname = productUrl.pathname.split("/");
1718
+ const handle = arrProductUrlPathname[arrProductUrlPathname.length - 1];
1713
1719
  let isLoadingAddToCart = clickedAddToCartId == variant_id;
1714
1720
  let isOutOfStock = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_quantity") ? !variants[0].inventory_quantity && showOptionOutOfStock : false;
1715
1721
  return cards ? /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: cards({
1716
1722
  product: {
1717
- ...product,
1723
+ ...{
1724
+ ...product,
1725
+ ...{
1726
+ id: `${SHOPIFY_GID_PRODUCT_ID}${id}`,
1727
+ handle
1728
+ }
1729
+ },
1718
1730
  ...{
1719
1731
  variants: variants.map((variant, index2) => {
1720
- const { inventory_quantity, ...otherObject } = variant || {};
1732
+ const { id: variant_id2, inventory_quantity, ...otherObject } = variant || {};
1721
1733
  return {
1722
1734
  ...otherObject,
1735
+ ...{
1736
+ id: `${SHOPIFY_GID_PRODUCT_VARIANT_ID}${variant_id2}`
1737
+ },
1723
1738
  is_out_of_stock: Object.hasOwn(variants[index2], "inventory_quantity") ? !inventory_quantity : false
1724
1739
  };
1725
1740
  })