@rebuy/rebuy-hydrogen 3.0.0-beta.15 → 3.0.0-beta.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.
- package/README.md +165 -4
- package/dist/components/ProductCard/ProductCard.d.ts +1 -1
- package/dist/components/ProductCard/ProductCard.d.ts.map +1 -1
- package/dist/components/ProductCard/types.d.ts +1 -0
- package/dist/components/ProductCard/types.d.ts.map +1 -1
- package/dist/components/ProductCarousel/ProductCarousel.d.ts +2 -16
- package/dist/components/ProductCarousel/ProductCarousel.d.ts.map +1 -1
- package/dist/components/ProductCarousel/types.d.ts +18 -0
- package/dist/components/ProductCarousel/types.d.ts.map +1 -0
- package/dist/components/RebuyLink/RebuyLink.d.ts +3 -0
- package/dist/components/RebuyLink/RebuyLink.d.ts.map +1 -0
- package/dist/components/RebuyLink/index.d.ts +2 -0
- package/dist/components/RebuyLink/index.d.ts.map +1 -0
- package/dist/components/RebuyLink/types.d.ts +10 -0
- package/dist/components/RebuyLink/types.d.ts.map +1 -0
- package/dist/constants/debug.d.ts +2 -1
- package/dist/constants/debug.d.ts.map +1 -1
- package/dist/index.css +68 -39
- package/dist/index.css.map +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +838 -507
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +754 -423
- package/dist/index.mjs.map +4 -4
- package/dist/smart-cart/components/CartItem/CartItem.d.ts.map +1 -1
- package/dist/smart-cart/components/LoginButton/LoginButton.d.ts.map +1 -1
- package/dist/smart-cart/components/SmartCartContainer/SmartCartContainer.d.ts.map +1 -1
- package/dist/types/common.d.ts +7 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/rebuyCustom.d.ts +0 -1
- package/dist/types/rebuyCustom.d.ts.map +1 -1
- package/dist/types/shopify.d.ts +1 -2
- package/dist/types/shopify.d.ts.map +1 -1
- package/dist/utils/convertToRebuyProduct.d.ts.map +1 -1
- package/dist/widgetContainer/RebuyWidgetContainer.d.ts.map +1 -1
- package/dist/widgets/RebuyDynamicBundleProducts/BundleImages.d.ts.map +1 -1
- package/dist/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.d.ts.map +1 -1
- package/dist/widgets/RebuyProductAddOns/RebuyProductAddOnCard.d.ts.map +1 -1
- package/dist/widgets/RebuyProductAddOns/RebuyProductAddOns.d.ts.map +1 -1
- package/dist/widgets/RebuyProductViewed/RebuyProductViewed.d.ts +3 -0
- package/dist/widgets/RebuyProductViewed/RebuyProductViewed.d.ts.map +1 -0
- package/dist/widgets/RebuyProductViewed/index.d.ts +2 -0
- package/dist/widgets/RebuyProductViewed/index.d.ts.map +1 -0
- package/dist/widgets/RebuyProductViewed/types.d.ts +8 -0
- package/dist/widgets/RebuyProductViewed/types.d.ts.map +1 -0
- package/dist/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.d.ts +3 -0
- package/dist/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.d.ts.map +1 -0
- package/dist/widgets/RebuyRecentlyViewedProducts/index.d.ts +2 -0
- package/dist/widgets/RebuyRecentlyViewedProducts/index.d.ts.map +1 -0
- package/dist/widgets/RebuyRecentlyViewedProducts/types.d.ts +11 -0
- package/dist/widgets/RebuyRecentlyViewedProducts/types.d.ts.map +1 -0
- package/dist/widgets/RebuyWidget/RebuyWidget.d.ts.map +1 -1
- package/dist/widgets/RebuyWidget/WidgetContent.d.ts +1 -1
- package/dist/widgets/RebuyWidget/WidgetContent.d.ts.map +1 -1
- package/dist/widgets/RebuyWidget/types.d.ts +2 -0
- package/dist/widgets/RebuyWidget/types.d.ts.map +1 -1
- package/dist/zustandStores/productViewed.d.ts +9 -0
- package/dist/zustandStores/productViewed.d.ts.map +1 -0
- package/package.json +9 -4
package/dist/index.js
CHANGED
@@ -37,6 +37,8 @@ __export(index_exports, {
|
|
37
37
|
RebuyHydrogenReactContextProvider: () => RebuyHydrogenReactContextProvider,
|
38
38
|
RebuyProductAddOns: () => RebuyProductAddOns,
|
39
39
|
RebuyProductRecommendations: () => RebuyProductRecommendations,
|
40
|
+
RebuyProductViewed: () => RebuyProductViewed,
|
41
|
+
RebuyRecentlyViewedProducts: () => RebuyRecentlyViewedProducts,
|
40
42
|
RebuySmartCart: () => RebuySmartCart,
|
41
43
|
RebuyWidget: () => RebuyWidget,
|
42
44
|
RebuyWidgetContainer: () => RebuyWidgetContainer,
|
@@ -1269,7 +1271,7 @@ var useTieredProgressBarStore = (0, import_zustand.create)((set, get) => ({
|
|
1269
1271
|
if (idsToFetch.length > 0) {
|
1270
1272
|
const productGids = idsToFetch.map((id) => `gid://shopify/Product/${id}`);
|
1271
1273
|
const graphqlQuery = `query getProductsByIds($ids: [ID!]!) { nodes(ids: $ids) { ... on Product { id title handle tags images(first: 1) { edges { node { url altText } } } variants(first: 30) { edges { node { id title sku availableForSale price { amount currencyCode } compareAtPrice { amount currencyCode } selectedOptions { name value } image { url altText } } } } } } }`;
|
1272
|
-
const response = await fetch(`https://${_shopifyDomain}/api/
|
1274
|
+
const response = await fetch(`https://${_shopifyDomain}/api/2025-01/graphql.json`, {
|
1273
1275
|
body: JSON.stringify({ query: graphqlQuery, variables: { ids: productGids } }),
|
1274
1276
|
headers: {
|
1275
1277
|
"Content-Type": "application/json",
|
@@ -3572,7 +3574,7 @@ var RebuyHydrogenReactContextProvider = ({
|
|
3572
3574
|
publicStoreDomain,
|
3573
3575
|
publicStorefrontId,
|
3574
3576
|
publicStorefrontToken,
|
3575
|
-
storefrontApiVersion = "
|
3577
|
+
storefrontApiVersion = "2025-01"
|
3576
3578
|
}) => {
|
3577
3579
|
const adaptedCallbacks = (0, import_react5.useMemo)(
|
3578
3580
|
() => ({
|
@@ -3863,7 +3865,14 @@ AnnouncementBar.displayName = "AnnouncementBar";
|
|
3863
3865
|
// src/smart-cart/components/CartItem/CartItem.tsx
|
3864
3866
|
var import_clsx = __toESM(require("clsx"), 1);
|
3865
3867
|
var import_react8 = require("react");
|
3868
|
+
var import_react_router4 = require("react-router");
|
3869
|
+
|
3870
|
+
// src/components/RebuyLink/RebuyLink.tsx
|
3866
3871
|
var import_react_router3 = require("react-router");
|
3872
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
3873
|
+
var RebuyLink = ({ ariaLabel, children, className, handle, onClick, role = "link" }) => {
|
3874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_router3.Link, { "aria-label": ariaLabel, className, onClick, rel: "nofollow", role, to: handle, children });
|
3875
|
+
};
|
3867
3876
|
|
3868
3877
|
// src/smart-cart/hooks/useCartItemFeatures.ts
|
3869
3878
|
var import_react7 = require("react");
|
@@ -4283,17 +4292,18 @@ var result2 = { "rebuy-cart-item": "CartItem_rebuy-cart-item", "rebuy-cart-item_
|
|
4283
4292
|
var CartItem_default = result2;
|
4284
4293
|
|
4285
4294
|
// src/smart-cart/components/CartItem/CartItem.tsx
|
4286
|
-
var
|
4287
|
-
var Spinner = ({ className }) => /* @__PURE__ */ (0,
|
4295
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
4296
|
+
var Spinner = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: (0, import_clsx.default)(CartItem_default["rebuy-cart-item__spinner"], className) });
|
4288
4297
|
var CartItem = ({ line }) => {
|
4289
4298
|
const { config, isCartBusy, isHydrogenReact, removeItem, updateItem } = useSmartCart();
|
4290
|
-
const itemFetcher = (0,
|
4299
|
+
const itemFetcher = (0, import_react_router4.useFetcher)();
|
4291
4300
|
const [isIncreasing, setIsIncreasing] = (0, import_react8.useState)(false);
|
4292
4301
|
const [isDecreasing, setIsDecreasing] = (0, import_react8.useState)(false);
|
4293
4302
|
const [isRemoving, setIsRemoving] = (0, import_react8.useState)(false);
|
4294
4303
|
const [isAdjustingBMSM, setIsAdjustingBMSM] = (0, import_react8.useState)(false);
|
4295
4304
|
const [isSwitchingSubscription, setIsSwitchingSubscription] = (0, import_react8.useState)(false);
|
4296
4305
|
const [switchingDirection, setSwitchingDirection] = (0, import_react8.useState)(null);
|
4306
|
+
const { toggleCart } = useSmartCart();
|
4297
4307
|
const {
|
4298
4308
|
actions: itemActionsLogic,
|
4299
4309
|
bmsm,
|
@@ -4513,7 +4523,7 @@ var CartItem = ({ line }) => {
|
|
4513
4523
|
}
|
4514
4524
|
}, [isHydrogenReact, isCartBusy, itemFetcher.state, itemFetcher.data]);
|
4515
4525
|
const selectValue = line.sellingPlanAllocation?.sellingPlan.id ?? "onetime";
|
4516
|
-
return /* @__PURE__ */ (0,
|
4526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
4517
4527
|
"li",
|
4518
4528
|
{
|
4519
4529
|
"aria-label": meta.ariaLabel,
|
@@ -4521,21 +4531,34 @@ var CartItem = ({ line }) => {
|
|
4521
4531
|
"data-line-id": line.id,
|
4522
4532
|
"data-variant-id": line.merchandise.id,
|
4523
4533
|
children: [
|
4524
|
-
/* @__PURE__ */ (0,
|
4525
|
-
|
4526
|
-
|
4527
|
-
|
4534
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: CartItem_default["rebuy-cart-item__media"], children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
4535
|
+
RebuyLink,
|
4536
|
+
{
|
4537
|
+
ariaLabel: meta.linkLabel,
|
4538
|
+
handle: meta.itemUrl,
|
4539
|
+
onClick: () => {
|
4540
|
+
toggleCart();
|
4541
|
+
},
|
4542
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("img", { alt: meta.imageAltText, height: 120, loading: "lazy", src: meta.imageUrl, width: 120 })
|
4543
|
+
}
|
4544
|
+
) }),
|
4545
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: CartItem_default["rebuy-cart-item__info"], children: [
|
4546
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
4547
|
+
RebuyLink,
|
4528
4548
|
{
|
4529
|
-
|
4549
|
+
ariaLabel: meta.linkLabel,
|
4530
4550
|
className: CartItem_default["rebuy-cart-item__product-title"],
|
4531
|
-
|
4551
|
+
handle: meta.itemUrl,
|
4552
|
+
onClick: () => {
|
4553
|
+
toggleCart();
|
4554
|
+
},
|
4532
4555
|
role: "heading",
|
4533
4556
|
children: meta.productTitle
|
4534
4557
|
}
|
4535
4558
|
),
|
4536
|
-
meta.variantTitle && /* @__PURE__ */ (0,
|
4537
|
-
properties.hasVisibleProperties && /* @__PURE__ */ (0,
|
4538
|
-
properties.deliveryFrequency && /* @__PURE__ */ (0,
|
4559
|
+
meta.variantTitle && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: CartItem_default["rebuy-cart-item__variant-title"], children: meta.variantTitle }),
|
4560
|
+
properties.hasVisibleProperties && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: CartItem_default["rebuy-cart-item__properties-list"], children: [
|
4561
|
+
properties.deliveryFrequency && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
4539
4562
|
"div",
|
4540
4563
|
{
|
4541
4564
|
className: (0, import_clsx.default)(
|
@@ -4545,7 +4568,7 @@ var CartItem = ({ line }) => {
|
|
4545
4568
|
children: properties.deliveryFrequency
|
4546
4569
|
}
|
4547
4570
|
),
|
4548
|
-
properties.visibleProperties.map((prop, index) => /* @__PURE__ */ (0,
|
4571
|
+
properties.visibleProperties.map((prop, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
4549
4572
|
"div",
|
4550
4573
|
{
|
4551
4574
|
className: (0, import_clsx.default)(
|
@@ -4553,16 +4576,16 @@ var CartItem = ({ line }) => {
|
|
4553
4576
|
getItemPropertyKeyClass(prop),
|
4554
4577
|
getItemPropertyValueClass(prop)
|
4555
4578
|
),
|
4556
|
-
children: prop.key !== "_Discount" ? /* @__PURE__ */ (0,
|
4557
|
-
/* @__PURE__ */ (0,
|
4558
|
-
/* @__PURE__ */ (0,
|
4559
|
-
/* @__PURE__ */ (0,
|
4560
|
-
] }) : /* @__PURE__ */ (0,
|
4579
|
+
children: prop.key !== "_Discount" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
4580
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: CartItem_default["rebuy-cart-item__property-key"], children: prop.key }),
|
4581
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: CartItem_default["rebuy-cart-item__property-separator"], children: ": " }),
|
4582
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: CartItem_default["rebuy-cart-item__property-value"], children: prop.value })
|
4583
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: CartItem_default["rebuy-cart-item__property-value"], children: prop.value })
|
4561
4584
|
},
|
4562
4585
|
`${line.id}-prop-${index}`
|
4563
4586
|
))
|
4564
4587
|
] }),
|
4565
|
-
/* @__PURE__ */ (0,
|
4588
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
4566
4589
|
"button",
|
4567
4590
|
{
|
4568
4591
|
"aria-label": `Remove ${meta.productTitle}`,
|
@@ -4570,11 +4593,11 @@ var CartItem = ({ line }) => {
|
|
4570
4593
|
disabled: isLoadingCombined,
|
4571
4594
|
onClick: handleRemoveItem,
|
4572
4595
|
type: "button",
|
4573
|
-
children: isRemoving ? /* @__PURE__ */ (0,
|
4596
|
+
children: isRemoving ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Spinner, {}) : "\u2715"
|
4574
4597
|
}
|
4575
4598
|
),
|
4576
|
-
!shouldHideQuantitySelector && /* @__PURE__ */ (0,
|
4577
|
-
/* @__PURE__ */ (0,
|
4599
|
+
!shouldHideQuantitySelector && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: CartItem_default["rebuy-cart-item__quantity-selector-area"], children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: CartItem_default["rebuy-cart-item__quantity-selector"], children: [
|
4600
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
4578
4601
|
"button",
|
4579
4602
|
{
|
4580
4603
|
"aria-label": `Decrease quantity of ${meta.productTitle}`,
|
@@ -4582,17 +4605,17 @@ var CartItem = ({ line }) => {
|
|
4582
4605
|
disabled: isLoadingCombined,
|
4583
4606
|
onClick: handleDecreaseQuantity,
|
4584
4607
|
type: "button",
|
4585
|
-
children: isDecreasing ? /* @__PURE__ */ (0,
|
4608
|
+
children: isDecreasing ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Spinner, {}) : "-"
|
4586
4609
|
}
|
4587
4610
|
),
|
4588
|
-
/* @__PURE__ */ (0,
|
4589
|
-
/* @__PURE__ */ (0,
|
4611
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { "aria-live": "polite", className: CartItem_default["rebuy-cart-item__quantity-selector-label"], children: [
|
4612
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(ScreenReaderText, { children: [
|
4590
4613
|
"Quantity of ",
|
4591
4614
|
meta.productTitle
|
4592
4615
|
] }),
|
4593
4616
|
line.quantity
|
4594
4617
|
] }),
|
4595
|
-
/* @__PURE__ */ (0,
|
4618
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
4596
4619
|
"button",
|
4597
4620
|
{
|
4598
4621
|
"aria-label": `Increase quantity of ${meta.productTitle}`,
|
@@ -4600,12 +4623,12 @@ var CartItem = ({ line }) => {
|
|
4600
4623
|
disabled: isLoadingCombined,
|
4601
4624
|
onClick: handleIncreaseQuantity,
|
4602
4625
|
type: "button",
|
4603
|
-
children: isIncreasing ? /* @__PURE__ */ (0,
|
4626
|
+
children: isIncreasing ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Spinner, {}) : "+"
|
4604
4627
|
}
|
4605
4628
|
)
|
4606
4629
|
] }) }),
|
4607
|
-
/* @__PURE__ */ (0,
|
4608
|
-
/* @__PURE__ */ (0,
|
4630
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: CartItem_default["rebuy-cart-item__price-details"], children: pricing.hasDiscount && pricing.compareAtDisplayPrice ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
4631
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
4609
4632
|
"span",
|
4610
4633
|
{
|
4611
4634
|
"aria-label": "Sale price",
|
@@ -4614,12 +4637,12 @@ var CartItem = ({ line }) => {
|
|
4614
4637
|
CartItem_default["rebuy-cart-item__money--sale"]
|
4615
4638
|
),
|
4616
4639
|
children: [
|
4617
|
-
/* @__PURE__ */ (0,
|
4640
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ScreenReaderText, { children: "Sale price" }),
|
4618
4641
|
pricing.displayPrice
|
4619
4642
|
]
|
4620
4643
|
}
|
4621
4644
|
),
|
4622
|
-
/* @__PURE__ */ (0,
|
4645
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
4623
4646
|
"span",
|
4624
4647
|
{
|
4625
4648
|
"aria-label": "Original price",
|
@@ -4628,17 +4651,17 @@ var CartItem = ({ line }) => {
|
|
4628
4651
|
CartItem_default["rebuy-cart-item__money--compare-at"]
|
4629
4652
|
),
|
4630
4653
|
children: [
|
4631
|
-
/* @__PURE__ */ (0,
|
4654
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ScreenReaderText, { children: "Original price" }),
|
4632
4655
|
pricing.compareAtDisplayPrice
|
4633
4656
|
]
|
4634
4657
|
}
|
4635
4658
|
)
|
4636
|
-
] }) : /* @__PURE__ */ (0,
|
4637
|
-
/* @__PURE__ */ (0,
|
4659
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { "aria-label": "Price", className: CartItem_default["rebuy-cart-item__money"], children: [
|
4660
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ScreenReaderText, { children: "Price" }),
|
4638
4661
|
pricing.displayPrice
|
4639
4662
|
] }) }),
|
4640
|
-
bundle.isBundleParent && bundle.showToggle && /* @__PURE__ */ (0,
|
4641
|
-
bundle.itemCount > 0 && /* @__PURE__ */ (0,
|
4663
|
+
bundle.isBundleParent && bundle.showToggle && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: CartItem_default["rebuy-cart-item__bundle-section"], children: [
|
4664
|
+
bundle.itemCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
4642
4665
|
"button",
|
4643
4666
|
{
|
4644
4667
|
"aria-controls": `bundle-details-${line.id}`,
|
@@ -4654,11 +4677,11 @@ var CartItem = ({ line }) => {
|
|
4654
4677
|
bundle.itemCount,
|
4655
4678
|
" item",
|
4656
4679
|
bundle.itemCount !== 1 ? "s" : "",
|
4657
|
-
/* @__PURE__ */ (0,
|
4680
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "aria-hidden": "true", className: CartItem_default["rebuy-cart-item__bundle-chev-icon"], children: isBundleExpanded ? "\u25B2" : "\u25BC" })
|
4658
4681
|
]
|
4659
4682
|
}
|
4660
4683
|
),
|
4661
|
-
bundle.itemCount > 0 && isBundleExpanded && /* @__PURE__ */ (0,
|
4684
|
+
bundle.itemCount > 0 && isBundleExpanded && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
4662
4685
|
"ul",
|
4663
4686
|
{
|
4664
4687
|
className: CartItem_default["rebuy-cart-item__bundle-children-list"],
|
@@ -4672,12 +4695,12 @@ var CartItem = ({ line }) => {
|
|
4672
4695
|
optionData,
|
4673
4696
|
index
|
4674
4697
|
);
|
4675
|
-
return /* @__PURE__ */ (0,
|
4698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
4676
4699
|
"li",
|
4677
4700
|
{
|
4678
4701
|
className: CartItem_default["rebuy-cart-item__bundle-child-item"],
|
4679
4702
|
children: [
|
4680
|
-
/* @__PURE__ */ (0,
|
4703
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: CartItem_default["rebuy-cart-item__bundle-child-media-wrapper"], children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: CartItem_default["rebuy-cart-item__bundle-child-image-wrapper"], children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
4681
4704
|
"img",
|
4682
4705
|
{
|
4683
4706
|
alt: childTitle,
|
@@ -4686,7 +4709,7 @@ var CartItem = ({ line }) => {
|
|
4686
4709
|
src: sizeImage(childImage, "40x40")
|
4687
4710
|
}
|
4688
4711
|
) }) }),
|
4689
|
-
/* @__PURE__ */ (0,
|
4712
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: CartItem_default["rebuy-cart-item__bundle-child-details"], children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h5", { className: CartItem_default["rebuy-cart-item__bundle-child-title"], children: childTitle }) })
|
4690
4713
|
]
|
4691
4714
|
},
|
4692
4715
|
`${line.id}-bundle-child-${index}`
|
@@ -4697,18 +4720,18 @@ var CartItem = ({ line }) => {
|
|
4697
4720
|
] })
|
4698
4721
|
] }),
|
4699
4722
|
" ",
|
4700
|
-
bmsm.isEnabledAndApplicable && /* @__PURE__ */ (0,
|
4723
|
+
bmsm.isEnabledAndApplicable && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: CartItem_default["rebuy-cart-item__bmsm-section"], children: bmsm.isButtonMode ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: CartItem_default["rebuy-cart-item__bmsm-button-wrapper"], children: bmsm.nextApplicableTiers.map((tier) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
4701
4724
|
"button",
|
4702
4725
|
{
|
4703
4726
|
"aria-label": `${bmsm.getButtonText(tier)} for ${meta.productTitle}`,
|
4704
4727
|
className: CartItem_default["rebuy-cart-item__bmsm-button"],
|
4705
4728
|
disabled: isLoadingCombined,
|
4706
4729
|
onClick: () => handleAdjustBMSMQuantity(tier.quantity ?? 0),
|
4707
|
-
children: /* @__PURE__ */ (0,
|
4730
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: bmsm.getButtonText(tier) })
|
4708
4731
|
},
|
4709
4732
|
`bmsm-${line.id}-${tier.quantity}`
|
4710
|
-
)) }) : /* @__PURE__ */ (0,
|
4711
|
-
sts.isEnabledAndApplicable && /* @__PURE__ */ (0,
|
4733
|
+
)) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: CartItem_default["rebuy-cart-item__bmsm-dynamic-message"], children: bmsm.dynamicText }) }),
|
4734
|
+
sts.isEnabledAndApplicable && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: CartItem_default["rebuy-cart-item__sts-section"], children: !sts.isCurrentlySubscription && sts.availableFrequencies.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
4712
4735
|
"button",
|
4713
4736
|
{
|
4714
4737
|
"aria-label": `Switch ${meta.productTitle} to a Subscription`,
|
@@ -4716,9 +4739,9 @@ var CartItem = ({ line }) => {
|
|
4716
4739
|
disabled: isLoadingCombined,
|
4717
4740
|
onClick: handleUpgradeToSubscriptionClick,
|
4718
4741
|
type: "button",
|
4719
|
-
children: isSwitchingSubscription && switchingDirection === "upgrading" ? /* @__PURE__ */ (0,
|
4742
|
+
children: isSwitchingSubscription && switchingDirection === "upgrading" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Spinner, {}) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: sts.getUpgradeButtonLabel() })
|
4720
4743
|
}
|
4721
|
-
) : sts.isCurrentlySubscription || sts.canDowngrade ? /* @__PURE__ */ (0,
|
4744
|
+
) : sts.isCurrentlySubscription || sts.canDowngrade ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: isSwitchingSubscription ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: CartItem_default["rebuy-cart-item__sts-loading-replacement"], children: sts.getLoadingLabel(switchingDirection) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
4722
4745
|
"select",
|
4723
4746
|
{
|
4724
4747
|
"aria-label": `Subscription delivery frequency for ${meta.productTitle}`,
|
@@ -4727,8 +4750,8 @@ var CartItem = ({ line }) => {
|
|
4727
4750
|
onChange: handleSwitchSubscriptionChange,
|
4728
4751
|
value: selectValue,
|
4729
4752
|
children: [
|
4730
|
-
sts.canDowngrade && /* @__PURE__ */ (0,
|
4731
|
-
sts.availableFrequencies.length > 0 && /* @__PURE__ */ (0,
|
4753
|
+
sts.canDowngrade && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("optgroup", { label: sts.getOneTimeGroupLabel(), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "onetime", children: sts.getOneTimeLabel() }) }),
|
4754
|
+
sts.availableFrequencies.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("optgroup", { label: sts.getGroupLabel(), children: sts.availableFrequencies.map((freq) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: freq.id, children: sts.getOptionLabel(freq.id) }, freq.id)) })
|
4732
4755
|
]
|
4733
4756
|
}
|
4734
4757
|
) }) : null })
|
@@ -4742,11 +4765,11 @@ var result3 = { "rebuy-empty-cart-message": "EmptyCart_rebuy-empty-cart-message"
|
|
4742
4765
|
var EmptyCart_default = result3;
|
4743
4766
|
|
4744
4767
|
// src/smart-cart/components/EmptyCart/EmptyCart.tsx
|
4745
|
-
var
|
4768
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
4746
4769
|
var EmptyCart = () => {
|
4747
4770
|
const { config } = useSmartCart();
|
4748
4771
|
const emptyCartMarkup = config?.empty_cart_markup || "<p>Your cart is empty.</p>";
|
4749
|
-
return /* @__PURE__ */ (0,
|
4772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: EmptyCart_default["rebuy-empty-cart-message"], dangerouslySetInnerHTML: { __html: emptyCartMarkup } });
|
4750
4773
|
};
|
4751
4774
|
|
4752
4775
|
// src/smart-cart/components/CartItemList/CartItemList.module.css
|
@@ -4754,7 +4777,7 @@ var result4 = { "rebuy-cart-item-list__container": "CartItemList_rebuy-cart-item
|
|
4754
4777
|
var CartItemList_default = result4;
|
4755
4778
|
|
4756
4779
|
// src/smart-cart/components/CartItemList/CartItemList.tsx
|
4757
|
-
var
|
4780
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
4758
4781
|
var CartItemList = ({ componentConfig }) => {
|
4759
4782
|
const { cartData, isLoading: isCartLoading, isProgressBarLineItemMode } = useSmartCart();
|
4760
4783
|
const lines = cartData?.lines?.nodes ?? [];
|
@@ -4765,13 +4788,13 @@ var CartItemList = ({ componentConfig }) => {
|
|
4765
4788
|
return true;
|
4766
4789
|
});
|
4767
4790
|
const hasVisibleItems = visibleLines.length > 0;
|
4768
|
-
return /* @__PURE__ */ (0,
|
4791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
4769
4792
|
"div",
|
4770
4793
|
{
|
4771
4794
|
className: CartItemList_default["rebuy-cart-item-list__container"],
|
4772
4795
|
"data-rebuy-component": "cart-items",
|
4773
4796
|
"data-rebuy-component-id": componentConfig.component_id,
|
4774
|
-
children: hasVisibleItems ? /* @__PURE__ */ (0,
|
4797
|
+
children: hasVisibleItems ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", { className: CartItemList_default["rebuy-cart-item-list"], "data-smartcart-items": "", role: "group", tabIndex: 0, children: visibleLines.map((line) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CartItem, { line }, line.id)) }) : !isCartLoading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(EmptyCart, {})
|
4775
4798
|
}
|
4776
4799
|
);
|
4777
4800
|
};
|
@@ -4779,14 +4802,14 @@ var CartItemList = ({ componentConfig }) => {
|
|
4779
4802
|
// src/smart-cart/components/CartNoteInput/CartNoteInput.tsx
|
4780
4803
|
var import_clsx2 = __toESM(require("clsx"), 1);
|
4781
4804
|
var import_react9 = __toESM(require("react"), 1);
|
4782
|
-
var
|
4805
|
+
var import_react_router5 = require("react-router");
|
4783
4806
|
|
4784
4807
|
// src/smart-cart/components/CartNoteInput/CartNoteInput.module.css
|
4785
4808
|
var result5 = { "rebuy-cart-note-input": "CartNoteInput_rebuy-cart-note-input", "rebuy-cart-note-input__toggle-control": "CartNoteInput_rebuy-cart-note-input__toggle-control", "rebuy-cart-note-input__toggle-checkbox": "CartNoteInput_rebuy-cart-note-input__toggle-checkbox", "rebuy-cart-note-input__toggle-label": "CartNoteInput_rebuy-cart-note-input__toggle-label", "rebuy-cart-note-input__textarea-wrapper": "CartNoteInput_rebuy-cart-note-input__textarea-wrapper", "rebuy-cart-note-input__textarea": "CartNoteInput_rebuy-cart-note-input__textarea", "rebuy-cart-note-input__save-button": "CartNoteInput_rebuy-cart-note-input__save-button", "rebuy-cart-note-input__save-button--visible": "CartNoteInput_rebuy-cart-note-input__save-button--visible", "rebuy-cart-note-input__save-button--saving": "CartNoteInput_rebuy-cart-note-input__save-button--saving", "rebuy-cart-note-input__save-button--saved": "CartNoteInput_rebuy-cart-note-input__save-button--saved", "rebuy-cart-note-input__save-button--error": "CartNoteInput_rebuy-cart-note-input__save-button--error", "rebuy-cart-note-input__meta-info": "CartNoteInput_rebuy-cart-note-input__meta-info", "rebuy-cart-note-input__meta-info--hidden": "CartNoteInput_rebuy-cart-note-input__meta-info--hidden", "rebuy-cart-note-input__remaining-chars-indicator": "CartNoteInput_rebuy-cart-note-input__remaining-chars-indicator", "rebuy-cart-note-input__help-text": "CartNoteInput_rebuy-cart-note-input__help-text", "rebuy-cart-note-input__content-area": "CartNoteInput_rebuy-cart-note-input__content-area" };
|
4786
4809
|
var CartNoteInput_default = result5;
|
4787
4810
|
|
4788
4811
|
// src/smart-cart/components/CartNoteInput/CartNoteInput.tsx
|
4789
|
-
var
|
4812
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
4790
4813
|
var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
4791
4814
|
const {
|
4792
4815
|
cartData,
|
@@ -4795,7 +4818,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4795
4818
|
isLoading: isGlobalCartLoading,
|
4796
4819
|
updateCartNote: hrUpdateCartNote
|
4797
4820
|
} = useSmartCart();
|
4798
|
-
const noteFetcher = (0,
|
4821
|
+
const noteFetcher = (0, import_react_router5.useFetcher)();
|
4799
4822
|
const textareaRef = (0, import_react9.useRef)(null);
|
4800
4823
|
const isTextareaFocusedRef = (0, import_react9.useRef)(false);
|
4801
4824
|
const settings = componentConfig.settings || {};
|
@@ -4947,15 +4970,15 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4947
4970
|
const helpTextId = `rebuy-cart-note-help-${componentConfig.component_id}`;
|
4948
4971
|
const remainingCharsId = `rebuy-cart-note-remaining-${componentConfig.component_id}`;
|
4949
4972
|
const describedByIds = [remainingChars !== null && currentNoteValue ? remainingCharsId : null, helpTextId].filter(Boolean).join(" ");
|
4950
|
-
return /* @__PURE__ */ (0,
|
4973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
4951
4974
|
"div",
|
4952
4975
|
{
|
4953
4976
|
className: CartNoteInput_default["rebuy-cart-note-input"],
|
4954
4977
|
"data-rebuy-component": "notes",
|
4955
4978
|
"data-rebuy-component-id": componentConfig.component_id ?? "notes",
|
4956
4979
|
children: [
|
4957
|
-
/* @__PURE__ */ (0,
|
4958
|
-
/* @__PURE__ */ (0,
|
4980
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: CartNoteInput_default["rebuy-cart-note-input__toggle-control"], children: [
|
4981
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
4959
4982
|
"input",
|
4960
4983
|
{
|
4961
4984
|
checked: isTextareaVisible,
|
@@ -4965,7 +4988,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4965
4988
|
type: "checkbox"
|
4966
4989
|
}
|
4967
4990
|
),
|
4968
|
-
/* @__PURE__ */ (0,
|
4991
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
4969
4992
|
"span",
|
4970
4993
|
{
|
4971
4994
|
className: CartNoteInput_default["rebuy-cart-note-input__toggle-label"],
|
@@ -4973,9 +4996,9 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4973
4996
|
}
|
4974
4997
|
)
|
4975
4998
|
] }),
|
4976
|
-
isTextareaVisible && /* @__PURE__ */ (0,
|
4977
|
-
/* @__PURE__ */ (0,
|
4978
|
-
/* @__PURE__ */ (0,
|
4999
|
+
isTextareaVisible && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: CartNoteInput_default["rebuy-cart-note-input__content-area"], children: [
|
5000
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: CartNoteInput_default["rebuy-cart-note-input__textarea-wrapper"], children: [
|
5001
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
4979
5002
|
"textarea",
|
4980
5003
|
{
|
4981
5004
|
"aria-describedby": describedByIds || void 0,
|
@@ -4993,7 +5016,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4993
5016
|
value: currentNoteValue
|
4994
5017
|
}
|
4995
5018
|
),
|
4996
|
-
/* @__PURE__ */ (0,
|
5019
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
4997
5020
|
"button",
|
4998
5021
|
{
|
4999
5022
|
"aria-label": saveMessage?.text || (isNoteChanged ? "Save note changes" : "Note is up to date"),
|
@@ -5005,7 +5028,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
5005
5028
|
}
|
5006
5029
|
)
|
5007
5030
|
] }),
|
5008
|
-
/* @__PURE__ */ (0,
|
5031
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
5009
5032
|
"div",
|
5010
5033
|
{
|
5011
5034
|
className: (0, import_clsx2.default)(
|
@@ -5013,7 +5036,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
5013
5036
|
!isNoteChanged && !saveMessage && CartNoteInput_default["rebuy-cart-note-input__meta-info--hidden"]
|
5014
5037
|
),
|
5015
5038
|
children: [
|
5016
|
-
limitChars && currentNoteValue.length > 0 && remainingChars !== null && /* @__PURE__ */ (0,
|
5039
|
+
limitChars && currentNoteValue.length > 0 && remainingChars !== null && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
5017
5040
|
"small",
|
5018
5041
|
{
|
5019
5042
|
"aria-live": "polite",
|
@@ -5022,7 +5045,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
5022
5045
|
children: `You have ${remainingChars} characters remaining.`
|
5023
5046
|
}
|
5024
5047
|
),
|
5025
|
-
/* @__PURE__ */ (0,
|
5048
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { className: CartNoteInput_default["rebuy-cart-note-input__help-text"], id: helpTextId, children: "Press Enter to save, Shift+Enter for new line." })
|
5026
5049
|
]
|
5027
5050
|
}
|
5028
5051
|
)
|
@@ -5042,7 +5065,7 @@ var result6 = { "rebuy-cart-subtotal": "CartSubtotal_rebuy-cart-subtotal", "rebu
|
|
5042
5065
|
var CartSubtotal_default = result6;
|
5043
5066
|
|
5044
5067
|
// src/smart-cart/components/CartSubtotal/CartSubtotal.tsx
|
5045
|
-
var
|
5068
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
5046
5069
|
var getDiscountAllocationTitle = (alloc) => {
|
5047
5070
|
switch (alloc.__typename) {
|
5048
5071
|
case "CartCodeDiscountAllocation":
|
@@ -5150,37 +5173,37 @@ var CartSubtotalComponent = ({ componentConfig }) => {
|
|
5150
5173
|
const primaryPrice = formattedFinalTotal;
|
5151
5174
|
const compareAtPrice = hasOrderDiscount ? formattedPreDiscountSubtotal : null;
|
5152
5175
|
const summaryId = `rebuy-discount-summary-details-${componentConfig.component_id}`;
|
5153
|
-
return /* @__PURE__ */ (0,
|
5176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
5154
5177
|
"div",
|
5155
5178
|
{
|
5156
5179
|
className: rootClasses,
|
5157
5180
|
"data-rebuy-component": "cart-subtotal",
|
5158
5181
|
"data-rebuy-component-id": componentConfig.component_id,
|
5159
5182
|
children: [
|
5160
|
-
/* @__PURE__ */ (0,
|
5161
|
-
/* @__PURE__ */ (0,
|
5162
|
-
/* @__PURE__ */ (0,
|
5163
|
-
/* @__PURE__ */ (0,
|
5164
|
-
compareAtPrice ? /* @__PURE__ */ (0,
|
5165
|
-
/* @__PURE__ */ (0,
|
5166
|
-
/* @__PURE__ */ (0,
|
5167
|
-
/* @__PURE__ */ (0,
|
5183
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: CartSubtotal_default["rebuy-cart-subtotal__row"], children: [
|
5184
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: CartSubtotal_default["rebuy-cart-subtotal__label"], children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: subtotalLabel }) }),
|
5185
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: CartSubtotal_default["rebuy-cart-subtotal__amount-wrapper"], children: [
|
5186
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ScreenReaderText, { children: "Cart subtotal" }),
|
5187
|
+
compareAtPrice ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
5188
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: CartSubtotal_default["rebuy-cart-subtotal__price--final"], children: [
|
5189
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ScreenReaderText, { children: "Final price" }),
|
5190
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: primaryPrice })
|
5168
5191
|
] }),
|
5169
|
-
/* @__PURE__ */ (0,
|
5170
|
-
/* @__PURE__ */ (0,
|
5171
|
-
/* @__PURE__ */ (0,
|
5192
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: CartSubtotal_default["rebuy-cart-subtotal__price--compare-at"], children: [
|
5193
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ScreenReaderText, { children: "Original price" }),
|
5194
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: compareAtPrice })
|
5172
5195
|
] })
|
5173
|
-
] }) : /* @__PURE__ */ (0,
|
5196
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: primaryPrice })
|
5174
5197
|
] })
|
5175
5198
|
] }),
|
5176
|
-
shouldShowDiscountSummary && /* @__PURE__ */ (0,
|
5199
|
+
shouldShowDiscountSummary && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
5177
5200
|
"div",
|
5178
5201
|
{
|
5179
5202
|
className: (0, import_clsx3.default)(CartSubtotal_default["rebuy-cart-subtotal__discount-summary"], {
|
5180
5203
|
[CartSubtotal_default["rebuy-cart-subtotal__discount-summary--expanded"]]: isDiscountSummaryExpanded
|
5181
5204
|
}),
|
5182
5205
|
children: [
|
5183
|
-
/* @__PURE__ */ (0,
|
5206
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
5184
5207
|
"button",
|
5185
5208
|
{
|
5186
5209
|
"aria-controls": summaryId,
|
@@ -5188,24 +5211,24 @@ var CartSubtotalComponent = ({ componentConfig }) => {
|
|
5188
5211
|
className: CartSubtotal_default["rebuy-cart-subtotal__discount-summary-header"],
|
5189
5212
|
onClick: toggleDiscountSummary,
|
5190
5213
|
children: [
|
5191
|
-
/* @__PURE__ */ (0,
|
5192
|
-
/* @__PURE__ */ (0,
|
5193
|
-
/* @__PURE__ */ (0,
|
5214
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: discountSummaryCountLabel }),
|
5215
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { "aria-hidden": "true", className: CartSubtotal_default["rebuy-cart-subtotal__discount-summary-icon"], children: [
|
5216
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("i", { children: "\u25BC" }),
|
5194
5217
|
" "
|
5195
5218
|
] })
|
5196
5219
|
]
|
5197
5220
|
}
|
5198
5221
|
),
|
5199
|
-
/* @__PURE__ */ (0,
|
5222
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
5200
5223
|
"div",
|
5201
5224
|
{
|
5202
5225
|
"aria-hidden": !isDiscountSummaryExpanded,
|
5203
5226
|
className: CartSubtotal_default["rebuy-cart-subtotal__discount-summary-details"],
|
5204
5227
|
id: summaryId,
|
5205
5228
|
role: "region",
|
5206
|
-
children: groupedCartLevelDiscounts.map((discount, index) => /* @__PURE__ */ (0,
|
5207
|
-
/* @__PURE__ */ (0,
|
5208
|
-
/* @__PURE__ */ (0,
|
5229
|
+
children: groupedCartLevelDiscounts.map((discount, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: CartSubtotal_default["rebuy-cart-subtotal__discount-summary-item"], children: [
|
5230
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: discount.title }),
|
5231
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: discount.amount })
|
5209
5232
|
] }, index))
|
5210
5233
|
}
|
5211
5234
|
)
|
@@ -5228,7 +5251,7 @@ var result7 = { "rebuy-cart-title-bar": "CartTitleBar_rebuy-cart-title-bar" };
|
|
5228
5251
|
var CartTitleBar_default = result7;
|
5229
5252
|
|
5230
5253
|
// src/smart-cart/components/CartTitleBar/CartTitleBar.tsx
|
5231
|
-
var
|
5254
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
5232
5255
|
var CartTitleBar = import_react11.default.memo(() => {
|
5233
5256
|
const { getComponentConfigByType } = useSmartCart();
|
5234
5257
|
const componentConfig = getComponentConfigByType("title_bar");
|
@@ -5242,16 +5265,16 @@ var CartTitleBar = import_react11.default.memo(() => {
|
|
5242
5265
|
const DynamicHeadingTag = headingTag;
|
5243
5266
|
if (title === "" && !screenReaderOnly) return null;
|
5244
5267
|
if (screenReaderOnly) {
|
5245
|
-
return /* @__PURE__ */ (0,
|
5268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
5246
5269
|
DynamicHeadingTag,
|
5247
5270
|
{
|
5248
5271
|
"data-rebuy-component-id": componentConfig?.component_id ?? "title_bar",
|
5249
5272
|
id: "rebuy-cart-title",
|
5250
|
-
children: /* @__PURE__ */ (0,
|
5273
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ScreenReaderText, { children: sanitizedTitle })
|
5251
5274
|
}
|
5252
5275
|
);
|
5253
5276
|
}
|
5254
|
-
return /* @__PURE__ */ (0,
|
5277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
5255
5278
|
DynamicHeadingTag,
|
5256
5279
|
{
|
5257
5280
|
className: CartTitleBar_default["rebuy-cart-title-bar"],
|
@@ -5266,14 +5289,14 @@ CartTitleBar.displayName = "CartTitleBar";
|
|
5266
5289
|
|
5267
5290
|
// src/smart-cart/components/CheckoutArea/CheckoutArea.tsx
|
5268
5291
|
var import_react12 = __toESM(require("react"), 1);
|
5269
|
-
var
|
5292
|
+
var import_react_router6 = require("react-router");
|
5270
5293
|
|
5271
5294
|
// src/smart-cart/components/CheckoutArea/CheckoutArea.module.css
|
5272
5295
|
var result8 = { "rebuy-checkout-area": "CheckoutArea_rebuy-checkout-area", "rebuy-checkout-area__terms": "CheckoutArea_rebuy-checkout-area__terms", "rebuy-checkout-area__terms-checkbox": "CheckoutArea_rebuy-checkout-area__terms-checkbox", "rebuy-checkout-area__terms-label": "CheckoutArea_rebuy-checkout-area__terms-label", "rebuy-checkout-area__installments-message": "CheckoutArea_rebuy-checkout-area__installments-message", "rebuy-checkout-area__checkout-button": "CheckoutArea_rebuy-checkout-area__checkout-button", "rebuy-checkout-area__view-cart-button": "CheckoutArea_rebuy-checkout-area__view-cart-button", "rebuy-checkout-area__continue-shopping-button": "CheckoutArea_rebuy-checkout-area__continue-shopping-button", "rebuy-checkout-area__shop-pay-button": "CheckoutArea_rebuy-checkout-area__shop-pay-button" };
|
5273
5296
|
var CheckoutArea_default = result8;
|
5274
5297
|
|
5275
5298
|
// src/smart-cart/components/CheckoutArea/CheckoutArea.tsx
|
5276
|
-
var
|
5299
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
5277
5300
|
var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
5278
5301
|
const {
|
5279
5302
|
cartData,
|
@@ -5284,7 +5307,7 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5284
5307
|
isLoading: isGlobalCartLoading,
|
5285
5308
|
updateCartAttributes: hrUpdateCartAttributes
|
5286
5309
|
} = useSmartCart();
|
5287
|
-
const termsFetcher = (0,
|
5310
|
+
const termsFetcher = (0, import_react_router6.useFetcher)();
|
5288
5311
|
const settings = componentConfig.settings;
|
5289
5312
|
const [termsAccepted, setTermsAccepted] = (0, import_react12.useState)(false);
|
5290
5313
|
const [processingSource, setProcessingSource] = (0, import_react12.useState)(null);
|
@@ -5481,15 +5504,15 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5481
5504
|
[]
|
5482
5505
|
);
|
5483
5506
|
if (!settings) return null;
|
5484
|
-
return /* @__PURE__ */ (0,
|
5507
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
5485
5508
|
"div",
|
5486
5509
|
{
|
5487
5510
|
className: CheckoutArea_default["rebuy-checkout-area"],
|
5488
5511
|
"data-rebuy-component": "checkout-area",
|
5489
5512
|
"data-rebuy-component-id": componentConfig.component_id,
|
5490
5513
|
children: [
|
5491
|
-
hasTermsEnabled && /* @__PURE__ */ (0,
|
5492
|
-
/* @__PURE__ */ (0,
|
5514
|
+
hasTermsEnabled && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: CheckoutArea_default["rebuy-checkout-area__terms"], children: [
|
5515
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
5493
5516
|
"input",
|
5494
5517
|
{
|
5495
5518
|
checked: termsAccepted,
|
@@ -5501,7 +5524,7 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5501
5524
|
type: "checkbox"
|
5502
5525
|
}
|
5503
5526
|
),
|
5504
|
-
/* @__PURE__ */ (0,
|
5527
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
5505
5528
|
"label",
|
5506
5529
|
{
|
5507
5530
|
className: CheckoutArea_default["rebuy-checkout-area__terms-label"],
|
@@ -5510,34 +5533,34 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5510
5533
|
}
|
5511
5534
|
)
|
5512
5535
|
] }),
|
5513
|
-
hasCheckoutButton && /* @__PURE__ */ (0,
|
5536
|
+
hasCheckoutButton && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
5514
5537
|
"button",
|
5515
5538
|
{
|
5516
5539
|
className: CheckoutArea_default["rebuy-checkout-area__checkout-button"],
|
5517
5540
|
disabled: isCheckoutDisabled,
|
5518
5541
|
onClick: handleCheckoutClick,
|
5519
5542
|
type: "button",
|
5520
|
-
children: /* @__PURE__ */ (0,
|
5543
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { dangerouslySetInnerHTML: { __html: checkoutLabel } })
|
5521
5544
|
}
|
5522
5545
|
),
|
5523
|
-
hasViewCartButton && /* @__PURE__ */ (0,
|
5546
|
+
hasViewCartButton && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
5524
5547
|
"button",
|
5525
5548
|
{
|
5526
5549
|
className: CheckoutArea_default["rebuy-checkout-area__view-cart-button"],
|
5527
5550
|
disabled: isAnyCriticalActionProcessing && processingSource !== "terms",
|
5528
5551
|
onClick: handleViewCartClick,
|
5529
5552
|
type: "button",
|
5530
|
-
children: /* @__PURE__ */ (0,
|
5553
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { dangerouslySetInnerHTML: { __html: viewCartLabel } })
|
5531
5554
|
}
|
5532
5555
|
),
|
5533
|
-
hasContinueShoppingButton && /* @__PURE__ */ (0,
|
5556
|
+
hasContinueShoppingButton && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
5534
5557
|
"button",
|
5535
5558
|
{
|
5536
5559
|
className: CheckoutArea_default["rebuy-checkout-area__continue-shopping-button"],
|
5537
5560
|
disabled: isAnyCriticalActionProcessing && processingSource !== "terms",
|
5538
5561
|
onClick: handleContinueShoppingClick,
|
5539
5562
|
type: "button",
|
5540
|
-
children: /* @__PURE__ */ (0,
|
5563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
5541
5564
|
"span",
|
5542
5565
|
{
|
5543
5566
|
dangerouslySetInnerHTML: {
|
@@ -5547,7 +5570,7 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5547
5570
|
)
|
5548
5571
|
}
|
5549
5572
|
),
|
5550
|
-
hasShopPayButton && /* @__PURE__ */ (0,
|
5573
|
+
hasShopPayButton && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
5551
5574
|
"button",
|
5552
5575
|
{
|
5553
5576
|
"aria-label": "Checkout with Shop Pay",
|
@@ -5557,7 +5580,7 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5557
5580
|
onClick: handleShopPayClick
|
5558
5581
|
}
|
5559
5582
|
),
|
5560
|
-
hasInstallments && installmentsMessage && hasItems && /* @__PURE__ */ (0,
|
5583
|
+
hasInstallments && installmentsMessage && hasItems && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
5561
5584
|
"div",
|
5562
5585
|
{
|
5563
5586
|
className: CheckoutArea_default["rebuy-checkout-area__installments-message"],
|
@@ -5566,7 +5589,7 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5566
5589
|
}
|
5567
5590
|
}
|
5568
5591
|
),
|
5569
|
-
hasPrePurchase && hasItems && /* @__PURE__ */ (0,
|
5592
|
+
hasPrePurchase && hasItems && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { "data-rebuy-id": settings.pre_purchase.widget_id })
|
5570
5593
|
]
|
5571
5594
|
}
|
5572
5595
|
);
|
@@ -5580,9 +5603,9 @@ var import_hydrogen6 = require("@shopify/hydrogen");
|
|
5580
5603
|
var import_react20 = require("react");
|
5581
5604
|
|
5582
5605
|
// src/assets/Close.tsx
|
5583
|
-
var
|
5606
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
5584
5607
|
var Close = () => {
|
5585
|
-
return /* @__PURE__ */ (0,
|
5608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("svg", { height: "1em", viewBox: "0 0 352 512", width: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("path", { d: "M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.19 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.19 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z" }) });
|
5586
5609
|
};
|
5587
5610
|
|
5588
5611
|
// src/hooks/useBreakpoint.ts
|
@@ -6091,7 +6114,6 @@ var defaultProductCardSettings = {
|
|
6091
6114
|
// src/components/ProductCard/ProductCard.tsx
|
6092
6115
|
var import_hydrogen5 = require("@shopify/hydrogen");
|
6093
6116
|
var import_react17 = require("react");
|
6094
|
-
var import_react_router6 = require("react-router");
|
6095
6117
|
|
6096
6118
|
// src/components/AddToCartBtn/HydrogenAddToCartBtn.tsx
|
6097
6119
|
var import_hydrogen3 = require("@shopify/hydrogen");
|
@@ -6101,7 +6123,7 @@ var result9 = { "rebuy-cart-button": "AddToCartBtn_rebuy-cart-button", "rebuy-ca
|
|
6101
6123
|
var AddToCartBtn_default = result9;
|
6102
6124
|
|
6103
6125
|
// src/components/AddToCartBtn/HydrogenAddToCartBtn.tsx
|
6104
|
-
var
|
6126
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
6105
6127
|
var HydrogenAddToCartBtn = ({
|
6106
6128
|
addToCartBtnText,
|
6107
6129
|
addToCartCallback,
|
@@ -6123,7 +6145,7 @@ var HydrogenAddToCartBtn = ({
|
|
6123
6145
|
addToCartCallback();
|
6124
6146
|
}
|
6125
6147
|
};
|
6126
|
-
return /* @__PURE__ */ (0,
|
6148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: AddToCartBtn_default["rebuy-cart-button__container"], children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
6127
6149
|
import_hydrogen3.CartForm,
|
6128
6150
|
{
|
6129
6151
|
action: import_hydrogen3.CartForm.ACTIONS.LinesAdd,
|
@@ -6131,7 +6153,7 @@ var HydrogenAddToCartBtn = ({
|
|
6131
6153
|
lines: linesToAdd
|
6132
6154
|
},
|
6133
6155
|
route: "/cart",
|
6134
|
-
children: (fetcher) => /* @__PURE__ */ (0,
|
6156
|
+
children: (fetcher) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
6135
6157
|
"button",
|
6136
6158
|
{
|
6137
6159
|
className: AddToCartBtn_default["rebuy-cart-button"],
|
@@ -6140,9 +6162,9 @@ var HydrogenAddToCartBtn = ({
|
|
6140
6162
|
type: "submit",
|
6141
6163
|
children: [
|
6142
6164
|
addToCartBtnText,
|
6143
|
-
moneyData && /* @__PURE__ */ (0,
|
6144
|
-
/* @__PURE__ */ (0,
|
6145
|
-
/* @__PURE__ */ (0,
|
6165
|
+
moneyData && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
6166
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: " | " }),
|
6167
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_hydrogen3.Money, { data: moneyData, withoutTrailingZeros: true })
|
6146
6168
|
] })
|
6147
6169
|
]
|
6148
6170
|
}
|
@@ -6153,7 +6175,7 @@ var HydrogenAddToCartBtn = ({
|
|
6153
6175
|
|
6154
6176
|
// src/components/AddToCartBtn/HydrogenReactAddToCartBtn.tsx
|
6155
6177
|
var import_hydrogen_react2 = require("@shopify/hydrogen-react");
|
6156
|
-
var
|
6178
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
6157
6179
|
var HydrogenReactAddToCartBtn = ({
|
6158
6180
|
addToCartBtnText,
|
6159
6181
|
addToCartCallback,
|
@@ -6176,17 +6198,17 @@ var HydrogenReactAddToCartBtn = ({
|
|
6176
6198
|
addToCartCallback();
|
6177
6199
|
}
|
6178
6200
|
};
|
6179
|
-
return /* @__PURE__ */ (0,
|
6201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("button", { className: AddToCartBtn_default["rebuy-cart-button"], disabled, onClick: handleAddToCart, type: "button", children: [
|
6180
6202
|
addToCartBtnText,
|
6181
|
-
moneyData && /* @__PURE__ */ (0,
|
6182
|
-
/* @__PURE__ */ (0,
|
6183
|
-
/* @__PURE__ */ (0,
|
6203
|
+
moneyData && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
6204
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: " | " }),
|
6205
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_hydrogen_react2.Money, { data: moneyData, withoutTrailingZeros: true })
|
6184
6206
|
] })
|
6185
6207
|
] });
|
6186
6208
|
};
|
6187
6209
|
|
6188
6210
|
// src/components/AddToCartBtn/AddToCartBtn.tsx
|
6189
|
-
var
|
6211
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
6190
6212
|
var AddToCartBtn = ({
|
6191
6213
|
addToCartBtnText,
|
6192
6214
|
addToCartCallback,
|
@@ -6208,7 +6230,7 @@ var AddToCartBtn = ({
|
|
6208
6230
|
selectedVariant: variant
|
6209
6231
|
}));
|
6210
6232
|
if (isHydrogenReact) {
|
6211
|
-
return /* @__PURE__ */ (0,
|
6233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
6212
6234
|
HydrogenReactAddToCartBtn,
|
6213
6235
|
{
|
6214
6236
|
addToCartBtnText,
|
@@ -6221,7 +6243,7 @@ var AddToCartBtn = ({
|
|
6221
6243
|
}
|
6222
6244
|
);
|
6223
6245
|
}
|
6224
|
-
return /* @__PURE__ */ (0,
|
6246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
6225
6247
|
HydrogenAddToCartBtn,
|
6226
6248
|
{
|
6227
6249
|
addToCartBtnText,
|
@@ -6244,14 +6266,14 @@ var result10 = { "rebuy-product-price": "ProductPrice_rebuy-product-price", "reb
|
|
6244
6266
|
var ProductPrice_default = result10;
|
6245
6267
|
|
6246
6268
|
// src/components/ProductPrice/ProductPrice.tsx
|
6247
|
-
var
|
6269
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
6248
6270
|
var RebuyProductPrice = ({ selectedVariant, settingsDiscount }) => {
|
6249
6271
|
if (!selectedVariant) return null;
|
6250
6272
|
const { compareAtPriceV2: compareAtPrice, priceV2: price } = selectedVariant;
|
6251
6273
|
const isDiscounted = (price2, compareAtPrice2) => Number(compareAtPrice2?.amount) > Number(price2?.amount);
|
6252
6274
|
const currentPriceIsOnSale = compareAtPrice && isDiscounted(price, compareAtPrice);
|
6253
6275
|
const CompareAtPrice = ({ data: compareAtPriceData }) => {
|
6254
|
-
return compareAtPriceData && /* @__PURE__ */ (0,
|
6276
|
+
return compareAtPriceData && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
6255
6277
|
import_hydrogen4.Money,
|
6256
6278
|
{
|
6257
6279
|
as: "span",
|
@@ -6261,8 +6283,8 @@ var RebuyProductPrice = ({ selectedVariant, settingsDiscount }) => {
|
|
6261
6283
|
}
|
6262
6284
|
);
|
6263
6285
|
};
|
6264
|
-
return price && /* @__PURE__ */ (0,
|
6265
|
-
/* @__PURE__ */ (0,
|
6286
|
+
return price && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: ProductPrice_default["rebuy-product-price"], children: [
|
6287
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
6266
6288
|
import_hydrogen4.Money,
|
6267
6289
|
{
|
6268
6290
|
as: "span",
|
@@ -6274,7 +6296,7 @@ var RebuyProductPrice = ({ selectedVariant, settingsDiscount }) => {
|
|
6274
6296
|
withoutTrailingZeros: true
|
6275
6297
|
}
|
6276
6298
|
),
|
6277
|
-
currentPriceIsOnSale && /* @__PURE__ */ (0,
|
6299
|
+
currentPriceIsOnSale && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CompareAtPrice, { data: compareAtPrice })
|
6278
6300
|
] });
|
6279
6301
|
};
|
6280
6302
|
|
@@ -6286,7 +6308,7 @@ var result11 = { "rebuy-quantity__container": "QuantityInput_rebuy-quantity__con
|
|
6286
6308
|
var QuantityInput_default = result11;
|
6287
6309
|
|
6288
6310
|
// src/components/QuantityInput/QuantityInput.tsx
|
6289
|
-
var
|
6311
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
6290
6312
|
var QuantityInput = ({
|
6291
6313
|
defaultQuantity = 1,
|
6292
6314
|
handleSelectedQuantity,
|
@@ -6302,7 +6324,7 @@ var QuantityInput = ({
|
|
6302
6324
|
}
|
6303
6325
|
};
|
6304
6326
|
const quantityOptions = Array.from({ length: maxValue - minValue + 1 }, (_, i) => minValue + i);
|
6305
|
-
return /* @__PURE__ */ (0,
|
6327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: QuantityInput_default["rebuy-quantity__container"], children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
6306
6328
|
"select",
|
6307
6329
|
{
|
6308
6330
|
"aria-label": "Product quantity",
|
@@ -6310,46 +6332,18 @@ var QuantityInput = ({
|
|
6310
6332
|
name: "quantity",
|
6311
6333
|
onChange: handleChange,
|
6312
6334
|
value: quantity,
|
6313
|
-
children: quantityOptions.map((value) => /* @__PURE__ */ (0,
|
6335
|
+
children: quantityOptions.map((value) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value, children: value }, `quantity-${value}`))
|
6314
6336
|
}
|
6315
6337
|
) });
|
6316
6338
|
};
|
6317
6339
|
|
6318
|
-
// src/components/Title/Title.tsx
|
6319
|
-
var import_clsx5 = __toESM(require("clsx"), 1);
|
6320
|
-
|
6321
|
-
// src/components/Title/Title.module.css
|
6322
|
-
var result12 = { "rebuy-title": "Title_rebuy-title" };
|
6323
|
-
var Title_default = result12;
|
6324
|
-
|
6325
|
-
// src/components/Title/Title.tsx
|
6326
|
-
var import_jsx_runtime22 = require("react/jsx-runtime");
|
6327
|
-
var Title = ({ className, level, style, text }) => {
|
6328
|
-
const combinedClassName = (0, import_clsx5.default)(Title_default["rebuy-title"], className);
|
6329
|
-
switch (level) {
|
6330
|
-
case "h1":
|
6331
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h1", { className: combinedClassName, style, children: text });
|
6332
|
-
default:
|
6333
|
-
case "h2":
|
6334
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h2", { className: combinedClassName, style, children: text });
|
6335
|
-
case "h3":
|
6336
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h3", { className: combinedClassName, style, children: text });
|
6337
|
-
case "h4":
|
6338
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h4", { className: combinedClassName, style, children: text });
|
6339
|
-
case "h5":
|
6340
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h5", { className: combinedClassName, style, children: text });
|
6341
|
-
case "h6":
|
6342
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h6", { className: combinedClassName, style, children: text });
|
6343
|
-
}
|
6344
|
-
};
|
6345
|
-
|
6346
6340
|
// src/components/VariantSelect/VariantSelect.tsx
|
6347
|
-
var
|
6341
|
+
var import_clsx5 = __toESM(require("clsx"), 1);
|
6348
6342
|
var import_react16 = require("react");
|
6349
6343
|
|
6350
6344
|
// src/components/VariantSelect/VariantSelect.module.css
|
6351
|
-
var
|
6352
|
-
var VariantSelect_default =
|
6345
|
+
var result12 = { "rebuy-variant__container": "VariantSelect_rebuy-variant__container", "rebuy-variant__select": "VariantSelect_rebuy-variant__select", "rebuy-variant__select-option": "VariantSelect_rebuy-variant__select-option", "rebuy-variant__buttons": "VariantSelect_rebuy-variant__buttons", "rebuy-variant__button": "VariantSelect_rebuy-variant__button", "rebuy-variant__button--selected": "VariantSelect_rebuy-variant__button--selected" };
|
6346
|
+
var VariantSelect_default = result12;
|
6353
6347
|
|
6354
6348
|
// src/components/VariantSelect/VariantSelect.tsx
|
6355
6349
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
@@ -6388,7 +6382,7 @@ var VariantSelect = ({ handleSelectedVariant, product, selectedId, style = "sele
|
|
6388
6382
|
"button",
|
6389
6383
|
{
|
6390
6384
|
"aria-pressed": id === selectedVariantId,
|
6391
|
-
className: (0,
|
6385
|
+
className: (0, import_clsx5.default)(
|
6392
6386
|
VariantSelect_default["rebuy-variant__button"],
|
6393
6387
|
id === selectedVariantId && VariantSelect_default["rebuy-variant__button--selected"]
|
6394
6388
|
),
|
@@ -6400,15 +6394,44 @@ var VariantSelect = ({ handleSelectedVariant, product, selectedId, style = "sele
|
|
6400
6394
|
)) }) });
|
6401
6395
|
};
|
6402
6396
|
|
6397
|
+
// src/components/Title/Title.tsx
|
6398
|
+
var import_clsx6 = __toESM(require("clsx"), 1);
|
6399
|
+
|
6400
|
+
// src/components/Title/Title.module.css
|
6401
|
+
var result13 = { "rebuy-title": "Title_rebuy-title" };
|
6402
|
+
var Title_default = result13;
|
6403
|
+
|
6404
|
+
// src/components/Title/Title.tsx
|
6405
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
6406
|
+
var Title = ({ className, level, style, text }) => {
|
6407
|
+
const combinedClassName = (0, import_clsx6.default)(Title_default["rebuy-title"], className);
|
6408
|
+
switch (level) {
|
6409
|
+
case "h1":
|
6410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h1", { className: combinedClassName, style, children: text });
|
6411
|
+
default:
|
6412
|
+
case "h2":
|
6413
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h2", { className: combinedClassName, style, children: text });
|
6414
|
+
case "h3":
|
6415
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h3", { className: combinedClassName, style, children: text });
|
6416
|
+
case "h4":
|
6417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h4", { className: combinedClassName, style, children: text });
|
6418
|
+
case "h5":
|
6419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h5", { className: combinedClassName, style, children: text });
|
6420
|
+
case "h6":
|
6421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h6", { className: combinedClassName, style, children: text });
|
6422
|
+
}
|
6423
|
+
};
|
6424
|
+
|
6403
6425
|
// src/components/ProductCard/ProductCard.module.css
|
6404
6426
|
var result14 = { "rebuy-product-card__container": "ProductCard_rebuy-product-card__container", "rebuy-product-card": "ProductCard_rebuy-product-card", "rebuy-product-card__content": "ProductCard_rebuy-product-card__content", "rebuy-product-card__header": "ProductCard_rebuy-product-card__header", "rebuy-product-card__info": "ProductCard_rebuy-product-card__info", "rebuy-product-card__actions": "ProductCard_rebuy-product-card__actions", "rebuy-product-card__media-link": "ProductCard_rebuy-product-card__media-link", "rebuy-product-card__image": "ProductCard_rebuy-product-card__image", "rebuy-product-card__title": "ProductCard_rebuy-product-card__title", "rebuy-product-card__title-link": "ProductCard_rebuy-product-card__title-link", "rebuy-product-card__actions-variant-select": "ProductCard_rebuy-product-card__actions-variant-select", "rebuy-product-card__variant-select": "ProductCard_rebuy-product-card__variant-select", "rebuy-product-card__actions-quantity": "ProductCard_rebuy-product-card__actions-quantity", "rebuy-product-card__actions-button": "ProductCard_rebuy-product-card__actions-button", "rebuy-product-card__vendor": "ProductCard_rebuy-product-card__vendor", "rebuy-product-card__variant-title": "ProductCard_rebuy-product-card__variant-title", "rebuy-product-card__review": "ProductCard_rebuy-product-card__review", "rebuy-product-card__star-rating": "ProductCard_rebuy-product-card__star-rating", "rebuy-product-card__star-rating-value": "ProductCard_rebuy-product-card__star-rating-value", "rebuy-product-card__star-rating-background": "ProductCard_rebuy-product-card__star-rating-background", "rebuy-product-card__star-rating-foreground": "ProductCard_rebuy-product-card__star-rating-foreground", "rebuy-product-card__review-count": "ProductCard_rebuy-product-card__review-count", "rebuy-product-card__review-count-parenthesis": "ProductCard_rebuy-product-card__review-count-parenthesis", "rebuy-product-card__review-count-number": "ProductCard_rebuy-product-card__review-count-number", "rebuy-product-card__review-count-label": "ProductCard_rebuy-product-card__review-count-label", "rebuy-product-card__description": "ProductCard_rebuy-product-card__description" };
|
6405
6427
|
var ProductCard_default = result14;
|
6406
6428
|
|
6407
6429
|
// src/components/ProductCard/ProductCard.tsx
|
6408
|
-
var
|
6430
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
6409
6431
|
var ProductCard = ({
|
6410
6432
|
addToCartBtnText,
|
6411
6433
|
addToCartCallback,
|
6434
|
+
isCrossSell,
|
6412
6435
|
isHydrogenReact,
|
6413
6436
|
isInPopup,
|
6414
6437
|
onPopupDismiss,
|
@@ -6420,6 +6443,7 @@ var ProductCard = ({
|
|
6420
6443
|
const [selectedVariant, setSelectedVariant] = (0, import_react17.useState)(product.variants.nodes[0]);
|
6421
6444
|
const [selectedQuantity, setSelectedQuantity] = (0, import_react17.useState)(settings?.quantityInput?.default_quantity || 1);
|
6422
6445
|
const [interactionStatus, setInteractionStatus] = (0, import_react17.useState)("ready");
|
6446
|
+
const { toggleCart } = useSmartCart();
|
6423
6447
|
const displayImage = selectedVariant.image || product.featuredImage;
|
6424
6448
|
const handleSelectedVariant = (0, import_react17.useCallback)((product2, variant_id) => {
|
6425
6449
|
const updatedVariant = product2.variants.nodes.find((variant) => variant.id === variant_id);
|
@@ -6431,6 +6455,9 @@ var ProductCard = ({
|
|
6431
6455
|
setSelectedQuantity(quantity);
|
6432
6456
|
}, []);
|
6433
6457
|
const handleLinkClick = (0, import_react17.useCallback)(() => {
|
6458
|
+
if (isCrossSell) {
|
6459
|
+
toggleCart();
|
6460
|
+
}
|
6434
6461
|
if (isInPopup && onPopupDismiss) {
|
6435
6462
|
onPopupDismiss();
|
6436
6463
|
}
|
@@ -6487,40 +6514,92 @@ var ProductCard = ({
|
|
6487
6514
|
const productReviewsRating = product.reviews?.star_rating;
|
6488
6515
|
const showProductDescription = settings?.productOptions?.show_product_description === "show" && product.description !== "" && product.description !== null;
|
6489
6516
|
const showQuantityInput = settings?.quantityInput?.enabled && settings?.quantityInput?.max_value !== null && settings?.quantityInput?.min_value !== null;
|
6490
|
-
return /* @__PURE__ */ (0,
|
6491
|
-
/* @__PURE__ */ (0,
|
6492
|
-
/* @__PURE__ */ (0,
|
6493
|
-
|
6494
|
-
|
6495
|
-
|
6496
|
-
|
6497
|
-
|
6498
|
-
|
6499
|
-
|
6500
|
-
|
6501
|
-
|
6517
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: ProductCard_default["rebuy-product-card__container"], children: [
|
6518
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: ProductCard_default["rebuy-product-card"], "data-layout": cardLayout, children: [
|
6519
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
|
6520
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6521
|
+
RebuyLink,
|
6522
|
+
{
|
6523
|
+
ariaLabel: `View ${product.title}`,
|
6524
|
+
className: ProductCard_default["rebuy-product-card__media-link"],
|
6525
|
+
handle: `/products/${product.handle}`,
|
6526
|
+
onClick: handleLinkClick,
|
6527
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6528
|
+
import_hydrogen5.Image,
|
6529
|
+
{
|
6530
|
+
alt: displayImage?.altText ?? `Picture of ${product.title}`,
|
6531
|
+
className: ProductCard_default["rebuy-product-card__image"],
|
6532
|
+
data: displayImage,
|
6533
|
+
sizes: "(max-width: 320px) 280px, (max-width: 768px) 720px, 1440px"
|
6534
|
+
}
|
6535
|
+
)
|
6536
|
+
}
|
6537
|
+
),
|
6538
|
+
settings?.layoutStyle === "grid" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: ProductCard_default["rebuy-product-card__content"], children: [
|
6539
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: ProductCard_default["rebuy-product-card__header"], children: [
|
6540
|
+
product.vendor && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: ProductCard_default["rebuy-product-card__vendor"], children: product.vendor }),
|
6541
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6542
|
+
RebuyLink,
|
6543
|
+
{
|
6544
|
+
ariaLabel: `View ${product.title}`,
|
6545
|
+
className: ProductCard_default["rebuy-product-card__title-link"],
|
6546
|
+
handle: `/products/${product.handle}`,
|
6547
|
+
onClick: handleLinkClick,
|
6548
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6549
|
+
Title,
|
6550
|
+
{
|
6551
|
+
className: ProductCard_default["rebuy-product-card__title"],
|
6552
|
+
level: productCardTitleLevel,
|
6553
|
+
text: product.title
|
6554
|
+
}
|
6555
|
+
)
|
6556
|
+
}
|
6557
|
+
),
|
6558
|
+
showVariantTitle && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: ProductCard_default["rebuy-product-card__variant-title"], children: selectedVariant.title })
|
6559
|
+
] }),
|
6560
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6561
|
+
RebuyProductPrice,
|
6502
6562
|
{
|
6503
|
-
|
6504
|
-
|
6505
|
-
data: displayImage,
|
6506
|
-
sizes: "(max-width: 320px) 280px, (max-width: 768px) 720px, 1440px"
|
6563
|
+
selectedVariant,
|
6564
|
+
settingsDiscount: settings?.settingsDiscount
|
6507
6565
|
}
|
6508
|
-
)
|
6509
|
-
|
6510
|
-
|
6511
|
-
|
6512
|
-
|
6513
|
-
|
6514
|
-
|
6515
|
-
|
6516
|
-
|
6566
|
+
),
|
6567
|
+
showReviews && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { "aria-label": "product star rating", className: ProductCard_default["rebuy-product-card__review"], children: [
|
6568
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: ProductCard_default["rebuy-product-card__star-rating"], children: [
|
6569
|
+
productReviewsRating && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: ProductCard_default["rebuy-product-card__star-rating-value"], children: [
|
6570
|
+
productReviewsRating,
|
6571
|
+
" stars out of 5 stars"
|
6572
|
+
] }),
|
6573
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: ProductCard_default["rebuy-product-card__star-rating-background"] }),
|
6574
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6575
|
+
"span",
|
6576
|
+
{
|
6577
|
+
className: ProductCard_default["rebuy-product-card__star-rating-foreground"],
|
6578
|
+
style: productReviewsRating ? { width: productReviewsRating / 5 * 100 + "%" } : {}
|
6579
|
+
}
|
6580
|
+
)
|
6581
|
+
] }),
|
6582
|
+
product.reviews?.review_count && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: ProductCard_default["rebuy-product-card__review-count"], children: [
|
6583
|
+
"(",
|
6584
|
+
product.reviews.review_count,
|
6585
|
+
")"
|
6586
|
+
] })
|
6587
|
+
] }),
|
6588
|
+
showProductDescription && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: ProductCard_default["rebuy-product-card__description"], children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { children: product.description }) })
|
6589
|
+
] })
|
6590
|
+
] }),
|
6591
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: ProductCard_default["rebuy-product-card__info"], children: [
|
6592
|
+
settings?.layoutStyle !== "grid" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: ProductCard_default["rebuy-product-card__content"], children: [
|
6593
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: ProductCard_default["rebuy-product-card__header"], children: [
|
6594
|
+
product.vendor && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: ProductCard_default["rebuy-product-card__vendor"], children: product.vendor }),
|
6595
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6596
|
+
RebuyLink,
|
6517
6597
|
{
|
6518
|
-
|
6598
|
+
ariaLabel: `View ${product.title}`,
|
6519
6599
|
className: ProductCard_default["rebuy-product-card__title-link"],
|
6600
|
+
handle: `/products/${product.handle}`,
|
6520
6601
|
onClick: handleLinkClick,
|
6521
|
-
|
6522
|
-
to: `/products/${product.handle}`,
|
6523
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
6602
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6524
6603
|
Title,
|
6525
6604
|
{
|
6526
6605
|
className: ProductCard_default["rebuy-product-card__title"],
|
@@ -6530,23 +6609,23 @@ var ProductCard = ({
|
|
6530
6609
|
)
|
6531
6610
|
}
|
6532
6611
|
),
|
6533
|
-
showVariantTitle && /* @__PURE__ */ (0,
|
6612
|
+
showVariantTitle && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: ProductCard_default["rebuy-product-card__variant-title"], children: selectedVariant.title })
|
6534
6613
|
] }),
|
6535
|
-
/* @__PURE__ */ (0,
|
6614
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6536
6615
|
RebuyProductPrice,
|
6537
6616
|
{
|
6538
6617
|
selectedVariant,
|
6539
6618
|
settingsDiscount: settings?.settingsDiscount
|
6540
6619
|
}
|
6541
6620
|
),
|
6542
|
-
showReviews && /* @__PURE__ */ (0,
|
6543
|
-
/* @__PURE__ */ (0,
|
6544
|
-
productReviewsRating && /* @__PURE__ */ (0,
|
6621
|
+
showReviews && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { "aria-label": "product star rating", className: ProductCard_default["rebuy-product-card__review"], children: [
|
6622
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: ProductCard_default["rebuy-product-card__star-rating"], children: [
|
6623
|
+
productReviewsRating && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: ProductCard_default["rebuy-product-card__star-rating-value"], children: [
|
6545
6624
|
productReviewsRating,
|
6546
6625
|
" stars out of 5 stars"
|
6547
6626
|
] }),
|
6548
|
-
/* @__PURE__ */ (0,
|
6549
|
-
/* @__PURE__ */ (0,
|
6627
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: ProductCard_default["rebuy-product-card__star-rating-background"] }),
|
6628
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6550
6629
|
"span",
|
6551
6630
|
{
|
6552
6631
|
className: ProductCard_default["rebuy-product-card__star-rating-foreground"],
|
@@ -6554,21 +6633,21 @@ var ProductCard = ({
|
|
6554
6633
|
}
|
6555
6634
|
)
|
6556
6635
|
] }),
|
6557
|
-
product.reviews?.review_count && /* @__PURE__ */ (0,
|
6636
|
+
product.reviews?.review_count && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: ProductCard_default["rebuy-product-card__review-count"], children: [
|
6558
6637
|
"(",
|
6559
6638
|
product.reviews.review_count,
|
6560
6639
|
")"
|
6561
6640
|
] })
|
6562
6641
|
] }),
|
6563
|
-
showProductDescription && /* @__PURE__ */ (0,
|
6642
|
+
showProductDescription && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: ProductCard_default["rebuy-product-card__description"], children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { children: product.description }) })
|
6564
6643
|
] }),
|
6565
|
-
/* @__PURE__ */ (0,
|
6566
|
-
showVariantSelect && cardLayout !== "line" && /* @__PURE__ */ (0,
|
6644
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: ProductCard_default["rebuy-product-card__actions"], children: [
|
6645
|
+
showVariantSelect && cardLayout !== "line" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6567
6646
|
"div",
|
6568
6647
|
{
|
6569
6648
|
className: ProductCard_default["rebuy-product-card__actions-variant-select"],
|
6570
6649
|
"data-layout": cardLayout,
|
6571
|
-
children: /* @__PURE__ */ (0,
|
6650
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6572
6651
|
VariantSelect,
|
6573
6652
|
{
|
6574
6653
|
handleSelectedVariant,
|
@@ -6579,7 +6658,7 @@ var ProductCard = ({
|
|
6579
6658
|
)
|
6580
6659
|
}
|
6581
6660
|
),
|
6582
|
-
showQuantityInput && /* @__PURE__ */ (0,
|
6661
|
+
showQuantityInput && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: ProductCard_default["rebuy-product-card__actions-quantity"], children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6583
6662
|
QuantityInput,
|
6584
6663
|
{
|
6585
6664
|
defaultQuantity: settings?.quantityInput?.default_quantity,
|
@@ -6588,7 +6667,7 @@ var ProductCard = ({
|
|
6588
6667
|
minValue: settings?.quantityInput?.min_value
|
6589
6668
|
}
|
6590
6669
|
) }),
|
6591
|
-
/* @__PURE__ */ (0,
|
6670
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: ProductCard_default["rebuy-product-card__actions-button"], children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6592
6671
|
AddToCartBtn,
|
6593
6672
|
{
|
6594
6673
|
addToCartBtnText: atcButtonLabel,
|
@@ -6603,7 +6682,7 @@ var ProductCard = ({
|
|
6603
6682
|
] })
|
6604
6683
|
] })
|
6605
6684
|
] }),
|
6606
|
-
showVariantSelect && cardLayout === "line" && /* @__PURE__ */ (0,
|
6685
|
+
showVariantSelect && cardLayout === "line" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: ProductCard_default["rebuy-product-card__variant-select"], "data-layout": cardLayout, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
6607
6686
|
VariantSelect,
|
6608
6687
|
{
|
6609
6688
|
handleSelectedVariant,
|
@@ -6623,12 +6702,15 @@ var result15 = { "rebuy-carousel": "ProductCarousel_rebuy-carousel", "rebuy-caro
|
|
6623
6702
|
var ProductCarousel_default = result15;
|
6624
6703
|
|
6625
6704
|
// src/components/ProductCarousel/ProductCarousel.tsx
|
6626
|
-
var
|
6705
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
6627
6706
|
var ProductCarousel = ({
|
6628
6707
|
addToCartBtnText,
|
6629
6708
|
addToCartCallback,
|
6630
6709
|
columns,
|
6710
|
+
isCrossSell,
|
6631
6711
|
isHydrogenReact,
|
6712
|
+
isInPopup,
|
6713
|
+
onPopupDismiss,
|
6632
6714
|
productCardTitleLevel,
|
6633
6715
|
products,
|
6634
6716
|
settings,
|
@@ -6669,18 +6751,21 @@ var ProductCarousel = ({
|
|
6669
6751
|
for (let i = 0; i < repeatedProducts.length; i += columns) {
|
6670
6752
|
slides.push(repeatedProducts.slice(i, i + columns));
|
6671
6753
|
}
|
6672
|
-
return /* @__PURE__ */ (0,
|
6673
|
-
/* @__PURE__ */ (0,
|
6754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: ProductCarousel_default["rebuy-carousel"], children: [
|
6755
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
6674
6756
|
"div",
|
6675
6757
|
{
|
6676
6758
|
className: ProductCarousel_default["rebuy-carousel__container"],
|
6677
6759
|
style: { transform: `translateX(-${currentSlide * 100}%)` },
|
6678
|
-
children: slides.map((slideProducts, index) => /* @__PURE__ */ (0,
|
6760
|
+
children: slides.map((slideProducts, index) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: ProductCarousel_default["rebuy-carousel__slide"], children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: ProductCarousel_default["rebuy-carousel__grid"], "data-columns": columns, children: slideProducts.map((product, productIndex) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
6679
6761
|
ProductCard,
|
6680
6762
|
{
|
6681
6763
|
addToCartBtnText,
|
6682
6764
|
addToCartCallback,
|
6765
|
+
isCrossSell,
|
6683
6766
|
isHydrogenReact,
|
6767
|
+
isInPopup,
|
6768
|
+
onPopupDismiss,
|
6684
6769
|
product,
|
6685
6770
|
productCardTitleLevel,
|
6686
6771
|
settings,
|
@@ -6690,11 +6775,11 @@ var ProductCarousel = ({
|
|
6690
6775
|
)) }) }, index))
|
6691
6776
|
}
|
6692
6777
|
),
|
6693
|
-
totalSlides > 1 && /* @__PURE__ */ (0,
|
6694
|
-
/* @__PURE__ */ (0,
|
6695
|
-
/* @__PURE__ */ (0,
|
6778
|
+
totalSlides > 1 && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: ProductCarousel_default["rebuy-carousel__controls"], children: [
|
6779
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { className: ProductCarousel_default["rebuy-carousel__prev"], onClick: prevSlide, type: "button", children: "\u2190" }),
|
6780
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { className: ProductCarousel_default["rebuy-carousel__next"], onClick: nextSlide, type: "button", children: "\u2192" })
|
6696
6781
|
] }),
|
6697
|
-
showPagination && totalSlides > 1 && /* @__PURE__ */ (0,
|
6782
|
+
showPagination && totalSlides > 1 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: ProductCarousel_default["rebuy-carousel__pagination"], children: Array.from({ length: totalSlides }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
6698
6783
|
"button",
|
6699
6784
|
{
|
6700
6785
|
className: ProductCarousel_default["rebuy-carousel__dot"],
|
@@ -6716,7 +6801,7 @@ var result16 = { "rebuy-timer__container": "Timer_rebuy-timer__container", "rebu
|
|
6716
6801
|
var Timer_default = result16;
|
6717
6802
|
|
6718
6803
|
// src/components/Timer/Timer.tsx
|
6719
|
-
var
|
6804
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
6720
6805
|
var Timer = ({ action, durationMinutes, durationSeconds, isPopup = false, onDismiss, title }) => {
|
6721
6806
|
const initialTotalSeconds = (durationMinutes || 0) * 60 + (durationSeconds || 0);
|
6722
6807
|
const [totalSeconds, setTotalSeconds] = (0, import_react19.useState)(initialTotalSeconds);
|
@@ -6759,16 +6844,16 @@ var Timer = ({ action, durationMinutes, durationSeconds, isPopup = false, onDism
|
|
6759
6844
|
return () => clearInterval(interval);
|
6760
6845
|
}, [timerActive, handleTimerEnd]);
|
6761
6846
|
const isUrgent = totalSeconds < 10;
|
6762
|
-
return /* @__PURE__ */ (0,
|
6763
|
-
/* @__PURE__ */ (0,
|
6764
|
-
/* @__PURE__ */ (0,
|
6847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: Timer_default["rebuy-timer__container"], children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { className: Timer_default["rebuy-timer__text"], children: [
|
6848
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: Timer_default["rebuy-timer__title"], children: title }),
|
6849
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
6765
6850
|
"span",
|
6766
6851
|
{
|
6767
6852
|
className: (0, import_clsx7.default)(Timer_default["rebuy-timer__display"], isUrgent && Timer_default["rebuy-timer__display--urgent"]),
|
6768
6853
|
children: [
|
6769
|
-
/* @__PURE__ */ (0,
|
6770
|
-
/* @__PURE__ */ (0,
|
6771
|
-
/* @__PURE__ */ (0,
|
6854
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: Timer_default["rebuy-timer__minutes"], children: formattedMinutes }),
|
6855
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: Timer_default["rebuy-timer__separator"], children: ":" }),
|
6856
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: Timer_default["rebuy-timer__seconds"], children: formattedSeconds })
|
6772
6857
|
]
|
6773
6858
|
}
|
6774
6859
|
)
|
@@ -6818,12 +6903,13 @@ var result17 = { "rebuy-widget__container": "RebuyWidget_rebuy-widget__container
|
|
6818
6903
|
var RebuyWidget_default = result17;
|
6819
6904
|
|
6820
6905
|
// src/widgets/RebuyWidget/WidgetContent.tsx
|
6821
|
-
var
|
6906
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
6822
6907
|
var WidgetContent = ({
|
6823
6908
|
addToCartCallback,
|
6824
6909
|
customTitle,
|
6825
6910
|
customTitleLevel,
|
6826
6911
|
customTitleStyle,
|
6912
|
+
isCrossSell,
|
6827
6913
|
isHydrogenReact,
|
6828
6914
|
isInPopup,
|
6829
6915
|
onDismiss,
|
@@ -6874,13 +6960,16 @@ var WidgetContent = ({
|
|
6874
6960
|
return null;
|
6875
6961
|
}
|
6876
6962
|
if (isCarousel) {
|
6877
|
-
return /* @__PURE__ */ (0,
|
6963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
6878
6964
|
ProductCarousel,
|
6879
6965
|
{
|
6880
6966
|
addToCartBtnText: settings?.language.add_to_cart,
|
6881
6967
|
addToCartCallback,
|
6882
6968
|
columns,
|
6969
|
+
isCrossSell,
|
6883
6970
|
isHydrogenReact,
|
6971
|
+
isInPopup,
|
6972
|
+
onPopupDismiss: onDismiss,
|
6884
6973
|
productCardTitleLevel,
|
6885
6974
|
products,
|
6886
6975
|
settings: productCardSettings,
|
@@ -6889,11 +6978,12 @@ var WidgetContent = ({
|
|
6889
6978
|
}
|
6890
6979
|
);
|
6891
6980
|
}
|
6892
|
-
return /* @__PURE__ */ (0,
|
6981
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: RebuyWidget_default["rebuy-widget__product-grid"], "data-columns": columns, role: "list", tabIndex: 0, children: products.map((product) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
6893
6982
|
ProductCard,
|
6894
6983
|
{
|
6895
6984
|
addToCartBtnText: settings?.language.add_to_cart,
|
6896
6985
|
addToCartCallback,
|
6986
|
+
isCrossSell,
|
6897
6987
|
isHydrogenReact,
|
6898
6988
|
isInPopup,
|
6899
6989
|
onPopupDismiss: onDismiss,
|
@@ -6904,8 +6994,8 @@ var WidgetContent = ({
|
|
6904
6994
|
}
|
6905
6995
|
) }, product.id)) });
|
6906
6996
|
};
|
6907
|
-
return /* @__PURE__ */ (0,
|
6908
|
-
hasTimer && /* @__PURE__ */ (0,
|
6997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: RebuyWidget_default["rebuy-widget__inner-content"], children: [
|
6998
|
+
hasTimer && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
6909
6999
|
Timer,
|
6910
7000
|
{
|
6911
7001
|
action: settings?.timer.action,
|
@@ -6916,7 +7006,7 @@ var WidgetContent = ({
|
|
6916
7006
|
title: settings?.language.timer_title
|
6917
7007
|
}
|
6918
7008
|
),
|
6919
|
-
hasSuperTitle && /* @__PURE__ */ (0,
|
7009
|
+
hasSuperTitle && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
6920
7010
|
Title,
|
6921
7011
|
{
|
6922
7012
|
level: getTitleLevel(customTitleLevel),
|
@@ -6924,7 +7014,7 @@ var WidgetContent = ({
|
|
6924
7014
|
text: settings.language.super_title
|
6925
7015
|
}
|
6926
7016
|
),
|
6927
|
-
hasPrimaryTitle && /* @__PURE__ */ (0,
|
7017
|
+
hasPrimaryTitle && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
6928
7018
|
Title,
|
6929
7019
|
{
|
6930
7020
|
level: getTitleLevel(customTitleLevel, hasSuperTitle ? true : false),
|
@@ -6932,19 +7022,20 @@ var WidgetContent = ({
|
|
6932
7022
|
text: primaryTitle
|
6933
7023
|
}
|
6934
7024
|
),
|
6935
|
-
hasDescription && /* @__PURE__ */ (0,
|
7025
|
+
hasDescription && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: RebuyWidget_default["rebuy-widget__description"], children: settings.language.description }),
|
6936
7026
|
renderProducts()
|
6937
7027
|
] });
|
6938
7028
|
};
|
6939
7029
|
|
6940
7030
|
// src/widgets/RebuyWidget/RebuyWidget.tsx
|
6941
|
-
var
|
7031
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6942
7032
|
var RebuyWidget = (props) => {
|
6943
7033
|
const {
|
6944
7034
|
addToCartCallback,
|
6945
7035
|
customTitle,
|
6946
7036
|
customTitleLevel = "h2",
|
6947
7037
|
customTitleStyle,
|
7038
|
+
isCrossSell,
|
6948
7039
|
isHydrogenReact,
|
6949
7040
|
popupTriggerId,
|
6950
7041
|
product,
|
@@ -7167,17 +7258,17 @@ var RebuyWidget = (props) => {
|
|
7167
7258
|
if (settings && !loadingSettings && shouldHideWidget) {
|
7168
7259
|
return null;
|
7169
7260
|
}
|
7170
|
-
return /* @__PURE__ */ (0,
|
7171
|
-
/* @__PURE__ */ (0,
|
7261
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: (settings || products?.length > 0) && !loadingSettings && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: RebuyWidget_default["rebuy-widget__container"], id: `rebuy-widget-${widgetId}`, children: settings?.display_type === "popup" && (settings.popup_trigger !== "add_to_cart" || settings.popup_trigger === "add_to_cart" && popupTriggerId) ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: showPopup && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: RebuyWidget_default["rebuy-widget__popup-overlay"], children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: RebuyWidget_default["rebuy-widget__popup-content"], ref: popupRef, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: RebuyWidget_default["rebuy-widget__content"], children: [
|
7262
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
7172
7263
|
"button",
|
7173
7264
|
{
|
7174
7265
|
"aria-label": "close modal",
|
7175
7266
|
className: RebuyWidget_default["rebuy-widget__modal-close"],
|
7176
7267
|
onClick: closePopup,
|
7177
|
-
children: /* @__PURE__ */ (0,
|
7268
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Close, {})
|
7178
7269
|
}
|
7179
7270
|
),
|
7180
|
-
/* @__PURE__ */ (0,
|
7271
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
7181
7272
|
WidgetContent,
|
7182
7273
|
{
|
7183
7274
|
addToCartCallback: () => {
|
@@ -7196,13 +7287,14 @@ var RebuyWidget = (props) => {
|
|
7196
7287
|
settings
|
7197
7288
|
}
|
7198
7289
|
)
|
7199
|
-
] }) }) }) }) : /* @__PURE__ */ (0,
|
7290
|
+
] }) }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: RebuyWidget_default["rebuy-widget__content"], children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
7200
7291
|
WidgetContent,
|
7201
7292
|
{
|
7202
7293
|
addToCartCallback,
|
7203
7294
|
customTitle,
|
7204
7295
|
customTitleLevel,
|
7205
7296
|
customTitleStyle,
|
7297
|
+
isCrossSell,
|
7206
7298
|
isHydrogenReact,
|
7207
7299
|
isInPopup: settings?.display_type === "popup",
|
7208
7300
|
products,
|
@@ -7212,14 +7304,14 @@ var RebuyWidget = (props) => {
|
|
7212
7304
|
};
|
7213
7305
|
|
7214
7306
|
// src/smart-cart/components/CrossSell/CrossSell.tsx
|
7215
|
-
var
|
7307
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
7216
7308
|
var CrossSell = ({ componentConfig }) => {
|
7217
7309
|
const widgetId = componentConfig.settings.widget_id;
|
7218
7310
|
if (!widgetId) {
|
7219
7311
|
console.warn("[CrossSell] Widget ID is missing from component configuration");
|
7220
7312
|
return null;
|
7221
7313
|
}
|
7222
|
-
return /* @__PURE__ */ (0,
|
7314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { "data-rebuy-component": "cross-sell-widget", "data-rebuy-component-id": widgetId, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(RebuyWidget, { isCrossSell: true, widgetId }) });
|
7223
7315
|
};
|
7224
7316
|
|
7225
7317
|
// src/smart-cart/components/CustomCode/CustomCodeBlock.tsx
|
@@ -7296,7 +7388,7 @@ var executeScriptsInContainer = (container, debugKey, debugContext) => {
|
|
7296
7388
|
};
|
7297
7389
|
|
7298
7390
|
// src/smart-cart/components/CustomCode/CustomCodeBlock.tsx
|
7299
|
-
var
|
7391
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
7300
7392
|
var CustomCodeBlock = import_react21.default.memo(({ componentConfig }) => {
|
7301
7393
|
const containerRef = (0, import_react21.useRef)(null);
|
7302
7394
|
const executedCodeRef = (0, import_react21.useRef)(null);
|
@@ -7323,7 +7415,7 @@ var CustomCodeBlock = import_react21.default.memo(({ componentConfig }) => {
|
|
7323
7415
|
if (!htmlCode) {
|
7324
7416
|
return null;
|
7325
7417
|
}
|
7326
|
-
return /* @__PURE__ */ (0,
|
7418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
7327
7419
|
"div",
|
7328
7420
|
{
|
7329
7421
|
dangerouslySetInnerHTML: { __html: htmlCode },
|
@@ -7425,7 +7517,7 @@ var result18 = { "rebuy-discount-code-input": "DiscountCodeInput_rebuy-discount-
|
|
7425
7517
|
var DiscountCodeInput_default = result18;
|
7426
7518
|
|
7427
7519
|
// src/smart-cart/components/DiscountCodeInput/DiscountCodeInput.tsx
|
7428
|
-
var
|
7520
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
7429
7521
|
var DiscountCodeInputComponent = ({ componentConfig }) => {
|
7430
7522
|
const {
|
7431
7523
|
applyDiscountCodes: hrApplyDiscountCodes,
|
@@ -7594,22 +7686,22 @@ var DiscountCodeInputComponent = ({ componentConfig }) => {
|
|
7594
7686
|
cartData
|
7595
7687
|
]);
|
7596
7688
|
if (!hasItems) return null;
|
7597
|
-
return /* @__PURE__ */ (0,
|
7689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
7598
7690
|
"div",
|
7599
7691
|
{
|
7600
7692
|
className: DiscountCodeInput_default["rebuy-discount-code-input"],
|
7601
7693
|
"data-rebuy-component": "discount-input",
|
7602
7694
|
"data-rebuy-component-id": componentConfig.component_id,
|
7603
7695
|
children: [
|
7604
|
-
/* @__PURE__ */ (0,
|
7605
|
-
/* @__PURE__ */ (0,
|
7696
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("form", { className: DiscountCodeInput_default["rebuy-discount-code-input__form"], onSubmit: handleApply, children: [
|
7697
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
7606
7698
|
"div",
|
7607
7699
|
{
|
7608
7700
|
className: (0, import_clsx8.default)(DiscountCodeInput_default["rebuy-discount-code-input__input-wrapper"], {
|
7609
7701
|
[DiscountCodeInput_default["rebuy-discount-code-input__input-wrapper--show-label"]]: !!inputValue || isInputFocused
|
7610
7702
|
}),
|
7611
7703
|
children: [
|
7612
|
-
/* @__PURE__ */ (0,
|
7704
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
7613
7705
|
"input",
|
7614
7706
|
{
|
7615
7707
|
"aria-label": lang.inputLabel,
|
@@ -7630,7 +7722,7 @@ var DiscountCodeInputComponent = ({ componentConfig }) => {
|
|
7630
7722
|
value: inputValue
|
7631
7723
|
}
|
7632
7724
|
),
|
7633
|
-
/* @__PURE__ */ (0,
|
7725
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
7634
7726
|
"label",
|
7635
7727
|
{
|
7636
7728
|
className: DiscountCodeInput_default["rebuy-discount-code-input__input-label"],
|
@@ -7641,7 +7733,7 @@ var DiscountCodeInputComponent = ({ componentConfig }) => {
|
|
7641
7733
|
]
|
7642
7734
|
}
|
7643
7735
|
),
|
7644
|
-
/* @__PURE__ */ (0,
|
7736
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
7645
7737
|
"button",
|
7646
7738
|
{
|
7647
7739
|
className: DiscountCodeInput_default["rebuy-discount-code-input__apply-button"],
|
@@ -7651,11 +7743,11 @@ var DiscountCodeInputComponent = ({ componentConfig }) => {
|
|
7651
7743
|
}
|
7652
7744
|
)
|
7653
7745
|
] }),
|
7654
|
-
discountManagerError && /* @__PURE__ */ (0,
|
7655
|
-
shouldShowTags && /* @__PURE__ */ (0,
|
7656
|
-
/* @__PURE__ */ (0,
|
7657
|
-
/* @__PURE__ */ (0,
|
7658
|
-
/* @__PURE__ */ (0,
|
7746
|
+
discountManagerError && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: DiscountCodeInput_default["rebuy-discount-code-input__error-message"], children: discountManagerError }),
|
7747
|
+
shouldShowTags && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: DiscountCodeInput_default["rebuy-discount-code-input__tags-list"], children: appliedCodes.map((code) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: DiscountCodeInput_default["rebuy-discount-code-input__tag"], children: [
|
7748
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: DiscountCodeInput_default["rebuy-discount-code-input__tag-icon"], children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("svg", { fill: "currentColor", height: "14", viewBox: "0 0 24 24", width: "14", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { d: "M21.41 11.58l-9-9C12.05 2.22 11.55 2 11 2H4c-1.1 0-2 .9-2 2v7c0 .55.22 1.05.59 1.42l9 9c.36.36.86.58 1.41.58.55 0 1.05-.22 1.41-.59l7-7c.37-.36.59-.86.59-1.41 0-.55-.23-1.06-.59-1.42zM5.5 7C4.67 7 4 6.33 4 5.5S4.67 4 5.5 4 7 4.67 7 5.5 6.33 7 5.5 7z" }) }) }),
|
7749
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: DiscountCodeInput_default["rebuy-discount-code-input__tag-text"], children: code }),
|
7750
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
7659
7751
|
"button",
|
7660
7752
|
{
|
7661
7753
|
"aria-label": `Remove discount code ${code}`,
|
@@ -7682,7 +7774,7 @@ var result19 = { "rebuy-login-button": "LoginButton_rebuy-login-button" };
|
|
7682
7774
|
var LoginButton_default = result19;
|
7683
7775
|
|
7684
7776
|
// src/smart-cart/components/LoginButton/LoginButton.tsx
|
7685
|
-
var
|
7777
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
7686
7778
|
var LoginButton = import_react24.default.memo(() => {
|
7687
7779
|
const { cartData, getComponentConfigByType } = useSmartCart();
|
7688
7780
|
const componentConfig = getComponentConfigByType("login");
|
@@ -7696,13 +7788,14 @@ var LoginButton = import_react24.default.memo(() => {
|
|
7696
7788
|
}
|
7697
7789
|
const loginLabel = componentConfig?.settings?.language?.title ?? "Login";
|
7698
7790
|
const loginUrl = componentConfig?.settings?.url ?? "/account/login";
|
7699
|
-
return /* @__PURE__ */ (0,
|
7700
|
-
|
7791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
7792
|
+
RebuyLink,
|
7701
7793
|
{
|
7794
|
+
ariaLabel: loginLabel,
|
7702
7795
|
className: LoginButton_default["rebuy-login-button"],
|
7703
7796
|
"data-rebuy-component": "login",
|
7704
7797
|
"data-rebuy-component-id": componentConfig.component_id ?? "login",
|
7705
|
-
|
7798
|
+
handle: loginUrl,
|
7706
7799
|
children: loginLabel
|
7707
7800
|
}
|
7708
7801
|
);
|
@@ -7919,7 +8012,7 @@ var useSmartCartApps = () => {
|
|
7919
8012
|
};
|
7920
8013
|
|
7921
8014
|
// src/smart-cart/components/SmartCartApp/SmartCartApp.tsx
|
7922
|
-
var
|
8015
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
7923
8016
|
var SmartCartApp = import_react26.default.memo(({ componentConfig }) => {
|
7924
8017
|
const containerRef = (0, import_react26.useRef)(null);
|
7925
8018
|
const executedScriptRef = (0, import_react26.useRef)(null);
|
@@ -7951,7 +8044,7 @@ var SmartCartApp = import_react26.default.memo(({ componentConfig }) => {
|
|
7951
8044
|
}
|
7952
8045
|
}, [scriptContent, appId, componentId]);
|
7953
8046
|
if (appsLoading) {
|
7954
|
-
return /* @__PURE__ */ (0,
|
8047
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { "data-rebuy-component-id": componentId, children: [
|
7955
8048
|
"Loading App (",
|
7956
8049
|
appId ?? "N/A",
|
7957
8050
|
")..."
|
@@ -7959,7 +8052,7 @@ var SmartCartApp = import_react26.default.memo(({ componentConfig }) => {
|
|
7959
8052
|
}
|
7960
8053
|
if (appsHookError) {
|
7961
8054
|
console.error(`[SmartCartApp - ${componentId}] Hook error prevented app rendering: ${appsHookError}`);
|
7962
|
-
return /* @__PURE__ */ (0,
|
8055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { "data-rebuy-component-id": componentId, children: "Error loading app data." });
|
7963
8056
|
}
|
7964
8057
|
if (appId === null) {
|
7965
8058
|
console.warn(`[SmartCartApp - ${componentId}] Missing App ID (settings.app_id) in configuration.`);
|
@@ -7972,7 +8065,7 @@ var SmartCartApp = import_react26.default.memo(({ componentConfig }) => {
|
|
7972
8065
|
);
|
7973
8066
|
return null;
|
7974
8067
|
}
|
7975
|
-
return /* @__PURE__ */ (0,
|
8068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7976
8069
|
"div",
|
7977
8070
|
{
|
7978
8071
|
dangerouslySetInnerHTML: { __html: scriptContent },
|
@@ -7999,7 +8092,7 @@ var result20 = { "rebuy-tiered-progress-bar": "TieredProgressBar_rebuy-tiered-pr
|
|
7999
8092
|
var TieredProgressBar_default = result20;
|
8000
8093
|
|
8001
8094
|
// src/smart-cart/components/TieredProgressBar/TPBGiftItem.tsx
|
8002
|
-
var
|
8095
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
8003
8096
|
var TieredProgressBarGiftItem = ({
|
8004
8097
|
isGloballySyncing,
|
8005
8098
|
onAddOrReAdd,
|
@@ -8025,14 +8118,14 @@ var TieredProgressBarGiftItem = ({
|
|
8025
8118
|
const imageAlt = image?.altText ?? title;
|
8026
8119
|
const isDisabled = isGloballySyncing || !!error;
|
8027
8120
|
const itemLevelError = error;
|
8028
|
-
return /* @__PURE__ */ (0,
|
8121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
8029
8122
|
"div",
|
8030
8123
|
{
|
8031
8124
|
className: (0, import_clsx9.default)(TieredProgressBar_default["rebuy-tiered-progress-bar__gift-item"], {
|
8032
8125
|
[TieredProgressBar_default["rebuy-tiered-progress-bar__gift-item--syncing"]]: isGloballySyncing
|
8033
8126
|
}),
|
8034
8127
|
children: [
|
8035
|
-
/* @__PURE__ */ (0,
|
8128
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__gift-item-image-wrapper"], children: imageSrc ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
8036
8129
|
"img",
|
8037
8130
|
{
|
8038
8131
|
alt: imageAlt,
|
@@ -8040,24 +8133,24 @@ var TieredProgressBarGiftItem = ({
|
|
8040
8133
|
loading: "lazy",
|
8041
8134
|
src: imageSrc
|
8042
8135
|
}
|
8043
|
-
) : /* @__PURE__ */ (0,
|
8136
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
8044
8137
|
"div",
|
8045
8138
|
{
|
8046
8139
|
"aria-label": "Gift product image placeholder",
|
8047
8140
|
className: TieredProgressBar_default["rebuy-tiered-progress-bar__gift-item-image"]
|
8048
8141
|
}
|
8049
8142
|
) }),
|
8050
|
-
/* @__PURE__ */ (0,
|
8051
|
-
/* @__PURE__ */ (0,
|
8052
|
-
displayStatus === "added" /* ADDED */ && displayVariantTitle && /* @__PURE__ */ (0,
|
8053
|
-
/* @__PURE__ */ (0,
|
8054
|
-
isGloballySyncing && /* @__PURE__ */ (0,
|
8055
|
-
itemLevelError && !isGloballySyncing && /* @__PURE__ */ (0,
|
8143
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__gift-item-details"], children: [
|
8144
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h4", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__gift-item-title"], id: `tpb-gift-${tierId}-title`, children: title }),
|
8145
|
+
displayStatus === "added" /* ADDED */ && displayVariantTitle && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__gift-item-variant-title"], children: displayVariantTitle }),
|
8146
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__gift-item-actions-wrapper"], children: [
|
8147
|
+
isGloballySyncing && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("button", { className: (0, import_clsx9.default)(TieredProgressBar_default["rebuy-tiered-progress-bar__gift-item-button"]), disabled: true, children: "Updating..." }),
|
8148
|
+
itemLevelError && !isGloballySyncing && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__error-message"], children: [
|
8056
8149
|
"Error: ",
|
8057
8150
|
itemLevelError
|
8058
8151
|
] }),
|
8059
|
-
!isGloballySyncing && !itemLevelError && /* @__PURE__ */ (0,
|
8060
|
-
displayStatus === "added" /* ADDED */ && /* @__PURE__ */ (0,
|
8152
|
+
!isGloballySyncing && !itemLevelError && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
8153
|
+
displayStatus === "added" /* ADDED */ && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
8061
8154
|
"button",
|
8062
8155
|
{
|
8063
8156
|
"aria-label": `Remove ${title} gift`,
|
@@ -8070,7 +8163,7 @@ var TieredProgressBarGiftItem = ({
|
|
8070
8163
|
children: "Remove"
|
8071
8164
|
}
|
8072
8165
|
),
|
8073
|
-
displayStatus === "needs_selection" /* NEEDS_SELECTION */ && /* @__PURE__ */ (0,
|
8166
|
+
displayStatus === "needs_selection" /* NEEDS_SELECTION */ && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
8074
8167
|
"select",
|
8075
8168
|
{
|
8076
8169
|
"aria-label": `Select option for ${title}`,
|
@@ -8079,10 +8172,10 @@ var TieredProgressBarGiftItem = ({
|
|
8079
8172
|
onChange: handleVariantChange,
|
8080
8173
|
value: "",
|
8081
8174
|
children: [
|
8082
|
-
/* @__PURE__ */ (0,
|
8175
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("option", { disabled: true, value: "", children: "Select Option" }),
|
8083
8176
|
availableChoices.map((variant) => {
|
8084
8177
|
const variantLabel = getFreeVariantTitle(variant) || variant.title;
|
8085
|
-
return /* @__PURE__ */ (0,
|
8178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("option", { value: variant.id, children: [
|
8086
8179
|
variantLabel,
|
8087
8180
|
" (",
|
8088
8181
|
formatMoney(variant.price.amount),
|
@@ -8092,7 +8185,7 @@ var TieredProgressBarGiftItem = ({
|
|
8092
8185
|
]
|
8093
8186
|
}
|
8094
8187
|
),
|
8095
|
-
canReAdd && displayStatus === "declined" /* DECLINED */ && /* @__PURE__ */ (0,
|
8188
|
+
canReAdd && displayStatus === "declined" /* DECLINED */ && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
8096
8189
|
"button",
|
8097
8190
|
{
|
8098
8191
|
"aria-label": `Re-add ${title} gift`,
|
@@ -8105,7 +8198,7 @@ var TieredProgressBarGiftItem = ({
|
|
8105
8198
|
children: "Re-Add Gift"
|
8106
8199
|
}
|
8107
8200
|
),
|
8108
|
-
displayStatus === "unavailable" /* UNAVAILABLE */ && !canReAdd && /* @__PURE__ */ (0,
|
8201
|
+
displayStatus === "unavailable" /* UNAVAILABLE */ && !canReAdd && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__gift-item-status-text"], children: "Unavailable" })
|
8109
8202
|
] })
|
8110
8203
|
] })
|
8111
8204
|
] })
|
@@ -8191,7 +8284,7 @@ var codeBlock = {
|
|
8191
8284
|
};
|
8192
8285
|
|
8193
8286
|
// src/smart-cart/components/TieredProgressBar/TieredProgressBar.tsx
|
8194
|
-
var
|
8287
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
8195
8288
|
var TieredProgressBar = import_react27.default.memo(() => {
|
8196
8289
|
const { hydrogenReactCartActions, isCartBusy, isHydrogenReact } = useSmartCart();
|
8197
8290
|
const tpbUserActionFetcher = (0, import_react_router8.useFetcher)();
|
@@ -8370,9 +8463,9 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8370
8463
|
const progressBarId = `tpb-main-${activeBarConfig.id}`;
|
8371
8464
|
const feedbackId = `tpb-feedback-text-${activeBarConfig.id}`;
|
8372
8465
|
const giftAreaTitleId = `tpb-giftarea-title-${activeBarConfig.id}`;
|
8373
|
-
return /* @__PURE__ */ (0,
|
8374
|
-
/* @__PURE__ */ (0,
|
8375
|
-
/* @__PURE__ */ (0,
|
8466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar"], "data-rebuy-component": "tiered-progress-bar", children: [
|
8467
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__main-progress-area"], id: progressBarId, children: [
|
8468
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__tier-markers-list"], children: activeBarConfig.tiers.map((tier) => {
|
8376
8469
|
const isReached = checkTierReachedCallback(tier);
|
8377
8470
|
const tierLabel = getTierLabel(tier, fetchedProductMap);
|
8378
8471
|
const iconRenderData = getTierIconComponent(tier, isReached, fetchedProductMap);
|
@@ -8387,7 +8480,7 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8387
8480
|
if (import_react27.default.isValidElement(iconRenderData)) iconElement = iconRenderData;
|
8388
8481
|
else if (iconRenderData.type === "image") {
|
8389
8482
|
const imageObject = iconRenderData;
|
8390
|
-
iconElement = /* @__PURE__ */ (0,
|
8483
|
+
iconElement = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
8391
8484
|
"img",
|
8392
8485
|
{
|
8393
8486
|
alt: imageObject.alt,
|
@@ -8396,7 +8489,7 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8396
8489
|
}
|
8397
8490
|
);
|
8398
8491
|
} else iconElement = null;
|
8399
|
-
return /* @__PURE__ */ (0,
|
8492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
8400
8493
|
"div",
|
8401
8494
|
{
|
8402
8495
|
className: (0, import_clsx10.default)(TieredProgressBar_default["rebuy-tiered-progress-bar__tier-step"], {
|
@@ -8404,7 +8497,7 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8404
8497
|
}),
|
8405
8498
|
title: `${tierLabel} (${isReached ? "Reached" : "Pending"} at ${formatMoney(getTierMinimum(tier))})`,
|
8406
8499
|
children: [
|
8407
|
-
/* @__PURE__ */ (0,
|
8500
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
8408
8501
|
"div",
|
8409
8502
|
{
|
8410
8503
|
className: TieredProgressBar_default["rebuy-tiered-progress-bar__tier-icon-wrapper"],
|
@@ -8412,13 +8505,13 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8412
8505
|
children: iconElement
|
8413
8506
|
}
|
8414
8507
|
),
|
8415
|
-
/* @__PURE__ */ (0,
|
8508
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__tier-label"], children: tierLabel })
|
8416
8509
|
]
|
8417
8510
|
},
|
8418
8511
|
tier.id
|
8419
8512
|
);
|
8420
8513
|
}) }),
|
8421
|
-
/* @__PURE__ */ (0,
|
8514
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__track"], children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
8422
8515
|
"div",
|
8423
8516
|
{
|
8424
8517
|
"aria-label": "Reward progress",
|
@@ -8432,25 +8525,25 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8432
8525
|
}
|
8433
8526
|
) })
|
8434
8527
|
] }),
|
8435
|
-
/* @__PURE__ */ (0,
|
8528
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { "aria-live": "polite", className: TieredProgressBar_default["rebuy-tiered-progress-bar__feedback-message"], id: feedbackId, children: [
|
8436
8529
|
(isContextLoading || productFetchStatus === "loading") && !feedbackText ? "Loading rewards..." : feedbackText,
|
8437
|
-
productFetchError && /* @__PURE__ */ (0,
|
8530
|
+
productFetchError && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__error-message"], children: [
|
8438
8531
|
"Could not load reward info.",
|
8439
8532
|
rebuyDebugLog.isKeyActive("smart-cart-tpb" /* SC_TPB */) && ` Details: ${productFetchError}`
|
8440
8533
|
] }),
|
8441
|
-
cartSyncError && /* @__PURE__ */ (0,
|
8534
|
+
cartSyncError && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__error-message"], children: [
|
8442
8535
|
"Could not update rewards.",
|
8443
8536
|
rebuyDebugLog.isKeyActive("smart-cart-tpb" /* SC_TPB */) && ` Details: ${cartSyncError}`
|
8444
8537
|
] }),
|
8445
|
-
userActionError && /* @__PURE__ */ (0,
|
8538
|
+
userActionError && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__error-message"], children: [
|
8446
8539
|
"Error: ",
|
8447
8540
|
userActionError.message
|
8448
8541
|
] })
|
8449
8542
|
] }),
|
8450
|
-
renderGiftArea && /* @__PURE__ */ (0,
|
8451
|
-
renderGiftAreaTitle && /* @__PURE__ */ (0,
|
8543
|
+
renderGiftArea && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__gift-area"], children: [
|
8544
|
+
renderGiftAreaTitle && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("h3", { className: TieredProgressBar_default["rebuy-tiered-progress-bar__gift-area-title"], id: giftAreaTitleId, children: giftAreaTitle }),
|
8452
8545
|
shouldDisableGiftActions && // If actions are disabled (likely loading something)
|
8453
|
-
productsToRenderInGiftArea.length === 0 && !productFetchError && !cartSyncError && !userActionError && /* @__PURE__ */ (0,
|
8546
|
+
productsToRenderInGiftArea.length === 0 && !productFetchError && !cartSyncError && !userActionError && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
8454
8547
|
"div",
|
8455
8548
|
{
|
8456
8549
|
style: {
|
@@ -8460,12 +8553,12 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8460
8553
|
children: "Loading gifts..."
|
8461
8554
|
}
|
8462
8555
|
),
|
8463
|
-
productsToRenderInGiftArea.length > 0 && /* @__PURE__ */ (0,
|
8556
|
+
productsToRenderInGiftArea.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
8464
8557
|
"div",
|
8465
8558
|
{
|
8466
8559
|
"aria-labelledby": renderGiftAreaTitle ? giftAreaTitleId : void 0,
|
8467
8560
|
className: TieredProgressBar_default["rebuy-tiered-progress-bar__gift-items-list"],
|
8468
|
-
children: productsToRenderInGiftArea.map((productState) => /* @__PURE__ */ (0,
|
8561
|
+
children: productsToRenderInGiftArea.map((productState) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
8469
8562
|
TieredProgressBarGiftItem,
|
8470
8563
|
{
|
8471
8564
|
isGloballySyncing: shouldDisableGiftActions,
|
@@ -8479,7 +8572,7 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8479
8572
|
}
|
8480
8573
|
)
|
8481
8574
|
] }),
|
8482
|
-
rebuyDebugLog.isKeyActive("smart-cart-tpb" /* SC_TPB */) && /* @__PURE__ */ (0,
|
8575
|
+
rebuyDebugLog.isKeyActive("smart-cart-tpb" /* SC_TPB */) && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
8483
8576
|
"button",
|
8484
8577
|
{
|
8485
8578
|
onClick: () => setShowDebugPanel(!showDebugPanel),
|
@@ -8491,7 +8584,7 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8491
8584
|
children: showDebugPanel ? "Hide Debug Panel" : "Show Debug Panel"
|
8492
8585
|
}
|
8493
8586
|
),
|
8494
|
-
rebuyDebugLog.isKeyActive("smart-cart-tpb" /* SC_TPB */) && showDebugPanel && /* @__PURE__ */ (0,
|
8587
|
+
rebuyDebugLog.isKeyActive("smart-cart-tpb" /* SC_TPB */) && showDebugPanel && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
8495
8588
|
"div",
|
8496
8589
|
{
|
8497
8590
|
style: {
|
@@ -8502,38 +8595,38 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8502
8595
|
width: "100%"
|
8503
8596
|
},
|
8504
8597
|
children: [
|
8505
|
-
/* @__PURE__ */ (0,
|
8506
|
-
/* @__PURE__ */ (0,
|
8507
|
-
/* @__PURE__ */ (0,
|
8598
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { style: infoText, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("strong", { children: "Progress Bar Debug Info" }) }),
|
8599
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { style: codeBlock, children: [
|
8600
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { children: [
|
8508
8601
|
"Subtotal: ",
|
8509
8602
|
formatMoney(currentSubtotal)
|
8510
8603
|
] }),
|
8511
|
-
/* @__PURE__ */ (0,
|
8604
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { children: [
|
8512
8605
|
"Visual Progress: ",
|
8513
8606
|
visualPercentageComplete.toFixed(0),
|
8514
8607
|
"%"
|
8515
8608
|
] }),
|
8516
|
-
/* @__PURE__ */ (0,
|
8609
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { children: [
|
8517
8610
|
"Actual Progress: ",
|
8518
8611
|
realPercentageComplete.toFixed(0),
|
8519
8612
|
"%"
|
8520
8613
|
] }),
|
8521
|
-
amountToNextTier > 0 && /* @__PURE__ */ (0,
|
8614
|
+
amountToNextTier > 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { children: [
|
8522
8615
|
"To Next Tier: ",
|
8523
8616
|
formatMoney(amountToNextTier)
|
8524
8617
|
] }),
|
8525
|
-
currentTier && /* @__PURE__ */ (0,
|
8618
|
+
currentTier && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { children: [
|
8526
8619
|
"Current Tier: ",
|
8527
8620
|
getTierLabel(currentTier)
|
8528
8621
|
] }),
|
8529
|
-
cartSyncError && /* @__PURE__ */ (0,
|
8622
|
+
cartSyncError && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { style: { color: "#f66" }, children: [
|
8530
8623
|
"Error: ",
|
8531
8624
|
cartSyncError
|
8532
8625
|
] })
|
8533
8626
|
] }),
|
8534
|
-
giftsForDisplay.length > 0 && /* @__PURE__ */ (0,
|
8535
|
-
/* @__PURE__ */ (0,
|
8536
|
-
/* @__PURE__ */ (0,
|
8627
|
+
giftsForDisplay.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { style: { marginTop: "8px" }, children: [
|
8628
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { style: infoText, children: "Gift Status:" }),
|
8629
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { style: codeBlock, children: giftsForDisplay.map((gift, idx) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { style: { marginBottom: "4px" }, children: [
|
8537
8630
|
"Tier ",
|
8538
8631
|
gift.tierId,
|
8539
8632
|
": ",
|
@@ -8549,7 +8642,7 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8549
8642
|
TieredProgressBar.displayName = "TieredProgressBar";
|
8550
8643
|
|
8551
8644
|
// src/smart-cart/components/componentRegistry.tsx
|
8552
|
-
var
|
8645
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
8553
8646
|
var componentRegistry = {
|
8554
8647
|
// Use 'any' for props initially, refine later
|
8555
8648
|
announcement_bar: AnnouncementBar,
|
@@ -8568,7 +8661,7 @@ var componentRegistry = {
|
|
8568
8661
|
};
|
8569
8662
|
|
8570
8663
|
// src/smart-cart/components/_Layouts/AnchorSlot.tsx
|
8571
|
-
var
|
8664
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
8572
8665
|
var AnchorSlot = ({ anchor, components, excludeTypes, includeTypes }) => {
|
8573
8666
|
const componentsForSlot = (0, import_react28.useMemo)(() => {
|
8574
8667
|
return components.filter((comp) => {
|
@@ -8586,13 +8679,13 @@ var AnchorSlot = ({ anchor, components, excludeTypes, includeTypes }) => {
|
|
8586
8679
|
});
|
8587
8680
|
return null;
|
8588
8681
|
}
|
8589
|
-
return /* @__PURE__ */ (0,
|
8682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children: componentsForSlot.map((componentConfig) => {
|
8590
8683
|
const Component = componentRegistry[componentConfig.type];
|
8591
8684
|
if (!Component) {
|
8592
8685
|
console.warn(`[SmartCartReact] No component registered for type: "${componentConfig.type}"`);
|
8593
8686
|
return null;
|
8594
8687
|
}
|
8595
|
-
return /* @__PURE__ */ (0,
|
8688
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Component, { componentConfig }, componentConfig.component_id);
|
8596
8689
|
}) });
|
8597
8690
|
};
|
8598
8691
|
|
@@ -8624,15 +8717,15 @@ var result21 = { "rebuy-smart-cart-layout__anchor-goal-box": "LayoutStyles_rebuy
|
|
8624
8717
|
var LayoutStyles_default = result21;
|
8625
8718
|
|
8626
8719
|
// src/smart-cart/components/_Layouts/DoubleColumnLayout.tsx
|
8627
|
-
var
|
8720
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
8628
8721
|
var DoubleColumnLayout = ({ components, itemCount, layout }) => {
|
8629
8722
|
const scrollAreaRef = (0, import_react30.useRef)(null);
|
8630
8723
|
const isScrolled = useIsScrolled(scrollAreaRef);
|
8631
8724
|
const layoutClass = layout === "double-right" ? LayoutStyles_default["rebuy-smart-cart-layout__flyout-inner--double-right"] : LayoutStyles_default["rebuy-smart-cart-layout__flyout-inner--double"];
|
8632
|
-
return /* @__PURE__ */ (0,
|
8633
|
-
/* @__PURE__ */ (0,
|
8634
|
-
/* @__PURE__ */ (0,
|
8635
|
-
/* @__PURE__ */ (0,
|
8725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: (0, import_clsx11.default)(LayoutStyles_default["rebuy-smart-cart-layout__flyout-inner"], layoutClass), children: [
|
8726
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: LayoutStyles_default["rebuy-smart-cart-layout__column--primary"], children: [
|
8727
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: LayoutStyles_default["rebuy-smart-cart-layout__anchor-goal-box"], "data-rebuy-cart-anchor": "goalBox", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AnchorSlot, { anchor: "goalBox", components }) }),
|
8728
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
8636
8729
|
"div",
|
8637
8730
|
{
|
8638
8731
|
className: (0, import_clsx11.default)(
|
@@ -8641,26 +8734,26 @@ var DoubleColumnLayout = ({ components, itemCount, layout }) => {
|
|
8641
8734
|
),
|
8642
8735
|
"data-rebuy-cart-scroll-area": true,
|
8643
8736
|
ref: scrollAreaRef,
|
8644
|
-
children: /* @__PURE__ */ (0,
|
8737
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: LayoutStyles_default["rebuy-smart-cart-layout__anchor-body"], "data-rebuy-cart-anchor": "body", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AnchorSlot, { anchor: "body", components }) })
|
8645
8738
|
}
|
8646
8739
|
),
|
8647
|
-
/* @__PURE__ */ (0,
|
8740
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
8648
8741
|
"div",
|
8649
8742
|
{
|
8650
8743
|
className: (0, import_clsx11.default)(LayoutStyles_default["rebuy-smart-cart-layout__anchor-footer"], {
|
8651
8744
|
[LayoutStyles_default["rebuy-smart-cart-layout__anchor-footer--hidden"]]: itemCount === 0
|
8652
8745
|
}),
|
8653
8746
|
"data-rebuy-cart-anchor": "footer",
|
8654
|
-
children: /* @__PURE__ */ (0,
|
8747
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AnchorSlot, { anchor: "footer", components })
|
8655
8748
|
}
|
8656
8749
|
)
|
8657
8750
|
] }),
|
8658
|
-
/* @__PURE__ */ (0,
|
8751
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: LayoutStyles_default["rebuy-smart-cart-layout__column--secondary"], children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
8659
8752
|
"div",
|
8660
8753
|
{
|
8661
8754
|
className: LayoutStyles_default["rebuy-smart-cart-layout__anchor-cross-sells"],
|
8662
8755
|
"data-rebuy-cart-anchor": "crossSells",
|
8663
|
-
children: /* @__PURE__ */ (0,
|
8756
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AnchorSlot, { anchor: "crossSells", components })
|
8664
8757
|
}
|
8665
8758
|
) })
|
8666
8759
|
] });
|
@@ -8669,13 +8762,13 @@ var DoubleColumnLayout = ({ components, itemCount, layout }) => {
|
|
8669
8762
|
// src/smart-cart/components/_Layouts/SingleColumnLayout.tsx
|
8670
8763
|
var import_clsx12 = __toESM(require("clsx"), 1);
|
8671
8764
|
var import_react31 = require("react");
|
8672
|
-
var
|
8765
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
8673
8766
|
var SingleColumnLayout = ({ components, itemCount }) => {
|
8674
8767
|
const scrollAreaRef = (0, import_react31.useRef)(null);
|
8675
8768
|
const isScrolled = useIsScrolled(scrollAreaRef);
|
8676
|
-
return /* @__PURE__ */ (0,
|
8677
|
-
/* @__PURE__ */ (0,
|
8678
|
-
/* @__PURE__ */ (0,
|
8769
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
8770
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: LayoutStyles_default["rebuy-smart-cart-layout__anchor-goal-box"], "data-rebuy-cart-anchor": "goalBox", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(AnchorSlot, { anchor: "goalBox", components }) }),
|
8771
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
8679
8772
|
"div",
|
8680
8773
|
{
|
8681
8774
|
className: (0, import_clsx12.default)(
|
@@ -8684,17 +8777,17 @@ var SingleColumnLayout = ({ components, itemCount }) => {
|
|
8684
8777
|
),
|
8685
8778
|
"data-rebuy-cart-scroll-area": true,
|
8686
8779
|
ref: scrollAreaRef,
|
8687
|
-
children: /* @__PURE__ */ (0,
|
8780
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: LayoutStyles_default["rebuy-smart-cart-layout__anchor-body"], "data-rebuy-cart-anchor": "body", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(AnchorSlot, { anchor: "body", components }) })
|
8688
8781
|
}
|
8689
8782
|
),
|
8690
|
-
/* @__PURE__ */ (0,
|
8783
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
8691
8784
|
"div",
|
8692
8785
|
{
|
8693
8786
|
className: (0, import_clsx12.default)(LayoutStyles_default["rebuy-smart-cart-layout__anchor-footer"], {
|
8694
8787
|
[LayoutStyles_default["rebuy-smart-cart-layout__anchor-footer--hidden"]]: itemCount === 0
|
8695
8788
|
}),
|
8696
8789
|
"data-rebuy-cart-anchor": "footer",
|
8697
|
-
children: /* @__PURE__ */ (0,
|
8790
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(AnchorSlot, { anchor: "footer", components })
|
8698
8791
|
}
|
8699
8792
|
)
|
8700
8793
|
] });
|
@@ -8705,12 +8798,37 @@ var result22 = { "rebuy-smart-cart": "SmartCartContainer_rebuy-smart-cart", "reb
|
|
8705
8798
|
var SmartCartContainer_default = result22;
|
8706
8799
|
|
8707
8800
|
// src/smart-cart/components/SmartCartContainer/SmartCartContainer.tsx
|
8708
|
-
var
|
8801
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
8709
8802
|
var SmartCartContainer = ({ containerId }) => {
|
8710
|
-
const {
|
8803
|
+
const { config, getItemCount, hideCart, isVisible } = useSmartCart();
|
8804
|
+
const containerRef = (0, import_react32.useRef)(null);
|
8805
|
+
const previousFocusRef = (0, import_react32.useRef)(null);
|
8711
8806
|
const components = (0, import_react32.useMemo)(() => config && Array.isArray(config.components) ? config.components : [], [config]);
|
8712
|
-
const
|
8713
|
-
|
8807
|
+
const handleClose = (0, import_react32.useCallback)(() => {
|
8808
|
+
hideCart();
|
8809
|
+
if (previousFocusRef.current) {
|
8810
|
+
previousFocusRef.current.focus();
|
8811
|
+
}
|
8812
|
+
}, [hideCart]);
|
8813
|
+
(0, import_react32.useEffect)(() => {
|
8814
|
+
if (isVisible) {
|
8815
|
+
previousFocusRef.current = document.activeElement;
|
8816
|
+
const closeButton = containerRef.current?.querySelector("#rebuy-cart-close");
|
8817
|
+
if (closeButton instanceof HTMLElement) {
|
8818
|
+
closeButton.focus();
|
8819
|
+
}
|
8820
|
+
}
|
8821
|
+
}, [isVisible]);
|
8822
|
+
(0, import_react32.useEffect)(() => {
|
8823
|
+
if (isVisible) {
|
8824
|
+
document.body.classList.add("rebuy-smart-cart-open");
|
8825
|
+
} else {
|
8826
|
+
document.body.classList.remove("rebuy-smart-cart-open");
|
8827
|
+
}
|
8828
|
+
return () => {
|
8829
|
+
document.body.classList.remove("rebuy-smart-cart-open");
|
8830
|
+
};
|
8831
|
+
}, [isVisible]);
|
8714
8832
|
const backgroundClassName = (0, import_clsx13.default)(SmartCartContainer_default["rebuy-smart-cart__overlay-background"], {
|
8715
8833
|
[SmartCartContainer_default["rebuy-smart-cart__overlay-background--visible"]]: isVisible
|
8716
8834
|
});
|
@@ -8723,40 +8841,41 @@ var SmartCartContainer = ({ containerId }) => {
|
|
8723
8841
|
}
|
8724
8842
|
);
|
8725
8843
|
const renderLayoutContent = () => {
|
8726
|
-
if (!config) return /* @__PURE__ */ (0,
|
8844
|
+
if (!config) return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { style: { padding: "20px", textAlign: "center" }, children: "Loading configuration..." });
|
8727
8845
|
switch (config.layout) {
|
8728
8846
|
case "double":
|
8729
8847
|
case "double-right":
|
8730
|
-
return /* @__PURE__ */ (0,
|
8848
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DoubleColumnLayout, { components, itemCount: getItemCount(), layout: config.layout });
|
8731
8849
|
default:
|
8732
|
-
return /* @__PURE__ */ (0,
|
8850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SingleColumnLayout, { components, itemCount: getItemCount() });
|
8733
8851
|
}
|
8734
8852
|
};
|
8735
8853
|
const defaultTitleId = "rebuy-smart-cart-default-title";
|
8736
8854
|
const titleBarComponent = components.find((c) => c.type === "title_bar");
|
8737
8855
|
const ariaLabelledBy = titleBarComponent ? `rebuy-title-${titleBarComponent.component_id}` : defaultTitleId;
|
8738
|
-
return /* @__PURE__ */ (0,
|
8739
|
-
/* @__PURE__ */ (0,
|
8740
|
-
/* @__PURE__ */ (0,
|
8856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_react32.default.Fragment, { children: [
|
8857
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: backgroundClassName, onClick: handleClose }),
|
8858
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
8741
8859
|
"div",
|
8742
8860
|
{
|
8743
|
-
"aria-hidden": !isVisible,
|
8744
8861
|
"aria-labelledby": ariaLabelledBy,
|
8745
8862
|
"aria-modal": "true",
|
8746
8863
|
className: flyoutContainerClasses,
|
8747
8864
|
"data-rebuy-cart-layout": config?.layout || "single",
|
8748
8865
|
id: containerId || "rebuy-cart-react",
|
8866
|
+
ref: containerRef,
|
8749
8867
|
role: "dialog",
|
8868
|
+
tabIndex: -1,
|
8750
8869
|
children: [
|
8751
|
-
/* @__PURE__ */ (0,
|
8752
|
-
/* @__PURE__ */ (0,
|
8753
|
-
/* @__PURE__ */ (0,
|
8754
|
-
/* @__PURE__ */ (0,
|
8870
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("header", { className: SmartCartContainer_default["rebuy-smart-cart__header"], "data-rebuy-cart-anchor": "header", children: [
|
8871
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: SmartCartContainer_default["rebuy-smart-cart__header-top-bar"], "data-rebuy-cart-header-top-bar": "", children: [
|
8872
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: SmartCartContainer_default["rebuy-smart-cart__header-content"], "data-rebuy-cart-header-top-inner": "", children: [
|
8873
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(AnchorSlot, { anchor: "header", components, includeTypes: ["title_bar", "login"] }),
|
8755
8874
|
!components.some(
|
8756
8875
|
(c) => c.type === "title_bar" && !c.settings?.screen_reader_only
|
8757
|
-
) && /* @__PURE__ */ (0,
|
8876
|
+
) && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h2", { id: defaultTitleId, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ScreenReaderText, { children: "Your Cart" }) })
|
8758
8877
|
] }),
|
8759
|
-
/* @__PURE__ */ (0,
|
8878
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
8760
8879
|
"button",
|
8761
8880
|
{
|
8762
8881
|
"aria-label": "Close Cart",
|
@@ -8766,15 +8885,15 @@ var SmartCartContainer = ({ containerId }) => {
|
|
8766
8885
|
type: "button",
|
8767
8886
|
children: [
|
8768
8887
|
"\u2715",
|
8769
|
-
/* @__PURE__ */ (0,
|
8888
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ScreenReaderText, { children: "Close Cart" })
|
8770
8889
|
]
|
8771
8890
|
}
|
8772
8891
|
)
|
8773
8892
|
] }),
|
8774
|
-
/* @__PURE__ */ (0,
|
8893
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(AnchorSlot, { anchor: "header", components, excludeTypes: ["title_bar", "login"] })
|
8775
8894
|
] }),
|
8776
8895
|
renderLayoutContent(),
|
8777
|
-
/* @__PURE__ */ (0,
|
8896
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { "aria-live": "polite", className: "rebuy-sr-only", id: "rebuy-cart-live-region" })
|
8778
8897
|
]
|
8779
8898
|
}
|
8780
8899
|
)
|
@@ -8782,9 +8901,9 @@ var SmartCartContainer = ({ containerId }) => {
|
|
8782
8901
|
};
|
8783
8902
|
|
8784
8903
|
// src/smart-cart/RebuySmartCart.tsx
|
8785
|
-
var
|
8904
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
8786
8905
|
var RebuySmartCart = () => {
|
8787
|
-
return /* @__PURE__ */ (0,
|
8906
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SmartCartContainer, {});
|
8788
8907
|
};
|
8789
8908
|
|
8790
8909
|
// src/widgetContainer/RebuyWidgetContainer.tsx
|
@@ -8793,19 +8912,8 @@ var Utilities5 = __toESM(require("@rebuy/rebuy/utilities"), 1);
|
|
8793
8912
|
var import_hydrogen7 = require("@shopify/hydrogen");
|
8794
8913
|
var import_react33 = __toESM(require("react"), 1);
|
8795
8914
|
var RebuyWidgetContainerBase = ({ children, ...props }) => {
|
8796
|
-
const {
|
8797
|
-
|
8798
|
-
collection,
|
8799
|
-
collectionId,
|
8800
|
-
dataSource,
|
8801
|
-
limit,
|
8802
|
-
options,
|
8803
|
-
product,
|
8804
|
-
productId,
|
8805
|
-
variant,
|
8806
|
-
variantId
|
8807
|
-
} = props;
|
8808
|
-
const { apiKey: apiKeyFromContext, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
|
8915
|
+
const { collection, collectionId, dataSource, limit, options, product, productId, variant, variantId } = props;
|
8916
|
+
const { apiKey, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
|
8809
8917
|
const rebuyContext = (0, import_react33.useContext)(RebuyContext);
|
8810
8918
|
const [rebuyApiClient, setRebuyApiClient] = (0, import_react33.useState)(null);
|
8811
8919
|
const [initialized, setInitialized] = (0, import_react33.useState)(false);
|
@@ -8814,10 +8922,9 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
|
|
8814
8922
|
const shopifyCollectionId = collection?.id ?? collectionId ?? null;
|
8815
8923
|
const [products, setProducts] = (0, import_react33.useState)([]);
|
8816
8924
|
const [metadata, setMetadata] = (0, import_react33.useState)();
|
8817
|
-
const finalApiKey = apiKeyFromProps || apiKeyFromContext;
|
8818
8925
|
(0, import_react33.useEffect)(() => {
|
8819
|
-
if (!rebuyApiClient &&
|
8820
|
-
const client = new import_rebuy3.RebuyClient(
|
8926
|
+
if (!rebuyApiClient && apiKey && configLoadingStatus === "success") {
|
8927
|
+
const client = new import_rebuy3.RebuyClient(apiKey);
|
8821
8928
|
const currentEndpoint = dataSource || "/api/v1/products/recommended";
|
8822
8929
|
if (rebuyContext?.contextParameters) {
|
8823
8930
|
const filteredParams = filterContextForWidgetEndpoints(rebuyContext.contextParameters, currentEndpoint);
|
@@ -8829,7 +8936,7 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
|
|
8829
8936
|
setRebuyApiClient(client);
|
8830
8937
|
setInitialized(true);
|
8831
8938
|
}
|
8832
|
-
}, [
|
8939
|
+
}, [apiKey, rebuyApiClient, configLoadingStatus, options, rebuyContext, dataSource]);
|
8833
8940
|
(0, import_react33.useEffect)(() => {
|
8834
8941
|
if (rebuyApiClient && rebuyContext?.contextParameters) {
|
8835
8942
|
const currentEndpoint = dataSource || "/api/v1/products/recommended";
|
@@ -8896,8 +9003,9 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
|
|
8896
9003
|
);
|
8897
9004
|
const childProps = {
|
8898
9005
|
...props,
|
8899
|
-
apiKey
|
9006
|
+
apiKey,
|
8900
9007
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
9008
|
+
isHydrogenReact: rebuyContext?.contextParameters?.isHydrogenReact,
|
8901
9009
|
key: product?.id,
|
8902
9010
|
metadata,
|
8903
9011
|
products
|
@@ -8914,7 +9022,7 @@ var result23 = { "container": "RebuyCompleteTheLook_container", "productGrid": "
|
|
8914
9022
|
var RebuyCompleteTheLook_default = result23;
|
8915
9023
|
|
8916
9024
|
// src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.tsx
|
8917
|
-
var
|
9025
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
8918
9026
|
var RebuyCompleteTheLook = (props) => {
|
8919
9027
|
const {
|
8920
9028
|
addToCartBtnText = "Add to cart",
|
@@ -8928,9 +9036,9 @@ var RebuyCompleteTheLook = (props) => {
|
|
8928
9036
|
rebuyDebugLog.log("widget-complete-the-look" /* WIDGET_COMPLETE_THE_LOOK */, "RebuyCompleteTheLook: No products found");
|
8929
9037
|
return null;
|
8930
9038
|
}
|
8931
|
-
return /* @__PURE__ */ (0,
|
8932
|
-
/* @__PURE__ */ (0,
|
8933
|
-
/* @__PURE__ */ (0,
|
9039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: RebuyCompleteTheLook_default.container, children: [
|
9040
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
|
9041
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("ul", { className: RebuyCompleteTheLook_default.productGrid, children: products.map((product) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("li", { className: RebuyCompleteTheLook_default.productItem, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
8934
9042
|
ProductCard,
|
8935
9043
|
{
|
8936
9044
|
addToCartBtnText,
|
@@ -8948,11 +9056,34 @@ var import_react35 = require("react");
|
|
8948
9056
|
|
8949
9057
|
// src/utils/convertToRebuyProduct.tsx
|
8950
9058
|
var convertToRebuyProduct = (isHydrogenReact, product) => {
|
8951
|
-
const mainProductVariants = isHydrogenReact ? product?.variants?.nodes?.map((variant) => {
|
8952
|
-
|
8953
|
-
|
8954
|
-
|
8955
|
-
|
9059
|
+
const mainProductVariants = isHydrogenReact ? product?.variants?.nodes?.map((variant) => ({
|
9060
|
+
availableForSale: variant.availableForSale,
|
9061
|
+
compareAtPriceV2: {
|
9062
|
+
amount: variant.compareAtPrice?.amount || "",
|
9063
|
+
currencyCode: variant.compareAtPrice?.currencyCode || "USD"
|
9064
|
+
},
|
9065
|
+
id: variant.id,
|
9066
|
+
image: variant.image ? {
|
9067
|
+
altText: variant.image.altText || null,
|
9068
|
+
height: variant.image.height || 100,
|
9069
|
+
id: variant.image.id || "",
|
9070
|
+
url: variant.image.url || "",
|
9071
|
+
width: variant.image.width || 100
|
9072
|
+
} : void 0,
|
9073
|
+
priceV2: {
|
9074
|
+
amount: variant.price.amount,
|
9075
|
+
currencyCode: variant.price.currencyCode
|
9076
|
+
},
|
9077
|
+
product: {
|
9078
|
+
handle: product.handle,
|
9079
|
+
id: product.id,
|
9080
|
+
title: product.title,
|
9081
|
+
vendor: product.vendor
|
9082
|
+
},
|
9083
|
+
selectedOptions: variant.selectedOptions,
|
9084
|
+
sku: variant.sku || "",
|
9085
|
+
title: variant.title
|
9086
|
+
})) || [] : product?.adjacentVariants.map((variant) => {
|
8956
9087
|
return {
|
8957
9088
|
availableForSale: variant.availableForSale,
|
8958
9089
|
compareAtPriceV2: {
|
@@ -9016,26 +9147,28 @@ var convertToRebuyProduct = (isHydrogenReact, product) => {
|
|
9016
9147
|
selected: true,
|
9017
9148
|
selectedOptions: product?.selectedVariant?.selectedOptions?.reduce((acc, option) => {
|
9018
9149
|
return { ...acc, [option.name]: option.value };
|
9150
|
+
}, {}) || product?.variants?.nodes[0]?.selectedOptions?.reduce((acc, option) => {
|
9151
|
+
return { ...acc, [option.name]: option.value };
|
9019
9152
|
}, {}) || {},
|
9020
9153
|
selectedSellingPlan: {},
|
9021
9154
|
selectedSellingPlanAllocation: {},
|
9022
9155
|
selectedVariant: {
|
9023
|
-
availableForSale: product?.selectedVariant?.availableForSale || false,
|
9156
|
+
availableForSale: product?.selectedVariant?.availableForSale || product?.variants?.nodes[0]?.availableForSale || false,
|
9024
9157
|
compareAtPriceV2: {
|
9025
|
-
amount: product?.selectedVariant?.compareAtPrice?.amount || "",
|
9026
|
-
currencyCode: product?.selectedVariant?.compareAtPrice?.currencyCode || "USD"
|
9158
|
+
amount: product?.selectedVariant?.compareAtPrice?.amount || product?.variants?.nodes[0]?.compareAtPrice?.amount || "",
|
9159
|
+
currencyCode: product?.selectedVariant?.compareAtPrice?.currencyCode || product?.variants?.nodes[0]?.compareAtPrice?.currencyCode || "USD"
|
9027
9160
|
},
|
9028
9161
|
id: product?.selectedVariant?.id || "",
|
9029
9162
|
image: {
|
9030
|
-
altText: product?.selectedVariant?.image?.altText || "",
|
9031
|
-
height: product?.selectedVariant?.image?.height || 100,
|
9032
|
-
id: product?.selectedVariant?.image?.id || "",
|
9033
|
-
url: product?.selectedVariant?.image?.url || "",
|
9034
|
-
width: product?.selectedVariant?.image?.width || 100
|
9163
|
+
altText: product?.selectedVariant?.image?.altText || product?.variants?.nodes[0]?.image?.altText || "",
|
9164
|
+
height: product?.selectedVariant?.image?.height || product?.variants?.nodes[0]?.image?.height || 100,
|
9165
|
+
id: product?.selectedVariant?.image?.id || product?.variants?.nodes[0]?.image?.id || "",
|
9166
|
+
url: product?.selectedVariant?.image?.url || product?.variants?.nodes[0]?.image?.url || "",
|
9167
|
+
width: product?.selectedVariant?.image?.width || product?.variants?.nodes[0]?.image?.width || 100
|
9035
9168
|
},
|
9036
9169
|
priceV2: {
|
9037
|
-
amount: product?.selectedVariant?.price.amount || "",
|
9038
|
-
currencyCode: product?.selectedVariant?.price.currencyCode || "USD"
|
9170
|
+
amount: product?.selectedVariant?.price.amount || product?.variants?.nodes[0]?.price.amount || "",
|
9171
|
+
currencyCode: product?.selectedVariant?.price.currencyCode || product?.variants?.nodes[0]?.price.currencyCode || "USD"
|
9039
9172
|
},
|
9040
9173
|
product: {
|
9041
9174
|
handle: product?.handle || "",
|
@@ -9043,9 +9176,9 @@ var convertToRebuyProduct = (isHydrogenReact, product) => {
|
|
9043
9176
|
title: product?.title || "",
|
9044
9177
|
vendor: product?.vendor || ""
|
9045
9178
|
},
|
9046
|
-
selectedOptions: product?.selectedVariant?.selectedOptions || [],
|
9047
|
-
sku: product?.selectedVariant?.sku || "",
|
9048
|
-
title: product?.selectedVariant?.title || ""
|
9179
|
+
selectedOptions: product?.selectedVariant?.selectedOptions || product?.variants?.nodes[0]?.selectedOptions || [],
|
9180
|
+
sku: product?.selectedVariant?.sku || product?.variants?.nodes[0]?.sku || "",
|
9181
|
+
title: product?.selectedVariant?.title || product?.variants?.nodes[0]?.title || ""
|
9049
9182
|
},
|
9050
9183
|
sellingPlanGroups: [],
|
9051
9184
|
seo: {
|
@@ -9172,19 +9305,18 @@ var convertToRebuyProduct = (isHydrogenReact, product) => {
|
|
9172
9305
|
// src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx
|
9173
9306
|
var import_hydrogen8 = require("@shopify/hydrogen");
|
9174
9307
|
var import_react34 = require("react");
|
9175
|
-
var import_react_router9 = require("react-router");
|
9176
9308
|
|
9177
9309
|
// src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.module.css
|
9178
9310
|
var result24 = { "container": "RebuyDynamicBundleProducts_container", "addCartBtnContainer": "RebuyDynamicBundleProducts_addCartBtnContainer", "bundleContainer": "RebuyDynamicBundleProducts_bundleContainer", "select": "RebuyDynamicBundleProducts_select", "bundleItemRowContainer": "RebuyDynamicBundleProducts_bundleItemRowContainer", "unselected": "RebuyDynamicBundleProducts_unselected", "bundleItemRow": "RebuyDynamicBundleProducts_bundleItemRow", "bundleItemInput": "RebuyDynamicBundleProducts_bundleItemInput", "bundleItemLabel": "RebuyDynamicBundleProducts_bundleItemLabel", "bundleImages": "RebuyDynamicBundleProducts_bundleImages", "bundleImage": "RebuyDynamicBundleProducts_bundleImage", "bundleImageDelimiter": "RebuyDynamicBundleProducts_bundleImageDelimiter", "compareAtPrice": "RebuyDynamicBundleProducts_compareAtPrice" };
|
9179
9311
|
var RebuyDynamicBundleProducts_default = result24;
|
9180
9312
|
|
9181
9313
|
// src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx
|
9182
|
-
var
|
9314
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
9183
9315
|
var BundleImages = ({ products }) => {
|
9184
9316
|
const selected = products.filter((product) => product.selected);
|
9185
|
-
return /* @__PURE__ */ (0,
|
9317
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("ul", { className: RebuyDynamicBundleProducts_default.bundleImages, children: products.map((product, index) => {
|
9186
9318
|
const image = product.selectedVariant?.image;
|
9187
|
-
const productImage = image ? /* @__PURE__ */ (0,
|
9319
|
+
const productImage = image ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
9188
9320
|
import_hydrogen8.Image,
|
9189
9321
|
{
|
9190
9322
|
alt: image.altText || `Picture of ${product.title}`,
|
@@ -9199,24 +9331,79 @@ var BundleImages = ({ products }) => {
|
|
9199
9331
|
product.title
|
9200
9332
|
);
|
9201
9333
|
const showDelimiter = selected[0]?.id !== product.id;
|
9202
|
-
return /* @__PURE__ */ (0,
|
9203
|
-
showDelimiter && /* @__PURE__ */ (0,
|
9204
|
-
/* @__PURE__ */ (0,
|
9334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react34.Fragment, { children: product.selected && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
9335
|
+
showDelimiter && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("li", { className: RebuyDynamicBundleProducts_default.bundleImageDelimiter, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { children: "+" }) }),
|
9336
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("li", { className: "flex items-center", children: product.default ? (
|
9205
9337
|
// Already on product page
|
9206
9338
|
productImage
|
9207
9339
|
) : (
|
9208
9340
|
// Link to product
|
9209
|
-
/* @__PURE__ */ (0,
|
9341
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
9342
|
+
RebuyLink,
|
9343
|
+
{
|
9344
|
+
ariaLabel: `View ${product.title}`,
|
9345
|
+
handle: `/products/${product.handle}`,
|
9346
|
+
children: productImage
|
9347
|
+
}
|
9348
|
+
)
|
9210
9349
|
) })
|
9211
9350
|
] }) }, product.id + "-BundleImages-" + index);
|
9212
9351
|
}) });
|
9213
9352
|
};
|
9214
9353
|
|
9354
|
+
// src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx
|
9355
|
+
var import_hydrogen9 = require("@shopify/hydrogen");
|
9356
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
9357
|
+
var BundlePrice = ({ products }) => {
|
9358
|
+
const isDisabled = products.filter((product) => product.selected).length < 1;
|
9359
|
+
const totalBundlePrice = () => {
|
9360
|
+
let total = 0;
|
9361
|
+
let currencyCode = "USD";
|
9362
|
+
for (const product of products) {
|
9363
|
+
if (product.selected && product.selectedVariant) {
|
9364
|
+
const { priceV2: price2 } = product.selectedVariant;
|
9365
|
+
total += Number(price2?.amount);
|
9366
|
+
currencyCode = price2?.currencyCode || "USD";
|
9367
|
+
}
|
9368
|
+
}
|
9369
|
+
return {
|
9370
|
+
amount: String(total),
|
9371
|
+
currencyCode
|
9372
|
+
};
|
9373
|
+
};
|
9374
|
+
const totalBundleCompareAtPrice = () => {
|
9375
|
+
let compareAtTotal = 0;
|
9376
|
+
let currencyCode = "USD";
|
9377
|
+
for (const product of products) {
|
9378
|
+
if (product.selected && product.selectedVariant) {
|
9379
|
+
const { compareAtPriceV2: compareAtPrice2, priceV2: price2 } = product.selectedVariant;
|
9380
|
+
currencyCode = price2?.currencyCode || "USD";
|
9381
|
+
compareAtTotal += Number((compareAtPrice2 || price2)?.amount);
|
9382
|
+
}
|
9383
|
+
}
|
9384
|
+
return {
|
9385
|
+
amount: String(compareAtTotal),
|
9386
|
+
currencyCode
|
9387
|
+
};
|
9388
|
+
};
|
9389
|
+
const isDiscounted = (price2, compareAtPrice2) => Number(compareAtPrice2?.amount) > Number(price2?.amount);
|
9390
|
+
const price = totalBundlePrice();
|
9391
|
+
const compareAtPrice = totalBundleCompareAtPrice();
|
9392
|
+
const CompareAtPrice = ({ data: compareAtPrice2 }) => {
|
9393
|
+
return compareAtPrice2 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_hydrogen9.Money, { as: "span", className: RebuyDynamicBundleProducts_default.compareAtPrice, data: compareAtPrice2, withoutTrailingZeros: true });
|
9394
|
+
};
|
9395
|
+
return products.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "flex items-center flex-col", children: !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("p", { className: "flex items-center gap-2 mb-2", children: [
|
9396
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { children: "Total Price:" }),
|
9397
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_hydrogen9.Money, { as: "span", data: price, withoutTrailingZeros: true }),
|
9398
|
+
isDiscounted(price, compareAtPrice) && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CompareAtPrice, { data: compareAtPrice })
|
9399
|
+
] }) });
|
9400
|
+
};
|
9401
|
+
|
9215
9402
|
// src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx
|
9216
9403
|
var import_clsx14 = __toESM(require("clsx"), 1);
|
9217
9404
|
|
9218
9405
|
// src/widgets/RebuyDynamicBundleProducts/Select.tsx
|
9219
|
-
var
|
9406
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
9220
9407
|
var Select = ({ onSelectVariant, product }) => {
|
9221
9408
|
const getOptionsLabel = (product2) => {
|
9222
9409
|
const options = product2.variants.nodes[0].selectedOptions;
|
@@ -9225,30 +9412,30 @@ var Select = ({ onSelectVariant, product }) => {
|
|
9225
9412
|
const useValues = optionsFromKeys.every((key) => ["name", "value"].includes(key));
|
9226
9413
|
return (useValues ? optionsFromValues : optionsFromKeys).join(" / ");
|
9227
9414
|
};
|
9228
|
-
return product && /* @__PURE__ */ (0,
|
9415
|
+
return product && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
9229
9416
|
"select",
|
9230
9417
|
{
|
9231
9418
|
"aria-label": "select variant",
|
9232
9419
|
className: RebuyDynamicBundleProducts_default.select,
|
9233
9420
|
onChange: (e) => onSelectVariant(product, e.target.value),
|
9234
9421
|
value: product.selectedVariant.id,
|
9235
|
-
children: /* @__PURE__ */ (0,
|
9422
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("optgroup", { label: getOptionsLabel(product), children: product.variants.nodes.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("option", { value: id, children: title }, id + "-BundleVariant")) })
|
9236
9423
|
}
|
9237
9424
|
);
|
9238
9425
|
};
|
9239
9426
|
|
9240
9427
|
// src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx
|
9241
|
-
var
|
9428
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
9242
9429
|
var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
|
9243
|
-
return /* @__PURE__ */ (0,
|
9430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("ul", { children: products.map((product, index) => {
|
9244
9431
|
const { availableForSale } = product.selectedVariant;
|
9245
9432
|
const isOutOfStock = !availableForSale;
|
9246
|
-
return /* @__PURE__ */ (0,
|
9433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
9247
9434
|
"li",
|
9248
9435
|
{
|
9249
9436
|
className: (0, import_clsx14.default)(RebuyDynamicBundleProducts_default.bundleItemRowContainer, !product.selected && RebuyDynamicBundleProducts_default.unselected),
|
9250
|
-
children: /* @__PURE__ */ (0,
|
9251
|
-
/* @__PURE__ */ (0,
|
9437
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemRow, children: [
|
9438
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
9252
9439
|
"input",
|
9253
9440
|
{
|
9254
9441
|
checked: product.selected && availableForSale,
|
@@ -9260,14 +9447,14 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
|
|
9260
9447
|
value: product.id
|
9261
9448
|
}
|
9262
9449
|
),
|
9263
|
-
/* @__PURE__ */ (0,
|
9264
|
-
/* @__PURE__ */ (0,
|
9265
|
-
isOutOfStock && /* @__PURE__ */ (0,
|
9266
|
-
product.default && /* @__PURE__ */ (0,
|
9450
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemInput, children: [
|
9451
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: RebuyDynamicBundleProducts_default.bundleItemLabel, htmlFor: `${product.id}-toggle`, children: [
|
9452
|
+
isOutOfStock && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("b", { children: "SOLD OUT" }),
|
9453
|
+
product.default && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("b", { children: "This item:" }),
|
9267
9454
|
product.title,
|
9268
|
-
/* @__PURE__ */ (0,
|
9455
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(RebuyProductPrice, { selectedVariant: product.selectedVariant })
|
9269
9456
|
] }),
|
9270
|
-
product.variants.nodes.length > 1 && /* @__PURE__ */ (0,
|
9457
|
+
product.variants.nodes.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Select, { onSelectVariant, product })
|
9271
9458
|
] })
|
9272
9459
|
] })
|
9273
9460
|
},
|
@@ -9276,56 +9463,8 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
|
|
9276
9463
|
}) });
|
9277
9464
|
};
|
9278
9465
|
|
9279
|
-
// src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx
|
9280
|
-
var import_hydrogen9 = require("@shopify/hydrogen");
|
9281
|
-
var import_jsx_runtime46 = require("react/jsx-runtime");
|
9282
|
-
var BundlePrice = ({ products }) => {
|
9283
|
-
const isDisabled = products.filter((product) => product.selected).length < 1;
|
9284
|
-
const totalBundlePrice = () => {
|
9285
|
-
let total = 0;
|
9286
|
-
let currencyCode = "USD";
|
9287
|
-
for (const product of products) {
|
9288
|
-
if (product.selected && product.selectedVariant) {
|
9289
|
-
const { priceV2: price2 } = product.selectedVariant;
|
9290
|
-
total += Number(price2?.amount);
|
9291
|
-
currencyCode = price2?.currencyCode || "USD";
|
9292
|
-
}
|
9293
|
-
}
|
9294
|
-
return {
|
9295
|
-
amount: String(total),
|
9296
|
-
currencyCode
|
9297
|
-
};
|
9298
|
-
};
|
9299
|
-
const totalBundleCompareAtPrice = () => {
|
9300
|
-
let compareAtTotal = 0;
|
9301
|
-
let currencyCode = "USD";
|
9302
|
-
for (const product of products) {
|
9303
|
-
if (product.selected && product.selectedVariant) {
|
9304
|
-
const { compareAtPriceV2: compareAtPrice2, priceV2: price2 } = product.selectedVariant;
|
9305
|
-
currencyCode = price2?.currencyCode || "USD";
|
9306
|
-
compareAtTotal += Number((compareAtPrice2 || price2)?.amount);
|
9307
|
-
}
|
9308
|
-
}
|
9309
|
-
return {
|
9310
|
-
amount: String(compareAtTotal),
|
9311
|
-
currencyCode
|
9312
|
-
};
|
9313
|
-
};
|
9314
|
-
const isDiscounted = (price2, compareAtPrice2) => Number(compareAtPrice2?.amount) > Number(price2?.amount);
|
9315
|
-
const price = totalBundlePrice();
|
9316
|
-
const compareAtPrice = totalBundleCompareAtPrice();
|
9317
|
-
const CompareAtPrice = ({ data: compareAtPrice2 }) => {
|
9318
|
-
return compareAtPrice2 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_hydrogen9.Money, { as: "span", className: RebuyDynamicBundleProducts_default.compareAtPrice, data: compareAtPrice2, withoutTrailingZeros: true });
|
9319
|
-
};
|
9320
|
-
return products.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "flex items-center flex-col", children: !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("p", { className: "flex items-center gap-2 mb-2", children: [
|
9321
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { children: "Total Price:" }),
|
9322
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_hydrogen9.Money, { as: "span", data: price, withoutTrailingZeros: true }),
|
9323
|
-
isDiscounted(price, compareAtPrice) && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CompareAtPrice, { data: compareAtPrice })
|
9324
|
-
] }) });
|
9325
|
-
};
|
9326
|
-
|
9327
9466
|
// src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
|
9328
|
-
var
|
9467
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
9329
9468
|
var RebuyDynamicBundleProducts = (props) => {
|
9330
9469
|
const {
|
9331
9470
|
addToCartBtnText = "Add to cart",
|
@@ -9371,12 +9510,12 @@ var RebuyDynamicBundleProducts = (props) => {
|
|
9371
9510
|
rebuyDebugLog.log("widget-dynamic-bundle-products" /* WIDGET_DYNAMIC_BUNDLE_PRODUCTS */, "RebuyDynamicBundleProducts: No products found");
|
9372
9511
|
return null;
|
9373
9512
|
}
|
9374
|
-
return /* @__PURE__ */ (0,
|
9375
|
-
/* @__PURE__ */ (0,
|
9376
|
-
/* @__PURE__ */ (0,
|
9377
|
-
/* @__PURE__ */ (0,
|
9378
|
-
/* @__PURE__ */ (0,
|
9379
|
-
/* @__PURE__ */ (0,
|
9513
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("section", { className: RebuyDynamicBundleProducts_default.container, children: [
|
9514
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
|
9515
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleContainer, children: [
|
9516
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(BundleImages, { products: bundleProducts }),
|
9517
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(BundlePrice, { products: bundleProducts }),
|
9518
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: RebuyDynamicBundleProducts_default.addCartBtnContainer, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
9380
9519
|
AddToCartBtn,
|
9381
9520
|
{
|
9382
9521
|
addToCartBtnText,
|
@@ -9388,7 +9527,7 @@ var RebuyDynamicBundleProducts = (props) => {
|
|
9388
9527
|
})
|
9389
9528
|
}
|
9390
9529
|
) }),
|
9391
|
-
/* @__PURE__ */ (0,
|
9530
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
9392
9531
|
BundleSelection,
|
9393
9532
|
{
|
9394
9533
|
onSelectVariant,
|
@@ -9406,14 +9545,13 @@ var import_react36 = require("react");
|
|
9406
9545
|
|
9407
9546
|
// src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx
|
9408
9547
|
var import_hydrogen10 = require("@shopify/hydrogen");
|
9409
|
-
var import_react_router10 = require("react-router");
|
9410
9548
|
|
9411
9549
|
// src/widgets/RebuyProductAddOns/RebuyProductAddOns.module.css
|
9412
9550
|
var result25 = { "container": "RebuyProductAddOns_container", "productAddOnsList": "RebuyProductAddOns_productAddOnsList", "addOnCard": "RebuyProductAddOns_addOnCard", "addOnCardContent": "RebuyProductAddOns_addOnCardContent", "addOnCardInput": "RebuyProductAddOns_addOnCardInput", "addOnCardContentImage": "RebuyProductAddOns_addOnCardContentImage", "addOnCardOutOfStock": "RebuyProductAddOns_addOnCardOutOfStock", "addOnCardTextContent": "RebuyProductAddOns_addOnCardTextContent", "addOnCardLearnMore": "RebuyProductAddOns_addOnCardLearnMore", "addCartBtnContainer": "RebuyProductAddOns_addCartBtnContainer", "productAddOnsFooter": "RebuyProductAddOns_productAddOnsFooter", "moneyContainer": "RebuyProductAddOns_moneyContainer" };
|
9413
9551
|
var RebuyProductAddOns_default = result25;
|
9414
9552
|
|
9415
9553
|
// src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx
|
9416
|
-
var
|
9554
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
9417
9555
|
var RebuyProductAddOnCard = ({
|
9418
9556
|
handleChange,
|
9419
9557
|
learnMoreText,
|
@@ -9422,8 +9560,8 @@ var RebuyProductAddOnCard = ({
|
|
9422
9560
|
titleLevel
|
9423
9561
|
}) => {
|
9424
9562
|
const { availableForSale, image } = product.selectedVariant || {};
|
9425
|
-
return /* @__PURE__ */ (0,
|
9426
|
-
/* @__PURE__ */ (0,
|
9563
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("label", { className: RebuyProductAddOns_default.addOnCard, htmlFor: product.id, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: RebuyProductAddOns_default.addOnCardContent, children: [
|
9564
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
9427
9565
|
"input",
|
9428
9566
|
{
|
9429
9567
|
checked: Boolean(product.selected),
|
@@ -9436,7 +9574,7 @@ var RebuyProductAddOnCard = ({
|
|
9436
9574
|
value: ""
|
9437
9575
|
}
|
9438
9576
|
),
|
9439
|
-
/* @__PURE__ */ (0,
|
9577
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: RebuyProductAddOns_default.addOnCardContentImage, children: image && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
9440
9578
|
import_hydrogen10.Image,
|
9441
9579
|
{
|
9442
9580
|
alt: image.altText || `Picture of ${product.title}`,
|
@@ -9445,17 +9583,25 @@ var RebuyProductAddOnCard = ({
|
|
9445
9583
|
width: 300
|
9446
9584
|
}
|
9447
9585
|
) }),
|
9448
|
-
/* @__PURE__ */ (0,
|
9449
|
-
!availableForSale && /* @__PURE__ */ (0,
|
9450
|
-
/* @__PURE__ */ (0,
|
9451
|
-
/* @__PURE__ */ (0,
|
9452
|
-
/* @__PURE__ */ (0,
|
9586
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: RebuyProductAddOns_default.addOnCardTextContent, children: [
|
9587
|
+
!availableForSale && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: RebuyProductAddOns_default.addOnCardOutOfStock, children: outOfStockText }),
|
9588
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Title, { level: titleLevel, text: product.title }),
|
9589
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(RebuyProductPrice, { selectedVariant: product.selectedVariant }),
|
9590
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
9591
|
+
RebuyLink,
|
9592
|
+
{
|
9593
|
+
ariaLabel: `View ${product.title}`,
|
9594
|
+
className: RebuyProductAddOns_default.addOnCardLearnMore,
|
9595
|
+
handle: `/products/${product.handle}`,
|
9596
|
+
children: learnMoreText
|
9597
|
+
}
|
9598
|
+
)
|
9453
9599
|
] })
|
9454
9600
|
] }) });
|
9455
9601
|
};
|
9456
9602
|
|
9457
9603
|
// src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx
|
9458
|
-
var
|
9604
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
9459
9605
|
var RebuyProductAddOns = (props) => {
|
9460
9606
|
const {
|
9461
9607
|
addToCartCallback,
|
@@ -9475,6 +9621,7 @@ var RebuyProductAddOns = (props) => {
|
|
9475
9621
|
const [addedItems, setAddedItems] = (0, import_react36.useState)(products);
|
9476
9622
|
const [subtotalWithProduct, setSubtotalWithProduct] = (0, import_react36.useState)();
|
9477
9623
|
const [subtotalWithOutProduct, setSubtotalWithOutProduct] = (0, import_react36.useState)();
|
9624
|
+
const convertedProduct = convertToRebuyProduct(isHydrogenReact || false, product);
|
9478
9625
|
(0, import_react36.useEffect)(() => {
|
9479
9626
|
let initialTotal = 0;
|
9480
9627
|
let currencyCode = "USD";
|
@@ -9493,14 +9640,14 @@ var RebuyProductAddOns = (props) => {
|
|
9493
9640
|
setSubtotalWithOutProduct({
|
9494
9641
|
amount: String(
|
9495
9642
|
initialTotal - Number(
|
9496
|
-
isHydrogenReact ?
|
9643
|
+
isHydrogenReact ? convertedProduct?.selectedVariant?.priceV2?.amount : product?.selectedOrFirstAvailableVariant?.price.amount
|
9497
9644
|
)
|
9498
9645
|
),
|
9499
9646
|
currencyCode
|
9500
9647
|
});
|
9501
9648
|
setAddedItems(products);
|
9502
9649
|
if (includeMainProduct) {
|
9503
|
-
setAddedItems([
|
9650
|
+
setAddedItems([convertedProduct, ...products]);
|
9504
9651
|
} else {
|
9505
9652
|
setAddedItems(products);
|
9506
9653
|
}
|
@@ -9540,7 +9687,7 @@ var RebuyProductAddOns = (props) => {
|
|
9540
9687
|
setSubtotalWithOutProduct({
|
9541
9688
|
amount: String(
|
9542
9689
|
total - Number(
|
9543
|
-
isHydrogenReact ?
|
9690
|
+
isHydrogenReact ? convertedProduct?.selectedVariant?.priceV2?.amount : product?.selectedOrFirstAvailableVariant?.price.amount
|
9544
9691
|
)
|
9545
9692
|
),
|
9546
9693
|
currencyCode
|
@@ -9550,9 +9697,9 @@ var RebuyProductAddOns = (props) => {
|
|
9550
9697
|
rebuyDebugLog.log("widget-product-add-ons" /* WIDGET_PRODUCT_ADD_ONS */, "RebuyProductAddOns: No products found");
|
9551
9698
|
return null;
|
9552
9699
|
}
|
9553
|
-
return /* @__PURE__ */ (0,
|
9554
|
-
/* @__PURE__ */ (0,
|
9555
|
-
/* @__PURE__ */ (0,
|
9700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: RebuyProductAddOns_default.container, children: [
|
9701
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
|
9702
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("ul", { className: RebuyProductAddOns_default.productAddOnsList, children: products.map((product2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
9556
9703
|
RebuyProductAddOnCard,
|
9557
9704
|
{
|
9558
9705
|
handleChange,
|
@@ -9562,16 +9709,16 @@ var RebuyProductAddOns = (props) => {
|
|
9562
9709
|
titleLevel: getTitleLevel(customTitleLevel, true)
|
9563
9710
|
}
|
9564
9711
|
) }, product2.id)) }),
|
9565
|
-
/* @__PURE__ */ (0,
|
9566
|
-
/* @__PURE__ */ (0,
|
9712
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: RebuyProductAddOns_default.productAddOnsFooter, children: [
|
9713
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
|
9567
9714
|
subtotalText,
|
9568
|
-
subtotalWithOutProduct && /* @__PURE__ */ (0,
|
9715
|
+
subtotalWithOutProduct && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_hydrogen_react3.Money, { data: subtotalWithOutProduct, withoutTrailingZeros: true })
|
9569
9716
|
] }),
|
9570
|
-
includeMainProduct && /* @__PURE__ */ (0,
|
9717
|
+
includeMainProduct && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
|
9571
9718
|
withProductText,
|
9572
|
-
subtotalWithProduct && /* @__PURE__ */ (0,
|
9719
|
+
subtotalWithProduct && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_hydrogen_react3.Money, { data: subtotalWithProduct, withoutTrailingZeros: true })
|
9573
9720
|
] }),
|
9574
|
-
/* @__PURE__ */ (0,
|
9721
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: RebuyProductAddOns_default.addCartBtnContainer, children: includeMainProduct ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
9575
9722
|
AddToCartBtn,
|
9576
9723
|
{
|
9577
9724
|
addToCartBtnText,
|
@@ -9581,7 +9728,7 @@ var RebuyProductAddOns = (props) => {
|
|
9581
9728
|
moneyData: subtotalWithProduct,
|
9582
9729
|
selectedVariants: addedItems.map((item) => item.selectedVariant)
|
9583
9730
|
}
|
9584
|
-
) : /* @__PURE__ */ (0,
|
9731
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
9585
9732
|
AddToCartBtn,
|
9586
9733
|
{
|
9587
9734
|
addToCartBtnText,
|
@@ -9597,11 +9744,11 @@ var RebuyProductAddOns = (props) => {
|
|
9597
9744
|
};
|
9598
9745
|
|
9599
9746
|
// src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.module.css
|
9600
|
-
var result26 = { "container": "RebuyProductRecommendations_container", "productGrid": "RebuyProductRecommendations_productGrid"
|
9747
|
+
var result26 = { "container": "RebuyProductRecommendations_container", "productGrid": "RebuyProductRecommendations_productGrid" };
|
9601
9748
|
var RebuyProductRecommendations_default = result26;
|
9602
9749
|
|
9603
9750
|
// src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.tsx
|
9604
|
-
var
|
9751
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
9605
9752
|
var RebuyProductRecommendations = (props) => {
|
9606
9753
|
const {
|
9607
9754
|
addToCartBtnText = "Add to cart",
|
@@ -9615,9 +9762,9 @@ var RebuyProductRecommendations = (props) => {
|
|
9615
9762
|
rebuyDebugLog.log("widget-product-recommendations" /* WIDGET_PRODUCT_RECOMMENDATIONS */, "RebuyProductRecommendations: No products found");
|
9616
9763
|
return null;
|
9617
9764
|
}
|
9618
|
-
return /* @__PURE__ */ (0,
|
9619
|
-
/* @__PURE__ */ (0,
|
9620
|
-
/* @__PURE__ */ (0,
|
9765
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("section", { className: RebuyProductRecommendations_default.container, children: [
|
9766
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
|
9767
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("ul", { className: RebuyProductRecommendations_default.productGrid, children: products.map((product) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
9621
9768
|
ProductCard,
|
9622
9769
|
{
|
9623
9770
|
addToCartBtnText,
|
@@ -9630,6 +9777,190 @@ var RebuyProductRecommendations = (props) => {
|
|
9630
9777
|
] });
|
9631
9778
|
};
|
9632
9779
|
|
9780
|
+
// src/widgets/RebuyProductViewed/RebuyProductViewed.tsx
|
9781
|
+
var import_rebuy4 = require("@rebuy/rebuy");
|
9782
|
+
var Utilities6 = __toESM(require("@rebuy/rebuy/utilities"), 1);
|
9783
|
+
var import_react37 = require("react");
|
9784
|
+
|
9785
|
+
// src/zustandStores/productViewed.ts
|
9786
|
+
var import_zustand2 = require("zustand");
|
9787
|
+
var useProductViewedStore = (0, import_zustand2.create)((set) => ({
|
9788
|
+
customerId: null,
|
9789
|
+
setCustomerId: (customerId) => set({ customerId }),
|
9790
|
+
setUuid: (uuid) => set({ uuid }),
|
9791
|
+
uuid: null
|
9792
|
+
}));
|
9793
|
+
|
9794
|
+
// src/widgets/RebuyProductViewed/RebuyProductViewed.tsx
|
9795
|
+
var RebuyProductViewed = ({ ...props }) => {
|
9796
|
+
const { apiKey: apiKeyFromContext } = useRebuyConfig();
|
9797
|
+
const { customerId, product, productHandle, productId } = props;
|
9798
|
+
const [event, setEvent] = (0, import_react37.useState)(null);
|
9799
|
+
const [Rebuy, setRebuy] = (0, import_react37.useState)(null);
|
9800
|
+
const shopifyProductId = product?.id ?? productId ?? null;
|
9801
|
+
const [initialized, setInitialized] = (0, import_react37.useState)(false);
|
9802
|
+
const { setCustomerId, setUuid } = useProductViewedStore();
|
9803
|
+
const request = (0, import_react37.useMemo)(() => {
|
9804
|
+
const request2 = {
|
9805
|
+
parameters: {}
|
9806
|
+
};
|
9807
|
+
if (shopifyProductId) {
|
9808
|
+
const productNumericId = Utilities6.getIdFromGraphUrl(shopifyProductId, "Product");
|
9809
|
+
if (productNumericId !== null) {
|
9810
|
+
request2.parameters.shopify_product_id = productNumericId.toString();
|
9811
|
+
}
|
9812
|
+
} else if (productHandle) {
|
9813
|
+
request2.parameters.shopify_product_handle = productHandle;
|
9814
|
+
}
|
9815
|
+
return request2;
|
9816
|
+
}, [productHandle, shopifyProductId]);
|
9817
|
+
(0, import_react37.useEffect)(() => {
|
9818
|
+
const recordView = async () => {
|
9819
|
+
if (!Rebuy) {
|
9820
|
+
return;
|
9821
|
+
}
|
9822
|
+
try {
|
9823
|
+
const response = await Rebuy.trackProductViewed(request.parameters);
|
9824
|
+
setEvent(response.data);
|
9825
|
+
if (response.data === "Received" && request.parameters.uuid) {
|
9826
|
+
setUuid(request.parameters.uuid);
|
9827
|
+
if (customerId && customerId !== "") {
|
9828
|
+
setCustomerId(customerId);
|
9829
|
+
}
|
9830
|
+
}
|
9831
|
+
} catch (error) {
|
9832
|
+
console.error("Error tracking product view:", error);
|
9833
|
+
}
|
9834
|
+
};
|
9835
|
+
if (!initialized && apiKeyFromContext) {
|
9836
|
+
const client = new import_rebuy4.RebuyClient(apiKeyFromContext);
|
9837
|
+
setRebuy(client);
|
9838
|
+
setInitialized(true);
|
9839
|
+
return;
|
9840
|
+
}
|
9841
|
+
recordView();
|
9842
|
+
}, [request.parameters, initialized, apiKeyFromContext, Rebuy]);
|
9843
|
+
if (Object.keys(request.parameters).length === 0) {
|
9844
|
+
console.warn("No parameters!");
|
9845
|
+
return;
|
9846
|
+
}
|
9847
|
+
return null;
|
9848
|
+
};
|
9849
|
+
|
9850
|
+
// src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.tsx
|
9851
|
+
var import_rebuy5 = require("@rebuy/rebuy");
|
9852
|
+
var import_hydrogen11 = require("@shopify/hydrogen");
|
9853
|
+
var import_react38 = require("react");
|
9854
|
+
|
9855
|
+
// src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.module.css
|
9856
|
+
var result27 = { "rebuy-recently-viewed-products-container": "RebuyRecentlyViewedProducts_rebuy-recently-viewed-products-container", "product-grid": "RebuyRecentlyViewedProducts_product-grid" };
|
9857
|
+
var RebuyRecentlyViewedProducts_default = result27;
|
9858
|
+
|
9859
|
+
// src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.tsx
|
9860
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
9861
|
+
var RebuyRecentlyViewedProducts = (props) => {
|
9862
|
+
const {
|
9863
|
+
addToCartBtnText = "Add to cart",
|
9864
|
+
addToCartCallback,
|
9865
|
+
customTitle = `Your recently viewed products`,
|
9866
|
+
customTitleLevel = "h2",
|
9867
|
+
customTitleStyle,
|
9868
|
+
limit,
|
9869
|
+
options,
|
9870
|
+
productId
|
9871
|
+
} = props;
|
9872
|
+
const { customerId, uuid } = useProductViewedStore();
|
9873
|
+
const { apiKey, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
|
9874
|
+
const rebuyContext = (0, import_react38.useContext)(RebuyContext);
|
9875
|
+
const [rebuyApiClient, setRebuyApiClient] = (0, import_react38.useState)(null);
|
9876
|
+
const [initialized, setInitialized] = (0, import_react38.useState)(false);
|
9877
|
+
const [products, setProducts] = (0, import_react38.useState)([]);
|
9878
|
+
const [metadata, setMetadata] = (0, import_react38.useState)();
|
9879
|
+
const rebuyConfigKey = rebuyConfig?.shop?.cache_key;
|
9880
|
+
const endpoint = customerId && customerId !== "" ? `/api/v1/products/viewed?key=${rebuyConfigKey}&customer_id=${customerId}` : `/api/v1/products/viewed?key=${rebuyConfigKey}&uuid=${uuid}`;
|
9881
|
+
(0, import_react38.useEffect)(() => {
|
9882
|
+
if (!rebuyApiClient && apiKey && configLoadingStatus === "success") {
|
9883
|
+
const client = new import_rebuy5.RebuyClient(apiKey);
|
9884
|
+
if (rebuyContext?.contextParameters) {
|
9885
|
+
const filteredParams = filterContextForWidgetEndpoints(rebuyContext.contextParameters, endpoint);
|
9886
|
+
client.setContextParameters(filteredParams);
|
9887
|
+
}
|
9888
|
+
if (options) {
|
9889
|
+
client.setDefaultParameters(options);
|
9890
|
+
}
|
9891
|
+
setRebuyApiClient(client);
|
9892
|
+
setInitialized(true);
|
9893
|
+
}
|
9894
|
+
}, [apiKey, rebuyApiClient, configLoadingStatus, options, rebuyContext, uuid, endpoint]);
|
9895
|
+
(0, import_react38.useEffect)(() => {
|
9896
|
+
if (rebuyApiClient && rebuyContext?.contextParameters) {
|
9897
|
+
const filteredParams = filterContextForWidgetEndpoints(rebuyContext.contextParameters, endpoint);
|
9898
|
+
rebuyApiClient.setContextParameters(filteredParams);
|
9899
|
+
}
|
9900
|
+
}, [rebuyApiClient, rebuyContext, uuid, endpoint]);
|
9901
|
+
const request = (0, import_react38.useMemo)(() => {
|
9902
|
+
const req = {
|
9903
|
+
endpoint,
|
9904
|
+
params: {}
|
9905
|
+
// Keeping this object generic to allow for custom endpoints
|
9906
|
+
};
|
9907
|
+
if (limit) {
|
9908
|
+
req.params.limit = limit;
|
9909
|
+
}
|
9910
|
+
return req;
|
9911
|
+
}, [limit, uuid, endpoint]);
|
9912
|
+
(0, import_react38.useEffect)(() => {
|
9913
|
+
let isMounted = true;
|
9914
|
+
if (!rebuyApiClient || !initialized || configLoadingStatus !== "success") return;
|
9915
|
+
const fetchData = async () => {
|
9916
|
+
try {
|
9917
|
+
const { data, metadata: metadata2 } = await rebuyApiClient.getStorefrontData(
|
9918
|
+
request.endpoint,
|
9919
|
+
request.params
|
9920
|
+
);
|
9921
|
+
if (isMounted) {
|
9922
|
+
setProducts(
|
9923
|
+
Array.isArray(data) ? data.filter((p) => p.id !== productId).map((p) => ({
|
9924
|
+
...p,
|
9925
|
+
variants: {
|
9926
|
+
nodes: p.variants ? (0, import_hydrogen11.flattenConnection)(p.variants) : []
|
9927
|
+
}
|
9928
|
+
})) : []
|
9929
|
+
);
|
9930
|
+
setMetadata(metadata2);
|
9931
|
+
}
|
9932
|
+
} catch (error) {
|
9933
|
+
console.error("[RebuyWidgetContainer] Error fetching widget data:", error);
|
9934
|
+
if (isMounted) {
|
9935
|
+
setProducts([]);
|
9936
|
+
setMetadata(void 0);
|
9937
|
+
}
|
9938
|
+
}
|
9939
|
+
};
|
9940
|
+
fetchData();
|
9941
|
+
return () => {
|
9942
|
+
isMounted = false;
|
9943
|
+
};
|
9944
|
+
}, [rebuyApiClient, initialized, request, configLoadingStatus, productId]);
|
9945
|
+
if (products.length === 0) {
|
9946
|
+
rebuyDebugLog.log("widget-recently-viewed-products" /* WIDGET_RECENTLY_VIEWED_PRODUCTS */, "RebuyRecentlyViewedProducts: No products found");
|
9947
|
+
return null;
|
9948
|
+
}
|
9949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: RebuyRecentlyViewedProducts_default["rebuy-recently-viewed-products-container"], children: [
|
9950
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
|
9951
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("ul", { className: RebuyRecentlyViewedProducts_default["product-grid"], children: products?.map((product) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
9952
|
+
ProductCard,
|
9953
|
+
{
|
9954
|
+
addToCartBtnText,
|
9955
|
+
addToCartCallback,
|
9956
|
+
product,
|
9957
|
+
productCardTitleLevel: getTitleLevel("h2")
|
9958
|
+
},
|
9959
|
+
product.id
|
9960
|
+
) }, product.id)) })
|
9961
|
+
] });
|
9962
|
+
};
|
9963
|
+
|
9633
9964
|
// src/constants/api.ts
|
9634
9965
|
var REBUY_THEME_STYLES_BASE_URL = "https://rebuyengine.com/api/v1/theme-styles";
|
9635
9966
|
|