@rebuy/rebuy-hydrogen 3.0.0-beta.17 → 3.0.0-beta.18
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.
- package/README.md +51 -3
- package/dist/context/RebuyWidgetContext.d.ts +7 -0
- package/dist/context/RebuyWidgetContext.d.ts.map +1 -0
- package/dist/index.css +27 -27
- package/dist/index.css.map +1 -1
- package/dist/index.js +176 -147
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +128 -99
- package/dist/index.mjs.map +4 -4
- package/dist/types/widgets.d.ts +4 -2
- package/dist/types/widgets.d.ts.map +1 -1
- package/dist/widgetContainer/RebuyWidgetContainer.d.ts.map +1 -1
- package/dist/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.d.ts.map +1 -1
- package/dist/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.d.ts.map +1 -1
- package/dist/widgets/RebuyProductAddOns/RebuyProductAddOns.d.ts.map +1 -1
- package/dist/widgets/RebuyProductRecommendations/RebuyProductRecommendations.d.ts.map +1 -1
- package/dist/widgets/RebuyWidget/RebuyWidget.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -6986,7 +6986,6 @@ var RebuyWidget = (props) => {
|
|
6986
6986
|
customTitleLevel = "h2",
|
6987
6987
|
customTitleStyle,
|
6988
6988
|
isCrossSell,
|
6989
|
-
isHydrogenReact,
|
6990
6989
|
popupTriggerId,
|
6991
6990
|
product,
|
6992
6991
|
productId,
|
@@ -7230,7 +7229,7 @@ var RebuyWidget = (props) => {
|
|
7230
7229
|
customTitle,
|
7231
7230
|
customTitleLevel,
|
7232
7231
|
customTitleStyle,
|
7233
|
-
isHydrogenReact,
|
7232
|
+
isHydrogenReact: rebuyGeneralContext?.contextParameters?.isHydrogenReact,
|
7234
7233
|
isInPopup: true,
|
7235
7234
|
onDismiss: closePopup,
|
7236
7235
|
products,
|
@@ -7245,7 +7244,7 @@ var RebuyWidget = (props) => {
|
|
7245
7244
|
customTitleLevel,
|
7246
7245
|
customTitleStyle,
|
7247
7246
|
isCrossSell,
|
7248
|
-
isHydrogenReact,
|
7247
|
+
isHydrogenReact: rebuyGeneralContext?.contextParameters?.isHydrogenReact,
|
7249
7248
|
isInPopup: settings?.display_type === "popup",
|
7250
7249
|
products,
|
7251
7250
|
settings
|
@@ -8860,11 +8859,33 @@ var RebuySmartCart = () => {
|
|
8860
8859
|
import { RebuyClient as RebuyClient3 } from "@rebuy/rebuy";
|
8861
8860
|
import * as Utilities5 from "@rebuy/rebuy/utilities";
|
8862
8861
|
import { flattenConnection as flattenConnection4 } from "@shopify/hydrogen";
|
8863
|
-
import
|
8862
|
+
import { useContext as useContext5, useEffect as useEffect22, useMemo as useMemo21, useState as useState21 } from "react";
|
8863
|
+
|
8864
|
+
// src/context/RebuyWidgetContext.tsx
|
8865
|
+
import { createContext as createContext4, useContext as useContext4 } from "react";
|
8866
|
+
import { jsx as jsx43 } from "react/jsx-runtime";
|
8867
|
+
var RebuyWidgetContext = createContext4({
|
8868
|
+
dataSource: "",
|
8869
|
+
isHydrogenReact: false,
|
8870
|
+
key: "",
|
8871
|
+
limit: 0,
|
8872
|
+
metadata: {},
|
8873
|
+
options: {},
|
8874
|
+
products: [],
|
8875
|
+
variant: void 0,
|
8876
|
+
variantId: void 0
|
8877
|
+
});
|
8878
|
+
var useRebuyWidget = () => useContext4(RebuyWidgetContext);
|
8879
|
+
var RebuyWidgetProvider = ({ children, value }) => {
|
8880
|
+
return /* @__PURE__ */ jsx43(RebuyWidgetContext.Provider, { value, children });
|
8881
|
+
};
|
8882
|
+
|
8883
|
+
// src/widgetContainer/RebuyWidgetContainer.tsx
|
8884
|
+
import { jsx as jsx44 } from "react/jsx-runtime";
|
8864
8885
|
var RebuyWidgetContainerBase = ({ children, ...props }) => {
|
8865
8886
|
const { collection, collectionId, dataSource, limit, options, product, productId, variant, variantId } = props;
|
8866
8887
|
const { apiKey, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
|
8867
|
-
const rebuyContext =
|
8888
|
+
const rebuyContext = useContext5(RebuyContext);
|
8868
8889
|
const [rebuyApiClient, setRebuyApiClient] = useState21(null);
|
8869
8890
|
const [initialized, setInitialized] = useState21(false);
|
8870
8891
|
const shopifyProductId = product?.id ?? productId ?? null;
|
@@ -8947,23 +8968,30 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
|
|
8947
8968
|
isMounted = false;
|
8948
8969
|
};
|
8949
8970
|
}, [rebuyApiClient, initialized, request, configLoadingStatus]);
|
8950
|
-
const childrenWithProps = (currentProps) => React12.Children.map(
|
8951
|
-
children,
|
8952
|
-
(child) => React12.isValidElement(child) ? React12.cloneElement(child, currentProps) : child
|
8953
|
-
);
|
8954
|
-
const childProps = {
|
8955
|
-
...props,
|
8956
|
-
apiKey,
|
8957
|
-
cacheKey: rebuyConfig?.shop?.cache_key,
|
8958
|
-
isHydrogenReact: rebuyContext?.contextParameters?.isHydrogenReact,
|
8959
|
-
key: product?.id,
|
8960
|
-
metadata,
|
8961
|
-
products
|
8962
|
-
};
|
8963
8971
|
if (configLoadingStatus !== "success" || !rebuyApiClient) {
|
8964
8972
|
return null;
|
8965
8973
|
}
|
8966
|
-
return
|
8974
|
+
return /* @__PURE__ */ jsx44(
|
8975
|
+
RebuyWidgetProvider,
|
8976
|
+
{
|
8977
|
+
value: {
|
8978
|
+
apiKey: apiKey ?? void 0,
|
8979
|
+
cacheKey: rebuyConfig?.shop?.cache_key,
|
8980
|
+
dataSource: dataSource || "/api/v1/products/recommended",
|
8981
|
+
isHydrogenReact: rebuyContext?.contextParameters?.isHydrogenReact || false,
|
8982
|
+
key: product?.id || "",
|
8983
|
+
limit: limit || 0,
|
8984
|
+
metadata: metadata || {},
|
8985
|
+
options: options || {},
|
8986
|
+
product,
|
8987
|
+
productId,
|
8988
|
+
products,
|
8989
|
+
variant,
|
8990
|
+
variantId
|
8991
|
+
},
|
8992
|
+
children
|
8993
|
+
}
|
8994
|
+
);
|
8967
8995
|
};
|
8968
8996
|
var RebuyWidgetContainer = RebuyWidgetContainerBase;
|
8969
8997
|
|
@@ -8972,32 +9000,33 @@ var result23 = { "container": "RebuyCompleteTheLook_container", "productGrid": "
|
|
8972
9000
|
var RebuyCompleteTheLook_default = result23;
|
8973
9001
|
|
8974
9002
|
// src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.tsx
|
8975
|
-
import { jsx as
|
9003
|
+
import { jsx as jsx45, jsxs as jsxs25 } from "react/jsx-runtime";
|
8976
9004
|
var RebuyCompleteTheLook = (props) => {
|
8977
9005
|
const {
|
8978
9006
|
addToCartBtnText = "Add to cart",
|
8979
9007
|
addToCartCallback,
|
8980
|
-
customTitle = `These pair with
|
9008
|
+
customTitle = `These pair with {product_title}`,
|
8981
9009
|
customTitleLevel = "h2",
|
8982
|
-
customTitleStyle
|
8983
|
-
products = []
|
9010
|
+
customTitleStyle
|
8984
9011
|
} = props;
|
9012
|
+
const { isHydrogenReact, product, products } = useRebuyWidget();
|
9013
|
+
const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
|
8985
9014
|
if (products.length === 0) {
|
8986
9015
|
rebuyDebugLog.log("widget-complete-the-look" /* WIDGET_COMPLETE_THE_LOOK */, "RebuyCompleteTheLook: No products found");
|
8987
9016
|
return null;
|
8988
9017
|
}
|
8989
9018
|
return /* @__PURE__ */ jsxs25("section", { className: RebuyCompleteTheLook_default.container, children: [
|
8990
|
-
/* @__PURE__ */
|
8991
|
-
/* @__PURE__ */
|
9019
|
+
/* @__PURE__ */ jsx45(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
|
9020
|
+
/* @__PURE__ */ jsx45("ul", { className: RebuyCompleteTheLook_default.productGrid, children: products.map((product2) => /* @__PURE__ */ jsx45("li", { className: RebuyCompleteTheLook_default.productItem, children: /* @__PURE__ */ jsx45(
|
8992
9021
|
ProductCard,
|
8993
9022
|
{
|
8994
9023
|
addToCartBtnText,
|
8995
9024
|
addToCartCallback,
|
8996
|
-
isHydrogenReact
|
8997
|
-
product,
|
9025
|
+
isHydrogenReact,
|
9026
|
+
product: product2,
|
8998
9027
|
productCardTitleLevel: getTitleLevel(customTitleLevel, true)
|
8999
9028
|
}
|
9000
|
-
) },
|
9029
|
+
) }, product2.id)) })
|
9001
9030
|
] });
|
9002
9031
|
};
|
9003
9032
|
|
@@ -9261,12 +9290,12 @@ var result24 = { "container": "RebuyDynamicBundleProducts_container", "addCartBt
|
|
9261
9290
|
var RebuyDynamicBundleProducts_default = result24;
|
9262
9291
|
|
9263
9292
|
// src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx
|
9264
|
-
import { Fragment as Fragment12, jsx as
|
9293
|
+
import { Fragment as Fragment12, jsx as jsx46, jsxs as jsxs26 } from "react/jsx-runtime";
|
9265
9294
|
var BundleImages = ({ products }) => {
|
9266
9295
|
const selected = products.filter((product) => product.selected);
|
9267
|
-
return /* @__PURE__ */
|
9296
|
+
return /* @__PURE__ */ jsx46("ul", { className: RebuyDynamicBundleProducts_default.bundleImages, children: products.map((product, index) => {
|
9268
9297
|
const image = product.selectedVariant?.image;
|
9269
|
-
const productImage = image ? /* @__PURE__ */
|
9298
|
+
const productImage = image ? /* @__PURE__ */ jsx46(
|
9270
9299
|
Image2,
|
9271
9300
|
{
|
9272
9301
|
alt: image.altText || `Picture of ${product.title}`,
|
@@ -9281,14 +9310,14 @@ var BundleImages = ({ products }) => {
|
|
9281
9310
|
product.title
|
9282
9311
|
);
|
9283
9312
|
const showDelimiter = selected[0]?.id !== product.id;
|
9284
|
-
return /* @__PURE__ */
|
9285
|
-
showDelimiter && /* @__PURE__ */
|
9286
|
-
/* @__PURE__ */
|
9313
|
+
return /* @__PURE__ */ jsx46(Fragment11, { children: product.selected && /* @__PURE__ */ jsxs26(Fragment12, { children: [
|
9314
|
+
showDelimiter && /* @__PURE__ */ jsx46("li", { className: RebuyDynamicBundleProducts_default.bundleImageDelimiter, children: /* @__PURE__ */ jsx46("span", { children: "+" }) }),
|
9315
|
+
/* @__PURE__ */ jsx46("li", { className: "flex items-center", children: product.default ? (
|
9287
9316
|
// Already on product page
|
9288
9317
|
productImage
|
9289
9318
|
) : (
|
9290
9319
|
// Link to product
|
9291
|
-
/* @__PURE__ */
|
9320
|
+
/* @__PURE__ */ jsx46(
|
9292
9321
|
RebuyLink,
|
9293
9322
|
{
|
9294
9323
|
ariaLabel: `View ${product.title}`,
|
@@ -9303,7 +9332,7 @@ var BundleImages = ({ products }) => {
|
|
9303
9332
|
|
9304
9333
|
// src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx
|
9305
9334
|
import { Money as Money4 } from "@shopify/hydrogen";
|
9306
|
-
import { jsx as
|
9335
|
+
import { jsx as jsx47, jsxs as jsxs27 } from "react/jsx-runtime";
|
9307
9336
|
var BundlePrice = ({ products }) => {
|
9308
9337
|
const isDisabled = products.filter((product) => product.selected).length < 1;
|
9309
9338
|
const totalBundlePrice = () => {
|
@@ -9340,12 +9369,12 @@ var BundlePrice = ({ products }) => {
|
|
9340
9369
|
const price = totalBundlePrice();
|
9341
9370
|
const compareAtPrice = totalBundleCompareAtPrice();
|
9342
9371
|
const CompareAtPrice = ({ data: compareAtPrice2 }) => {
|
9343
|
-
return compareAtPrice2 && /* @__PURE__ */
|
9372
|
+
return compareAtPrice2 && /* @__PURE__ */ jsx47(Money4, { as: "span", className: RebuyDynamicBundleProducts_default.compareAtPrice, data: compareAtPrice2, withoutTrailingZeros: true });
|
9344
9373
|
};
|
9345
|
-
return products.length > 0 && /* @__PURE__ */
|
9346
|
-
/* @__PURE__ */
|
9347
|
-
/* @__PURE__ */
|
9348
|
-
isDiscounted(price, compareAtPrice) && /* @__PURE__ */
|
9374
|
+
return products.length > 0 && /* @__PURE__ */ jsx47("div", { className: "flex items-center flex-col", children: !isDisabled && /* @__PURE__ */ jsxs27("p", { className: "flex items-center gap-2 mb-2", children: [
|
9375
|
+
/* @__PURE__ */ jsx47("span", { children: "Total Price:" }),
|
9376
|
+
/* @__PURE__ */ jsx47(Money4, { as: "span", data: price, withoutTrailingZeros: true }),
|
9377
|
+
isDiscounted(price, compareAtPrice) && /* @__PURE__ */ jsx47(CompareAtPrice, { data: compareAtPrice })
|
9349
9378
|
] }) });
|
9350
9379
|
};
|
9351
9380
|
|
@@ -9353,7 +9382,7 @@ var BundlePrice = ({ products }) => {
|
|
9353
9382
|
import clsx14 from "clsx";
|
9354
9383
|
|
9355
9384
|
// src/widgets/RebuyDynamicBundleProducts/Select.tsx
|
9356
|
-
import { jsx as
|
9385
|
+
import { jsx as jsx48 } from "react/jsx-runtime";
|
9357
9386
|
var Select = ({ onSelectVariant, product }) => {
|
9358
9387
|
const getOptionsLabel = (product2) => {
|
9359
9388
|
const options = product2.variants.nodes[0].selectedOptions;
|
@@ -9362,30 +9391,30 @@ var Select = ({ onSelectVariant, product }) => {
|
|
9362
9391
|
const useValues = optionsFromKeys.every((key) => ["name", "value"].includes(key));
|
9363
9392
|
return (useValues ? optionsFromValues : optionsFromKeys).join(" / ");
|
9364
9393
|
};
|
9365
|
-
return product && /* @__PURE__ */
|
9394
|
+
return product && /* @__PURE__ */ jsx48(
|
9366
9395
|
"select",
|
9367
9396
|
{
|
9368
9397
|
"aria-label": "select variant",
|
9369
9398
|
className: RebuyDynamicBundleProducts_default.select,
|
9370
9399
|
onChange: (e) => onSelectVariant(product, e.target.value),
|
9371
9400
|
value: product.selectedVariant.id,
|
9372
|
-
children: /* @__PURE__ */
|
9401
|
+
children: /* @__PURE__ */ jsx48("optgroup", { label: getOptionsLabel(product), children: product.variants.nodes.map(({ id, title }) => /* @__PURE__ */ jsx48("option", { value: id, children: title }, id + "-BundleVariant")) })
|
9373
9402
|
}
|
9374
9403
|
);
|
9375
9404
|
};
|
9376
9405
|
|
9377
9406
|
// src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx
|
9378
|
-
import { jsx as
|
9407
|
+
import { jsx as jsx49, jsxs as jsxs28 } from "react/jsx-runtime";
|
9379
9408
|
var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
|
9380
|
-
return /* @__PURE__ */
|
9409
|
+
return /* @__PURE__ */ jsx49("ul", { children: products.map((product, index) => {
|
9381
9410
|
const { availableForSale } = product.selectedVariant;
|
9382
9411
|
const isOutOfStock = !availableForSale;
|
9383
|
-
return /* @__PURE__ */
|
9412
|
+
return /* @__PURE__ */ jsx49(
|
9384
9413
|
"li",
|
9385
9414
|
{
|
9386
9415
|
className: clsx14(RebuyDynamicBundleProducts_default.bundleItemRowContainer, !product.selected && RebuyDynamicBundleProducts_default.unselected),
|
9387
9416
|
children: /* @__PURE__ */ jsxs28("div", { className: RebuyDynamicBundleProducts_default.bundleItemRow, children: [
|
9388
|
-
/* @__PURE__ */
|
9417
|
+
/* @__PURE__ */ jsx49(
|
9389
9418
|
"input",
|
9390
9419
|
{
|
9391
9420
|
checked: product.selected && availableForSale,
|
@@ -9399,12 +9428,12 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
|
|
9399
9428
|
),
|
9400
9429
|
/* @__PURE__ */ jsxs28("div", { className: RebuyDynamicBundleProducts_default.bundleItemInput, children: [
|
9401
9430
|
/* @__PURE__ */ jsxs28("label", { className: RebuyDynamicBundleProducts_default.bundleItemLabel, htmlFor: `${product.id}-toggle`, children: [
|
9402
|
-
isOutOfStock && /* @__PURE__ */
|
9403
|
-
product.default && /* @__PURE__ */
|
9431
|
+
isOutOfStock && /* @__PURE__ */ jsx49("b", { children: "SOLD OUT" }),
|
9432
|
+
product.default && /* @__PURE__ */ jsx49("b", { children: "This item:" }),
|
9404
9433
|
product.title,
|
9405
|
-
/* @__PURE__ */
|
9434
|
+
/* @__PURE__ */ jsx49(RebuyProductPrice, { selectedVariant: product.selectedVariant })
|
9406
9435
|
] }),
|
9407
|
-
product.variants.nodes.length > 1 && /* @__PURE__ */
|
9436
|
+
product.variants.nodes.length > 1 && /* @__PURE__ */ jsx49(Select, { onSelectVariant, product })
|
9408
9437
|
] })
|
9409
9438
|
] })
|
9410
9439
|
},
|
@@ -9414,18 +9443,17 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
|
|
9414
9443
|
};
|
9415
9444
|
|
9416
9445
|
// src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
|
9417
|
-
import { jsx as
|
9446
|
+
import { jsx as jsx50, jsxs as jsxs29 } from "react/jsx-runtime";
|
9418
9447
|
var RebuyDynamicBundleProducts = (props) => {
|
9419
9448
|
const {
|
9420
9449
|
addToCartBtnText = "Add to cart",
|
9421
9450
|
addToCartCallback,
|
9422
|
-
customTitle = `These pair with
|
9451
|
+
customTitle = `These pair with {product_title}`,
|
9423
9452
|
customTitleLevel = "h2",
|
9424
|
-
customTitleStyle
|
9425
|
-
isHydrogenReact,
|
9426
|
-
product,
|
9427
|
-
products = []
|
9453
|
+
customTitleStyle
|
9428
9454
|
} = props;
|
9455
|
+
const { isHydrogenReact, product, products } = useRebuyWidget();
|
9456
|
+
const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
|
9429
9457
|
const [bundleProducts, setBundleProducts] = useState22([]);
|
9430
9458
|
useEffect23(() => {
|
9431
9459
|
const mainProduct = convertToRebuyProduct(isHydrogenReact || false, product);
|
@@ -9461,11 +9489,11 @@ var RebuyDynamicBundleProducts = (props) => {
|
|
9461
9489
|
return null;
|
9462
9490
|
}
|
9463
9491
|
return /* @__PURE__ */ jsxs29("section", { className: RebuyDynamicBundleProducts_default.container, children: [
|
9464
|
-
/* @__PURE__ */
|
9492
|
+
/* @__PURE__ */ jsx50(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
|
9465
9493
|
/* @__PURE__ */ jsxs29("div", { className: RebuyDynamicBundleProducts_default.bundleContainer, children: [
|
9466
|
-
/* @__PURE__ */
|
9467
|
-
/* @__PURE__ */
|
9468
|
-
/* @__PURE__ */
|
9494
|
+
/* @__PURE__ */ jsx50(BundleImages, { products: bundleProducts }),
|
9495
|
+
/* @__PURE__ */ jsx50(BundlePrice, { products: bundleProducts }),
|
9496
|
+
/* @__PURE__ */ jsx50("div", { className: RebuyDynamicBundleProducts_default.addCartBtnContainer, children: /* @__PURE__ */ jsx50(
|
9469
9497
|
AddToCartBtn,
|
9470
9498
|
{
|
9471
9499
|
addToCartBtnText,
|
@@ -9477,7 +9505,7 @@ var RebuyDynamicBundleProducts = (props) => {
|
|
9477
9505
|
})
|
9478
9506
|
}
|
9479
9507
|
) }),
|
9480
|
-
/* @__PURE__ */
|
9508
|
+
/* @__PURE__ */ jsx50(
|
9481
9509
|
BundleSelection,
|
9482
9510
|
{
|
9483
9511
|
onSelectVariant,
|
@@ -9501,7 +9529,7 @@ var result25 = { "container": "RebuyProductAddOns_container", "productAddOnsList
|
|
9501
9529
|
var RebuyProductAddOns_default = result25;
|
9502
9530
|
|
9503
9531
|
// src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx
|
9504
|
-
import { jsx as
|
9532
|
+
import { jsx as jsx51, jsxs as jsxs30 } from "react/jsx-runtime";
|
9505
9533
|
var RebuyProductAddOnCard = ({
|
9506
9534
|
handleChange,
|
9507
9535
|
learnMoreText,
|
@@ -9510,8 +9538,8 @@ var RebuyProductAddOnCard = ({
|
|
9510
9538
|
titleLevel
|
9511
9539
|
}) => {
|
9512
9540
|
const { availableForSale, image } = product.selectedVariant || {};
|
9513
|
-
return /* @__PURE__ */
|
9514
|
-
/* @__PURE__ */
|
9541
|
+
return /* @__PURE__ */ jsx51("label", { className: RebuyProductAddOns_default.addOnCard, htmlFor: product.id, children: /* @__PURE__ */ jsxs30("div", { className: RebuyProductAddOns_default.addOnCardContent, children: [
|
9542
|
+
/* @__PURE__ */ jsx51(
|
9515
9543
|
"input",
|
9516
9544
|
{
|
9517
9545
|
checked: Boolean(product.selected),
|
@@ -9524,7 +9552,7 @@ var RebuyProductAddOnCard = ({
|
|
9524
9552
|
value: ""
|
9525
9553
|
}
|
9526
9554
|
),
|
9527
|
-
/* @__PURE__ */
|
9555
|
+
/* @__PURE__ */ jsx51("div", { className: RebuyProductAddOns_default.addOnCardContentImage, children: image && /* @__PURE__ */ jsx51(
|
9528
9556
|
Image3,
|
9529
9557
|
{
|
9530
9558
|
alt: image.altText || `Picture of ${product.title}`,
|
@@ -9534,10 +9562,10 @@ var RebuyProductAddOnCard = ({
|
|
9534
9562
|
}
|
9535
9563
|
) }),
|
9536
9564
|
/* @__PURE__ */ jsxs30("div", { className: RebuyProductAddOns_default.addOnCardTextContent, children: [
|
9537
|
-
!availableForSale && /* @__PURE__ */
|
9538
|
-
/* @__PURE__ */
|
9539
|
-
/* @__PURE__ */
|
9540
|
-
/* @__PURE__ */
|
9565
|
+
!availableForSale && /* @__PURE__ */ jsx51("p", { className: RebuyProductAddOns_default.addOnCardOutOfStock, children: outOfStockText }),
|
9566
|
+
/* @__PURE__ */ jsx51(Title, { level: titleLevel, text: product.title }),
|
9567
|
+
/* @__PURE__ */ jsx51(RebuyProductPrice, { selectedVariant: product.selectedVariant }),
|
9568
|
+
/* @__PURE__ */ jsx51(
|
9541
9569
|
RebuyLink,
|
9542
9570
|
{
|
9543
9571
|
ariaLabel: `View ${product.title}`,
|
@@ -9551,23 +9579,23 @@ var RebuyProductAddOnCard = ({
|
|
9551
9579
|
};
|
9552
9580
|
|
9553
9581
|
// src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx
|
9554
|
-
import { jsx as
|
9582
|
+
import { jsx as jsx52, jsxs as jsxs31 } from "react/jsx-runtime";
|
9555
9583
|
var RebuyProductAddOns = (props) => {
|
9556
9584
|
const {
|
9585
|
+
addToCartBtnText = "Add to cart",
|
9557
9586
|
addToCartCallback,
|
9558
|
-
customTitle = `These pair with
|
9587
|
+
customTitle = `These pair with {product_title}`,
|
9559
9588
|
customTitleLevel = "h2",
|
9560
9589
|
customTitleStyle,
|
9561
9590
|
includeMainProduct = false,
|
9562
|
-
isHydrogenReact,
|
9563
9591
|
learnMoreText = "Learn more",
|
9564
9592
|
outOfStockText = "Out of stock",
|
9565
|
-
product,
|
9566
|
-
products = [],
|
9567
|
-
addToCartBtnText = "Add to cart",
|
9568
9593
|
subtotalText = "Add-ons Subtotal: ",
|
9569
|
-
withProductText = `With
|
9594
|
+
withProductText = `With {product_title}: `
|
9570
9595
|
} = props;
|
9596
|
+
const { isHydrogenReact, product, products } = useRebuyWidget();
|
9597
|
+
const productTitleClean = customTitle.replace("{product_title}", product?.title ?? "");
|
9598
|
+
const withProductTextClean = withProductText.replace("{product_title}", product?.title ?? "");
|
9571
9599
|
const [addedItems, setAddedItems] = useState23(products);
|
9572
9600
|
const [subtotalWithProduct, setSubtotalWithProduct] = useState23();
|
9573
9601
|
const [subtotalWithOutProduct, setSubtotalWithOutProduct] = useState23();
|
@@ -9648,8 +9676,8 @@ var RebuyProductAddOns = (props) => {
|
|
9648
9676
|
return null;
|
9649
9677
|
}
|
9650
9678
|
return /* @__PURE__ */ jsxs31("div", { className: RebuyProductAddOns_default.container, children: [
|
9651
|
-
/* @__PURE__ */
|
9652
|
-
/* @__PURE__ */
|
9679
|
+
/* @__PURE__ */ jsx52(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitleClean }),
|
9680
|
+
/* @__PURE__ */ jsx52("ul", { className: RebuyProductAddOns_default.productAddOnsList, children: products.map((product2) => /* @__PURE__ */ jsx52("li", { children: /* @__PURE__ */ jsx52(
|
9653
9681
|
RebuyProductAddOnCard,
|
9654
9682
|
{
|
9655
9683
|
handleChange,
|
@@ -9662,13 +9690,13 @@ var RebuyProductAddOns = (props) => {
|
|
9662
9690
|
/* @__PURE__ */ jsxs31("div", { className: RebuyProductAddOns_default.productAddOnsFooter, children: [
|
9663
9691
|
/* @__PURE__ */ jsxs31("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
|
9664
9692
|
subtotalText,
|
9665
|
-
subtotalWithOutProduct && /* @__PURE__ */
|
9693
|
+
subtotalWithOutProduct && /* @__PURE__ */ jsx52(Money5, { data: subtotalWithOutProduct, withoutTrailingZeros: true })
|
9666
9694
|
] }),
|
9667
9695
|
includeMainProduct && /* @__PURE__ */ jsxs31("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
|
9668
|
-
|
9669
|
-
subtotalWithProduct && /* @__PURE__ */
|
9696
|
+
withProductTextClean,
|
9697
|
+
subtotalWithProduct && /* @__PURE__ */ jsx52(Money5, { data: subtotalWithProduct, withoutTrailingZeros: true })
|
9670
9698
|
] }),
|
9671
|
-
/* @__PURE__ */
|
9699
|
+
/* @__PURE__ */ jsx52("div", { className: RebuyProductAddOns_default.addCartBtnContainer, children: includeMainProduct ? /* @__PURE__ */ jsx52(
|
9672
9700
|
AddToCartBtn,
|
9673
9701
|
{
|
9674
9702
|
addToCartBtnText,
|
@@ -9678,7 +9706,7 @@ var RebuyProductAddOns = (props) => {
|
|
9678
9706
|
moneyData: subtotalWithProduct,
|
9679
9707
|
selectedVariants: addedItems.map((item) => item.selectedVariant)
|
9680
9708
|
}
|
9681
|
-
) : /* @__PURE__ */
|
9709
|
+
) : /* @__PURE__ */ jsx52(
|
9682
9710
|
AddToCartBtn,
|
9683
9711
|
{
|
9684
9712
|
addToCartBtnText,
|
@@ -9698,32 +9726,33 @@ var result26 = { "container": "RebuyProductRecommendations_container", "productG
|
|
9698
9726
|
var RebuyProductRecommendations_default = result26;
|
9699
9727
|
|
9700
9728
|
// src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.tsx
|
9701
|
-
import { jsx as
|
9729
|
+
import { jsx as jsx53, jsxs as jsxs32 } from "react/jsx-runtime";
|
9702
9730
|
var RebuyProductRecommendations = (props) => {
|
9703
9731
|
const {
|
9704
9732
|
addToCartBtnText = "Add to cart",
|
9705
9733
|
addToCartCallback,
|
9706
|
-
customTitle = `These pair with
|
9734
|
+
customTitle = `These pair with {product_title}`,
|
9707
9735
|
customTitleLevel = "h2",
|
9708
|
-
customTitleStyle
|
9709
|
-
products = []
|
9736
|
+
customTitleStyle
|
9710
9737
|
} = props;
|
9738
|
+
const { isHydrogenReact, product, products } = useRebuyWidget();
|
9739
|
+
const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
|
9711
9740
|
if (products.length === 0) {
|
9712
9741
|
rebuyDebugLog.log("widget-product-recommendations" /* WIDGET_PRODUCT_RECOMMENDATIONS */, "RebuyProductRecommendations: No products found");
|
9713
9742
|
return null;
|
9714
9743
|
}
|
9715
9744
|
return /* @__PURE__ */ jsxs32("section", { className: RebuyProductRecommendations_default.container, children: [
|
9716
|
-
/* @__PURE__ */
|
9717
|
-
/* @__PURE__ */
|
9745
|
+
/* @__PURE__ */ jsx53(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
|
9746
|
+
/* @__PURE__ */ jsx53("ul", { className: RebuyProductRecommendations_default.productGrid, children: products.map((product2) => /* @__PURE__ */ jsx53("li", { children: /* @__PURE__ */ jsx53(
|
9718
9747
|
ProductCard,
|
9719
9748
|
{
|
9720
9749
|
addToCartBtnText,
|
9721
9750
|
addToCartCallback,
|
9722
|
-
isHydrogenReact
|
9723
|
-
product,
|
9751
|
+
isHydrogenReact,
|
9752
|
+
product: product2,
|
9724
9753
|
productCardTitleLevel: getTitleLevel(customTitleLevel, true)
|
9725
9754
|
}
|
9726
|
-
) },
|
9755
|
+
) }, product2.id)) })
|
9727
9756
|
] });
|
9728
9757
|
};
|
9729
9758
|
|
@@ -9800,14 +9829,14 @@ var RebuyProductViewed = ({ ...props }) => {
|
|
9800
9829
|
// src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.tsx
|
9801
9830
|
import { RebuyClient as RebuyClient5 } from "@rebuy/rebuy";
|
9802
9831
|
import { flattenConnection as flattenConnection5 } from "@shopify/hydrogen";
|
9803
|
-
import { useContext as
|
9832
|
+
import { useContext as useContext6, useEffect as useEffect26, useMemo as useMemo23, useState as useState25 } from "react";
|
9804
9833
|
|
9805
9834
|
// src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.module.css
|
9806
9835
|
var result27 = { "rebuy-recently-viewed-products-container": "RebuyRecentlyViewedProducts_rebuy-recently-viewed-products-container", "product-grid": "RebuyRecentlyViewedProducts_product-grid" };
|
9807
9836
|
var RebuyRecentlyViewedProducts_default = result27;
|
9808
9837
|
|
9809
9838
|
// src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.tsx
|
9810
|
-
import { jsx as
|
9839
|
+
import { jsx as jsx54, jsxs as jsxs33 } from "react/jsx-runtime";
|
9811
9840
|
var RebuyRecentlyViewedProducts = (props) => {
|
9812
9841
|
const {
|
9813
9842
|
addToCartBtnText = "Add to cart",
|
@@ -9821,7 +9850,7 @@ var RebuyRecentlyViewedProducts = (props) => {
|
|
9821
9850
|
} = props;
|
9822
9851
|
const { customerId, uuid } = useProductViewedStore();
|
9823
9852
|
const { apiKey, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
|
9824
|
-
const rebuyContext =
|
9853
|
+
const rebuyContext = useContext6(RebuyContext);
|
9825
9854
|
const [rebuyApiClient, setRebuyApiClient] = useState25(null);
|
9826
9855
|
const [initialized, setInitialized] = useState25(false);
|
9827
9856
|
const [products, setProducts] = useState25([]);
|
@@ -9897,8 +9926,8 @@ var RebuyRecentlyViewedProducts = (props) => {
|
|
9897
9926
|
return null;
|
9898
9927
|
}
|
9899
9928
|
return /* @__PURE__ */ jsxs33("div", { className: RebuyRecentlyViewedProducts_default["rebuy-recently-viewed-products-container"], children: [
|
9900
|
-
/* @__PURE__ */
|
9901
|
-
/* @__PURE__ */
|
9929
|
+
/* @__PURE__ */ jsx54(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
|
9930
|
+
/* @__PURE__ */ jsx54("ul", { className: RebuyRecentlyViewedProducts_default["product-grid"], children: products?.map((product) => /* @__PURE__ */ jsx54("li", { children: /* @__PURE__ */ jsx54(
|
9902
9931
|
ProductCard,
|
9903
9932
|
{
|
9904
9933
|
addToCartBtnText,
|