@rebuy/rebuy-hydrogen 3.0.0-beta.17 → 3.0.0-beta.19
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 +54 -6
- package/dist/components/Timer/Timer.d.ts +1 -1
- package/dist/components/Timer/Timer.d.ts.map +1 -1
- package/dist/components/Timer/types.d.ts +4 -0
- package/dist/components/Timer/types.d.ts.map +1 -1
- package/dist/context/RebuyWidgetContext.d.ts +7 -0
- package/dist/context/RebuyWidgetContext.d.ts.map +1 -0
- package/dist/hooks/useBFCacheReset.d.ts +7 -0
- package/dist/hooks/useBFCacheReset.d.ts.map +1 -0
- package/dist/index.css +27 -27
- package/dist/index.css.map +1 -1
- package/dist/index.js +553 -480
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +319 -246
- package/dist/index.mjs.map +4 -4
- package/dist/providers/RebuyHydrogenContextProvider.d.ts.map +1 -1
- package/dist/providers/RebuyHydrogenReactContextProvider.d.ts.map +1 -1
- package/dist/types/widgets.d.ts +172 -170
- package/dist/types/widgets.d.ts.map +1 -1
- package/dist/widgetContainer/RebuyWidgetContainer.d.ts.map +1 -1
- package/dist/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.d.ts.map +1 -1
- package/dist/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.d.ts.map +1 -1
- package/dist/widgets/RebuyProductAddOns/RebuyProductAddOns.d.ts.map +1 -1
- package/dist/widgets/RebuyProductRecommendations/RebuyProductRecommendations.d.ts.map +1 -1
- package/dist/widgets/RebuyWidget/RebuyWidget.d.ts.map +1 -1
- package/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/package.json +1 -9
package/dist/index.js
CHANGED
@@ -50,7 +50,7 @@ module.exports = __toCommonJS(index_exports);
|
|
50
50
|
|
51
51
|
// src/providers/RebuyHydrogenContextProvider.tsx
|
52
52
|
var Utilities2 = __toESM(require("@rebuy/rebuy/utilities"), 1);
|
53
|
-
var
|
53
|
+
var import_react5 = require("react");
|
54
54
|
var import_react_router = require("react-router");
|
55
55
|
|
56
56
|
// src/context/RebuyConfigContext.tsx
|
@@ -315,9 +315,26 @@ var useRebuyConfig = () => {
|
|
315
315
|
var import_react2 = require("react");
|
316
316
|
var RebuyContext = (0, import_react2.createContext)(null);
|
317
317
|
|
318
|
+
// src/hooks/useBFCacheReset.ts
|
319
|
+
var import_react3 = require("react");
|
320
|
+
var useBFCacheReset = () => {
|
321
|
+
const [resetKey, setResetKey] = (0, import_react3.useState)(() => Date.now());
|
322
|
+
(0, import_react3.useEffect)(() => {
|
323
|
+
const handlePageShow = (event) => {
|
324
|
+
if (event.persisted) {
|
325
|
+
console.log("[useBFCacheReset] B/F cache detected, triggering reset");
|
326
|
+
setResetKey(Date.now());
|
327
|
+
}
|
328
|
+
};
|
329
|
+
window.addEventListener("pageshow", handlePageShow);
|
330
|
+
return () => window.removeEventListener("pageshow", handlePageShow);
|
331
|
+
}, []);
|
332
|
+
return resetKey;
|
333
|
+
};
|
334
|
+
|
318
335
|
// src/smart-cart/context/SmartCartContext.tsx
|
319
336
|
var import_lodash_es2 = require("lodash-es");
|
320
|
-
var
|
337
|
+
var import_react4 = require("react");
|
321
338
|
var import_shallow = require("zustand/react/shallow");
|
322
339
|
|
323
340
|
// src/smart-cart/store/tieredProgressBarStore.ts
|
@@ -2136,7 +2153,7 @@ var mapHydrogenCartToStorefrontCartData = (cartSource, contextParameters) => {
|
|
2136
2153
|
|
2137
2154
|
// src/smart-cart/context/SmartCartContext.tsx
|
2138
2155
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
2139
|
-
var SmartCartContext = (0,
|
2156
|
+
var SmartCartContext = (0, import_react4.createContext)(null);
|
2140
2157
|
var mapStorefrontAttributesToHRAttributes = (attributes) => {
|
2141
2158
|
if (!attributes) return [];
|
2142
2159
|
return attributes.filter((attr) => typeof attr.key === "string" && attr.value !== null).map((attr) => ({
|
@@ -2154,12 +2171,12 @@ var SmartCartProvider = ({
|
|
2154
2171
|
shopifyDomain,
|
2155
2172
|
storefrontAccessToken
|
2156
2173
|
}) => {
|
2157
|
-
const rebuyContext = (0,
|
2158
|
-
const [isVisible, setIsVisible] = (0,
|
2159
|
-
const showCart = (0,
|
2160
|
-
const hideCart = (0,
|
2161
|
-
const toggleCart = (0,
|
2162
|
-
const { contextParameters, isHydrogenReact } = (0,
|
2174
|
+
const rebuyContext = (0, import_react4.useContext)(RebuyContext);
|
2175
|
+
const [isVisible, setIsVisible] = (0, import_react4.useState)(false);
|
2176
|
+
const showCart = (0, import_react4.useCallback)(() => setIsVisible(true), []);
|
2177
|
+
const hideCart = (0, import_react4.useCallback)(() => setIsVisible(false), []);
|
2178
|
+
const toggleCart = (0, import_react4.useCallback)(() => setIsVisible((prev) => !prev), []);
|
2179
|
+
const { contextParameters, isHydrogenReact } = (0, import_react4.useMemo)(() => {
|
2163
2180
|
if (!rebuyContext) {
|
2164
2181
|
return { contextParameters: null, isHydrogenReact: false };
|
2165
2182
|
}
|
@@ -2171,8 +2188,8 @@ var SmartCartProvider = ({
|
|
2171
2188
|
const hReactActions = contextParameters?.hydrogenReactCartActions;
|
2172
2189
|
const hReactStatus = contextParameters?.hydrogenReactCartStatus;
|
2173
2190
|
const hReactError = contextParameters?.hydrogenReactCartError;
|
2174
|
-
const prevCartData = (0,
|
2175
|
-
const mappedStorefrontCartData = (0,
|
2191
|
+
const prevCartData = (0, import_react4.useRef)(null);
|
2192
|
+
const mappedStorefrontCartData = (0, import_react4.useMemo)(() => {
|
2176
2193
|
const cartSource = hydrogenCart ?? contextParameters?.hydrogenCart;
|
2177
2194
|
if (!cartSource) {
|
2178
2195
|
rebuyDebugLog.log(
|
@@ -2198,13 +2215,13 @@ var SmartCartProvider = ({
|
|
2198
2215
|
prevCartData.current = cartData;
|
2199
2216
|
return cartData;
|
2200
2217
|
}, [hydrogenCart, contextParameters]);
|
2201
|
-
const isLoading = (0,
|
2218
|
+
const isLoading = (0, import_react4.useMemo)(() => {
|
2202
2219
|
if (isHydrogenReact && hReactStatus) {
|
2203
2220
|
return ["fetching", "creating", "updating"].includes(hReactStatus);
|
2204
2221
|
}
|
2205
2222
|
return !rebuyContext || !contextParameters;
|
2206
2223
|
}, [isHydrogenReact, hReactStatus, rebuyContext, contextParameters]);
|
2207
|
-
const error = (0,
|
2224
|
+
const error = (0, import_react4.useMemo)(() => {
|
2208
2225
|
if (isHydrogenReact && hReactError) {
|
2209
2226
|
if (typeof hReactError === "string") return hReactError;
|
2210
2227
|
if (hReactError instanceof Error) return hReactError.message;
|
@@ -2216,7 +2233,7 @@ var SmartCartProvider = ({
|
|
2216
2233
|
}
|
2217
2234
|
return null;
|
2218
2235
|
}, [isHydrogenReact, hReactError]);
|
2219
|
-
const isCartReady = (0,
|
2236
|
+
const isCartReady = (0, import_react4.useMemo)(() => !!mappedStorefrontCartData, [mappedStorefrontCartData]);
|
2220
2237
|
const tpbStoreInstance = useTieredProgressBarStore();
|
2221
2238
|
const {
|
2222
2239
|
activeBarConfig,
|
@@ -2246,23 +2263,23 @@ var SmartCartProvider = ({
|
|
2246
2263
|
"smart-cart-ctx-tpb-selector" /* SC_CTX_TPB_SELECTOR */,
|
2247
2264
|
`tpbCartSyncStatus: ${tpbCartSyncStatus}, tpbUserActionStatus: ${tpbUserActionStatus}`
|
2248
2265
|
);
|
2249
|
-
const isProcessingTPBGifts = (0,
|
2266
|
+
const isProcessingTPBGifts = (0, import_react4.useMemo)(() => {
|
2250
2267
|
return tpbCartSyncStatus === "syncing" || tpbCartSyncStatus === "awaiting_cart_update" || tpbUserActionStatus === "pending";
|
2251
2268
|
}, [tpbCartSyncStatus, tpbUserActionStatus]);
|
2252
|
-
const isCartBusy = (0,
|
2269
|
+
const isCartBusy = (0, import_react4.useMemo)(() => {
|
2253
2270
|
return isLoading || isProcessingTPBGifts;
|
2254
2271
|
}, [isLoading, isProcessingTPBGifts]);
|
2255
2272
|
rebuyDebugLog.log("smart-cart-ctx" /* SC_CTX */, "isCartBusy state:", isCartBusy);
|
2256
|
-
const progressBarSettings = (0,
|
2273
|
+
const progressBarSettings = (0, import_react4.useMemo)(() => {
|
2257
2274
|
const tpbComponentConfig = config?.components?.find((comp) => comp.type === "tiered_progress_bar");
|
2258
2275
|
return tpbComponentConfig?.settings ?? null;
|
2259
2276
|
}, [config]);
|
2260
|
-
(0,
|
2277
|
+
(0, import_react4.useEffect)(() => {
|
2261
2278
|
if (progressBarSettings && isCartReady && shopifyDomain && storefrontAccessToken) {
|
2262
2279
|
tpbInit(progressBarSettings, shopifyDomain, storefrontAccessToken);
|
2263
2280
|
}
|
2264
2281
|
}, [progressBarSettings, isCartReady, shopifyDomain, storefrontAccessToken, tpbInit]);
|
2265
|
-
(0,
|
2282
|
+
(0, import_react4.useEffect)(() => {
|
2266
2283
|
const currentTpbState = useTieredProgressBarStore.getState();
|
2267
2284
|
const newTpbIsCartReady = isCartReady;
|
2268
2285
|
if (!(0, import_lodash_es2.isEqual)(currentTpbState.cartData, mappedStorefrontCartData) || currentTpbState.isCartReady !== newTpbIsCartReady) {
|
@@ -2283,7 +2300,7 @@ var SmartCartProvider = ({
|
|
2283
2300
|
);
|
2284
2301
|
return Promise.resolve(null);
|
2285
2302
|
};
|
2286
|
-
const addItems = (0,
|
2303
|
+
const addItems = (0, import_react4.useCallback)(
|
2287
2304
|
(items) => {
|
2288
2305
|
if (isHydrogenReact && hReactActions?.linesAdd) {
|
2289
2306
|
const linesToAdd = items.map((item) => ({
|
@@ -2300,7 +2317,7 @@ var SmartCartProvider = ({
|
|
2300
2317
|
},
|
2301
2318
|
[isHydrogenReact, hReactActions]
|
2302
2319
|
);
|
2303
|
-
const addItem = (0,
|
2320
|
+
const addItem = (0, import_react4.useCallback)(
|
2304
2321
|
(variantId, attributes, quantity = 1) => {
|
2305
2322
|
const mappedAttributes = mapStorefrontAttributesToHRAttributes(attributes);
|
2306
2323
|
const item = {
|
@@ -2314,7 +2331,7 @@ var SmartCartProvider = ({
|
|
2314
2331
|
[addItems]
|
2315
2332
|
// Dependency is the refactored addItems
|
2316
2333
|
);
|
2317
|
-
const updateItems = (0,
|
2334
|
+
const updateItems = (0, import_react4.useCallback)(
|
2318
2335
|
(updates) => {
|
2319
2336
|
if (isHydrogenReact && hReactActions?.linesUpdate) {
|
2320
2337
|
const linesToUpdate = updates.map((update) => ({
|
@@ -2332,7 +2349,7 @@ var SmartCartProvider = ({
|
|
2332
2349
|
},
|
2333
2350
|
[isHydrogenReact, hReactActions]
|
2334
2351
|
);
|
2335
|
-
const updateItem = (0,
|
2352
|
+
const updateItem = (0, import_react4.useCallback)(
|
2336
2353
|
(lineId, updates) => {
|
2337
2354
|
const updatePayload = {
|
2338
2355
|
id: lineId,
|
@@ -2342,7 +2359,7 @@ var SmartCartProvider = ({
|
|
2342
2359
|
},
|
2343
2360
|
[updateItems]
|
2344
2361
|
);
|
2345
|
-
const removeItems = (0,
|
2362
|
+
const removeItems = (0, import_react4.useCallback)(
|
2346
2363
|
(lineIds) => {
|
2347
2364
|
if (isHydrogenReact && hReactActions?.linesRemove) {
|
2348
2365
|
rebuyDebugLog.log("smart-cart-ctx-h-react" /* SC_CTX_H_REACT */, "Dispatching H-React linesRemove:", lineIds);
|
@@ -2353,8 +2370,8 @@ var SmartCartProvider = ({
|
|
2353
2370
|
},
|
2354
2371
|
[isHydrogenReact, hReactActions]
|
2355
2372
|
);
|
2356
|
-
const removeItem = (0,
|
2357
|
-
const applyDiscountCodes = (0,
|
2373
|
+
const removeItem = (0, import_react4.useCallback)((lineId) => removeItems([lineId]), [removeItems]);
|
2374
|
+
const applyDiscountCodes = (0, import_react4.useCallback)(
|
2358
2375
|
(codes) => {
|
2359
2376
|
if (isHydrogenReact && hReactActions?.discountCodesUpdate) {
|
2360
2377
|
rebuyDebugLog.log("smart-cart-ctx-h-react" /* SC_CTX_H_REACT */, "Dispatching H-React discountCodesUpdate:", codes);
|
@@ -2365,7 +2382,7 @@ var SmartCartProvider = ({
|
|
2365
2382
|
},
|
2366
2383
|
[isHydrogenReact, hReactActions]
|
2367
2384
|
);
|
2368
|
-
const updateCartAttributes = (0,
|
2385
|
+
const updateCartAttributes = (0, import_react4.useCallback)(
|
2369
2386
|
(attributes) => {
|
2370
2387
|
if (isHydrogenReact && hReactActions?.cartAttributesUpdate) {
|
2371
2388
|
const attrsToUpdate = mapStorefrontAttributesToHRAttributes(attributes);
|
@@ -2377,7 +2394,7 @@ var SmartCartProvider = ({
|
|
2377
2394
|
},
|
2378
2395
|
[isHydrogenReact, hReactActions]
|
2379
2396
|
);
|
2380
|
-
const updateCartNote = (0,
|
2397
|
+
const updateCartNote = (0, import_react4.useCallback)(
|
2381
2398
|
(note) => {
|
2382
2399
|
if (isHydrogenReact && hReactActions?.noteUpdate) {
|
2383
2400
|
const noteToUpdate = note ?? "";
|
@@ -2389,7 +2406,7 @@ var SmartCartProvider = ({
|
|
2389
2406
|
},
|
2390
2407
|
[isHydrogenReact, hReactActions]
|
2391
2408
|
);
|
2392
|
-
const checkout = (0,
|
2409
|
+
const checkout = (0, import_react4.useCallback)(() => {
|
2393
2410
|
const checkoutUrl = mappedStorefrontCartData?.checkoutUrl;
|
2394
2411
|
if (checkoutUrl) {
|
2395
2412
|
window.location.href = checkoutUrl;
|
@@ -2401,7 +2418,7 @@ var SmartCartProvider = ({
|
|
2401
2418
|
);
|
2402
2419
|
}
|
2403
2420
|
}, [mappedStorefrontCartData]);
|
2404
|
-
(0,
|
2421
|
+
(0, import_react4.useEffect)(() => {
|
2405
2422
|
const conditions = {
|
2406
2423
|
activeBarConfigPresent: !!activeBarConfig,
|
2407
2424
|
cartDataIsEqual: (0, import_lodash_es2.isEqual)(tpbInternalCartData, mappedStorefrontCartData),
|
@@ -2438,20 +2455,20 @@ var SmartCartProvider = ({
|
|
2438
2455
|
tpbSyncCartGifts,
|
2439
2456
|
mappedStorefrontCartData
|
2440
2457
|
]);
|
2441
|
-
const getItemCount = (0,
|
2442
|
-
const getCartSubtotal = (0,
|
2458
|
+
const getItemCount = (0, import_react4.useCallback)(() => mappedStorefrontCartData?.totalQuantity ?? 0, [mappedStorefrontCartData]);
|
2459
|
+
const getCartSubtotal = (0, import_react4.useCallback)(
|
2443
2460
|
() => mappedStorefrontCartData?.cost?.subtotalAmount?.amount ?? "0.00",
|
2444
2461
|
[mappedStorefrontCartData]
|
2445
2462
|
);
|
2446
|
-
const getComponentConfigByType = (0,
|
2463
|
+
const getComponentConfigByType = (0, import_react4.useCallback)(
|
2447
2464
|
(type) => config?.components?.find((comp) => comp.type === type),
|
2448
2465
|
[config?.components]
|
2449
2466
|
);
|
2450
|
-
const getComponentConfigById = (0,
|
2467
|
+
const getComponentConfigById = (0, import_react4.useCallback)(
|
2451
2468
|
(id) => config?.components?.find((comp) => comp.component_id === id),
|
2452
2469
|
[config?.components]
|
2453
2470
|
);
|
2454
|
-
const combinedValue = (0,
|
2471
|
+
const combinedValue = (0, import_react4.useMemo)(
|
2455
2472
|
() => ({
|
2456
2473
|
addItem,
|
2457
2474
|
addItems,
|
@@ -2525,7 +2542,7 @@ var SmartCartProvider = ({
|
|
2525
2542
|
};
|
2526
2543
|
var warningLogged = false;
|
2527
2544
|
var useSmartCart = () => {
|
2528
|
-
const context = (0,
|
2545
|
+
const context = (0, import_react4.useContext)(SmartCartContext);
|
2529
2546
|
if (context === void 0 || context === null) {
|
2530
2547
|
if (!warningLogged) {
|
2531
2548
|
console.warn(
|
@@ -2776,6 +2793,7 @@ var RebuyHydrogenContext = ({
|
|
2776
2793
|
shop,
|
2777
2794
|
sourceHydrogenCart
|
2778
2795
|
}) => {
|
2796
|
+
const resetKey = useBFCacheReset();
|
2779
2797
|
const {
|
2780
2798
|
apiKey,
|
2781
2799
|
fetchError: configFetchError,
|
@@ -2784,11 +2802,11 @@ var RebuyHydrogenContext = ({
|
|
2784
2802
|
shopDomain: configShopDomain,
|
2785
2803
|
smartCartConfig
|
2786
2804
|
} = useRebuyConfig();
|
2787
|
-
const warningLogged2 = (0,
|
2805
|
+
const warningLogged2 = (0, import_react5.useRef)(false);
|
2788
2806
|
const location = (0, import_react_router.useLocation)();
|
2789
2807
|
const queryObject = Utilities2.queryStringToObject(location.search);
|
2790
2808
|
const windowUrl = `${shop}${location.pathname}${location.search}`;
|
2791
|
-
const contextParameters = (0,
|
2809
|
+
const contextParameters = (0, import_react5.useMemo)(
|
2792
2810
|
() => createContextParameters({
|
2793
2811
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
2794
2812
|
isHydrogenReact: false,
|
@@ -2798,8 +2816,8 @@ var RebuyHydrogenContext = ({
|
|
2798
2816
|
}),
|
2799
2817
|
[rebuyConfig?.shop?.cache_key, windowUrl, queryObject, sourceHydrogenCart]
|
2800
2818
|
);
|
2801
|
-
const defaultContextValue = (0,
|
2802
|
-
const contextValue = (0,
|
2819
|
+
const defaultContextValue = (0, import_react5.useMemo)(() => null, []);
|
2820
|
+
const contextValue = (0, import_react5.useMemo)(
|
2803
2821
|
() => configLoadingStatus === "success" && rebuyConfig ? { contextParameters } : defaultContextValue,
|
2804
2822
|
[configLoadingStatus, rebuyConfig, contextParameters, defaultContextValue]
|
2805
2823
|
);
|
@@ -2817,7 +2835,8 @@ var RebuyHydrogenContext = ({
|
|
2817
2835
|
shopifyDomain: shopifyDomainForSmartCart,
|
2818
2836
|
storefrontAccessToken,
|
2819
2837
|
children
|
2820
|
-
}
|
2838
|
+
},
|
2839
|
+
`smart-cart-${resetKey}`
|
2821
2840
|
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
2822
2841
|
enableSmartCart && !hasAllSmartCartPrerequisites && !warningLogged2.current && (() => {
|
2823
2842
|
console.warn(
|
@@ -2875,7 +2894,7 @@ var RebuyHydrogenContextProvider = ({
|
|
2875
2894
|
// src/providers/RebuyHydrogenReactContextProvider.tsx
|
2876
2895
|
var Utilities3 = __toESM(require("@rebuy/rebuy/utilities"), 1);
|
2877
2896
|
var import_hydrogen_react = require("@shopify/hydrogen-react");
|
2878
|
-
var
|
2897
|
+
var import_react6 = require("react");
|
2879
2898
|
var import_react_router2 = require("react-router");
|
2880
2899
|
|
2881
2900
|
// src/queries/cart.queries.ts
|
@@ -3419,6 +3438,7 @@ var RebuyHydrogenReactContext = ({
|
|
3419
3438
|
publicPrimaryDomain,
|
3420
3439
|
publicStorefrontToken
|
3421
3440
|
}) => {
|
3441
|
+
const resetKey = useBFCacheReset();
|
3422
3442
|
const {
|
3423
3443
|
apiKey,
|
3424
3444
|
fetchError: configFetchError,
|
@@ -3426,7 +3446,7 @@ var RebuyHydrogenReactContext = ({
|
|
3426
3446
|
rebuyConfig,
|
3427
3447
|
shopDomain: configShopDomain
|
3428
3448
|
} = useRebuyConfig();
|
3429
|
-
const warningLogged2 = (0,
|
3449
|
+
const warningLogged2 = (0, import_react6.useRef)(false);
|
3430
3450
|
const location = (0, import_react_router2.useLocation)();
|
3431
3451
|
const queryObject = Utilities3.queryStringToObject(location.search);
|
3432
3452
|
const windowUrl = publicPrimaryDomain ? `${publicPrimaryDomain}${location.pathname}${location.search}` : "";
|
@@ -3442,7 +3462,7 @@ var RebuyHydrogenReactContext = ({
|
|
3442
3462
|
status: hydrogenReactCartStatus,
|
3443
3463
|
...hydrogenReactCartData
|
3444
3464
|
} = (0, import_hydrogen_react.useCart)();
|
3445
|
-
const hydrogenReactCartActions = (0,
|
3465
|
+
const hydrogenReactCartActions = (0, import_react6.useMemo)(
|
3446
3466
|
() => ({
|
3447
3467
|
cartAttributesUpdate,
|
3448
3468
|
cartCreate,
|
@@ -3454,7 +3474,7 @@ var RebuyHydrogenReactContext = ({
|
|
3454
3474
|
}),
|
3455
3475
|
[cartAttributesUpdate, cartCreate, discountCodesUpdate, linesAdd, linesRemove, linesUpdate, noteUpdate]
|
3456
3476
|
);
|
3457
|
-
const contextParameters = (0,
|
3477
|
+
const contextParameters = (0, import_react6.useMemo)(() => {
|
3458
3478
|
const propsForParamCreation = {
|
3459
3479
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
3460
3480
|
hydrogenReactCartActions,
|
@@ -3476,8 +3496,8 @@ var RebuyHydrogenReactContext = ({
|
|
3476
3496
|
hydrogenReactCartStatus,
|
3477
3497
|
hydrogenReactCartError
|
3478
3498
|
]);
|
3479
|
-
const defaultContextValue = (0,
|
3480
|
-
const rebuyContextValue = (0,
|
3499
|
+
const defaultContextValue = (0, import_react6.useMemo)(() => ({ contextParameters: {} }), []);
|
3500
|
+
const rebuyContextValue = (0, import_react6.useMemo)(
|
3481
3501
|
() => configLoadingStatus === "success" && rebuyConfig ? { contextParameters } : defaultContextValue,
|
3482
3502
|
[configLoadingStatus, rebuyConfig, contextParameters, defaultContextValue]
|
3483
3503
|
);
|
@@ -3486,7 +3506,7 @@ var RebuyHydrogenReactContext = ({
|
|
3486
3506
|
const shopifyDomainForSmartCart = configShopDomain || rebuyConfig?.shop?.domain || "";
|
3487
3507
|
const storefrontAccessToken = publicStorefrontToken || rebuyConfig?.shop?.storefront_access_token || "";
|
3488
3508
|
const hasAllSmartCartPrerequisites = enableSmartCart && configLoadingStatus === "success" && !!rebuyConfig && !!(smartCartConfig && apiKey && shopifyDomainForSmartCart && storefrontAccessToken);
|
3489
|
-
(0,
|
3509
|
+
(0, import_react6.useEffect)(() => {
|
3490
3510
|
if (configLoadingStatus === "loading") return;
|
3491
3511
|
const smartCartDetails = enableSmartCart ? {
|
3492
3512
|
hasAllSmartCartPrerequisites,
|
@@ -3523,7 +3543,8 @@ var RebuyHydrogenReactContext = ({
|
|
3523
3543
|
shopifyDomain: shopifyDomainForSmartCart,
|
3524
3544
|
storefrontAccessToken,
|
3525
3545
|
children
|
3526
|
-
}
|
3546
|
+
},
|
3547
|
+
`smart-cart-react-${resetKey}`
|
3527
3548
|
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
3528
3549
|
enableSmartCart && !hasAllSmartCartPrerequisites && !warningLogged2.current && (() => {
|
3529
3550
|
console.warn(
|
@@ -3576,7 +3597,7 @@ var RebuyHydrogenReactContextProvider = ({
|
|
3576
3597
|
publicStorefrontToken,
|
3577
3598
|
storefrontApiVersion = "2025-01"
|
3578
3599
|
}) => {
|
3579
|
-
const adaptedCallbacks = (0,
|
3600
|
+
const adaptedCallbacks = (0, import_react6.useMemo)(
|
3580
3601
|
() => ({
|
3581
3602
|
onAttributesUpdate: onAttributesUpdate ? () => onAttributesUpdate() : void 0,
|
3582
3603
|
onAttributesUpdateComplete: onAttributesUpdateComplete ? () => onAttributesUpdateComplete() : void 0,
|
@@ -3662,14 +3683,14 @@ var RebuyHydrogenReactContextProvider = ({
|
|
3662
3683
|
|
3663
3684
|
// src/smart-cart/components/SmartCartContainer/SmartCartContainer.tsx
|
3664
3685
|
var import_clsx13 = __toESM(require("clsx"), 1);
|
3665
|
-
var
|
3686
|
+
var import_react33 = __toESM(require("react"), 1);
|
3666
3687
|
|
3667
3688
|
// src/smart-cart/components/_Layouts/AnchorSlot.tsx
|
3668
|
-
var
|
3689
|
+
var import_react29 = require("react");
|
3669
3690
|
|
3670
3691
|
// src/smart-cart/components/AnnouncementBar/AnnouncementBar.tsx
|
3671
3692
|
var import_dompurify = __toESM(require("dompurify"), 1);
|
3672
|
-
var
|
3693
|
+
var import_react7 = __toESM(require("react"), 1);
|
3673
3694
|
|
3674
3695
|
// src/smart-cart/components/ScreenReaderText/ScreenReaderText.tsx
|
3675
3696
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
@@ -3683,17 +3704,17 @@ var AnnouncementBar_default = result;
|
|
3683
3704
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
3684
3705
|
var AUTOPLAY_INTERVAL = 5e3;
|
3685
3706
|
var DRAG_THRESHOLD = 50;
|
3686
|
-
var AnnouncementBar =
|
3707
|
+
var AnnouncementBar = import_react7.default.memo(({ componentConfig }) => {
|
3687
3708
|
const { isVisible } = useSmartCart();
|
3688
|
-
const [currentSlideIndex, setCurrentSlideIndex] = (0,
|
3689
|
-
const [isPaused, setIsPaused] = (0,
|
3690
|
-
const [isFocused, setIsFocused] = (0,
|
3691
|
-
const intervalRef = (0,
|
3692
|
-
const containerRef = (0,
|
3693
|
-
const [isDragging, setIsDragging] = (0,
|
3694
|
-
const [startX, setStartX] = (0,
|
3695
|
-
const [dragOffset, setDragOffset] = (0,
|
3696
|
-
const sanitizedMessages = (0,
|
3709
|
+
const [currentSlideIndex, setCurrentSlideIndex] = (0, import_react7.useState)(0);
|
3710
|
+
const [isPaused, setIsPaused] = (0, import_react7.useState)(false);
|
3711
|
+
const [isFocused, setIsFocused] = (0, import_react7.useState)(false);
|
3712
|
+
const intervalRef = (0, import_react7.useRef)(null);
|
3713
|
+
const containerRef = (0, import_react7.useRef)(null);
|
3714
|
+
const [isDragging, setIsDragging] = (0, import_react7.useState)(false);
|
3715
|
+
const [startX, setStartX] = (0, import_react7.useState)(0);
|
3716
|
+
const [dragOffset, setDragOffset] = (0, import_react7.useState)(0);
|
3717
|
+
const sanitizedMessages = (0, import_react7.useMemo)(() => {
|
3697
3718
|
const settings = componentConfig?.settings;
|
3698
3719
|
const rawMessages = settings?.messages ?? [];
|
3699
3720
|
if (!Array.isArray(rawMessages)) {
|
@@ -3704,13 +3725,13 @@ var AnnouncementBar = import_react6.default.memo(({ componentConfig }) => {
|
|
3704
3725
|
}, [componentConfig]);
|
3705
3726
|
const messageCount = sanitizedMessages.length;
|
3706
3727
|
const isCarousel = messageCount >= 2;
|
3707
|
-
const clearTimer = (0,
|
3728
|
+
const clearTimer = (0, import_react7.useCallback)(() => {
|
3708
3729
|
if (intervalRef.current) {
|
3709
3730
|
clearInterval(intervalRef.current);
|
3710
3731
|
intervalRef.current = null;
|
3711
3732
|
}
|
3712
3733
|
}, []);
|
3713
|
-
const startTimer = (0,
|
3734
|
+
const startTimer = (0, import_react7.useCallback)(() => {
|
3714
3735
|
clearTimer();
|
3715
3736
|
if (!isPaused && isVisible && isCarousel && !isFocused && !isDragging) {
|
3716
3737
|
intervalRef.current = setInterval(() => {
|
@@ -3718,17 +3739,17 @@ var AnnouncementBar = import_react6.default.memo(({ componentConfig }) => {
|
|
3718
3739
|
}, AUTOPLAY_INTERVAL);
|
3719
3740
|
}
|
3720
3741
|
}, [clearTimer, isPaused, isVisible, isCarousel, messageCount, isFocused, isDragging]);
|
3721
|
-
const goToSlide = (0,
|
3742
|
+
const goToSlide = (0, import_react7.useCallback)(
|
3722
3743
|
(index) => {
|
3723
3744
|
setCurrentSlideIndex((index + messageCount) % messageCount);
|
3724
3745
|
},
|
3725
3746
|
[messageCount]
|
3726
3747
|
);
|
3727
|
-
(0,
|
3748
|
+
(0, import_react7.useEffect)(() => {
|
3728
3749
|
startTimer();
|
3729
3750
|
return clearTimer;
|
3730
3751
|
}, [startTimer, isPaused, isVisible, isFocused]);
|
3731
|
-
(0,
|
3752
|
+
(0, import_react7.useEffect)(() => {
|
3732
3753
|
if (!isVisible) {
|
3733
3754
|
setCurrentSlideIndex(0);
|
3734
3755
|
setIsPaused(false);
|
@@ -3864,7 +3885,7 @@ AnnouncementBar.displayName = "AnnouncementBar";
|
|
3864
3885
|
|
3865
3886
|
// src/smart-cart/components/CartItem/CartItem.tsx
|
3866
3887
|
var import_clsx = __toESM(require("clsx"), 1);
|
3867
|
-
var
|
3888
|
+
var import_react9 = require("react");
|
3868
3889
|
var import_react_router4 = require("react-router");
|
3869
3890
|
|
3870
3891
|
// src/components/RebuyLink/RebuyLink.tsx
|
@@ -3875,7 +3896,7 @@ var RebuyLink = ({ ariaLabel, children, className, handle, onClick, role = "link
|
|
3875
3896
|
};
|
3876
3897
|
|
3877
3898
|
// src/smart-cart/hooks/useCartItemFeatures.ts
|
3878
|
-
var
|
3899
|
+
var import_react8 = require("react");
|
3879
3900
|
|
3880
3901
|
// src/smart-cart/utils/imageUtils.ts
|
3881
3902
|
var sizeImage = (src, size) => {
|
@@ -3904,107 +3925,107 @@ var mapCartAttributes = (attributes) => {
|
|
3904
3925
|
}));
|
3905
3926
|
};
|
3906
3927
|
var useCartItemFeatures = ({ config, line }) => {
|
3907
|
-
const [isBundleExpanded, setIsBundleExpanded] = (0,
|
3908
|
-
const productTitle = (0,
|
3909
|
-
const variantTitle = (0,
|
3928
|
+
const [isBundleExpanded, setIsBundleExpanded] = (0, import_react8.useState)(false);
|
3929
|
+
const productTitle = (0, import_react8.useMemo)(() => line.merchandise.product.title, [line.merchandise.product.title]);
|
3930
|
+
const variantTitle = (0, import_react8.useMemo)(
|
3910
3931
|
() => line.merchandise.title !== "Default Title" ? line.merchandise.title : null,
|
3911
3932
|
[line.merchandise.title]
|
3912
3933
|
);
|
3913
|
-
const itemUrl = (0,
|
3914
|
-
const imageAltText = (0,
|
3915
|
-
const imageUrl = (0,
|
3916
|
-
const linkLabel = (0,
|
3917
|
-
const tagCssClasses = (0,
|
3918
|
-
const attributeCssClasses = (0,
|
3919
|
-
const baseCssClasses = (0,
|
3934
|
+
const itemUrl = (0, import_react8.useMemo)(() => getItemURL(line), [line]);
|
3935
|
+
const imageAltText = (0, import_react8.useMemo)(() => getItemImageAlt(line), [line]);
|
3936
|
+
const imageUrl = (0, import_react8.useMemo)(() => sizeImage(line.merchandise.image?.url, "120x120"), [line.merchandise.image?.url]);
|
3937
|
+
const linkLabel = (0, import_react8.useMemo)(() => getItemLinkLabel(line), [line]);
|
3938
|
+
const tagCssClasses = (0, import_react8.useMemo)(() => getItemProductTagsClasses(line), [line]);
|
3939
|
+
const attributeCssClasses = (0, import_react8.useMemo)(() => getItemAttributeClasses(line), [line]);
|
3940
|
+
const baseCssClasses = (0, import_react8.useMemo)(
|
3920
3941
|
() => `product-${line.merchandise.product.handle}`,
|
3921
3942
|
[line.merchandise.product.handle]
|
3922
3943
|
);
|
3923
|
-
const pricing = (0,
|
3924
|
-
const deliveryFrequency = (0,
|
3925
|
-
const standardProperties = (0,
|
3926
|
-
const discountProperties = (0,
|
3927
|
-
const allVisibleProperties = (0,
|
3944
|
+
const pricing = (0, import_react8.useMemo)(() => calculatePricingData(line), [line]);
|
3945
|
+
const deliveryFrequency = (0, import_react8.useMemo)(() => getItemDeliveryFrequency(line), [line]);
|
3946
|
+
const standardProperties = (0, import_react8.useMemo)(() => getVisibleItemProperties(line), [line]);
|
3947
|
+
const discountProperties = (0, import_react8.useMemo)(() => getDiscountProperties(line), [line]);
|
3948
|
+
const allVisibleProperties = (0, import_react8.useMemo)(
|
3928
3949
|
() => [...standardProperties, ...discountProperties],
|
3929
3950
|
[standardProperties, discountProperties]
|
3930
3951
|
);
|
3931
|
-
const hasVisibleProperties = (0,
|
3952
|
+
const hasVisibleProperties = (0, import_react8.useMemo)(
|
3932
3953
|
() => allVisibleProperties.length > 0 || !!deliveryFrequency,
|
3933
3954
|
[allVisibleProperties, deliveryFrequency]
|
3934
3955
|
);
|
3935
|
-
const isBundleParent = (0,
|
3936
|
-
const bundleItemCount = (0,
|
3937
|
-
const shouldHideBundleOptions = (0,
|
3938
|
-
const showBundleToggle = (0,
|
3956
|
+
const isBundleParent = (0, import_react8.useMemo)(() => itemIsBundle(line), [line]);
|
3957
|
+
const bundleItemCount = (0, import_react8.useMemo)(() => isBundleParent ? getItemBundleLength(line) : 0, [isBundleParent, line]);
|
3958
|
+
const shouldHideBundleOptions = (0, import_react8.useMemo)(() => isBundleParent && hideBundleOptions(line), [isBundleParent, line]);
|
3959
|
+
const showBundleToggle = (0, import_react8.useMemo)(
|
3939
3960
|
() => isBundleParent && !shouldHideBundleOptions && bundleItemCount > 0,
|
3940
3961
|
[isBundleParent, shouldHideBundleOptions, bundleItemCount]
|
3941
3962
|
);
|
3942
|
-
const shouldHideQuantitySelector = (0,
|
3963
|
+
const shouldHideQuantitySelector = (0, import_react8.useMemo)(() => {
|
3943
3964
|
if (isTieredProgressBarGiftItem(line)) return true;
|
3944
3965
|
if (isCartItemHiddenByStandardLogic(line)) return true;
|
3945
3966
|
return false;
|
3946
3967
|
}, [line]);
|
3947
|
-
const isBmsmGloballyEnabled = (0,
|
3948
|
-
const isBmsmEligible = (0,
|
3968
|
+
const isBmsmGloballyEnabled = (0, import_react8.useMemo)(() => isBMSMEnabled(config), [config]);
|
3969
|
+
const isBmsmEligible = (0, import_react8.useMemo)(
|
3949
3970
|
() => isBmsmGloballyEnabled && itemHasBMSM(line, config),
|
3950
3971
|
[isBmsmGloballyEnabled, line, config]
|
3951
3972
|
);
|
3952
|
-
const bmsmNotAtFinalTier = (0,
|
3973
|
+
const bmsmNotAtFinalTier = (0, import_react8.useMemo)(
|
3953
3974
|
() => isBmsmEligible && bMSMFinalTierNotReached(line, config),
|
3954
3975
|
[isBmsmEligible, line, config]
|
3955
3976
|
);
|
3956
|
-
const isBmsmEnabledAndApplicable = (0,
|
3977
|
+
const isBmsmEnabledAndApplicable = (0, import_react8.useMemo)(
|
3957
3978
|
() => isBmsmEligible && bmsmNotAtFinalTier,
|
3958
3979
|
[isBmsmEligible, bmsmNotAtFinalTier]
|
3959
3980
|
);
|
3960
|
-
const isBmsmButtonMode = (0,
|
3981
|
+
const isBmsmButtonMode = (0, import_react8.useMemo)(
|
3961
3982
|
() => isBmsmEnabledAndApplicable && hasBMSMButtons(config),
|
3962
3983
|
[isBmsmEnabledAndApplicable, config]
|
3963
3984
|
);
|
3964
|
-
const bmsmTiers = (0,
|
3985
|
+
const bmsmTiers = (0, import_react8.useMemo)(
|
3965
3986
|
() => isBmsmEnabledAndApplicable ? getBMSMTiers(config) : [],
|
3966
3987
|
[isBmsmEnabledAndApplicable, config]
|
3967
3988
|
);
|
3968
|
-
const bmsmNextApplicableTiers = (0,
|
3989
|
+
const bmsmNextApplicableTiers = (0, import_react8.useMemo)(
|
3969
3990
|
() => isBmsmButtonMode ? bmsmTiers.filter((tier) => tier.quantity && tier.quantity > line.quantity).sort((a, b) => (a.quantity ?? 0) - (b.quantity ?? 0)) : [],
|
3970
3991
|
[isBmsmButtonMode, bmsmTiers, line.quantity]
|
3971
3992
|
);
|
3972
|
-
const bmsmDynamicText = (0,
|
3993
|
+
const bmsmDynamicText = (0, import_react8.useMemo)(
|
3973
3994
|
() => isBmsmEnabledAndApplicable && !isBmsmButtonMode ? buyMoreSaveMoreDynamicText(line, config) : "",
|
3974
3995
|
[isBmsmEnabledAndApplicable, isBmsmButtonMode, line, config]
|
3975
3996
|
);
|
3976
|
-
const isStsGloballyEnabled = (0,
|
3977
|
-
const productHasSellingPlans = (0,
|
3997
|
+
const isStsGloballyEnabled = (0, import_react8.useMemo)(() => config?.switch_to_subscription_enabled ?? false, [config]);
|
3998
|
+
const productHasSellingPlans = (0, import_react8.useMemo)(
|
3978
3999
|
() => (line.merchandise.product.sellingPlanGroups?.edges ?? []).length > 0,
|
3979
4000
|
[line.merchandise.product.sellingPlanGroups]
|
3980
4001
|
);
|
3981
|
-
const isStsEligible = (0,
|
4002
|
+
const isStsEligible = (0, import_react8.useMemo)(
|
3982
4003
|
() => isStsGloballyEnabled && productHasSellingPlans,
|
3983
4004
|
[isStsGloballyEnabled, productHasSellingPlans]
|
3984
4005
|
);
|
3985
|
-
const isCurrentlySubscription = (0,
|
3986
|
-
const productRequiresSellingPlan = (0,
|
4006
|
+
const isCurrentlySubscription = (0, import_react8.useMemo)(() => !!line.sellingPlanAllocation, [line.sellingPlanAllocation]);
|
4007
|
+
const productRequiresSellingPlan = (0, import_react8.useMemo)(
|
3987
4008
|
() => line.merchandise.product.requiresSellingPlan ?? false,
|
3988
4009
|
[line.merchandise.product]
|
3989
4010
|
);
|
3990
|
-
const downgradeGloballyAllowed = (0,
|
4011
|
+
const downgradeGloballyAllowed = (0, import_react8.useMemo)(
|
3991
4012
|
() => !(config?.switch_to_subscription?.disable_downgrade ?? false),
|
3992
4013
|
[config?.switch_to_subscription?.disable_downgrade]
|
3993
4014
|
);
|
3994
|
-
const canStsDowngrade = (0,
|
4015
|
+
const canStsDowngrade = (0, import_react8.useMemo)(
|
3995
4016
|
() => isStsEligible && downgradeGloballyAllowed && !productRequiresSellingPlan,
|
3996
4017
|
[isStsEligible, downgradeGloballyAllowed, productRequiresSellingPlan]
|
3997
4018
|
);
|
3998
|
-
const stsAvailableFrequencies = (0,
|
3999
|
-
const defaultSellingPlanDiscountPercent = (0,
|
4019
|
+
const stsAvailableFrequencies = (0, import_react8.useMemo)(() => getAvailableSellingPlans(line), [line]);
|
4020
|
+
const defaultSellingPlanDiscountPercent = (0, import_react8.useMemo)(
|
4000
4021
|
() => calculateDefaultSellingPlanDiscount(stsAvailableFrequencies, line),
|
4001
4022
|
[stsAvailableFrequencies, line]
|
4002
4023
|
);
|
4003
|
-
const isStsEnabledAndApplicable = (0,
|
4024
|
+
const isStsEnabledAndApplicable = (0, import_react8.useMemo)(
|
4004
4025
|
() => isStsEligible && (canStsDowngrade || stsAvailableFrequencies.length > 1 || !isCurrentlySubscription && stsAvailableFrequencies.length > 0),
|
4005
4026
|
[isStsEligible, canStsDowngrade, stsAvailableFrequencies.length, isCurrentlySubscription]
|
4006
4027
|
);
|
4007
|
-
const getStsLabel = (0,
|
4028
|
+
const getStsLabel = (0, import_react8.useCallback)(
|
4008
4029
|
// This remains as it's for UI text
|
4009
4030
|
(key, fallback) => {
|
4010
4031
|
const labelTemplate = config?.switch_to_subscription?.language?.[key] ?? fallback ?? key.toString();
|
@@ -4016,7 +4037,7 @@ var useCartItemFeatures = ({ config, line }) => {
|
|
4016
4037
|
},
|
4017
4038
|
[config?.switch_to_subscription?.language, defaultSellingPlanDiscountPercent]
|
4018
4039
|
);
|
4019
|
-
const prepareDecreaseQuantity = (0,
|
4040
|
+
const prepareDecreaseQuantity = (0, import_react8.useCallback)(() => {
|
4020
4041
|
const newQuantity = line.quantity - 1;
|
4021
4042
|
if (newQuantity <= 0) {
|
4022
4043
|
rebuyDebugLog.log("smart-cart-cart-item-features" /* SC_CART_ITEM_FEATURES */, `Preparing remove for ${line.id} (qty became 0).`);
|
@@ -4048,7 +4069,7 @@ var useCartItemFeatures = ({ config, line }) => {
|
|
4048
4069
|
rebuyDebugLog.log("smart-cart-cart-item-features" /* SC_CART_ITEM_FEATURES */, `Preparing decrease qty for ${line.id} to ${newQuantity}.`);
|
4049
4070
|
return { attributes: finalAttributesInput, lineId: line.id, quantity: newQuantity };
|
4050
4071
|
}, [line, config]);
|
4051
|
-
const prepareIncreaseQuantity = (0,
|
4072
|
+
const prepareIncreaseQuantity = (0, import_react8.useCallback)(() => {
|
4052
4073
|
const newQuantity = line.quantity + 1;
|
4053
4074
|
let finalAttributes = void 0;
|
4054
4075
|
const currentAttributes = line.attributes;
|
@@ -4073,11 +4094,11 @@ var useCartItemFeatures = ({ config, line }) => {
|
|
4073
4094
|
rebuyDebugLog.log("smart-cart-cart-item-features" /* SC_CART_ITEM_FEATURES */, `Preparing increase qty for ${line.id} to ${newQuantity}.`);
|
4074
4095
|
return { attributes: finalAttributesInput, lineId: line.id, quantity: newQuantity };
|
4075
4096
|
}, [line, config]);
|
4076
|
-
const prepareRemoveItem = (0,
|
4097
|
+
const prepareRemoveItem = (0, import_react8.useCallback)(() => {
|
4077
4098
|
rebuyDebugLog.log("smart-cart-cart-item-features" /* SC_CART_ITEM_FEATURES */, `Preparing remove for ${line.id}.`);
|
4078
4099
|
return { lineId: line.id };
|
4079
4100
|
}, [line.id]);
|
4080
|
-
const prepareAdjustBMSMQuantity = (0,
|
4101
|
+
const prepareAdjustBMSMQuantity = (0, import_react8.useCallback)(
|
4081
4102
|
(tierQuantity) => {
|
4082
4103
|
if (tierQuantity === line.quantity) return null;
|
4083
4104
|
const currentAttributes = line.attributes;
|
@@ -4098,10 +4119,10 @@ var useCartItemFeatures = ({ config, line }) => {
|
|
4098
4119
|
},
|
4099
4120
|
[line]
|
4100
4121
|
);
|
4101
|
-
const toggleBundle = (0,
|
4122
|
+
const toggleBundle = (0, import_react8.useCallback)(() => {
|
4102
4123
|
setIsBundleExpanded((prev) => !prev);
|
4103
4124
|
}, []);
|
4104
|
-
const prepareSubscriptionSwitch = (0,
|
4125
|
+
const prepareSubscriptionSwitch = (0, import_react8.useCallback)(
|
4105
4126
|
(targetSellingPlanId) => {
|
4106
4127
|
const currentAttributes = line.attributes;
|
4107
4128
|
let finalAttributesArray = void 0;
|
@@ -4148,7 +4169,7 @@ var useCartItemFeatures = ({ config, line }) => {
|
|
4148
4169
|
},
|
4149
4170
|
[line, isCurrentlySubscription]
|
4150
4171
|
);
|
4151
|
-
return (0,
|
4172
|
+
return (0, import_react8.useMemo)(
|
4152
4173
|
() => ({
|
4153
4174
|
actions: {
|
4154
4175
|
prepareAdjustBMSMQuantity,
|
@@ -4297,12 +4318,12 @@ var Spinner = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("
|
|
4297
4318
|
var CartItem = ({ line }) => {
|
4298
4319
|
const { config, isCartBusy, isHydrogenReact, removeItem, updateItem } = useSmartCart();
|
4299
4320
|
const itemFetcher = (0, import_react_router4.useFetcher)();
|
4300
|
-
const [isIncreasing, setIsIncreasing] = (0,
|
4301
|
-
const [isDecreasing, setIsDecreasing] = (0,
|
4302
|
-
const [isRemoving, setIsRemoving] = (0,
|
4303
|
-
const [isAdjustingBMSM, setIsAdjustingBMSM] = (0,
|
4304
|
-
const [isSwitchingSubscription, setIsSwitchingSubscription] = (0,
|
4305
|
-
const [switchingDirection, setSwitchingDirection] = (0,
|
4321
|
+
const [isIncreasing, setIsIncreasing] = (0, import_react9.useState)(false);
|
4322
|
+
const [isDecreasing, setIsDecreasing] = (0, import_react9.useState)(false);
|
4323
|
+
const [isRemoving, setIsRemoving] = (0, import_react9.useState)(false);
|
4324
|
+
const [isAdjustingBMSM, setIsAdjustingBMSM] = (0, import_react9.useState)(false);
|
4325
|
+
const [isSwitchingSubscription, setIsSwitchingSubscription] = (0, import_react9.useState)(false);
|
4326
|
+
const [switchingDirection, setSwitchingDirection] = (0, import_react9.useState)(null);
|
4306
4327
|
const { toggleCart } = useSmartCart();
|
4307
4328
|
const {
|
4308
4329
|
actions: itemActionsLogic,
|
@@ -4315,7 +4336,7 @@ var CartItem = ({ line }) => {
|
|
4315
4336
|
shouldHideQuantitySelector,
|
4316
4337
|
sts
|
4317
4338
|
} = useCartItemFeatures({ config, line });
|
4318
|
-
const isLoadingCombined = (0,
|
4339
|
+
const isLoadingCombined = (0, import_react9.useMemo)(() => {
|
4319
4340
|
if (isCartBusy) {
|
4320
4341
|
return true;
|
4321
4342
|
}
|
@@ -4343,7 +4364,7 @@ var CartItem = ({ line }) => {
|
|
4343
4364
|
meta.attributeCssClasses,
|
4344
4365
|
{ [CartItem_default["rebuy-cart-item--updating"]]: isLoadingCombined }
|
4345
4366
|
);
|
4346
|
-
const handleDecreaseQuantity = (0,
|
4367
|
+
const handleDecreaseQuantity = (0, import_react9.useCallback)(() => {
|
4347
4368
|
if (isLoadingCombined) return;
|
4348
4369
|
const payload = itemActionsLogic.prepareDecreaseQuantity();
|
4349
4370
|
setIsDecreasing(true);
|
@@ -4377,7 +4398,7 @@ var CartItem = ({ line }) => {
|
|
4377
4398
|
}
|
4378
4399
|
}
|
4379
4400
|
}, [isLoadingCombined, itemActionsLogic, isHydrogenReact, updateItem, removeItem, itemFetcher]);
|
4380
|
-
const handleIncreaseQuantity = (0,
|
4401
|
+
const handleIncreaseQuantity = (0, import_react9.useCallback)(() => {
|
4381
4402
|
if (isLoadingCombined) return;
|
4382
4403
|
setIsIncreasing(true);
|
4383
4404
|
const payload = itemActionsLogic.prepareIncreaseQuantity();
|
@@ -4395,7 +4416,7 @@ var CartItem = ({ line }) => {
|
|
4395
4416
|
);
|
4396
4417
|
}
|
4397
4418
|
}, [isLoadingCombined, itemActionsLogic, isHydrogenReact, updateItem, itemFetcher]);
|
4398
|
-
const handleRemoveItem = (0,
|
4419
|
+
const handleRemoveItem = (0, import_react9.useCallback)(() => {
|
4399
4420
|
if (isLoadingCombined) return;
|
4400
4421
|
setIsRemoving(true);
|
4401
4422
|
const payload = itemActionsLogic.prepareRemoveItem();
|
@@ -4411,7 +4432,7 @@ var CartItem = ({ line }) => {
|
|
4411
4432
|
);
|
4412
4433
|
}
|
4413
4434
|
}, [isLoadingCombined, itemActionsLogic, isHydrogenReact, removeItem, itemFetcher]);
|
4414
|
-
const handleAdjustBMSMQuantity = (0,
|
4435
|
+
const handleAdjustBMSMQuantity = (0, import_react9.useCallback)(
|
4415
4436
|
(tierQuantity) => {
|
4416
4437
|
if (isLoadingCombined) return;
|
4417
4438
|
const payload = itemActionsLogic.prepareAdjustBMSMQuantity(tierQuantity);
|
@@ -4433,7 +4454,7 @@ var CartItem = ({ line }) => {
|
|
4433
4454
|
},
|
4434
4455
|
[isLoadingCombined, itemActionsLogic, isHydrogenReact, updateItem, itemFetcher]
|
4435
4456
|
);
|
4436
|
-
const handleSwitchSubscriptionChange = (0,
|
4457
|
+
const handleSwitchSubscriptionChange = (0, import_react9.useCallback)(
|
4437
4458
|
(event) => {
|
4438
4459
|
if (isLoadingCombined) return;
|
4439
4460
|
const targetValue = event.target.value;
|
@@ -4465,7 +4486,7 @@ var CartItem = ({ line }) => {
|
|
4465
4486
|
},
|
4466
4487
|
[isLoadingCombined, itemActionsLogic, isHydrogenReact, updateItem, itemFetcher, sts.isCurrentlySubscription]
|
4467
4488
|
);
|
4468
|
-
const handleUpgradeToSubscriptionClick = (0,
|
4489
|
+
const handleUpgradeToSubscriptionClick = (0, import_react9.useCallback)(() => {
|
4469
4490
|
if (isLoadingCombined || sts.isCurrentlySubscription || sts.availableFrequencies.length === 0) return;
|
4470
4491
|
const defaultFrequencyId = sts.availableFrequencies[0].id;
|
4471
4492
|
if (!defaultFrequencyId) return;
|
@@ -4500,7 +4521,7 @@ var CartItem = ({ line }) => {
|
|
4500
4521
|
sts.isCurrentlySubscription,
|
4501
4522
|
sts.availableFrequencies
|
4502
4523
|
]);
|
4503
|
-
(0,
|
4524
|
+
(0, import_react9.useEffect)(() => {
|
4504
4525
|
const resetLocalSpinners = () => {
|
4505
4526
|
setIsIncreasing(false);
|
4506
4527
|
setIsDecreasing(false);
|
@@ -4801,7 +4822,7 @@ var CartItemList = ({ componentConfig }) => {
|
|
4801
4822
|
|
4802
4823
|
// src/smart-cart/components/CartNoteInput/CartNoteInput.tsx
|
4803
4824
|
var import_clsx2 = __toESM(require("clsx"), 1);
|
4804
|
-
var
|
4825
|
+
var import_react10 = __toESM(require("react"), 1);
|
4805
4826
|
var import_react_router5 = require("react-router");
|
4806
4827
|
|
4807
4828
|
// src/smart-cart/components/CartNoteInput/CartNoteInput.module.css
|
@@ -4810,7 +4831,7 @@ var CartNoteInput_default = result5;
|
|
4810
4831
|
|
4811
4832
|
// src/smart-cart/components/CartNoteInput/CartNoteInput.tsx
|
4812
4833
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
4813
|
-
var CartNoteInput =
|
4834
|
+
var CartNoteInput = import_react10.default.memo(({ componentConfig }) => {
|
4814
4835
|
const {
|
4815
4836
|
cartData,
|
4816
4837
|
getItemCount,
|
@@ -4819,27 +4840,27 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4819
4840
|
updateCartNote: hrUpdateCartNote
|
4820
4841
|
} = useSmartCart();
|
4821
4842
|
const noteFetcher = (0, import_react_router5.useFetcher)();
|
4822
|
-
const textareaRef = (0,
|
4823
|
-
const isTextareaFocusedRef = (0,
|
4843
|
+
const textareaRef = (0, import_react10.useRef)(null);
|
4844
|
+
const isTextareaFocusedRef = (0, import_react10.useRef)(false);
|
4824
4845
|
const settings = componentConfig.settings || {};
|
4825
4846
|
const label = settings?.language?.notes_label ?? "Add a note (optional)";
|
4826
4847
|
const placeholder = settings?.language?.notes_placeholder ?? "Your notes...";
|
4827
4848
|
const limitChars = settings?.limit_characters ?? true;
|
4828
4849
|
const maxLength = settings?.max_length ?? 200;
|
4829
|
-
const [currentNoteValue, setCurrentNoteValue] = (0,
|
4830
|
-
const [isTextareaVisible, setIsTextareaVisible] = (0,
|
4831
|
-
const [isSaving, setIsSaving] = (0,
|
4832
|
-
const [saveMessage, setSaveMessage] = (0,
|
4833
|
-
const saveMessageTimerRef = (0,
|
4850
|
+
const [currentNoteValue, setCurrentNoteValue] = (0, import_react10.useState)(cartData?.note || "");
|
4851
|
+
const [isTextareaVisible, setIsTextareaVisible] = (0, import_react10.useState)(!!cartData?.note);
|
4852
|
+
const [isSaving, setIsSaving] = (0, import_react10.useState)(false);
|
4853
|
+
const [saveMessage, setSaveMessage] = (0, import_react10.useState)(null);
|
4854
|
+
const saveMessageTimerRef = (0, import_react10.useRef)(null);
|
4834
4855
|
const currentCartNoteFromCtx = cartData?.note || "";
|
4835
4856
|
const isNoteChanged = currentNoteValue.trim() !== currentCartNoteFromCtx.trim();
|
4836
4857
|
const hasItems = getItemCount() > 0;
|
4837
|
-
const isLoadingCombined = (0,
|
4858
|
+
const isLoadingCombined = (0, import_react10.useMemo)(() => {
|
4838
4859
|
if (isHydrogenReact) return isGlobalCartLoading || isSaving;
|
4839
4860
|
return noteFetcher.state !== "idle" || isSaving;
|
4840
4861
|
}, [isHydrogenReact, isGlobalCartLoading, noteFetcher.state, isSaving]);
|
4841
4862
|
const canSave = isNoteChanged && !isLoadingCombined;
|
4842
|
-
(0,
|
4863
|
+
(0, import_react10.useEffect)(() => {
|
4843
4864
|
const noteFromCart = cartData?.note || "";
|
4844
4865
|
if (!isTextareaFocusedRef.current && !isSaving && noteFromCart !== currentNoteValue) {
|
4845
4866
|
setCurrentNoteValue(noteFromCart);
|
@@ -4848,7 +4869,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4848
4869
|
} else if (!noteFromCart && isTextareaVisible && !isSaving && !currentNoteValue.trim()) {
|
4849
4870
|
}
|
4850
4871
|
}, [cartData?.note, isSaving, currentNoteValue, isTextareaVisible]);
|
4851
|
-
(0,
|
4872
|
+
(0, import_react10.useEffect)(() => {
|
4852
4873
|
return () => {
|
4853
4874
|
if (saveMessageTimerRef.current) clearTimeout(saveMessageTimerRef.current);
|
4854
4875
|
};
|
@@ -4858,7 +4879,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4858
4879
|
if (saveMessageTimerRef.current) clearTimeout(saveMessageTimerRef.current);
|
4859
4880
|
saveMessageTimerRef.current = setTimeout(() => setSaveMessage(null), 3e3);
|
4860
4881
|
};
|
4861
|
-
const handleToggle = (0,
|
4882
|
+
const handleToggle = (0, import_react10.useCallback)(
|
4862
4883
|
(event) => {
|
4863
4884
|
const checked = event.target.checked;
|
4864
4885
|
setIsTextareaVisible(checked);
|
@@ -4883,7 +4904,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4883
4904
|
[currentNoteValue, isHydrogenReact, hrUpdateCartNote, noteFetcher]
|
4884
4905
|
// currentNoteValue IS needed here
|
4885
4906
|
);
|
4886
|
-
const handleInputChange = (0,
|
4907
|
+
const handleInputChange = (0, import_react10.useCallback)(
|
4887
4908
|
(event) => {
|
4888
4909
|
let value = event.target.value;
|
4889
4910
|
if (limitChars && value.length > maxLength) value = value.substring(0, maxLength);
|
@@ -4898,7 +4919,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4898
4919
|
const handleTextareaBlur = () => {
|
4899
4920
|
isTextareaFocusedRef.current = false;
|
4900
4921
|
};
|
4901
|
-
const handleSave = (0,
|
4922
|
+
const handleSave = (0, import_react10.useCallback)(() => {
|
4902
4923
|
if (!canSave) return;
|
4903
4924
|
setIsSaving(true);
|
4904
4925
|
const noteToSave = currentNoteValue.trim();
|
@@ -4912,7 +4933,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4912
4933
|
});
|
4913
4934
|
}
|
4914
4935
|
}, [canSave, currentNoteValue, isHydrogenReact, hrUpdateCartNote, noteFetcher]);
|
4915
|
-
const handleKeyDown = (0,
|
4936
|
+
const handleKeyDown = (0, import_react10.useCallback)(
|
4916
4937
|
(event) => {
|
4917
4938
|
if (event.key === "Enter" && !event.shiftKey) {
|
4918
4939
|
event.preventDefault();
|
@@ -4921,7 +4942,7 @@ var CartNoteInput = import_react9.default.memo(({ componentConfig }) => {
|
|
4921
4942
|
},
|
4922
4943
|
[handleSave]
|
4923
4944
|
);
|
4924
|
-
(0,
|
4945
|
+
(0, import_react10.useEffect)(() => {
|
4925
4946
|
if (isHydrogenReact) {
|
4926
4947
|
if (!isGlobalCartLoading && isSaving) {
|
4927
4948
|
setIsSaving(false);
|
@@ -5058,7 +5079,7 @@ CartNoteInput.displayName = "CartNoteInput";
|
|
5058
5079
|
|
5059
5080
|
// src/smart-cart/components/CartSubtotal/CartSubtotal.tsx
|
5060
5081
|
var import_clsx3 = __toESM(require("clsx"), 1);
|
5061
|
-
var
|
5082
|
+
var import_react11 = __toESM(require("react"), 1);
|
5062
5083
|
|
5063
5084
|
// src/smart-cart/components/CartSubtotal/CartSubtotal.module.css
|
5064
5085
|
var result6 = { "rebuy-cart-subtotal": "CartSubtotal_rebuy-cart-subtotal", "rebuy-cart-subtotal--simple": "CartSubtotal_rebuy-cart-subtotal--simple", "rebuy-cart-subtotal__label": "CartSubtotal_rebuy-cart-subtotal__label", "rebuy-cart-subtotal__amount-wrapper": "CartSubtotal_rebuy-cart-subtotal__amount-wrapper", "rebuy-cart-subtotal__price--compare-at": "CartSubtotal_rebuy-cart-subtotal__price--compare-at", "rebuy-cart-subtotal__price--final": "CartSubtotal_rebuy-cart-subtotal__price--final", "rebuy-cart-subtotal--with-summary": "CartSubtotal_rebuy-cart-subtotal--with-summary", "rebuy-cart-subtotal__row": "CartSubtotal_rebuy-cart-subtotal__row", "rebuy-cart-subtotal__discount-summary": "CartSubtotal_rebuy-cart-subtotal__discount-summary", "rebuy-cart-subtotal__discount-summary-header": "CartSubtotal_rebuy-cart-subtotal__discount-summary-header", "rebuy-cart-subtotal__discount-summary-icon": "CartSubtotal_rebuy-cart-subtotal__discount-summary-icon", "rebuy-cart-subtotal__discount-summary--expanded": "CartSubtotal_rebuy-cart-subtotal__discount-summary--expanded", "rebuy-cart-subtotal__discount-summary-details": "CartSubtotal_rebuy-cart-subtotal__discount-summary-details", "rebuy-cart-subtotal__discount-summary-item": "CartSubtotal_rebuy-cart-subtotal__discount-summary-item" };
|
@@ -5080,61 +5101,61 @@ var getDiscountAllocationTitle = (alloc) => {
|
|
5080
5101
|
};
|
5081
5102
|
var CartSubtotalComponent = ({ componentConfig }) => {
|
5082
5103
|
const { cartData } = useSmartCart();
|
5083
|
-
const [isDiscountSummaryExpanded, setIsDiscountSummaryExpanded] = (0,
|
5084
|
-
const settings = (0,
|
5104
|
+
const [isDiscountSummaryExpanded, setIsDiscountSummaryExpanded] = (0, import_react11.useState)(false);
|
5105
|
+
const settings = (0, import_react11.useMemo)(
|
5085
5106
|
() => componentConfig?.settings ?? {},
|
5086
5107
|
[componentConfig?.settings]
|
5087
5108
|
);
|
5088
|
-
const allLines = (0,
|
5089
|
-
const excludedLines = (0,
|
5109
|
+
const allLines = (0, import_react11.useMemo)(() => cartData?.lines?.edges ?? [], [cartData?.lines?.edges]);
|
5110
|
+
const excludedLines = (0, import_react11.useMemo)(
|
5090
5111
|
() => allLines.map((edge) => edge.node).filter(
|
5091
5112
|
(line) => line.merchandise.product.tags?.includes("smart-cart-subtotal-excluded" /* EXCLUDE_FROM_CART_SUBTOTAL */)
|
5092
5113
|
),
|
5093
5114
|
[allLines]
|
5094
5115
|
);
|
5095
|
-
const excludedLinesValue = (0,
|
5116
|
+
const excludedLinesValue = (0, import_react11.useMemo)(
|
5096
5117
|
() => excludedLines.reduce((sum, line) => sum + parseFloat(line.cost.subtotalAmount?.amount ?? "0"), 0),
|
5097
5118
|
[excludedLines]
|
5098
5119
|
);
|
5099
|
-
const apiSubtotalAmount = (0,
|
5120
|
+
const apiSubtotalAmount = (0, import_react11.useMemo)(
|
5100
5121
|
() => parseFloat(cartData?.cost?.subtotalAmount?.amount ?? "0"),
|
5101
5122
|
[cartData?.cost?.subtotalAmount?.amount]
|
5102
5123
|
);
|
5103
|
-
const apiTotalAmount = (0,
|
5124
|
+
const apiTotalAmount = (0, import_react11.useMemo)(
|
5104
5125
|
() => parseFloat(cartData?.cost?.totalAmount?.amount ?? "0"),
|
5105
5126
|
[cartData?.cost?.totalAmount?.amount]
|
5106
5127
|
);
|
5107
|
-
const adjustedPreDiscountSubtotal = (0,
|
5128
|
+
const adjustedPreDiscountSubtotal = (0, import_react11.useMemo)(
|
5108
5129
|
() => Math.max(0, apiSubtotalAmount - excludedLinesValue),
|
5109
5130
|
[apiSubtotalAmount, excludedLinesValue]
|
5110
5131
|
);
|
5111
|
-
const adjustedFinalTotal = (0,
|
5132
|
+
const adjustedFinalTotal = (0, import_react11.useMemo)(
|
5112
5133
|
() => Math.max(0, apiTotalAmount - excludedLinesValue),
|
5113
5134
|
[apiTotalAmount, excludedLinesValue]
|
5114
5135
|
);
|
5115
|
-
const totalItemCount = (0,
|
5116
|
-
const subtotalLabel = (0,
|
5136
|
+
const totalItemCount = (0, import_react11.useMemo)(() => cartData?.totalQuantity ?? 0, [cartData?.totalQuantity]);
|
5137
|
+
const subtotalLabel = (0, import_react11.useMemo)(() => {
|
5117
5138
|
const singular = settings.subtotal_singular_text ?? "Subtotal ({{item_count}} item)";
|
5118
5139
|
const plural = settings.subtotal_plural_text ?? "Subtotal ({{item_count}} items)";
|
5119
5140
|
return (totalItemCount === 1 ? singular : plural).replace("{{item_count}}", String(totalItemCount));
|
5120
5141
|
}, [totalItemCount, settings.subtotal_singular_text, settings.subtotal_plural_text]);
|
5121
|
-
const currencyCode = (0,
|
5142
|
+
const currencyCode = (0, import_react11.useMemo)(
|
5122
5143
|
() => cartData?.cost?.subtotalAmount?.currencyCode ?? "USD",
|
5123
5144
|
[cartData?.cost?.subtotalAmount?.currencyCode]
|
5124
5145
|
);
|
5125
|
-
const hasOrderDiscount = (0,
|
5146
|
+
const hasOrderDiscount = (0, import_react11.useMemo)(
|
5126
5147
|
() => adjustedPreDiscountSubtotal > adjustedFinalTotal,
|
5127
5148
|
[adjustedPreDiscountSubtotal, adjustedFinalTotal]
|
5128
5149
|
);
|
5129
|
-
const formattedFinalTotal = (0,
|
5150
|
+
const formattedFinalTotal = (0, import_react11.useMemo)(
|
5130
5151
|
() => formatMoney(adjustedFinalTotal, currencyCode),
|
5131
5152
|
[adjustedFinalTotal, currencyCode]
|
5132
5153
|
);
|
5133
|
-
const formattedPreDiscountSubtotal = (0,
|
5154
|
+
const formattedPreDiscountSubtotal = (0, import_react11.useMemo)(
|
5134
5155
|
() => formatMoney(adjustedPreDiscountSubtotal, currencyCode),
|
5135
5156
|
[adjustedPreDiscountSubtotal, currencyCode]
|
5136
5157
|
);
|
5137
|
-
const groupedCartLevelDiscounts = (0,
|
5158
|
+
const groupedCartLevelDiscounts = (0, import_react11.useMemo)(() => {
|
5138
5159
|
if (!cartData?.discountAllocations) return [];
|
5139
5160
|
const grouped = cartData.discountAllocations.reduce((acc, alloc) => {
|
5140
5161
|
const amount = parseFloat(alloc.discountedAmount?.amount ?? "0");
|
@@ -5148,11 +5169,11 @@ var CartSubtotalComponent = ({ componentConfig }) => {
|
|
5148
5169
|
title
|
5149
5170
|
}));
|
5150
5171
|
}, [cartData?.discountAllocations, currencyCode]);
|
5151
|
-
const shouldShowDiscountSummary = (0,
|
5172
|
+
const shouldShowDiscountSummary = (0, import_react11.useMemo)(
|
5152
5173
|
() => settings.show_discount_summary === true && groupedCartLevelDiscounts.length > 0,
|
5153
5174
|
[settings.show_discount_summary, groupedCartLevelDiscounts.length]
|
5154
5175
|
);
|
5155
|
-
const discountSummaryCountLabel = (0,
|
5176
|
+
const discountSummaryCountLabel = (0, import_react11.useMemo)(() => {
|
5156
5177
|
if (!shouldShowDiscountSummary) return "";
|
5157
5178
|
const count = groupedCartLevelDiscounts.length;
|
5158
5179
|
const singular = settings.discount_summary_count_label ?? "{{discount_count}} order discount applied";
|
@@ -5164,7 +5185,7 @@ var CartSubtotalComponent = ({ componentConfig }) => {
|
|
5164
5185
|
settings.discount_summary_count_label,
|
5165
5186
|
settings.discount_summary_count_label_plural
|
5166
5187
|
]);
|
5167
|
-
const toggleDiscountSummary = (0,
|
5188
|
+
const toggleDiscountSummary = (0, import_react11.useCallback)(() => setIsDiscountSummaryExpanded((prev) => !prev), []);
|
5168
5189
|
if (totalItemCount === 0) return null;
|
5169
5190
|
const rootClasses = (0, import_clsx3.default)(
|
5170
5191
|
CartSubtotal_default["rebuy-cart-subtotal"],
|
@@ -5239,12 +5260,12 @@ var CartSubtotalComponent = ({ componentConfig }) => {
|
|
5239
5260
|
}
|
5240
5261
|
);
|
5241
5262
|
};
|
5242
|
-
var CartSubtotal =
|
5263
|
+
var CartSubtotal = import_react11.default.memo(CartSubtotalComponent);
|
5243
5264
|
CartSubtotal.displayName = "CartSubtotal";
|
5244
5265
|
|
5245
5266
|
// src/smart-cart/components/CartTitleBar/CartTitleBar.tsx
|
5246
5267
|
var import_dompurify2 = __toESM(require("dompurify"), 1);
|
5247
|
-
var
|
5268
|
+
var import_react12 = __toESM(require("react"), 1);
|
5248
5269
|
|
5249
5270
|
// src/smart-cart/components/CartTitleBar/CartTitleBar.module.css
|
5250
5271
|
var result7 = { "rebuy-cart-title-bar": "CartTitleBar_rebuy-cart-title-bar" };
|
@@ -5252,13 +5273,13 @@ var CartTitleBar_default = result7;
|
|
5252
5273
|
|
5253
5274
|
// src/smart-cart/components/CartTitleBar/CartTitleBar.tsx
|
5254
5275
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
5255
|
-
var CartTitleBar =
|
5276
|
+
var CartTitleBar = import_react12.default.memo(() => {
|
5256
5277
|
const { getComponentConfigByType } = useSmartCart();
|
5257
5278
|
const componentConfig = getComponentConfigByType("title_bar");
|
5258
5279
|
const title = componentConfig?.settings?.title ?? "Your Cart";
|
5259
5280
|
const headingTag = componentConfig?.settings?.heading_tag ?? "h2";
|
5260
5281
|
const screenReaderOnly = componentConfig?.settings?.screen_reader_only ?? false;
|
5261
|
-
const sanitizedTitle = (0,
|
5282
|
+
const sanitizedTitle = (0, import_react12.useMemo)(() => {
|
5262
5283
|
if (typeof window !== "undefined") return import_dompurify2.default.sanitize(title);
|
5263
5284
|
return title;
|
5264
5285
|
}, [title]);
|
@@ -5288,7 +5309,7 @@ var CartTitleBar = import_react11.default.memo(() => {
|
|
5288
5309
|
CartTitleBar.displayName = "CartTitleBar";
|
5289
5310
|
|
5290
5311
|
// src/smart-cart/components/CheckoutArea/CheckoutArea.tsx
|
5291
|
-
var
|
5312
|
+
var import_react13 = __toESM(require("react"), 1);
|
5292
5313
|
var import_react_router6 = require("react-router");
|
5293
5314
|
|
5294
5315
|
// src/smart-cart/components/CheckoutArea/CheckoutArea.module.css
|
@@ -5297,7 +5318,7 @@ var CheckoutArea_default = result8;
|
|
5297
5318
|
|
5298
5319
|
// src/smart-cart/components/CheckoutArea/CheckoutArea.tsx
|
5299
5320
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
5300
|
-
var CheckoutArea =
|
5321
|
+
var CheckoutArea = import_react13.default.memo(({ componentConfig }) => {
|
5301
5322
|
const {
|
5302
5323
|
cartData,
|
5303
5324
|
checkout,
|
@@ -5309,9 +5330,9 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5309
5330
|
} = useSmartCart();
|
5310
5331
|
const termsFetcher = (0, import_react_router6.useFetcher)();
|
5311
5332
|
const settings = componentConfig.settings;
|
5312
|
-
const [termsAccepted, setTermsAccepted] = (0,
|
5313
|
-
const [processingSource, setProcessingSource] = (0,
|
5314
|
-
(0,
|
5333
|
+
const [termsAccepted, setTermsAccepted] = (0, import_react13.useState)(false);
|
5334
|
+
const [processingSource, setProcessingSource] = (0, import_react13.useState)(null);
|
5335
|
+
(0, import_react13.useEffect)(() => {
|
5315
5336
|
const termsAttr = cartData?.attributes?.find((attr) => attr.key === "Terms and Conditions");
|
5316
5337
|
const acceptedInCart = termsAttr?.value === "Accepted";
|
5317
5338
|
if (processingSource !== "terms" && termsAccepted !== acceptedInCart) {
|
@@ -5319,58 +5340,58 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5319
5340
|
}
|
5320
5341
|
}, [cartData?.attributes, termsAccepted, processingSource]);
|
5321
5342
|
const hasItems = getItemCount() > 0;
|
5322
|
-
const hasTermsEnabled = (0,
|
5323
|
-
const isLoadingCombined = (0,
|
5343
|
+
const hasTermsEnabled = (0, import_react13.useMemo)(() => !!settings?.terms?.enabled, [settings?.terms?.enabled]);
|
5344
|
+
const isLoadingCombined = (0, import_react13.useMemo)(() => {
|
5324
5345
|
if (isHydrogenReact) return isGlobalCartLoading || processingSource === "terms";
|
5325
5346
|
return termsFetcher.state !== "idle" || processingSource === "terms";
|
5326
5347
|
}, [isHydrogenReact, isGlobalCartLoading, termsFetcher.state, processingSource]);
|
5327
|
-
const isAnyCriticalActionProcessing = (0,
|
5348
|
+
const isAnyCriticalActionProcessing = (0, import_react13.useMemo)(() => {
|
5328
5349
|
if (isHydrogenReact) return isGlobalCartLoading;
|
5329
5350
|
return termsFetcher.state !== "idle" || processingSource === "checkout" || processingSource === "shop_pay" || processingSource === "view_cart";
|
5330
5351
|
}, [isHydrogenReact, isGlobalCartLoading, termsFetcher.state, processingSource]);
|
5331
|
-
const isCheckoutDisabled = (0,
|
5352
|
+
const isCheckoutDisabled = (0, import_react13.useMemo)(
|
5332
5353
|
() => !hasItems || isAnyCriticalActionProcessing || hasTermsEnabled && !termsAccepted,
|
5333
5354
|
[hasItems, isAnyCriticalActionProcessing, hasTermsEnabled, termsAccepted]
|
5334
5355
|
);
|
5335
|
-
const isTermsCheckboxDisabled = (0,
|
5356
|
+
const isTermsCheckboxDisabled = (0, import_react13.useMemo)(() => {
|
5336
5357
|
if (isHydrogenReact) return isGlobalCartLoading || processingSource === "terms";
|
5337
5358
|
return termsFetcher.state !== "idle" || processingSource === "terms";
|
5338
5359
|
}, [isHydrogenReact, isGlobalCartLoading, termsFetcher.state, processingSource]);
|
5339
|
-
const hasCheckoutButton = (0,
|
5340
|
-
const hasViewCartButton = (0,
|
5360
|
+
const hasCheckoutButton = (0, import_react13.useMemo)(() => !!settings?.checkout_button?.enabled, [settings?.checkout_button?.enabled]);
|
5361
|
+
const hasViewCartButton = (0, import_react13.useMemo)(
|
5341
5362
|
() => !!settings?.view_cart_button?.enabled,
|
5342
5363
|
[settings?.view_cart_button?.enabled]
|
5343
5364
|
);
|
5344
|
-
const hasContinueShoppingButton = (0,
|
5365
|
+
const hasContinueShoppingButton = (0, import_react13.useMemo)(
|
5345
5366
|
() => !!settings?.continue_shopping_button?.enabled,
|
5346
5367
|
[settings?.continue_shopping_button?.enabled]
|
5347
5368
|
);
|
5348
|
-
const hasShopPayButton = (0,
|
5349
|
-
const hasInstallments = (0,
|
5369
|
+
const hasShopPayButton = (0, import_react13.useMemo)(() => !!settings?.shop_pay?.enabled, [settings?.shop_pay?.enabled]);
|
5370
|
+
const hasInstallments = (0, import_react13.useMemo)(
|
5350
5371
|
() => settings?.installments?.enabled && settings?.installments?.provider,
|
5351
5372
|
[settings?.installments?.enabled, settings?.installments?.provider]
|
5352
5373
|
);
|
5353
|
-
const hasPrePurchase = (0,
|
5374
|
+
const hasPrePurchase = (0, import_react13.useMemo)(
|
5354
5375
|
() => settings?.pre_purchase?.enabled && settings?.pre_purchase?.widget_id,
|
5355
5376
|
[settings?.pre_purchase?.enabled, settings?.pre_purchase?.widget_id]
|
5356
5377
|
);
|
5357
|
-
const checkoutLabel = (0,
|
5378
|
+
const checkoutLabel = (0, import_react13.useMemo)(
|
5358
5379
|
() => processingSource === "checkout" ? settings?.language?.checking_out_label ?? "Checking Out..." : settings?.language?.checkout_label ?? "Checkout \u2192",
|
5359
5380
|
[processingSource, settings?.language]
|
5360
5381
|
);
|
5361
|
-
const viewCartLabel = (0,
|
5382
|
+
const viewCartLabel = (0, import_react13.useMemo)(
|
5362
5383
|
() => processingSource === "view_cart" ? settings?.language?.view_cart_working_label ?? "Redirecting..." : settings?.language?.view_cart_label ?? "View Cart",
|
5363
5384
|
[processingSource, settings?.language]
|
5364
5385
|
);
|
5365
|
-
const continueShoppingLabel = (0,
|
5386
|
+
const continueShoppingLabel = (0, import_react13.useMemo)(
|
5366
5387
|
() => settings?.language?.continue_shopping_label ?? "Continue Shopping",
|
5367
5388
|
[settings?.language?.continue_shopping_label]
|
5368
5389
|
);
|
5369
|
-
const termsLabel = (0,
|
5390
|
+
const termsLabel = (0, import_react13.useMemo)(
|
5370
5391
|
() => settings?.language?.terms_and_conditions_label ?? "I agree to the terms and conditions",
|
5371
5392
|
[settings?.language?.terms_and_conditions_label]
|
5372
5393
|
);
|
5373
|
-
const installmentsMessage = (0,
|
5394
|
+
const installmentsMessage = (0, import_react13.useMemo)(() => {
|
5374
5395
|
const totalAmountData = cartData?.cost?.totalAmount;
|
5375
5396
|
if (!hasInstallments || !totalAmountData?.amount || !totalAmountData?.currencyCode) return "";
|
5376
5397
|
const paymentCount = parseInt(settings?.installments?.payment_count ?? "4", 10);
|
@@ -5383,7 +5404,7 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5383
5404
|
const termsUrl = settings?.installments?.terms_url ?? "#";
|
5384
5405
|
return `or ${paymentCount} interest-free installments of ${formattedPayment} by <a target="_blank" rel="noopener noreferrer" href="${termsUrl}">${provider}</a>`;
|
5385
5406
|
}, [hasInstallments, cartData?.cost?.totalAmount, settings?.installments]);
|
5386
|
-
const handleTermsChange = (0,
|
5407
|
+
const handleTermsChange = (0, import_react13.useCallback)(async () => {
|
5387
5408
|
if (!hasTermsEnabled || isTermsCheckboxDisabled || !hasItems) return;
|
5388
5409
|
setProcessingSource("terms");
|
5389
5410
|
const newAcceptedState = !termsAccepted;
|
@@ -5417,7 +5438,7 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5417
5438
|
termsFetcher,
|
5418
5439
|
cartData?.attributes
|
5419
5440
|
]);
|
5420
|
-
(0,
|
5441
|
+
(0, import_react13.useEffect)(() => {
|
5421
5442
|
if (processingSource === "terms") {
|
5422
5443
|
if (isHydrogenReact && !isGlobalCartLoading) {
|
5423
5444
|
setProcessingSource(null);
|
@@ -5456,7 +5477,7 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5456
5477
|
termsAccepted,
|
5457
5478
|
cartData?.attributes
|
5458
5479
|
]);
|
5459
|
-
const handleCheckoutClick = (0,
|
5480
|
+
const handleCheckoutClick = (0, import_react13.useCallback)(() => {
|
5460
5481
|
if (isCheckoutDisabled) return;
|
5461
5482
|
setProcessingSource("checkout");
|
5462
5483
|
const routing = settings?.checkout_button?.routing ?? "automatic";
|
@@ -5471,16 +5492,16 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5471
5492
|
setProcessingSource(null);
|
5472
5493
|
}
|
5473
5494
|
}, [isCheckoutDisabled, settings?.checkout_button, checkout]);
|
5474
|
-
const handleViewCartClick = (0,
|
5495
|
+
const handleViewCartClick = (0, import_react13.useCallback)(() => {
|
5475
5496
|
if (isAnyCriticalActionProcessing && processingSource !== "terms") return;
|
5476
5497
|
setProcessingSource("view_cart");
|
5477
5498
|
window.location.href = "/cart";
|
5478
5499
|
}, [isAnyCriticalActionProcessing, processingSource]);
|
5479
|
-
const handleContinueShoppingClick = (0,
|
5500
|
+
const handleContinueShoppingClick = (0, import_react13.useCallback)(() => {
|
5480
5501
|
if (isAnyCriticalActionProcessing && processingSource !== "terms") return;
|
5481
5502
|
hideCart();
|
5482
5503
|
}, [isAnyCriticalActionProcessing, processingSource, hideCart]);
|
5483
|
-
const handleShopPayClick = (0,
|
5504
|
+
const handleShopPayClick = (0, import_react13.useCallback)(() => {
|
5484
5505
|
if (isLoadingCombined || !!processingSource && processingSource !== "terms" || !hasItems) return;
|
5485
5506
|
setProcessingSource("shop_pay");
|
5486
5507
|
try {
|
@@ -5497,7 +5518,7 @@ var CheckoutArea = import_react12.default.memo(({ componentConfig }) => {
|
|
5497
5518
|
setProcessingSource(null);
|
5498
5519
|
}
|
5499
5520
|
}, [isLoadingCombined, processingSource, hasItems, cartData?.checkoutUrl]);
|
5500
|
-
const shopPaySvg = (0,
|
5521
|
+
const shopPaySvg = (0, import_react13.useMemo)(
|
5501
5522
|
() => ({
|
5502
5523
|
__html: `<?xml version="1.0" encoding="UTF-8"?><svg width="80" height="30" fill="none" viewBox="0 0 4317 1037" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)" fill="#fff"><path d="m1106 326.19c-34.62-72.633-100.26-119.55-199.17-119.55-30.36 0.529-60.193 8.026-87.198 21.908-27.003 13.884-50.46 33.785-68.555 58.168l-3.61 4.398v-284.67c0-1.6452-0.653-3.2229-1.817-4.3862-1.163-1.1633-2.742-1.817-4.387-1.817h-139.85c-1.625 0.029561-3.173 0.69609-4.312 1.8562-1.14 1.1601-1.778 2.7211-1.778 4.3469v816.56c0 1.615 0.643 3.163 1.785 4.305 1.142 1.143 2.69 1.785 4.305 1.785h149.78c1.626 0 3.187-0.637 4.347-1.778 1.16-1.139 1.826-2.687 1.856-4.312v-348.16c0-67.67 45.113-115.6 117.3-115.6 78.949 0 98.912 64.964 98.912 131.17v332.6c0 1.615 0.641 3.163 1.783 4.305 1.142 1.143 2.692 1.785 4.307 1.785h149.44c1.63 0 3.19-0.637 4.35-1.778 1.16-1.139 1.83-2.687 1.86-4.312v-352.45c0-12.068 0-23.911-1.58-35.414-2.57-37.698-11.97-74.616-27.75-108.95z"/><path d="m358.09 447.21s-76.242-17.933-104.32-25.151c-28.084-7.218-77.145-22.557-77.145-59.663s39.587-48.949 79.739-48.949c40.151 0 84.814 9.7 88.31 54.25 0.141 1.606 0.88 3.098 2.07 4.186 1.191 1.086 2.746 1.684 4.358 1.679l147.63-0.564c0.869 2e-3 1.729-0.175 2.526-0.52s1.514-0.851 2.107-1.487c0.593-0.634 1.049-1.385 1.338-2.204 0.289-0.82 0.408-1.69 0.345-2.557-9.135-142.56-134.21-193.54-249.59-193.54-136.81 0-236.85 90.227-236.85 189.7 0 72.633 20.527 140.76 181.92 188.12 28.309 8.233 66.769 18.947 100.38 28.309 40.376 11.279 62.143 28.309 62.143 55.151 0 31.128-45.113 52.782-89.437 52.782-64.174 0-109.74-23.797-113.46-66.543-0.194-1.563-0.955-3.003-2.141-4.043-1.185-1.04-2.711-1.608-4.288-1.596l-147.3 0.677c-0.86355 0-1.7182 0.173-2.5133 0.511-0.79503 0.337-1.514 0.83-2.114 1.452-0.6 0.62-1.0688 1.356-1.3783 2.162-0.30948 0.807-0.45331 1.667-0.42301 2.53 6.767 134.55 136.69 207.07 257.83 207.07 180.45 0 262-101.5 262-196.58 0.226-44.663-10.038-146.39-161.73-185.19z"/><path d="m2257.4 206.41c-74.99 0-137.82 41.504-178.31 91.582v-85.717c0-1.596-0.63-3.129-1.75-4.267-1.1-1.139-2.63-1.794-4.23-1.822h-140.07c-1.61 0-3.17 0.64-4.31 1.782-1.14 1.143-1.79 2.693-1.79 4.307v800.77c0.04 1.59 0.7 3.12 1.84 4.23 1.14 1.12 2.67 1.75 4.26 1.75h149.89c1.58 0 3.1-0.63 4.22-1.75s1.75-2.65 1.75-4.23v-263.24h2.26c23.79 36.315 88.87 79.851 173.92 79.851 159.91 0 293.23-132.63 293.23-311.85 0.12-172-132.52-311.4-300.91-311.4zm-13.87 470.65c-31.56 0.784-62.67-7.857-89.3-24.819-26.63-16.964-47.62-41.479-60.27-70.418-12.64-28.94-16.38-60.991-10.72-92.063 5.64-31.072 20.43-59.755 42.45-82.388 22.03-22.636 50.3-38.194 81.21-44.69 30.9-6.496 63.04-3.637 92.31 8.214 29.28 11.85 54.35 32.155 72.04 58.322 17.68 26.168 27.16 57.009 27.25 88.591 0.32 20.643-3.44 41.149-11.05 60.339s-18.95 36.686-33.35 51.483c-14.39 14.797-31.57 26.604-50.56 34.743-18.97 8.14-39.36 12.45-60.01 12.686z"/><path d="m1483.3 171.23c-139.74 0-209.44 47.482-265.39 85.491l-1.69 1.127c-2.88 1.974-4.91 4.966-5.69 8.374-0.77 3.409-0.23 6.983 1.52 10.01l55.26 95.188c1.04 1.782 2.46 3.313 4.15 4.482 1.7 1.17 3.63 1.951 5.67 2.286 1.99 0.359 4.03 0.272 5.98-0.255s3.76-1.478 5.3-2.791l4.39-3.608c28.76-24.136 74.89-56.393 186.55-65.19 62.14-4.961 115.83 11.279 155.41 48.272 43.54 40.152 69.6 105 69.6 173.46 0 125.98-74.22 205.15-193.43 206.73-98.24-0.564-164.22-51.768-164.22-127.45 0-40.152 18.16-66.317 53.58-92.483 2.7-1.934 4.61-4.781 5.38-8.015s0.34-6.637-1.21-9.579l-49.63-93.837c-0.91-1.679-2.15-3.161-3.64-4.361s-3.2-2.094-5.04-2.631c-1.88-0.559-3.85-0.717-5.79-0.466-1.95 0.253-3.82 0.911-5.49 1.933-55.71 33.045-124.06 93.497-120.34 209.66 4.51 147.86 127.45 260.76 287.26 265.38h18.95c189.92-6.204 327.07-147.18 327.07-338.35 0-175.49-127.9-363.39-364.51-363.39z"/><path d="m3148.9 261.46h-95.2c-2.22 0.029-4.36 0.93-5.94 2.509-1.59 1.58-2.49 3.715-2.5 5.95v199.74c0.01 2.225 0.92 4.346 2.51 5.908 1.58 1.562 3.71 2.439 5.93 2.439h95.2c57.97 0 100.72-45.678 100.72-108.27s-42.75-108.27-100.72-108.27z"/><path d="m3441.4 614.8c0 28.985 24.47 45.113 67.1 45.113 57.97 0 92.25-31.354 92.25-86.957v-16.014l-86.83 4.511c-45.8 2.255-72.52 21.317-72.52 53.347z"/><path d="m4146.3 2.0498h-1279c-20.97-2e-5 -41.76 4.1346-61.13 12.167-19.39 8.0328-37 19.806-51.82 34.648-14.84 14.842-26.6 32.46-34.62 51.85-8.03 19.389-12.14 40.168-12.12 61.15v700.16c0 42.366 16.82 82.999 46.77 112.97 29.95 29.968 70.57 46.818 112.92 46.848h1279c21.01 0.06 41.83-4.02 61.26-12.01 19.42-7.99 37.08-19.737 51.97-34.557 14.87-14.823 26.7-32.434 34.78-51.828 8.07-19.393 12.23-40.187 12.27-61.193v-700.16c0.03-21.048-4.08-41.898-12.12-61.35-8.04-19.452-19.85-37.122-34.74-51.995-14.89-14.873-32.58-26.655-52.04-34.668-19.46-8.0136-40.32-12.101-61.38-12.026zm-992.5 554.56h-100.6c-2.24 0-4.38 0.89-5.98 2.476-1.58 1.587-2.48 3.739-2.48 5.983v143.23c0 2.243-0.89 4.395-2.47 5.981-1.59 1.587-3.74 2.478-5.98 2.478h-70.84c-2.22-0.029-4.37-0.93-5.95-2.511-1.58-1.578-2.46-3.713-2.5-5.948v-516.66c0-2.242 0.89-4.394 2.49-5.981 1.58-1.586 3.72-2.477 5.96-2.477h188.35c106.7 0 183.05 77.708 183.05 186.77s-75.79 186.88-182.47 186.88l-0.58-0.224zm530.09 151.58c0.02 1.12-0.18 2.231-0.61 3.271-0.42 1.039-1.04 1.986-1.82 2.783-0.8 0.797-1.73 1.431-2.77 1.863-1.02 0.431-2.14 0.654-3.26 0.654h-66.88c-1.12 0-2.23-0.223-3.26-0.654-1.04-0.432-1.98-1.066-2.76-1.863s-1.41-1.744-1.82-2.783c-0.42-1.04-0.63-2.151-0.61-3.271v-15.451c0.1-1.357-0.22-2.713-0.95-3.865-0.71-1.154-1.78-2.045-3.06-2.54-1.26-0.494-2.65-0.565-3.96-0.203-1.33 0.36-2.48 1.135-3.31 2.209-19.97 21.767-52.45 37.556-104.22 37.556-76.23 0-126.66-39.699-126.66-108.27-0.73-16.72 2.72-33.359 10.05-48.408 7.32-15.046 18.3-28.026 31.92-37.758 27.51-20.64 70.14-31.354 133.41-33.836l67.1-2.255v-19.626c0-39.587-26.61-56.391-69.36-56.391-42.74 0-69.7 15.113-76 39.813-0.51 1.744-1.58 3.27-3.06 4.333-1.46 1.064-3.25 1.602-5.07 1.531h-66.2c-1.22 0.031-2.43-0.207-3.55-0.693-1.1-0.488-2.11-1.214-2.92-2.128-0.8-0.915-1.4-1.992-1.74-3.162-0.35-1.169-0.44-2.398-0.25-3.603 9.93-58.648 58.42-103.2 161.85-103.2 109.85 0 149.43 51.092 149.43 148.65l0.34 207.3zm416.63-335.2-148.87 397.11c-33.84 92.256-93.06 115.94-157.91 115.94-12.21 0.298-24.41-1.184-36.2-4.398-1.84-0.495-3.45-1.579-4.63-3.089-1.15-1.507-1.78-3.355-1.8-5.258v-60.34c0-1.262 0.27-2.51 0.8-3.654 0.54-1.144 1.31-2.157 2.28-2.964 0.98-0.809 2.11-1.392 3.33-1.71s2.5-0.363 3.74-0.131c10.23 1.94 20.61 2.922 31.02 2.934 17.93 0.899 35.65-4.247 50.32-14.615 14.65-10.368 25.41-25.358 30.54-42.567l4.41-13.873c0.68-1.856 0.68-3.894 0-5.752l-139.19-357.52c-0.42-1.278-0.54-2.64-0.34-3.972 0.21-1.333 0.72-2.6 1.48-3.698 0.79-1.098 1.82-1.997 3.01-2.625 1.19-0.627 2.52-0.965 3.86-0.984h67.68c1.73 0.017 3.41 0.551 4.84 1.537 1.43 0.984 2.53 2.374 3.16 3.99l94.52 252.18c0.63 1.647 1.73 3.066 3.18 4.067 1.46 1.003 3.17 1.538 4.94 1.538 1.75 0 3.49-0.535 4.93-1.538 1.45-1.001 2.57-2.42 3.18-4.067l82.01-251.51c0.54-1.715 1.63-3.209 3.09-4.264 1.46-1.056 3.21-1.617 5.01-1.601h69.38c1.33-6e-3 2.65 0.306 3.86 0.904 1.19 0.6 2.24 1.472 3.04 2.547s1.33 2.322 1.56 3.643c0.24 1.319 0.16 2.675-0.23 3.958v-0.226z"/></g><defs><clipPath id="a"><rect transform="translate(0 .24023)" width="4317" height="1036.8" fill="#fff"/></clipPath></defs></svg>`
|
5503
5524
|
}),
|
@@ -5600,7 +5621,7 @@ CheckoutArea.displayName = "CheckoutArea";
|
|
5600
5621
|
var import_rebuy2 = require("@rebuy/rebuy");
|
5601
5622
|
var Utilities4 = __toESM(require("@rebuy/rebuy/utilities"), 1);
|
5602
5623
|
var import_hydrogen6 = require("@shopify/hydrogen");
|
5603
|
-
var
|
5624
|
+
var import_react21 = require("react");
|
5604
5625
|
|
5605
5626
|
// src/assets/Close.tsx
|
5606
5627
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
@@ -5609,10 +5630,10 @@ var Close = () => {
|
|
5609
5630
|
};
|
5610
5631
|
|
5611
5632
|
// src/hooks/useBreakpoint.ts
|
5612
|
-
var
|
5633
|
+
var import_react14 = require("react");
|
5613
5634
|
var useBreakpoint = (settings) => {
|
5614
|
-
const [breakpoint, setBreakpoint] = (0,
|
5615
|
-
(0,
|
5635
|
+
const [breakpoint, setBreakpoint] = (0, import_react14.useState)("medium");
|
5636
|
+
(0, import_react14.useEffect)(() => {
|
5616
5637
|
if (!settings?.breakpoints) return;
|
5617
5638
|
const handleResize = () => {
|
5618
5639
|
const width = window.innerWidth;
|
@@ -5645,18 +5666,18 @@ var useBreakpoint = (settings) => {
|
|
5645
5666
|
};
|
5646
5667
|
|
5647
5668
|
// src/hooks/usePopupTrigger.tsx
|
5648
|
-
var
|
5669
|
+
var import_react15 = require("react");
|
5649
5670
|
var usePopupTrigger = (settings, popupTriggerId, widgetId, popupShownOnce, showPopup, setShowPopup, setPopupShownOnce) => {
|
5650
5671
|
const delayInMs = settings?.display_type === "popup" ? (settings?.popup_delay || 0) * 1e3 : 0;
|
5651
5672
|
const popupTrigger = settings?.popup_trigger;
|
5652
|
-
const showPopupWithDelay = (0,
|
5673
|
+
const showPopupWithDelay = (0, import_react15.useCallback)(() => {
|
5653
5674
|
if (!settings || settings.display_type !== "popup") return;
|
5654
5675
|
setTimeout(() => {
|
5655
5676
|
setShowPopup(true);
|
5656
5677
|
setPopupShownOnce(true);
|
5657
5678
|
}, delayInMs);
|
5658
5679
|
}, [delayInMs, setShowPopup, setPopupShownOnce, settings]);
|
5659
|
-
(0,
|
5680
|
+
(0, import_react15.useEffect)(() => {
|
5660
5681
|
if (!settings || settings.display_type !== "popup" || popupTrigger !== "load" || popupShownOnce) return;
|
5661
5682
|
const timer = setTimeout(() => {
|
5662
5683
|
setShowPopup(true);
|
@@ -5664,7 +5685,7 @@ var usePopupTrigger = (settings, popupTriggerId, widgetId, popupShownOnce, showP
|
|
5664
5685
|
}, delayInMs);
|
5665
5686
|
return () => clearTimeout(timer);
|
5666
5687
|
}, [popupTrigger, popupShownOnce, delayInMs, setShowPopup, setPopupShownOnce, settings]);
|
5667
|
-
(0,
|
5688
|
+
(0, import_react15.useEffect)(() => {
|
5668
5689
|
if (!settings || settings.display_type !== "popup" || popupTrigger !== "add_to_cart" || !popupTriggerId) return;
|
5669
5690
|
const selector = `#${popupTriggerId}`;
|
5670
5691
|
const handleCartAdd = () => {
|
@@ -5696,7 +5717,7 @@ var usePopupTrigger = (settings, popupTriggerId, widgetId, popupShownOnce, showP
|
|
5696
5717
|
});
|
5697
5718
|
};
|
5698
5719
|
}, [popupTrigger, popupTriggerId, showPopup, showPopupWithDelay, settings]);
|
5699
|
-
(0,
|
5720
|
+
(0, import_react15.useEffect)(() => {
|
5700
5721
|
if (!settings || settings.display_type !== "popup" || popupTrigger !== "submit") return;
|
5701
5722
|
const selector = "form";
|
5702
5723
|
const handleSubmit = () => {
|
@@ -5712,7 +5733,7 @@ var usePopupTrigger = (settings, popupTriggerId, widgetId, popupShownOnce, showP
|
|
5712
5733
|
});
|
5713
5734
|
};
|
5714
5735
|
}, [popupTrigger, showPopupWithDelay, settings]);
|
5715
|
-
(0,
|
5736
|
+
(0, import_react15.useEffect)(() => {
|
5716
5737
|
if (!settings || settings.display_type !== "popup" || popupTrigger !== "exit") return;
|
5717
5738
|
const handleExitIntent = (e) => {
|
5718
5739
|
if (e.clientY <= 0 && !popupShownOnce) {
|
@@ -6113,7 +6134,7 @@ var defaultProductCardSettings = {
|
|
6113
6134
|
|
6114
6135
|
// src/components/ProductCard/ProductCard.tsx
|
6115
6136
|
var import_hydrogen5 = require("@shopify/hydrogen");
|
6116
|
-
var
|
6137
|
+
var import_react18 = require("react");
|
6117
6138
|
|
6118
6139
|
// src/components/AddToCartBtn/HydrogenAddToCartBtn.tsx
|
6119
6140
|
var import_hydrogen3 = require("@shopify/hydrogen");
|
@@ -6301,7 +6322,7 @@ var RebuyProductPrice = ({ selectedVariant, settingsDiscount }) => {
|
|
6301
6322
|
};
|
6302
6323
|
|
6303
6324
|
// src/components/QuantityInput/QuantityInput.tsx
|
6304
|
-
var
|
6325
|
+
var import_react16 = require("react");
|
6305
6326
|
|
6306
6327
|
// src/components/QuantityInput/QuantityInput.module.css
|
6307
6328
|
var result11 = { "rebuy-quantity__container": "QuantityInput_rebuy-quantity__container", "rebuy-quantity__select": "QuantityInput_rebuy-quantity__select" };
|
@@ -6315,7 +6336,7 @@ var QuantityInput = ({
|
|
6315
6336
|
maxValue = 10,
|
6316
6337
|
minValue = 1
|
6317
6338
|
}) => {
|
6318
|
-
const [quantity, setQuantity] = (0,
|
6339
|
+
const [quantity, setQuantity] = (0, import_react16.useState)(defaultQuantity);
|
6319
6340
|
const handleChange = (event) => {
|
6320
6341
|
const newValue = parseInt(event.target.value, 10);
|
6321
6342
|
setQuantity(newValue);
|
@@ -6339,7 +6360,7 @@ var QuantityInput = ({
|
|
6339
6360
|
|
6340
6361
|
// src/components/VariantSelect/VariantSelect.tsx
|
6341
6362
|
var import_clsx5 = __toESM(require("clsx"), 1);
|
6342
|
-
var
|
6363
|
+
var import_react17 = require("react");
|
6343
6364
|
|
6344
6365
|
// src/components/VariantSelect/VariantSelect.module.css
|
6345
6366
|
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" };
|
@@ -6348,8 +6369,8 @@ var VariantSelect_default = result12;
|
|
6348
6369
|
// src/components/VariantSelect/VariantSelect.tsx
|
6349
6370
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
6350
6371
|
var VariantSelect = ({ handleSelectedVariant, product, selectedId, style = "select" }) => {
|
6351
|
-
const [selectedVariantId, setSelectedVariantId] = (0,
|
6352
|
-
(0,
|
6372
|
+
const [selectedVariantId, setSelectedVariantId] = (0, import_react17.useState)(selectedId || product.variants.nodes[0]?.id);
|
6373
|
+
(0, import_react17.useEffect)(() => {
|
6353
6374
|
if (selectedId && selectedId !== selectedVariantId) {
|
6354
6375
|
setSelectedVariantId(selectedId);
|
6355
6376
|
}
|
@@ -6440,21 +6461,21 @@ var ProductCard = ({
|
|
6440
6461
|
settings = defaultProductCardSettings,
|
6441
6462
|
variantOptionsText
|
6442
6463
|
}) => {
|
6443
|
-
const [selectedVariant, setSelectedVariant] = (0,
|
6444
|
-
const [selectedQuantity, setSelectedQuantity] = (0,
|
6445
|
-
const [interactionStatus, setInteractionStatus] = (0,
|
6464
|
+
const [selectedVariant, setSelectedVariant] = (0, import_react18.useState)(product.variants.nodes[0]);
|
6465
|
+
const [selectedQuantity, setSelectedQuantity] = (0, import_react18.useState)(settings?.quantityInput?.default_quantity || 1);
|
6466
|
+
const [interactionStatus, setInteractionStatus] = (0, import_react18.useState)("ready");
|
6446
6467
|
const { toggleCart } = useSmartCart();
|
6447
6468
|
const displayImage = selectedVariant.image || product.featuredImage;
|
6448
|
-
const handleSelectedVariant = (0,
|
6469
|
+
const handleSelectedVariant = (0, import_react18.useCallback)((product2, variant_id) => {
|
6449
6470
|
const updatedVariant = product2.variants.nodes.find((variant) => variant.id === variant_id);
|
6450
6471
|
if (updatedVariant) {
|
6451
6472
|
setSelectedVariant(updatedVariant);
|
6452
6473
|
}
|
6453
6474
|
}, []);
|
6454
|
-
const handleSelectedQuantity = (0,
|
6475
|
+
const handleSelectedQuantity = (0, import_react18.useCallback)((quantity) => {
|
6455
6476
|
setSelectedQuantity(quantity);
|
6456
6477
|
}, []);
|
6457
|
-
const handleLinkClick = (0,
|
6478
|
+
const handleLinkClick = (0, import_react18.useCallback)(() => {
|
6458
6479
|
if (isCrossSell) {
|
6459
6480
|
toggleCart();
|
6460
6481
|
}
|
@@ -6465,7 +6486,7 @@ var ProductCard = ({
|
|
6465
6486
|
const cardLayout = settings?.layoutStyle || "grid";
|
6466
6487
|
const productOptions = settings?.productOptions;
|
6467
6488
|
const showVariantOptionsSetting = productOptions?.show_variant_options || "always";
|
6468
|
-
const showVariantSelect = (0,
|
6489
|
+
const showVariantSelect = (0, import_react18.useMemo)(() => {
|
6469
6490
|
if (product?.variants.nodes.length <= 1) {
|
6470
6491
|
const firstVariantTitle = product.variants.nodes[0]?.title?.toLowerCase();
|
6471
6492
|
if (firstVariantTitle === "default title" || firstVariantTitle === "default") {
|
@@ -6488,10 +6509,10 @@ var ProductCard = ({
|
|
6488
6509
|
return true;
|
6489
6510
|
}
|
6490
6511
|
}, [product?.variants.nodes, showVariantOptionsSetting, interactionStatus, cardLayout]);
|
6491
|
-
const isSelectionRequiredBeforeAddToCart = (0,
|
6512
|
+
const isSelectionRequiredBeforeAddToCart = (0, import_react18.useMemo)(() => {
|
6492
6513
|
return product?.variants.nodes.length > 1 && !showVariantSelect && interactionStatus === "ready";
|
6493
6514
|
}, [product?.variants.nodes, showVariantSelect, interactionStatus]);
|
6494
|
-
const atcButtonLabel = (0,
|
6515
|
+
const atcButtonLabel = (0, import_react18.useMemo)(() => {
|
6495
6516
|
if (isSelectionRequiredBeforeAddToCart) {
|
6496
6517
|
if (product.options && product.options.length === 1) {
|
6497
6518
|
return `${product.options[0].name}`;
|
@@ -6500,12 +6521,12 @@ var ProductCard = ({
|
|
6500
6521
|
}
|
6501
6522
|
return addToCartBtnText || "Add to Cart";
|
6502
6523
|
}, [isSelectionRequiredBeforeAddToCart, product.options, variantOptionsText, addToCartBtnText]);
|
6503
|
-
const handlePrimaryAction = (0,
|
6524
|
+
const handlePrimaryAction = (0, import_react18.useCallback)(() => {
|
6504
6525
|
if (isSelectionRequiredBeforeAddToCart) {
|
6505
6526
|
setInteractionStatus("selecting");
|
6506
6527
|
} else {
|
6507
|
-
if (isInPopup
|
6508
|
-
onPopupDismiss();
|
6528
|
+
if (isInPopup) {
|
6529
|
+
onPopupDismiss?.();
|
6509
6530
|
}
|
6510
6531
|
}
|
6511
6532
|
}, [isSelectionRequiredBeforeAddToCart, isInPopup, onPopupDismiss]);
|
@@ -6674,7 +6695,7 @@ var ProductCard = ({
|
|
6674
6695
|
addToCartCallback,
|
6675
6696
|
disableShopifyAddAction: isSelectionRequiredBeforeAddToCart,
|
6676
6697
|
isHydrogenReact,
|
6677
|
-
onClickAction: handlePrimaryAction,
|
6698
|
+
onClickAction: isSelectionRequiredBeforeAddToCart ? handlePrimaryAction : void 0,
|
6678
6699
|
quantity: selectedQuantity,
|
6679
6700
|
selectedVariants: isSelectionRequiredBeforeAddToCart ? [] : [selectedVariant]
|
6680
6701
|
}
|
@@ -6695,7 +6716,7 @@ var ProductCard = ({
|
|
6695
6716
|
};
|
6696
6717
|
|
6697
6718
|
// src/components/ProductCarousel/ProductCarousel.tsx
|
6698
|
-
var
|
6719
|
+
var import_react19 = require("react");
|
6699
6720
|
|
6700
6721
|
// src/components/ProductCarousel/ProductCarousel.module.css
|
6701
6722
|
var result15 = { "rebuy-carousel": "ProductCarousel_rebuy-carousel", "rebuy-carousel__container": "ProductCarousel_rebuy-carousel__container", "rebuy-carousel__slide": "ProductCarousel_rebuy-carousel__slide", "rebuy-carousel__controls": "ProductCarousel_rebuy-carousel__controls", "rebuy-carousel__prev": "ProductCarousel_rebuy-carousel__prev", "rebuy-carousel__next": "ProductCarousel_rebuy-carousel__next", "rebuy-carousel__pagination": "ProductCarousel_rebuy-carousel__pagination", "rebuy-carousel__dot": "ProductCarousel_rebuy-carousel__dot", "rebuy-carousel__grid": "ProductCarousel_rebuy-carousel__grid" };
|
@@ -6717,10 +6738,10 @@ var ProductCarousel = ({
|
|
6717
6738
|
showPagination = true,
|
6718
6739
|
variantOptionsText
|
6719
6740
|
}) => {
|
6720
|
-
const [currentSlide, setCurrentSlide] = (0,
|
6721
|
-
const [totalSlides, setTotalSlides] = (0,
|
6722
|
-
const [repeatedProducts, setRepeatedProducts] = (0,
|
6723
|
-
(0,
|
6741
|
+
const [currentSlide, setCurrentSlide] = (0, import_react19.useState)(0);
|
6742
|
+
const [totalSlides, setTotalSlides] = (0, import_react19.useState)(0);
|
6743
|
+
const [repeatedProducts, setRepeatedProducts] = (0, import_react19.useState)([]);
|
6744
|
+
(0, import_react19.useEffect)(() => {
|
6724
6745
|
if (products.length === 0) {
|
6725
6746
|
setRepeatedProducts([]);
|
6726
6747
|
return;
|
@@ -6733,7 +6754,7 @@ var ProductCarousel = ({
|
|
6733
6754
|
}
|
6734
6755
|
setRepeatedProducts(repeated);
|
6735
6756
|
}, [products, columns]);
|
6736
|
-
(0,
|
6757
|
+
(0, import_react19.useEffect)(() => {
|
6737
6758
|
if (repeatedProducts.length && columns) {
|
6738
6759
|
setTotalSlides(Math.ceil(repeatedProducts.length / columns));
|
6739
6760
|
}
|
@@ -6794,7 +6815,7 @@ var ProductCarousel = ({
|
|
6794
6815
|
|
6795
6816
|
// src/components/Timer/Timer.tsx
|
6796
6817
|
var import_clsx7 = __toESM(require("clsx"), 1);
|
6797
|
-
var
|
6818
|
+
var import_react20 = require("react");
|
6798
6819
|
|
6799
6820
|
// src/components/Timer/Timer.module.css
|
6800
6821
|
var result16 = { "rebuy-timer__container": "Timer_rebuy-timer__container", "rebuy-timer__text": "Timer_rebuy-timer__text", "rebuy-timer__title": "Timer_rebuy-timer__title", "rebuy-timer__display": "Timer_rebuy-timer__display", "rebuy-timer__display--urgent": "Timer_rebuy-timer__display--urgent", "rebuy-timer__minutes": "Timer_rebuy-timer__minutes", "rebuy-timer__seconds": "Timer_rebuy-timer__seconds", "rebuy-timer__separator": "Timer_rebuy-timer__separator" };
|
@@ -6802,15 +6823,24 @@ var Timer_default = result16;
|
|
6802
6823
|
|
6803
6824
|
// src/components/Timer/Timer.tsx
|
6804
6825
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
6805
|
-
var Timer = ({
|
6826
|
+
var Timer = ({
|
6827
|
+
action,
|
6828
|
+
cartCount,
|
6829
|
+
checkoutUrl,
|
6830
|
+
durationMinutes,
|
6831
|
+
durationSeconds,
|
6832
|
+
isPopup = false,
|
6833
|
+
onDismiss,
|
6834
|
+
title
|
6835
|
+
}) => {
|
6806
6836
|
const initialTotalSeconds = (durationMinutes || 0) * 60 + (durationSeconds || 0);
|
6807
|
-
const [totalSeconds, setTotalSeconds] = (0,
|
6808
|
-
const [timerActive, setTimerActive] = (0,
|
6837
|
+
const [totalSeconds, setTotalSeconds] = (0, import_react20.useState)(initialTotalSeconds);
|
6838
|
+
const [timerActive, setTimerActive] = (0, import_react20.useState)(true);
|
6809
6839
|
const minutes = Math.floor(totalSeconds / 60);
|
6810
6840
|
const seconds = totalSeconds % 60;
|
6811
6841
|
const formattedMinutes = String(minutes).padStart(2, "0");
|
6812
6842
|
const formattedSeconds = String(seconds).padStart(2, "0");
|
6813
|
-
const handleTimerEnd = (0,
|
6843
|
+
const handleTimerEnd = (0, import_react20.useCallback)(() => {
|
6814
6844
|
setTimerActive(false);
|
6815
6845
|
switch (action) {
|
6816
6846
|
case "dismiss":
|
@@ -6819,7 +6849,14 @@ var Timer = ({ action, durationMinutes, durationSeconds, isPopup = false, onDism
|
|
6819
6849
|
}
|
6820
6850
|
break;
|
6821
6851
|
case "checkout":
|
6822
|
-
|
6852
|
+
if (checkoutUrl && cartCount && cartCount > 0) {
|
6853
|
+
window.location.href = checkoutUrl;
|
6854
|
+
} else {
|
6855
|
+
console.warn("Timer: No checkout URL available for checkout action");
|
6856
|
+
if (isPopup && onDismiss) {
|
6857
|
+
onDismiss();
|
6858
|
+
}
|
6859
|
+
}
|
6823
6860
|
break;
|
6824
6861
|
case "cart":
|
6825
6862
|
window.location.href = "/cart";
|
@@ -6828,8 +6865,8 @@ var Timer = ({ action, durationMinutes, durationSeconds, isPopup = false, onDism
|
|
6828
6865
|
default:
|
6829
6866
|
break;
|
6830
6867
|
}
|
6831
|
-
}, [action, isPopup, onDismiss]);
|
6832
|
-
(0,
|
6868
|
+
}, [action, checkoutUrl, isPopup, onDismiss]);
|
6869
|
+
(0, import_react20.useEffect)(() => {
|
6833
6870
|
if (!timerActive) return;
|
6834
6871
|
const interval = setInterval(() => {
|
6835
6872
|
setTotalSeconds((prevSeconds) => {
|
@@ -6906,6 +6943,8 @@ var RebuyWidget_default = result17;
|
|
6906
6943
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
6907
6944
|
var WidgetContent = ({
|
6908
6945
|
addToCartCallback,
|
6946
|
+
cartCount,
|
6947
|
+
checkoutUrl,
|
6909
6948
|
customTitle,
|
6910
6949
|
customTitleLevel,
|
6911
6950
|
customTitleStyle,
|
@@ -6999,6 +7038,8 @@ var WidgetContent = ({
|
|
6999
7038
|
Timer,
|
7000
7039
|
{
|
7001
7040
|
action: settings?.timer.action,
|
7041
|
+
cartCount,
|
7042
|
+
checkoutUrl,
|
7002
7043
|
durationMinutes: settings?.timer.duration_minutes,
|
7003
7044
|
durationSeconds: settings?.timer.duration_seconds,
|
7004
7045
|
isPopup: settings?.display_type === "popup",
|
@@ -7036,7 +7077,6 @@ var RebuyWidget = (props) => {
|
|
7036
7077
|
customTitleLevel = "h2",
|
7037
7078
|
customTitleStyle,
|
7038
7079
|
isCrossSell,
|
7039
|
-
isHydrogenReact,
|
7040
7080
|
popupTriggerId,
|
7041
7081
|
product,
|
7042
7082
|
productId,
|
@@ -7045,26 +7085,26 @@ var RebuyWidget = (props) => {
|
|
7045
7085
|
widgetId
|
7046
7086
|
} = props;
|
7047
7087
|
const { apiKey: apiKeyFromConfig, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
|
7048
|
-
const [settings, setSettings] = (0,
|
7049
|
-
const [loadingSettings, setLoadingSettings] = (0,
|
7050
|
-
const [error, setError] = (0,
|
7051
|
-
const [showPopup, setShowPopup] = (0,
|
7052
|
-
const [popupShownOnce, setPopupShownOnce] = (0,
|
7053
|
-
const popupRef = (0,
|
7054
|
-
const [clientInstance, setClientInstance] = (0,
|
7055
|
-
const rebuyGeneralContext = (0,
|
7088
|
+
const [settings, setSettings] = (0, import_react21.useState)(null);
|
7089
|
+
const [loadingSettings, setLoadingSettings] = (0, import_react21.useState)(true);
|
7090
|
+
const [error, setError] = (0, import_react21.useState)(null);
|
7091
|
+
const [showPopup, setShowPopup] = (0, import_react21.useState)(false);
|
7092
|
+
const [popupShownOnce, setPopupShownOnce] = (0, import_react21.useState)(false);
|
7093
|
+
const popupRef = (0, import_react21.useRef)(null);
|
7094
|
+
const [clientInstance, setClientInstance] = (0, import_react21.useState)(null);
|
7095
|
+
const rebuyGeneralContext = (0, import_react21.useContext)(RebuyContext);
|
7056
7096
|
const generalContextParams = rebuyGeneralContext?.contextParameters;
|
7057
7097
|
const mainCacheKey = rebuyConfig?.shop?.cache_key;
|
7058
7098
|
const generalContextCacheKey = generalContextParams?.cache_key;
|
7059
7099
|
const cacheKeyToUse = mainCacheKey || generalContextCacheKey || "";
|
7060
|
-
const [initialized, setInitialized] = (0,
|
7100
|
+
const [initialized, setInitialized] = (0, import_react21.useState)(false);
|
7061
7101
|
const shopifyProductId = product?.id ?? productId ?? null;
|
7062
7102
|
const shopifyVariantId = variant?.id ?? variantId ?? null;
|
7063
|
-
const [products, setProducts] = (0,
|
7103
|
+
const [products, setProducts] = (0, import_react21.useState)([]);
|
7064
7104
|
const currentBreakpoint = useBreakpoint(settings);
|
7065
7105
|
const shouldHideWidget = settings?.layout?.[currentBreakpoint]?.style === "none";
|
7066
7106
|
usePopupTrigger(settings, popupTriggerId, widgetId, popupShownOnce, showPopup, setShowPopup, setPopupShownOnce);
|
7067
|
-
(0,
|
7107
|
+
(0, import_react21.useEffect)(() => {
|
7068
7108
|
if (!clientInstance && apiKeyFromConfig && configLoadingStatus === "success") {
|
7069
7109
|
const client = new import_rebuy2.RebuyClient(apiKeyFromConfig);
|
7070
7110
|
if (generalContextParams) {
|
@@ -7075,12 +7115,12 @@ var RebuyWidget = (props) => {
|
|
7075
7115
|
setInitialized(true);
|
7076
7116
|
}
|
7077
7117
|
}, [clientInstance, apiKeyFromConfig, configLoadingStatus, generalContextParams]);
|
7078
|
-
(0,
|
7118
|
+
(0, import_react21.useEffect)(() => {
|
7079
7119
|
if (!clientInstance || !generalContextParams) return;
|
7080
7120
|
const filteredParams = filterContextForWidgetEndpoints(generalContextParams, settings?.endpoint);
|
7081
7121
|
clientInstance.setContextParameters(filteredParams);
|
7082
7122
|
}, [clientInstance, generalContextParams, settings]);
|
7083
|
-
(0,
|
7123
|
+
(0, import_react21.useEffect)(() => {
|
7084
7124
|
if (configLoadingStatus === "loading") {
|
7085
7125
|
return;
|
7086
7126
|
}
|
@@ -7139,13 +7179,13 @@ var RebuyWidget = (props) => {
|
|
7139
7179
|
};
|
7140
7180
|
fetchSettings();
|
7141
7181
|
}, [widgetId, clientInstance, configLoadingStatus, apiKeyFromConfig, cacheKeyToUse, initialized]);
|
7142
|
-
const cartProductIds = (0,
|
7182
|
+
const cartProductIds = (0, import_react21.useMemo)(() => {
|
7143
7183
|
return (generalContextParams?.cart?.items || []).map((item) => item.product_id).filter(Boolean).join(",");
|
7144
7184
|
}, [generalContextParams?.cart?.items]);
|
7145
|
-
const cartVariantIds = (0,
|
7185
|
+
const cartVariantIds = (0, import_react21.useMemo)(() => {
|
7146
7186
|
return (generalContextParams?.cart?.items || []).map((item) => item.variant_id).filter(Boolean).join(",");
|
7147
7187
|
}, [generalContextParams?.cart?.items]);
|
7148
|
-
const request = (0,
|
7188
|
+
const request = (0, import_react21.useMemo)(() => {
|
7149
7189
|
const req = {
|
7150
7190
|
endpoint: settings?.endpoint || "/api/v1/products/recommended",
|
7151
7191
|
params: {}
|
@@ -7175,7 +7215,7 @@ var RebuyWidget = (props) => {
|
|
7175
7215
|
}
|
7176
7216
|
return req;
|
7177
7217
|
}, [settings, shopifyProductId, shopifyVariantId, cartProductIds, cartVariantIds]);
|
7178
|
-
(0,
|
7218
|
+
(0, import_react21.useEffect)(() => {
|
7179
7219
|
let isMounted = true;
|
7180
7220
|
if (!clientInstance || !initialized || !settings || configLoadingStatus !== "success") return;
|
7181
7221
|
const fetchData = async () => {
|
@@ -7227,7 +7267,7 @@ var RebuyWidget = (props) => {
|
|
7227
7267
|
apiKeyFromConfig,
|
7228
7268
|
cacheKeyToUse
|
7229
7269
|
]);
|
7230
|
-
(0,
|
7270
|
+
(0, import_react21.useEffect)(() => {
|
7231
7271
|
if (!showPopup) return;
|
7232
7272
|
const handleClickOutside = (event) => {
|
7233
7273
|
if (popupRef.current && !popupRef.current.contains(event.target)) {
|
@@ -7277,10 +7317,12 @@ var RebuyWidget = (props) => {
|
|
7277
7317
|
closePopup();
|
7278
7318
|
}, 0);
|
7279
7319
|
},
|
7320
|
+
cartCount: generalContextParams?.cart_count || 0,
|
7321
|
+
checkoutUrl: generalContextParams?.checkoutUrl,
|
7280
7322
|
customTitle,
|
7281
7323
|
customTitleLevel,
|
7282
7324
|
customTitleStyle,
|
7283
|
-
isHydrogenReact,
|
7325
|
+
isHydrogenReact: rebuyGeneralContext?.contextParameters?.isHydrogenReact,
|
7284
7326
|
isInPopup: true,
|
7285
7327
|
onDismiss: closePopup,
|
7286
7328
|
products,
|
@@ -7291,11 +7333,12 @@ var RebuyWidget = (props) => {
|
|
7291
7333
|
WidgetContent,
|
7292
7334
|
{
|
7293
7335
|
addToCartCallback,
|
7336
|
+
checkoutUrl: generalContextParams?.checkoutUrl,
|
7294
7337
|
customTitle,
|
7295
7338
|
customTitleLevel,
|
7296
7339
|
customTitleStyle,
|
7297
7340
|
isCrossSell,
|
7298
|
-
isHydrogenReact,
|
7341
|
+
isHydrogenReact: rebuyGeneralContext?.contextParameters?.isHydrogenReact,
|
7299
7342
|
isInPopup: settings?.display_type === "popup",
|
7300
7343
|
products,
|
7301
7344
|
settings
|
@@ -7315,7 +7358,7 @@ var CrossSell = ({ componentConfig }) => {
|
|
7315
7358
|
};
|
7316
7359
|
|
7317
7360
|
// src/smart-cart/components/CustomCode/CustomCodeBlock.tsx
|
7318
|
-
var
|
7361
|
+
var import_react22 = __toESM(require("react"), 1);
|
7319
7362
|
|
7320
7363
|
// src/utils/nonceManager.ts
|
7321
7364
|
var cachedNonce = void 0;
|
@@ -7389,12 +7432,12 @@ var executeScriptsInContainer = (container, debugKey, debugContext) => {
|
|
7389
7432
|
|
7390
7433
|
// src/smart-cart/components/CustomCode/CustomCodeBlock.tsx
|
7391
7434
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
7392
|
-
var CustomCodeBlock =
|
7393
|
-
const containerRef = (0,
|
7394
|
-
const executedCodeRef = (0,
|
7435
|
+
var CustomCodeBlock = import_react22.default.memo(({ componentConfig }) => {
|
7436
|
+
const containerRef = (0, import_react22.useRef)(null);
|
7437
|
+
const executedCodeRef = (0, import_react22.useRef)(null);
|
7395
7438
|
const componentId = componentConfig.component_id;
|
7396
|
-
const htmlCode = (0,
|
7397
|
-
(0,
|
7439
|
+
const htmlCode = (0, import_react22.useMemo)(() => componentConfig.settings?.html_code ?? null, [componentConfig.settings?.html_code]);
|
7440
|
+
(0, import_react22.useEffect)(() => {
|
7398
7441
|
const container = containerRef.current;
|
7399
7442
|
if (htmlCode && container && executedCodeRef.current !== htmlCode) {
|
7400
7443
|
const timerId = setTimeout(() => {
|
@@ -7430,20 +7473,20 @@ CustomCodeBlock.displayName = "CustomCodeBlock";
|
|
7430
7473
|
|
7431
7474
|
// src/smart-cart/components/DiscountCodeInput/DiscountCodeInput.tsx
|
7432
7475
|
var import_clsx8 = __toESM(require("clsx"), 1);
|
7433
|
-
var
|
7476
|
+
var import_react24 = __toESM(require("react"), 1);
|
7434
7477
|
var import_react_router7 = require("react-router");
|
7435
7478
|
|
7436
7479
|
// src/smart-cart/hooks/useDiscountManager.ts
|
7437
|
-
var
|
7480
|
+
var import_react23 = require("react");
|
7438
7481
|
var GENERIC_ERROR_CODE_MESSAGE = "{{code}} is not valid for this cart.";
|
7439
7482
|
var useDiscountManager = () => {
|
7440
7483
|
const { cartData, error: cartErrorFromCtx, getComponentConfigByType } = useSmartCart();
|
7441
|
-
const [isProcessing, setIsProcessing] = (0,
|
7442
|
-
const [currentError, setCurrentError] = (0,
|
7443
|
-
const [appliedCodesState, setAppliedCodesState] = (0,
|
7444
|
-
const componentConfig = (0,
|
7445
|
-
const settings = (0,
|
7446
|
-
(0,
|
7484
|
+
const [isProcessing, setIsProcessing] = (0, import_react23.useState)(false);
|
7485
|
+
const [currentError, setCurrentError] = (0, import_react23.useState)(null);
|
7486
|
+
const [appliedCodesState, setAppliedCodesState] = (0, import_react23.useState)([]);
|
7487
|
+
const componentConfig = (0, import_react23.useMemo)(() => getComponentConfigByType("discount_code"), [getComponentConfigByType]);
|
7488
|
+
const settings = (0, import_react23.useMemo)(() => componentConfig?.settings ?? null, [componentConfig]);
|
7489
|
+
(0, import_react23.useEffect)(() => {
|
7447
7490
|
const codesFromApi = cartData?.discountCodes?.filter((dc) => dc.applicable).map((dc) => dc.code) ?? [];
|
7448
7491
|
if (JSON.stringify(codesFromApi) !== JSON.stringify(appliedCodesState)) {
|
7449
7492
|
setAppliedCodesState(codesFromApi);
|
@@ -7454,7 +7497,7 @@ var useDiscountManager = () => {
|
|
7454
7497
|
}
|
7455
7498
|
}, [cartData?.discountCodes, appliedCodesState, currentError]);
|
7456
7499
|
const errorToDisplay = currentError ?? cartErrorFromCtx;
|
7457
|
-
const prepareApplyCode = (0,
|
7500
|
+
const prepareApplyCode = (0, import_react23.useCallback)(
|
7458
7501
|
(code) => {
|
7459
7502
|
if (!code) return null;
|
7460
7503
|
const codeUpper = code.trim().toUpperCase();
|
@@ -7463,7 +7506,7 @@ var useDiscountManager = () => {
|
|
7463
7506
|
},
|
7464
7507
|
[appliedCodesState]
|
7465
7508
|
);
|
7466
|
-
const prepareRemoveCode = (0,
|
7509
|
+
const prepareRemoveCode = (0, import_react23.useCallback)(
|
7467
7510
|
(codeToRemove) => {
|
7468
7511
|
const codeUpper = codeToRemove.trim().toUpperCase();
|
7469
7512
|
const codesToKeep = appliedCodesState.filter((c) => c.toUpperCase() !== codeUpper);
|
@@ -7471,7 +7514,7 @@ var useDiscountManager = () => {
|
|
7471
7514
|
},
|
7472
7515
|
[appliedCodesState]
|
7473
7516
|
);
|
7474
|
-
const prepareRemoveAllCodes = (0,
|
7517
|
+
const prepareRemoveAllCodes = (0, import_react23.useCallback)(() => {
|
7475
7518
|
return { codes: [] };
|
7476
7519
|
}, []);
|
7477
7520
|
const processActionResult = (resultCart, attemptedCode) => {
|
@@ -7537,12 +7580,12 @@ var DiscountCodeInputComponent = ({ componentConfig }) => {
|
|
7537
7580
|
setIsProcessing: setDiscountManagerIsProcessing,
|
7538
7581
|
settings
|
7539
7582
|
} = useDiscountManager();
|
7540
|
-
const [inputValue, setInputValue] = (0,
|
7541
|
-
const [isInputFocused, setIsInputFocused] = (0,
|
7542
|
-
const [isLocallyProcessing, setIsLocallyProcessing] = (0,
|
7543
|
-
const inputRef = (0,
|
7583
|
+
const [inputValue, setInputValue] = (0, import_react24.useState)("");
|
7584
|
+
const [isInputFocused, setIsInputFocused] = (0, import_react24.useState)(false);
|
7585
|
+
const [isLocallyProcessing, setIsLocallyProcessing] = (0, import_react24.useState)(false);
|
7586
|
+
const inputRef = (0, import_react24.useRef)(null);
|
7544
7587
|
const hasItems = getItemCount() > 0;
|
7545
|
-
const lang = (0,
|
7588
|
+
const lang = (0, import_react24.useMemo)(
|
7546
7589
|
() => ({
|
7547
7590
|
// applyingLabel: settings?.language?.discount_applying_label ?? 'Applying...',
|
7548
7591
|
buttonLabel: settings?.language?.discount_button_label ?? "Apply",
|
@@ -7550,23 +7593,23 @@ var DiscountCodeInputComponent = ({ componentConfig }) => {
|
|
7550
7593
|
}),
|
7551
7594
|
[settings]
|
7552
7595
|
);
|
7553
|
-
const isLoadingCombined = (0,
|
7596
|
+
const isLoadingCombined = (0, import_react24.useMemo)(() => {
|
7554
7597
|
if (isHydrogenReact) return isGlobalCartLoading || isLocallyProcessing;
|
7555
7598
|
return discountFetcher.state !== "idle" || isLocallyProcessing;
|
7556
7599
|
}, [isHydrogenReact, isGlobalCartLoading, discountFetcher.state, isLocallyProcessing]);
|
7557
7600
|
const shouldShowTags = appliedCodes.length > 0;
|
7558
|
-
const discountTotalAmount = (0,
|
7601
|
+
const discountTotalAmount = (0, import_react24.useMemo)(() => {
|
7559
7602
|
if (!cartData || !shouldShowTags || !Array.isArray(cartData.discountAllocations)) {
|
7560
7603
|
return 0;
|
7561
7604
|
}
|
7562
7605
|
return cartData.discountAllocations.filter((alloc) => alloc.__typename === "CartCodeDiscountAllocation").reduce((sum, alloc) => sum + parseFloat(alloc.discountedAmount.amount), 0);
|
7563
7606
|
}, [cartData, shouldShowTags]);
|
7564
|
-
const _formattedDiscountTotal = (0,
|
7607
|
+
const _formattedDiscountTotal = (0, import_react24.useMemo)(() => {
|
7565
7608
|
if (discountTotalAmount <= 0) return "";
|
7566
7609
|
const currencyCode = cartData?.cost?.totalAmount?.currencyCode ?? "USD";
|
7567
7610
|
return `- ${formatMoney(discountTotalAmount, void 0, currencyCode)}`;
|
7568
7611
|
}, [discountTotalAmount, cartData, appliedCodes]);
|
7569
|
-
const handleApply = (0,
|
7612
|
+
const handleApply = (0, import_react24.useCallback)(
|
7570
7613
|
(event) => {
|
7571
7614
|
event.preventDefault();
|
7572
7615
|
if (!inputValue.trim() || isLoadingCombined) return;
|
@@ -7603,7 +7646,7 @@ var DiscountCodeInputComponent = ({ componentConfig }) => {
|
|
7603
7646
|
setDiscountManagerError
|
7604
7647
|
]
|
7605
7648
|
);
|
7606
|
-
const handleRemove = (0,
|
7649
|
+
const handleRemove = (0, import_react24.useCallback)(
|
7607
7650
|
(code) => {
|
7608
7651
|
if (isLoadingCombined) return;
|
7609
7652
|
const payloadFromManager = prepareRemoveCode(code);
|
@@ -7636,7 +7679,7 @@ var DiscountCodeInputComponent = ({ componentConfig }) => {
|
|
7636
7679
|
setDiscountManagerError
|
7637
7680
|
]
|
7638
7681
|
);
|
7639
|
-
(0,
|
7682
|
+
(0, import_react24.useEffect)(() => {
|
7640
7683
|
if (isHydrogenReact) {
|
7641
7684
|
if (!isGlobalCartLoading && isLocallyProcessing) {
|
7642
7685
|
setIsLocallyProcessing(false);
|
@@ -7763,11 +7806,11 @@ var DiscountCodeInputComponent = ({ componentConfig }) => {
|
|
7763
7806
|
}
|
7764
7807
|
);
|
7765
7808
|
};
|
7766
|
-
var DiscountCodeInput =
|
7809
|
+
var DiscountCodeInput = import_react24.default.memo(DiscountCodeInputComponent);
|
7767
7810
|
DiscountCodeInput.displayName = "DiscountCodeInput";
|
7768
7811
|
|
7769
7812
|
// src/smart-cart/components/LoginButton/LoginButton.tsx
|
7770
|
-
var
|
7813
|
+
var import_react25 = __toESM(require("react"), 1);
|
7771
7814
|
|
7772
7815
|
// src/smart-cart/components/LoginButton/LoginButton.module.css
|
7773
7816
|
var result19 = { "rebuy-login-button": "LoginButton_rebuy-login-button" };
|
@@ -7775,7 +7818,7 @@ var LoginButton_default = result19;
|
|
7775
7818
|
|
7776
7819
|
// src/smart-cart/components/LoginButton/LoginButton.tsx
|
7777
7820
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
7778
|
-
var LoginButton =
|
7821
|
+
var LoginButton = import_react25.default.memo(() => {
|
7779
7822
|
const { cartData, getComponentConfigByType } = useSmartCart();
|
7780
7823
|
const componentConfig = getComponentConfigByType("login");
|
7781
7824
|
const isLoggedInViaApi = !!cartData?.buyerIdentity?.customer?.id;
|
@@ -7803,10 +7846,10 @@ var LoginButton = import_react24.default.memo(() => {
|
|
7803
7846
|
LoginButton.displayName = "LoginButton";
|
7804
7847
|
|
7805
7848
|
// src/smart-cart/components/SmartCartApp/SmartCartApp.tsx
|
7806
|
-
var
|
7849
|
+
var import_react27 = __toESM(require("react"), 1);
|
7807
7850
|
|
7808
7851
|
// src/smart-cart/hooks/useSmartCartApps.ts
|
7809
|
-
var
|
7852
|
+
var import_react26 = require("react");
|
7810
7853
|
|
7811
7854
|
// src/smart-cart/types/smart-cart-app.ts
|
7812
7855
|
var import_zod2 = require("zod");
|
@@ -7828,11 +7871,11 @@ var smartCartAppMerchantConfigSchema = import_zod2.z.object({
|
|
7828
7871
|
// src/smart-cart/hooks/useSmartCartApps.ts
|
7829
7872
|
var useSmartCartApps = () => {
|
7830
7873
|
const { apiKey, cacheKey, config, shopifyDomain } = useSmartCart();
|
7831
|
-
const [enrichedApps, setEnrichedApps] = (0,
|
7832
|
-
const [isLoading, setIsLoading] = (0,
|
7833
|
-
const [error, setError] = (0,
|
7874
|
+
const [enrichedApps, setEnrichedApps] = (0, import_react26.useState)(/* @__PURE__ */ new Map());
|
7875
|
+
const [isLoading, setIsLoading] = (0, import_react26.useState)(false);
|
7876
|
+
const [error, setError] = (0, import_react26.useState)(null);
|
7834
7877
|
const initialAppsConfig = config?.apps;
|
7835
|
-
(0,
|
7878
|
+
(0, import_react26.useEffect)(() => {
|
7836
7879
|
let isMounted = true;
|
7837
7880
|
const fetchAndEnrichApps = async () => {
|
7838
7881
|
if (!initialAppsConfig || initialAppsConfig.length === 0) {
|
@@ -8013,19 +8056,19 @@ var useSmartCartApps = () => {
|
|
8013
8056
|
|
8014
8057
|
// src/smart-cart/components/SmartCartApp/SmartCartApp.tsx
|
8015
8058
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
8016
|
-
var SmartCartApp =
|
8017
|
-
const containerRef = (0,
|
8018
|
-
const executedScriptRef = (0,
|
8059
|
+
var SmartCartApp = import_react27.default.memo(({ componentConfig }) => {
|
8060
|
+
const containerRef = (0, import_react27.useRef)(null);
|
8061
|
+
const executedScriptRef = (0, import_react27.useRef)(null);
|
8019
8062
|
const { enrichedApps, error: appsHookError, isLoading: appsLoading } = useSmartCartApps();
|
8020
8063
|
const componentId = componentConfig.component_id;
|
8021
|
-
const appId = (0,
|
8064
|
+
const appId = (0, import_react27.useMemo)(
|
8022
8065
|
() => componentConfig.settings?.app_id ? Number(componentConfig.settings.app_id) : null,
|
8023
8066
|
[componentConfig.settings?.app_id]
|
8024
8067
|
);
|
8025
8068
|
const appData = appId !== null ? enrichedApps.get(appId) : null;
|
8026
8069
|
const enabledAppData = appData?.enabled ? appData : null;
|
8027
8070
|
const scriptContent = enabledAppData?.script ?? null;
|
8028
|
-
(0,
|
8071
|
+
(0, import_react27.useEffect)(() => {
|
8029
8072
|
const container = containerRef.current;
|
8030
8073
|
if (container && scriptContent && executedScriptRef.current !== scriptContent) {
|
8031
8074
|
const timerId = setTimeout(() => {
|
@@ -8080,7 +8123,7 @@ SmartCartApp.displayName = "SmartCartApp";
|
|
8080
8123
|
|
8081
8124
|
// src/smart-cart/components/TieredProgressBar/TieredProgressBar.tsx
|
8082
8125
|
var import_clsx10 = __toESM(require("clsx"), 1);
|
8083
|
-
var
|
8126
|
+
var import_react28 = __toESM(require("react"), 1);
|
8084
8127
|
var import_react_router8 = require("react-router");
|
8085
8128
|
var import_shallow2 = require("zustand/shallow");
|
8086
8129
|
|
@@ -8285,10 +8328,10 @@ var codeBlock = {
|
|
8285
8328
|
|
8286
8329
|
// src/smart-cart/components/TieredProgressBar/TieredProgressBar.tsx
|
8287
8330
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
8288
|
-
var TieredProgressBar =
|
8331
|
+
var TieredProgressBar = import_react28.default.memo(() => {
|
8289
8332
|
const { hydrogenReactCartActions, isCartBusy, isHydrogenReact } = useSmartCart();
|
8290
8333
|
const tpbUserActionFetcher = (0, import_react_router8.useFetcher)();
|
8291
|
-
const [showDebugPanel, setShowDebugPanel] = (0,
|
8334
|
+
const [showDebugPanel, setShowDebugPanel] = (0, import_react28.useState)(false);
|
8292
8335
|
const {
|
8293
8336
|
_lastFetchedBarId,
|
8294
8337
|
activeBarConfig,
|
@@ -8330,10 +8373,10 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8330
8373
|
const handleRemoveGiftStore = useTieredProgressBarStore((state) => state.handleRemoveGift);
|
8331
8374
|
const clearUserActionError = useTieredProgressBarStore((state) => state.clearUserActionError);
|
8332
8375
|
const setSubmitFunctions = useTieredProgressBarStore((state) => state.setSubmitFunctions);
|
8333
|
-
const shouldDisableGiftActions = (0,
|
8376
|
+
const shouldDisableGiftActions = (0, import_react28.useMemo)(() => {
|
8334
8377
|
return isCartBusy || productFetchStatus === "loading";
|
8335
8378
|
}, [isCartBusy, productFetchStatus]);
|
8336
|
-
(0,
|
8379
|
+
(0, import_react28.useEffect)(() => {
|
8337
8380
|
if (isHydrogenReact) {
|
8338
8381
|
const hReactLinesAdd = hydrogenReactCartActions?.linesAdd;
|
8339
8382
|
const hReactLinesRemove = hydrogenReactCartActions?.linesRemove;
|
@@ -8374,13 +8417,13 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8374
8417
|
rebuyDebugLog.log("smart-cart-tpb" /* SC_TPB */, "Set Remix fetcher submit functions for TPB.");
|
8375
8418
|
}
|
8376
8419
|
}, [isHydrogenReact, hydrogenReactCartActions, tpbUserActionFetcher, setSubmitFunctions]);
|
8377
|
-
(0,
|
8420
|
+
(0, import_react28.useEffect)(() => {
|
8378
8421
|
if (userActionError) {
|
8379
8422
|
const timer = setTimeout(() => clearUserActionError(), 5e3);
|
8380
8423
|
return () => clearTimeout(timer);
|
8381
8424
|
}
|
8382
8425
|
}, [userActionError, clearUserActionError]);
|
8383
|
-
const { amountToNextTier, currentTier, lastReachedTier, realPercentageComplete, visualPercentageComplete } = (0,
|
8426
|
+
const { amountToNextTier, currentTier, lastReachedTier, realPercentageComplete, visualPercentageComplete } = (0, import_react28.useMemo)(() => {
|
8384
8427
|
let calculatedAmountToNextTier = 0, calculatedCurrentTier = null, calculatedLastReachedTier = null, calculatedRealPercentageComplete = 0;
|
8385
8428
|
if (activeBarConfig && activeBarConfig.tiers.length > 0 && isCartReady) {
|
8386
8429
|
const allTiers = activeBarConfig.tiers;
|
@@ -8408,31 +8451,31 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8408
8451
|
visualPercentageComplete: calculatedVisualPercentageComplete
|
8409
8452
|
};
|
8410
8453
|
}, [activeBarConfig, currentSubtotal, hasFreeShippingOnSubscription, isCartReady]);
|
8411
|
-
const giftsForDisplay = (0,
|
8412
|
-
const feedbackText = (0,
|
8454
|
+
const giftsForDisplay = (0, import_react28.useMemo)(() => Array.from(giftStates.values()), [giftStates]);
|
8455
|
+
const feedbackText = (0, import_react28.useMemo)(
|
8413
8456
|
() => getTierFeedbackText(activeBarConfig, currentTier, lastReachedTier, amountToNextTier, fetchedProductMap),
|
8414
8457
|
[activeBarConfig, currentTier, lastReachedTier, amountToNextTier, fetchedProductMap]
|
8415
8458
|
);
|
8416
|
-
const handleVariantSelect = (0,
|
8459
|
+
const handleVariantSelect = (0, import_react28.useCallback)(
|
8417
8460
|
(tierId, variantGid) => {
|
8418
8461
|
handleSelectVariantStore(tierId, variantGid);
|
8419
8462
|
},
|
8420
8463
|
[handleSelectVariantStore]
|
8421
8464
|
);
|
8422
|
-
const handleGiftAddOrReAdd = (0,
|
8465
|
+
const handleGiftAddOrReAdd = (0, import_react28.useCallback)(
|
8423
8466
|
(tierId) => {
|
8424
8467
|
handleAddOrReAddGiftStore(tierId);
|
8425
8468
|
},
|
8426
8469
|
[handleAddOrReAddGiftStore]
|
8427
8470
|
);
|
8428
|
-
const handleGiftRemove = (0,
|
8471
|
+
const handleGiftRemove = (0, import_react28.useCallback)(
|
8429
8472
|
(tierId) => {
|
8430
8473
|
handleRemoveGiftStore(tierId);
|
8431
8474
|
},
|
8432
8475
|
[handleRemoveGiftStore]
|
8433
8476
|
);
|
8434
8477
|
const lineItemMode = activeBarConfig?.use_line_item_mode ?? false;
|
8435
|
-
const productsToRenderInGiftArea = (0,
|
8478
|
+
const productsToRenderInGiftArea = (0, import_react28.useMemo)(
|
8436
8479
|
() => giftsForDisplay.filter((p) => {
|
8437
8480
|
if (!p.isReached) return false;
|
8438
8481
|
if (p.displayStatus === "unavailable" /* UNAVAILABLE */ && !p.error && !p.canReAdd) return false;
|
@@ -8442,7 +8485,7 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8442
8485
|
}),
|
8443
8486
|
[giftsForDisplay, lineItemMode]
|
8444
8487
|
);
|
8445
|
-
const renderGiftArea = (0,
|
8488
|
+
const renderGiftArea = (0, import_react28.useMemo)(
|
8446
8489
|
() => shouldRenderGiftArea(activeBarConfig, productsToRenderInGiftArea.length > 0),
|
8447
8490
|
[activeBarConfig, productsToRenderInGiftArea.length]
|
8448
8491
|
);
|
@@ -8477,7 +8520,7 @@ var TieredProgressBar = import_react27.default.memo(() => {
|
|
8477
8520
|
width: configuredIconSize
|
8478
8521
|
};
|
8479
8522
|
let iconElement;
|
8480
|
-
if (
|
8523
|
+
if (import_react28.default.isValidElement(iconRenderData)) iconElement = iconRenderData;
|
8481
8524
|
else if (iconRenderData.type === "image") {
|
8482
8525
|
const imageObject = iconRenderData;
|
8483
8526
|
iconElement = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -8663,7 +8706,7 @@ var componentRegistry = {
|
|
8663
8706
|
// src/smart-cart/components/_Layouts/AnchorSlot.tsx
|
8664
8707
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
8665
8708
|
var AnchorSlot = ({ anchor, components, excludeTypes, includeTypes }) => {
|
8666
|
-
const componentsForSlot = (0,
|
8709
|
+
const componentsForSlot = (0, import_react29.useMemo)(() => {
|
8667
8710
|
return components.filter((comp) => {
|
8668
8711
|
const isCorrectAnchor = comp.anchor === anchor;
|
8669
8712
|
const isVisible = comp.visibility_status !== "hidden";
|
@@ -8691,13 +8734,13 @@ var AnchorSlot = ({ anchor, components, excludeTypes, includeTypes }) => {
|
|
8691
8734
|
|
8692
8735
|
// src/smart-cart/components/_Layouts/DoubleColumnLayout.tsx
|
8693
8736
|
var import_clsx11 = __toESM(require("clsx"), 1);
|
8694
|
-
var
|
8737
|
+
var import_react31 = require("react");
|
8695
8738
|
|
8696
8739
|
// src/smart-cart/hooks/useIsScrolled.ts
|
8697
|
-
var
|
8740
|
+
var import_react30 = require("react");
|
8698
8741
|
var useIsScrolled = (scrollElementRef) => {
|
8699
|
-
const [isScrolled, setIsScrolled] = (0,
|
8700
|
-
(0,
|
8742
|
+
const [isScrolled, setIsScrolled] = (0, import_react30.useState)(false);
|
8743
|
+
(0, import_react30.useEffect)(() => {
|
8701
8744
|
const scrollElement = scrollElementRef.current;
|
8702
8745
|
if (!scrollElement) return;
|
8703
8746
|
const handleScroll = () => {
|
@@ -8719,7 +8762,7 @@ var LayoutStyles_default = result21;
|
|
8719
8762
|
// src/smart-cart/components/_Layouts/DoubleColumnLayout.tsx
|
8720
8763
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
8721
8764
|
var DoubleColumnLayout = ({ components, itemCount, layout }) => {
|
8722
|
-
const scrollAreaRef = (0,
|
8765
|
+
const scrollAreaRef = (0, import_react31.useRef)(null);
|
8723
8766
|
const isScrolled = useIsScrolled(scrollAreaRef);
|
8724
8767
|
const layoutClass = layout === "double-right" ? LayoutStyles_default["rebuy-smart-cart-layout__flyout-inner--double-right"] : LayoutStyles_default["rebuy-smart-cart-layout__flyout-inner--double"];
|
8725
8768
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: (0, import_clsx11.default)(LayoutStyles_default["rebuy-smart-cart-layout__flyout-inner"], layoutClass), children: [
|
@@ -8761,10 +8804,10 @@ var DoubleColumnLayout = ({ components, itemCount, layout }) => {
|
|
8761
8804
|
|
8762
8805
|
// src/smart-cart/components/_Layouts/SingleColumnLayout.tsx
|
8763
8806
|
var import_clsx12 = __toESM(require("clsx"), 1);
|
8764
|
-
var
|
8807
|
+
var import_react32 = require("react");
|
8765
8808
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
8766
8809
|
var SingleColumnLayout = ({ components, itemCount }) => {
|
8767
|
-
const scrollAreaRef = (0,
|
8810
|
+
const scrollAreaRef = (0, import_react32.useRef)(null);
|
8768
8811
|
const isScrolled = useIsScrolled(scrollAreaRef);
|
8769
8812
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
8770
8813
|
/* @__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 }) }),
|
@@ -8801,16 +8844,16 @@ var SmartCartContainer_default = result22;
|
|
8801
8844
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
8802
8845
|
var SmartCartContainer = ({ containerId }) => {
|
8803
8846
|
const { config, getItemCount, hideCart, isVisible } = useSmartCart();
|
8804
|
-
const containerRef = (0,
|
8805
|
-
const previousFocusRef = (0,
|
8806
|
-
const components = (0,
|
8807
|
-
const handleClose = (0,
|
8847
|
+
const containerRef = (0, import_react33.useRef)(null);
|
8848
|
+
const previousFocusRef = (0, import_react33.useRef)(null);
|
8849
|
+
const components = (0, import_react33.useMemo)(() => config && Array.isArray(config.components) ? config.components : [], [config]);
|
8850
|
+
const handleClose = (0, import_react33.useCallback)(() => {
|
8808
8851
|
hideCart();
|
8809
8852
|
if (previousFocusRef.current) {
|
8810
8853
|
previousFocusRef.current.focus();
|
8811
8854
|
}
|
8812
8855
|
}, [hideCart]);
|
8813
|
-
(0,
|
8856
|
+
(0, import_react33.useEffect)(() => {
|
8814
8857
|
if (isVisible) {
|
8815
8858
|
previousFocusRef.current = document.activeElement;
|
8816
8859
|
const closeButton = containerRef.current?.querySelector("#rebuy-cart-close");
|
@@ -8819,7 +8862,7 @@ var SmartCartContainer = ({ containerId }) => {
|
|
8819
8862
|
}
|
8820
8863
|
}
|
8821
8864
|
}, [isVisible]);
|
8822
|
-
(0,
|
8865
|
+
(0, import_react33.useEffect)(() => {
|
8823
8866
|
if (isVisible) {
|
8824
8867
|
document.body.classList.add("rebuy-smart-cart-open");
|
8825
8868
|
} else {
|
@@ -8853,7 +8896,7 @@ var SmartCartContainer = ({ containerId }) => {
|
|
8853
8896
|
const defaultTitleId = "rebuy-smart-cart-default-title";
|
8854
8897
|
const titleBarComponent = components.find((c) => c.type === "title_bar");
|
8855
8898
|
const ariaLabelledBy = titleBarComponent ? `rebuy-title-${titleBarComponent.component_id}` : defaultTitleId;
|
8856
|
-
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
8899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_react33.default.Fragment, { children: [
|
8857
8900
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: backgroundClassName, onClick: handleClose }),
|
8858
8901
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
8859
8902
|
"div",
|
@@ -8910,19 +8953,41 @@ var RebuySmartCart = () => {
|
|
8910
8953
|
var import_rebuy3 = require("@rebuy/rebuy");
|
8911
8954
|
var Utilities5 = __toESM(require("@rebuy/rebuy/utilities"), 1);
|
8912
8955
|
var import_hydrogen7 = require("@shopify/hydrogen");
|
8913
|
-
var
|
8956
|
+
var import_react35 = require("react");
|
8957
|
+
|
8958
|
+
// src/context/RebuyWidgetContext.tsx
|
8959
|
+
var import_react34 = require("react");
|
8960
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
8961
|
+
var RebuyWidgetContext = (0, import_react34.createContext)({
|
8962
|
+
dataSource: "",
|
8963
|
+
isHydrogenReact: false,
|
8964
|
+
key: "",
|
8965
|
+
limit: 0,
|
8966
|
+
metadata: {},
|
8967
|
+
options: {},
|
8968
|
+
products: [],
|
8969
|
+
variant: void 0,
|
8970
|
+
variantId: void 0
|
8971
|
+
});
|
8972
|
+
var useRebuyWidget = () => (0, import_react34.useContext)(RebuyWidgetContext);
|
8973
|
+
var RebuyWidgetProvider = ({ children, value }) => {
|
8974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(RebuyWidgetContext.Provider, { value, children });
|
8975
|
+
};
|
8976
|
+
|
8977
|
+
// src/widgetContainer/RebuyWidgetContainer.tsx
|
8978
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
8914
8979
|
var RebuyWidgetContainerBase = ({ children, ...props }) => {
|
8915
8980
|
const { collection, collectionId, dataSource, limit, options, product, productId, variant, variantId } = props;
|
8916
8981
|
const { apiKey, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
|
8917
|
-
const rebuyContext = (0,
|
8918
|
-
const [rebuyApiClient, setRebuyApiClient] = (0,
|
8919
|
-
const [initialized, setInitialized] = (0,
|
8982
|
+
const rebuyContext = (0, import_react35.useContext)(RebuyContext);
|
8983
|
+
const [rebuyApiClient, setRebuyApiClient] = (0, import_react35.useState)(null);
|
8984
|
+
const [initialized, setInitialized] = (0, import_react35.useState)(false);
|
8920
8985
|
const shopifyProductId = product?.id ?? productId ?? null;
|
8921
8986
|
const shopifyVariantId = variant?.id ?? variantId ?? null;
|
8922
8987
|
const shopifyCollectionId = collection?.id ?? collectionId ?? null;
|
8923
|
-
const [products, setProducts] = (0,
|
8924
|
-
const [metadata, setMetadata] = (0,
|
8925
|
-
(0,
|
8988
|
+
const [products, setProducts] = (0, import_react35.useState)([]);
|
8989
|
+
const [metadata, setMetadata] = (0, import_react35.useState)();
|
8990
|
+
(0, import_react35.useEffect)(() => {
|
8926
8991
|
if (!rebuyApiClient && apiKey && configLoadingStatus === "success") {
|
8927
8992
|
const client = new import_rebuy3.RebuyClient(apiKey);
|
8928
8993
|
const currentEndpoint = dataSource || "/api/v1/products/recommended";
|
@@ -8937,14 +9002,14 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
|
|
8937
9002
|
setInitialized(true);
|
8938
9003
|
}
|
8939
9004
|
}, [apiKey, rebuyApiClient, configLoadingStatus, options, rebuyContext, dataSource]);
|
8940
|
-
(0,
|
9005
|
+
(0, import_react35.useEffect)(() => {
|
8941
9006
|
if (rebuyApiClient && rebuyContext?.contextParameters) {
|
8942
9007
|
const currentEndpoint = dataSource || "/api/v1/products/recommended";
|
8943
9008
|
const filteredParams = filterContextForWidgetEndpoints(rebuyContext.contextParameters, currentEndpoint);
|
8944
9009
|
rebuyApiClient.setContextParameters(filteredParams);
|
8945
9010
|
}
|
8946
9011
|
}, [rebuyApiClient, rebuyContext, dataSource]);
|
8947
|
-
const request = (0,
|
9012
|
+
const request = (0, import_react35.useMemo)(() => {
|
8948
9013
|
const req = {
|
8949
9014
|
endpoint: dataSource || "/api/v1/products/recommended",
|
8950
9015
|
params: {}
|
@@ -8964,7 +9029,7 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
|
|
8964
9029
|
}
|
8965
9030
|
return req;
|
8966
9031
|
}, [dataSource, shopifyProductId, shopifyVariantId, shopifyCollectionId, limit]);
|
8967
|
-
(0,
|
9032
|
+
(0, import_react35.useEffect)(() => {
|
8968
9033
|
let isMounted = true;
|
8969
9034
|
if (!rebuyApiClient || !initialized || configLoadingStatus !== "success") return;
|
8970
9035
|
const fetchData = async () => {
|
@@ -8997,23 +9062,30 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
|
|
8997
9062
|
isMounted = false;
|
8998
9063
|
};
|
8999
9064
|
}, [rebuyApiClient, initialized, request, configLoadingStatus]);
|
9000
|
-
const childrenWithProps = (currentProps) => import_react33.default.Children.map(
|
9001
|
-
children,
|
9002
|
-
(child) => import_react33.default.isValidElement(child) ? import_react33.default.cloneElement(child, currentProps) : child
|
9003
|
-
);
|
9004
|
-
const childProps = {
|
9005
|
-
...props,
|
9006
|
-
apiKey,
|
9007
|
-
cacheKey: rebuyConfig?.shop?.cache_key,
|
9008
|
-
isHydrogenReact: rebuyContext?.contextParameters?.isHydrogenReact,
|
9009
|
-
key: product?.id,
|
9010
|
-
metadata,
|
9011
|
-
products
|
9012
|
-
};
|
9013
9065
|
if (configLoadingStatus !== "success" || !rebuyApiClient) {
|
9014
9066
|
return null;
|
9015
9067
|
}
|
9016
|
-
return
|
9068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
9069
|
+
RebuyWidgetProvider,
|
9070
|
+
{
|
9071
|
+
value: {
|
9072
|
+
apiKey: apiKey ?? void 0,
|
9073
|
+
cacheKey: rebuyConfig?.shop?.cache_key,
|
9074
|
+
dataSource: dataSource || "/api/v1/products/recommended",
|
9075
|
+
isHydrogenReact: rebuyContext?.contextParameters?.isHydrogenReact || false,
|
9076
|
+
key: product?.id || "",
|
9077
|
+
limit: limit || 0,
|
9078
|
+
metadata: metadata || {},
|
9079
|
+
options: options || {},
|
9080
|
+
product,
|
9081
|
+
productId,
|
9082
|
+
products,
|
9083
|
+
variant,
|
9084
|
+
variantId
|
9085
|
+
},
|
9086
|
+
children
|
9087
|
+
}
|
9088
|
+
);
|
9017
9089
|
};
|
9018
9090
|
var RebuyWidgetContainer = RebuyWidgetContainerBase;
|
9019
9091
|
|
@@ -9022,37 +9094,38 @@ var result23 = { "container": "RebuyCompleteTheLook_container", "productGrid": "
|
|
9022
9094
|
var RebuyCompleteTheLook_default = result23;
|
9023
9095
|
|
9024
9096
|
// src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.tsx
|
9025
|
-
var
|
9097
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
9026
9098
|
var RebuyCompleteTheLook = (props) => {
|
9027
9099
|
const {
|
9028
9100
|
addToCartBtnText = "Add to cart",
|
9029
9101
|
addToCartCallback,
|
9030
|
-
customTitle = `These pair with
|
9102
|
+
customTitle = `These pair with {product_title}`,
|
9031
9103
|
customTitleLevel = "h2",
|
9032
|
-
customTitleStyle
|
9033
|
-
products = []
|
9104
|
+
customTitleStyle
|
9034
9105
|
} = props;
|
9106
|
+
const { isHydrogenReact, product, products } = useRebuyWidget();
|
9107
|
+
const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
|
9035
9108
|
if (products.length === 0) {
|
9036
9109
|
rebuyDebugLog.log("widget-complete-the-look" /* WIDGET_COMPLETE_THE_LOOK */, "RebuyCompleteTheLook: No products found");
|
9037
9110
|
return null;
|
9038
9111
|
}
|
9039
|
-
return /* @__PURE__ */ (0,
|
9040
|
-
/* @__PURE__ */ (0,
|
9041
|
-
/* @__PURE__ */ (0,
|
9112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("section", { className: RebuyCompleteTheLook_default.container, children: [
|
9113
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
|
9114
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("ul", { className: RebuyCompleteTheLook_default.productGrid, children: products.map((product2) => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("li", { className: RebuyCompleteTheLook_default.productItem, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
9042
9115
|
ProductCard,
|
9043
9116
|
{
|
9044
9117
|
addToCartBtnText,
|
9045
9118
|
addToCartCallback,
|
9046
|
-
isHydrogenReact
|
9047
|
-
product,
|
9119
|
+
isHydrogenReact,
|
9120
|
+
product: product2,
|
9048
9121
|
productCardTitleLevel: getTitleLevel(customTitleLevel, true)
|
9049
9122
|
}
|
9050
|
-
) },
|
9123
|
+
) }, product2.id)) })
|
9051
9124
|
] });
|
9052
9125
|
};
|
9053
9126
|
|
9054
9127
|
// src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
|
9055
|
-
var
|
9128
|
+
var import_react37 = require("react");
|
9056
9129
|
|
9057
9130
|
// src/utils/convertToRebuyProduct.tsx
|
9058
9131
|
var convertToRebuyProduct = (isHydrogenReact, product) => {
|
@@ -9304,19 +9377,19 @@ var convertToRebuyProduct = (isHydrogenReact, product) => {
|
|
9304
9377
|
|
9305
9378
|
// src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx
|
9306
9379
|
var import_hydrogen8 = require("@shopify/hydrogen");
|
9307
|
-
var
|
9380
|
+
var import_react36 = require("react");
|
9308
9381
|
|
9309
9382
|
// src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.module.css
|
9310
9383
|
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" };
|
9311
9384
|
var RebuyDynamicBundleProducts_default = result24;
|
9312
9385
|
|
9313
9386
|
// src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx
|
9314
|
-
var
|
9387
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
9315
9388
|
var BundleImages = ({ products }) => {
|
9316
9389
|
const selected = products.filter((product) => product.selected);
|
9317
|
-
return /* @__PURE__ */ (0,
|
9390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("ul", { className: RebuyDynamicBundleProducts_default.bundleImages, children: products.map((product, index) => {
|
9318
9391
|
const image = product.selectedVariant?.image;
|
9319
|
-
const productImage = image ? /* @__PURE__ */ (0,
|
9392
|
+
const productImage = image ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
9320
9393
|
import_hydrogen8.Image,
|
9321
9394
|
{
|
9322
9395
|
alt: image.altText || `Picture of ${product.title}`,
|
@@ -9331,14 +9404,14 @@ var BundleImages = ({ products }) => {
|
|
9331
9404
|
product.title
|
9332
9405
|
);
|
9333
9406
|
const showDelimiter = selected[0]?.id !== product.id;
|
9334
|
-
return /* @__PURE__ */ (0,
|
9335
|
-
showDelimiter && /* @__PURE__ */ (0,
|
9336
|
-
/* @__PURE__ */ (0,
|
9407
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_react36.Fragment, { children: product.selected && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
|
9408
|
+
showDelimiter && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("li", { className: RebuyDynamicBundleProducts_default.bundleImageDelimiter, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { children: "+" }) }),
|
9409
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("li", { className: "flex items-center", children: product.default ? (
|
9337
9410
|
// Already on product page
|
9338
9411
|
productImage
|
9339
9412
|
) : (
|
9340
9413
|
// Link to product
|
9341
|
-
/* @__PURE__ */ (0,
|
9414
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
9342
9415
|
RebuyLink,
|
9343
9416
|
{
|
9344
9417
|
ariaLabel: `View ${product.title}`,
|
@@ -9353,7 +9426,7 @@ var BundleImages = ({ products }) => {
|
|
9353
9426
|
|
9354
9427
|
// src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx
|
9355
9428
|
var import_hydrogen9 = require("@shopify/hydrogen");
|
9356
|
-
var
|
9429
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
9357
9430
|
var BundlePrice = ({ products }) => {
|
9358
9431
|
const isDisabled = products.filter((product) => product.selected).length < 1;
|
9359
9432
|
const totalBundlePrice = () => {
|
@@ -9390,12 +9463,12 @@ var BundlePrice = ({ products }) => {
|
|
9390
9463
|
const price = totalBundlePrice();
|
9391
9464
|
const compareAtPrice = totalBundleCompareAtPrice();
|
9392
9465
|
const CompareAtPrice = ({ data: compareAtPrice2 }) => {
|
9393
|
-
return compareAtPrice2 && /* @__PURE__ */ (0,
|
9466
|
+
return compareAtPrice2 && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_hydrogen9.Money, { as: "span", className: RebuyDynamicBundleProducts_default.compareAtPrice, data: compareAtPrice2, withoutTrailingZeros: true });
|
9394
9467
|
};
|
9395
|
-
return products.length > 0 && /* @__PURE__ */ (0,
|
9396
|
-
/* @__PURE__ */ (0,
|
9397
|
-
/* @__PURE__ */ (0,
|
9398
|
-
isDiscounted(price, compareAtPrice) && /* @__PURE__ */ (0,
|
9468
|
+
return products.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "flex items-center flex-col", children: !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("p", { className: "flex items-center gap-2 mb-2", children: [
|
9469
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Total Price:" }),
|
9470
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_hydrogen9.Money, { as: "span", data: price, withoutTrailingZeros: true }),
|
9471
|
+
isDiscounted(price, compareAtPrice) && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(CompareAtPrice, { data: compareAtPrice })
|
9399
9472
|
] }) });
|
9400
9473
|
};
|
9401
9474
|
|
@@ -9403,7 +9476,7 @@ var BundlePrice = ({ products }) => {
|
|
9403
9476
|
var import_clsx14 = __toESM(require("clsx"), 1);
|
9404
9477
|
|
9405
9478
|
// src/widgets/RebuyDynamicBundleProducts/Select.tsx
|
9406
|
-
var
|
9479
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
9407
9480
|
var Select = ({ onSelectVariant, product }) => {
|
9408
9481
|
const getOptionsLabel = (product2) => {
|
9409
9482
|
const options = product2.variants.nodes[0].selectedOptions;
|
@@ -9412,30 +9485,30 @@ var Select = ({ onSelectVariant, product }) => {
|
|
9412
9485
|
const useValues = optionsFromKeys.every((key) => ["name", "value"].includes(key));
|
9413
9486
|
return (useValues ? optionsFromValues : optionsFromKeys).join(" / ");
|
9414
9487
|
};
|
9415
|
-
return product && /* @__PURE__ */ (0,
|
9488
|
+
return product && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
9416
9489
|
"select",
|
9417
9490
|
{
|
9418
9491
|
"aria-label": "select variant",
|
9419
9492
|
className: RebuyDynamicBundleProducts_default.select,
|
9420
9493
|
onChange: (e) => onSelectVariant(product, e.target.value),
|
9421
9494
|
value: product.selectedVariant.id,
|
9422
|
-
children: /* @__PURE__ */ (0,
|
9495
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("optgroup", { label: getOptionsLabel(product), children: product.variants.nodes.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("option", { value: id, children: title }, id + "-BundleVariant")) })
|
9423
9496
|
}
|
9424
9497
|
);
|
9425
9498
|
};
|
9426
9499
|
|
9427
9500
|
// src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx
|
9428
|
-
var
|
9501
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
9429
9502
|
var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
|
9430
|
-
return /* @__PURE__ */ (0,
|
9503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("ul", { children: products.map((product, index) => {
|
9431
9504
|
const { availableForSale } = product.selectedVariant;
|
9432
9505
|
const isOutOfStock = !availableForSale;
|
9433
|
-
return /* @__PURE__ */ (0,
|
9506
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
9434
9507
|
"li",
|
9435
9508
|
{
|
9436
9509
|
className: (0, import_clsx14.default)(RebuyDynamicBundleProducts_default.bundleItemRowContainer, !product.selected && RebuyDynamicBundleProducts_default.unselected),
|
9437
|
-
children: /* @__PURE__ */ (0,
|
9438
|
-
/* @__PURE__ */ (0,
|
9510
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemRow, children: [
|
9511
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
9439
9512
|
"input",
|
9440
9513
|
{
|
9441
9514
|
checked: product.selected && availableForSale,
|
@@ -9447,14 +9520,14 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
|
|
9447
9520
|
value: product.id
|
9448
9521
|
}
|
9449
9522
|
),
|
9450
|
-
/* @__PURE__ */ (0,
|
9451
|
-
/* @__PURE__ */ (0,
|
9452
|
-
isOutOfStock && /* @__PURE__ */ (0,
|
9453
|
-
product.default && /* @__PURE__ */ (0,
|
9523
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemInput, children: [
|
9524
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("label", { className: RebuyDynamicBundleProducts_default.bundleItemLabel, htmlFor: `${product.id}-toggle`, children: [
|
9525
|
+
isOutOfStock && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("b", { children: "SOLD OUT" }),
|
9526
|
+
product.default && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("b", { children: "This item:" }),
|
9454
9527
|
product.title,
|
9455
|
-
/* @__PURE__ */ (0,
|
9528
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(RebuyProductPrice, { selectedVariant: product.selectedVariant })
|
9456
9529
|
] }),
|
9457
|
-
product.variants.nodes.length > 1 && /* @__PURE__ */ (0,
|
9530
|
+
product.variants.nodes.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Select, { onSelectVariant, product })
|
9458
9531
|
] })
|
9459
9532
|
] })
|
9460
9533
|
},
|
@@ -9464,20 +9537,19 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
|
|
9464
9537
|
};
|
9465
9538
|
|
9466
9539
|
// src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
|
9467
|
-
var
|
9540
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
9468
9541
|
var RebuyDynamicBundleProducts = (props) => {
|
9469
9542
|
const {
|
9470
9543
|
addToCartBtnText = "Add to cart",
|
9471
9544
|
addToCartCallback,
|
9472
|
-
customTitle = `These pair with
|
9545
|
+
customTitle = `These pair with {product_title}`,
|
9473
9546
|
customTitleLevel = "h2",
|
9474
|
-
customTitleStyle
|
9475
|
-
isHydrogenReact,
|
9476
|
-
product,
|
9477
|
-
products = []
|
9547
|
+
customTitleStyle
|
9478
9548
|
} = props;
|
9479
|
-
const
|
9480
|
-
|
9549
|
+
const { isHydrogenReact, product, products } = useRebuyWidget();
|
9550
|
+
const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
|
9551
|
+
const [bundleProducts, setBundleProducts] = (0, import_react37.useState)([]);
|
9552
|
+
(0, import_react37.useEffect)(() => {
|
9481
9553
|
const mainProduct = convertToRebuyProduct(isHydrogenReact || false, product);
|
9482
9554
|
const formattedProducts = products.map((product2) => {
|
9483
9555
|
return {
|
@@ -9488,14 +9560,14 @@ var RebuyDynamicBundleProducts = (props) => {
|
|
9488
9560
|
});
|
9489
9561
|
setBundleProducts([mainProduct, ...formattedProducts]);
|
9490
9562
|
}, [product, products, isHydrogenReact]);
|
9491
|
-
const onToggleBundleItem = (0,
|
9563
|
+
const onToggleBundleItem = (0, import_react37.useCallback)(
|
9492
9564
|
(product2) => {
|
9493
9565
|
product2.selected = !product2.selected;
|
9494
9566
|
setBundleProducts([...bundleProducts]);
|
9495
9567
|
},
|
9496
9568
|
[bundleProducts]
|
9497
9569
|
);
|
9498
|
-
const onSelectVariant = (0,
|
9570
|
+
const onSelectVariant = (0, import_react37.useCallback)(
|
9499
9571
|
(product2, variant_id) => {
|
9500
9572
|
const variant = product2.variants.nodes.find(({ id }) => id === variant_id);
|
9501
9573
|
if (variant) {
|
@@ -9510,12 +9582,12 @@ var RebuyDynamicBundleProducts = (props) => {
|
|
9510
9582
|
rebuyDebugLog.log("widget-dynamic-bundle-products" /* WIDGET_DYNAMIC_BUNDLE_PRODUCTS */, "RebuyDynamicBundleProducts: No products found");
|
9511
9583
|
return null;
|
9512
9584
|
}
|
9513
|
-
return /* @__PURE__ */ (0,
|
9514
|
-
/* @__PURE__ */ (0,
|
9515
|
-
/* @__PURE__ */ (0,
|
9516
|
-
/* @__PURE__ */ (0,
|
9517
|
-
/* @__PURE__ */ (0,
|
9518
|
-
/* @__PURE__ */ (0,
|
9585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("section", { className: RebuyDynamicBundleProducts_default.container, children: [
|
9586
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
|
9587
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleContainer, children: [
|
9588
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(BundleImages, { products: bundleProducts }),
|
9589
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(BundlePrice, { products: bundleProducts }),
|
9590
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: RebuyDynamicBundleProducts_default.addCartBtnContainer, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
9519
9591
|
AddToCartBtn,
|
9520
9592
|
{
|
9521
9593
|
addToCartBtnText,
|
@@ -9527,7 +9599,7 @@ var RebuyDynamicBundleProducts = (props) => {
|
|
9527
9599
|
})
|
9528
9600
|
}
|
9529
9601
|
) }),
|
9530
|
-
/* @__PURE__ */ (0,
|
9602
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
9531
9603
|
BundleSelection,
|
9532
9604
|
{
|
9533
9605
|
onSelectVariant,
|
@@ -9541,7 +9613,7 @@ var RebuyDynamicBundleProducts = (props) => {
|
|
9541
9613
|
|
9542
9614
|
// src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx
|
9543
9615
|
var import_hydrogen_react3 = require("@shopify/hydrogen-react");
|
9544
|
-
var
|
9616
|
+
var import_react38 = require("react");
|
9545
9617
|
|
9546
9618
|
// src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx
|
9547
9619
|
var import_hydrogen10 = require("@shopify/hydrogen");
|
@@ -9551,7 +9623,7 @@ var result25 = { "container": "RebuyProductAddOns_container", "productAddOnsList
|
|
9551
9623
|
var RebuyProductAddOns_default = result25;
|
9552
9624
|
|
9553
9625
|
// src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx
|
9554
|
-
var
|
9626
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
9555
9627
|
var RebuyProductAddOnCard = ({
|
9556
9628
|
handleChange,
|
9557
9629
|
learnMoreText,
|
@@ -9560,8 +9632,8 @@ var RebuyProductAddOnCard = ({
|
|
9560
9632
|
titleLevel
|
9561
9633
|
}) => {
|
9562
9634
|
const { availableForSale, image } = product.selectedVariant || {};
|
9563
|
-
return /* @__PURE__ */ (0,
|
9564
|
-
/* @__PURE__ */ (0,
|
9635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("label", { className: RebuyProductAddOns_default.addOnCard, htmlFor: product.id, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: RebuyProductAddOns_default.addOnCardContent, children: [
|
9636
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
9565
9637
|
"input",
|
9566
9638
|
{
|
9567
9639
|
checked: Boolean(product.selected),
|
@@ -9574,7 +9646,7 @@ var RebuyProductAddOnCard = ({
|
|
9574
9646
|
value: ""
|
9575
9647
|
}
|
9576
9648
|
),
|
9577
|
-
/* @__PURE__ */ (0,
|
9649
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: RebuyProductAddOns_default.addOnCardContentImage, children: image && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
9578
9650
|
import_hydrogen10.Image,
|
9579
9651
|
{
|
9580
9652
|
alt: image.altText || `Picture of ${product.title}`,
|
@@ -9583,11 +9655,11 @@ var RebuyProductAddOnCard = ({
|
|
9583
9655
|
width: 300
|
9584
9656
|
}
|
9585
9657
|
) }),
|
9586
|
-
/* @__PURE__ */ (0,
|
9587
|
-
!availableForSale && /* @__PURE__ */ (0,
|
9588
|
-
/* @__PURE__ */ (0,
|
9589
|
-
/* @__PURE__ */ (0,
|
9590
|
-
/* @__PURE__ */ (0,
|
9658
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: RebuyProductAddOns_default.addOnCardTextContent, children: [
|
9659
|
+
!availableForSale && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: RebuyProductAddOns_default.addOnCardOutOfStock, children: outOfStockText }),
|
9660
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Title, { level: titleLevel, text: product.title }),
|
9661
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(RebuyProductPrice, { selectedVariant: product.selectedVariant }),
|
9662
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
9591
9663
|
RebuyLink,
|
9592
9664
|
{
|
9593
9665
|
ariaLabel: `View ${product.title}`,
|
@@ -9601,28 +9673,28 @@ var RebuyProductAddOnCard = ({
|
|
9601
9673
|
};
|
9602
9674
|
|
9603
9675
|
// src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx
|
9604
|
-
var
|
9676
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
9605
9677
|
var RebuyProductAddOns = (props) => {
|
9606
9678
|
const {
|
9679
|
+
addToCartBtnText = "Add to cart",
|
9607
9680
|
addToCartCallback,
|
9608
|
-
customTitle = `These pair with
|
9681
|
+
customTitle = `These pair with {product_title}`,
|
9609
9682
|
customTitleLevel = "h2",
|
9610
9683
|
customTitleStyle,
|
9611
9684
|
includeMainProduct = false,
|
9612
|
-
isHydrogenReact,
|
9613
9685
|
learnMoreText = "Learn more",
|
9614
9686
|
outOfStockText = "Out of stock",
|
9615
|
-
product,
|
9616
|
-
products = [],
|
9617
|
-
addToCartBtnText = "Add to cart",
|
9618
9687
|
subtotalText = "Add-ons Subtotal: ",
|
9619
|
-
withProductText = `With
|
9688
|
+
withProductText = `With {product_title}: `
|
9620
9689
|
} = props;
|
9621
|
-
const
|
9622
|
-
const
|
9623
|
-
const
|
9690
|
+
const { isHydrogenReact, product, products } = useRebuyWidget();
|
9691
|
+
const productTitleClean = customTitle.replace("{product_title}", product?.title ?? "");
|
9692
|
+
const withProductTextClean = withProductText.replace("{product_title}", product?.title ?? "");
|
9693
|
+
const [addedItems, setAddedItems] = (0, import_react38.useState)(products);
|
9694
|
+
const [subtotalWithProduct, setSubtotalWithProduct] = (0, import_react38.useState)();
|
9695
|
+
const [subtotalWithOutProduct, setSubtotalWithOutProduct] = (0, import_react38.useState)();
|
9624
9696
|
const convertedProduct = convertToRebuyProduct(isHydrogenReact || false, product);
|
9625
|
-
(0,
|
9697
|
+
(0, import_react38.useEffect)(() => {
|
9626
9698
|
let initialTotal = 0;
|
9627
9699
|
let currencyCode = "USD";
|
9628
9700
|
products.map((product2) => {
|
@@ -9652,7 +9724,7 @@ var RebuyProductAddOns = (props) => {
|
|
9652
9724
|
setAddedItems(products);
|
9653
9725
|
}
|
9654
9726
|
}, [products, product, isHydrogenReact, includeMainProduct]);
|
9655
|
-
const handleChange = (0,
|
9727
|
+
const handleChange = (0, import_react38.useCallback)(
|
9656
9728
|
(event, product2) => {
|
9657
9729
|
const newProducts = [...products];
|
9658
9730
|
const productIndex = newProducts.findIndex((p) => p.id === product2.id);
|
@@ -9671,7 +9743,7 @@ var RebuyProductAddOns = (props) => {
|
|
9671
9743
|
},
|
9672
9744
|
[products]
|
9673
9745
|
);
|
9674
|
-
(0,
|
9746
|
+
(0, import_react38.useEffect)(() => {
|
9675
9747
|
let total = 0;
|
9676
9748
|
let currencyCode = "USD";
|
9677
9749
|
addedItems.forEach((item) => {
|
@@ -9697,9 +9769,9 @@ var RebuyProductAddOns = (props) => {
|
|
9697
9769
|
rebuyDebugLog.log("widget-product-add-ons" /* WIDGET_PRODUCT_ADD_ONS */, "RebuyProductAddOns: No products found");
|
9698
9770
|
return null;
|
9699
9771
|
}
|
9700
|
-
return /* @__PURE__ */ (0,
|
9701
|
-
/* @__PURE__ */ (0,
|
9702
|
-
/* @__PURE__ */ (0,
|
9772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: RebuyProductAddOns_default.container, children: [
|
9773
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitleClean }),
|
9774
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("ul", { className: RebuyProductAddOns_default.productAddOnsList, children: products.map((product2) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
9703
9775
|
RebuyProductAddOnCard,
|
9704
9776
|
{
|
9705
9777
|
handleChange,
|
@@ -9709,16 +9781,16 @@ var RebuyProductAddOns = (props) => {
|
|
9709
9781
|
titleLevel: getTitleLevel(customTitleLevel, true)
|
9710
9782
|
}
|
9711
9783
|
) }, product2.id)) }),
|
9712
|
-
/* @__PURE__ */ (0,
|
9713
|
-
/* @__PURE__ */ (0,
|
9784
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: RebuyProductAddOns_default.productAddOnsFooter, children: [
|
9785
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
|
9714
9786
|
subtotalText,
|
9715
|
-
subtotalWithOutProduct && /* @__PURE__ */ (0,
|
9787
|
+
subtotalWithOutProduct && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_hydrogen_react3.Money, { data: subtotalWithOutProduct, withoutTrailingZeros: true })
|
9716
9788
|
] }),
|
9717
|
-
includeMainProduct && /* @__PURE__ */ (0,
|
9718
|
-
|
9719
|
-
subtotalWithProduct && /* @__PURE__ */ (0,
|
9789
|
+
includeMainProduct && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
|
9790
|
+
withProductTextClean,
|
9791
|
+
subtotalWithProduct && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_hydrogen_react3.Money, { data: subtotalWithProduct, withoutTrailingZeros: true })
|
9720
9792
|
] }),
|
9721
|
-
/* @__PURE__ */ (0,
|
9793
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: RebuyProductAddOns_default.addCartBtnContainer, children: includeMainProduct ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
9722
9794
|
AddToCartBtn,
|
9723
9795
|
{
|
9724
9796
|
addToCartBtnText,
|
@@ -9728,7 +9800,7 @@ var RebuyProductAddOns = (props) => {
|
|
9728
9800
|
moneyData: subtotalWithProduct,
|
9729
9801
|
selectedVariants: addedItems.map((item) => item.selectedVariant)
|
9730
9802
|
}
|
9731
|
-
) : /* @__PURE__ */ (0,
|
9803
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
9732
9804
|
AddToCartBtn,
|
9733
9805
|
{
|
9734
9806
|
addToCartBtnText,
|
@@ -9748,39 +9820,40 @@ var result26 = { "container": "RebuyProductRecommendations_container", "productG
|
|
9748
9820
|
var RebuyProductRecommendations_default = result26;
|
9749
9821
|
|
9750
9822
|
// src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.tsx
|
9751
|
-
var
|
9823
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
9752
9824
|
var RebuyProductRecommendations = (props) => {
|
9753
9825
|
const {
|
9754
9826
|
addToCartBtnText = "Add to cart",
|
9755
9827
|
addToCartCallback,
|
9756
|
-
customTitle = `These pair with
|
9828
|
+
customTitle = `These pair with {product_title}`,
|
9757
9829
|
customTitleLevel = "h2",
|
9758
|
-
customTitleStyle
|
9759
|
-
products = []
|
9830
|
+
customTitleStyle
|
9760
9831
|
} = props;
|
9832
|
+
const { isHydrogenReact, product, products } = useRebuyWidget();
|
9833
|
+
const productTitle = customTitle.replace("{product_title}", product?.title ?? "");
|
9761
9834
|
if (products.length === 0) {
|
9762
9835
|
rebuyDebugLog.log("widget-product-recommendations" /* WIDGET_PRODUCT_RECOMMENDATIONS */, "RebuyProductRecommendations: No products found");
|
9763
9836
|
return null;
|
9764
9837
|
}
|
9765
|
-
return /* @__PURE__ */ (0,
|
9766
|
-
/* @__PURE__ */ (0,
|
9767
|
-
/* @__PURE__ */ (0,
|
9838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("section", { className: RebuyProductRecommendations_default.container, children: [
|
9839
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: productTitle }),
|
9840
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("ul", { className: RebuyProductRecommendations_default.productGrid, children: products.map((product2) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
9768
9841
|
ProductCard,
|
9769
9842
|
{
|
9770
9843
|
addToCartBtnText,
|
9771
9844
|
addToCartCallback,
|
9772
|
-
isHydrogenReact
|
9773
|
-
product,
|
9845
|
+
isHydrogenReact,
|
9846
|
+
product: product2,
|
9774
9847
|
productCardTitleLevel: getTitleLevel(customTitleLevel, true)
|
9775
9848
|
}
|
9776
|
-
) },
|
9849
|
+
) }, product2.id)) })
|
9777
9850
|
] });
|
9778
9851
|
};
|
9779
9852
|
|
9780
9853
|
// src/widgets/RebuyProductViewed/RebuyProductViewed.tsx
|
9781
9854
|
var import_rebuy4 = require("@rebuy/rebuy");
|
9782
9855
|
var Utilities6 = __toESM(require("@rebuy/rebuy/utilities"), 1);
|
9783
|
-
var
|
9856
|
+
var import_react39 = require("react");
|
9784
9857
|
|
9785
9858
|
// src/zustandStores/productViewed.ts
|
9786
9859
|
var import_zustand2 = require("zustand");
|
@@ -9795,12 +9868,12 @@ var useProductViewedStore = (0, import_zustand2.create)((set) => ({
|
|
9795
9868
|
var RebuyProductViewed = ({ ...props }) => {
|
9796
9869
|
const { apiKey: apiKeyFromContext } = useRebuyConfig();
|
9797
9870
|
const { customerId, product, productHandle, productId } = props;
|
9798
|
-
const [event, setEvent] = (0,
|
9799
|
-
const [Rebuy, setRebuy] = (0,
|
9871
|
+
const [event, setEvent] = (0, import_react39.useState)(null);
|
9872
|
+
const [Rebuy, setRebuy] = (0, import_react39.useState)(null);
|
9800
9873
|
const shopifyProductId = product?.id ?? productId ?? null;
|
9801
|
-
const [initialized, setInitialized] = (0,
|
9874
|
+
const [initialized, setInitialized] = (0, import_react39.useState)(false);
|
9802
9875
|
const { setCustomerId, setUuid } = useProductViewedStore();
|
9803
|
-
const request = (0,
|
9876
|
+
const request = (0, import_react39.useMemo)(() => {
|
9804
9877
|
const request2 = {
|
9805
9878
|
parameters: {}
|
9806
9879
|
};
|
@@ -9814,7 +9887,7 @@ var RebuyProductViewed = ({ ...props }) => {
|
|
9814
9887
|
}
|
9815
9888
|
return request2;
|
9816
9889
|
}, [productHandle, shopifyProductId]);
|
9817
|
-
(0,
|
9890
|
+
(0, import_react39.useEffect)(() => {
|
9818
9891
|
const recordView = async () => {
|
9819
9892
|
if (!Rebuy) {
|
9820
9893
|
return;
|
@@ -9850,14 +9923,14 @@ var RebuyProductViewed = ({ ...props }) => {
|
|
9850
9923
|
// src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.tsx
|
9851
9924
|
var import_rebuy5 = require("@rebuy/rebuy");
|
9852
9925
|
var import_hydrogen11 = require("@shopify/hydrogen");
|
9853
|
-
var
|
9926
|
+
var import_react40 = require("react");
|
9854
9927
|
|
9855
9928
|
// src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.module.css
|
9856
9929
|
var result27 = { "rebuy-recently-viewed-products-container": "RebuyRecentlyViewedProducts_rebuy-recently-viewed-products-container", "product-grid": "RebuyRecentlyViewedProducts_product-grid" };
|
9857
9930
|
var RebuyRecentlyViewedProducts_default = result27;
|
9858
9931
|
|
9859
9932
|
// src/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.tsx
|
9860
|
-
var
|
9933
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
9861
9934
|
var RebuyRecentlyViewedProducts = (props) => {
|
9862
9935
|
const {
|
9863
9936
|
addToCartBtnText = "Add to cart",
|
@@ -9871,14 +9944,14 @@ var RebuyRecentlyViewedProducts = (props) => {
|
|
9871
9944
|
} = props;
|
9872
9945
|
const { customerId, uuid } = useProductViewedStore();
|
9873
9946
|
const { apiKey, loadingStatus: configLoadingStatus, rebuyConfig } = useRebuyConfig();
|
9874
|
-
const rebuyContext = (0,
|
9875
|
-
const [rebuyApiClient, setRebuyApiClient] = (0,
|
9876
|
-
const [initialized, setInitialized] = (0,
|
9877
|
-
const [products, setProducts] = (0,
|
9878
|
-
const [metadata, setMetadata] = (0,
|
9947
|
+
const rebuyContext = (0, import_react40.useContext)(RebuyContext);
|
9948
|
+
const [rebuyApiClient, setRebuyApiClient] = (0, import_react40.useState)(null);
|
9949
|
+
const [initialized, setInitialized] = (0, import_react40.useState)(false);
|
9950
|
+
const [products, setProducts] = (0, import_react40.useState)([]);
|
9951
|
+
const [metadata, setMetadata] = (0, import_react40.useState)();
|
9879
9952
|
const rebuyConfigKey = rebuyConfig?.shop?.cache_key;
|
9880
9953
|
const endpoint = customerId && customerId !== "" ? `/api/v1/products/viewed?key=${rebuyConfigKey}&customer_id=${customerId}` : `/api/v1/products/viewed?key=${rebuyConfigKey}&uuid=${uuid}`;
|
9881
|
-
(0,
|
9954
|
+
(0, import_react40.useEffect)(() => {
|
9882
9955
|
if (!rebuyApiClient && apiKey && configLoadingStatus === "success") {
|
9883
9956
|
const client = new import_rebuy5.RebuyClient(apiKey);
|
9884
9957
|
if (rebuyContext?.contextParameters) {
|
@@ -9892,13 +9965,13 @@ var RebuyRecentlyViewedProducts = (props) => {
|
|
9892
9965
|
setInitialized(true);
|
9893
9966
|
}
|
9894
9967
|
}, [apiKey, rebuyApiClient, configLoadingStatus, options, rebuyContext, uuid, endpoint]);
|
9895
|
-
(0,
|
9968
|
+
(0, import_react40.useEffect)(() => {
|
9896
9969
|
if (rebuyApiClient && rebuyContext?.contextParameters) {
|
9897
9970
|
const filteredParams = filterContextForWidgetEndpoints(rebuyContext.contextParameters, endpoint);
|
9898
9971
|
rebuyApiClient.setContextParameters(filteredParams);
|
9899
9972
|
}
|
9900
9973
|
}, [rebuyApiClient, rebuyContext, uuid, endpoint]);
|
9901
|
-
const request = (0,
|
9974
|
+
const request = (0, import_react40.useMemo)(() => {
|
9902
9975
|
const req = {
|
9903
9976
|
endpoint,
|
9904
9977
|
params: {}
|
@@ -9909,7 +9982,7 @@ var RebuyRecentlyViewedProducts = (props) => {
|
|
9909
9982
|
}
|
9910
9983
|
return req;
|
9911
9984
|
}, [limit, uuid, endpoint]);
|
9912
|
-
(0,
|
9985
|
+
(0, import_react40.useEffect)(() => {
|
9913
9986
|
let isMounted = true;
|
9914
9987
|
if (!rebuyApiClient || !initialized || configLoadingStatus !== "success") return;
|
9915
9988
|
const fetchData = async () => {
|
@@ -9946,9 +10019,9 @@ var RebuyRecentlyViewedProducts = (props) => {
|
|
9946
10019
|
rebuyDebugLog.log("widget-recently-viewed-products" /* WIDGET_RECENTLY_VIEWED_PRODUCTS */, "RebuyRecentlyViewedProducts: No products found");
|
9947
10020
|
return null;
|
9948
10021
|
}
|
9949
|
-
return /* @__PURE__ */ (0,
|
9950
|
-
/* @__PURE__ */ (0,
|
9951
|
-
/* @__PURE__ */ (0,
|
10022
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: RebuyRecentlyViewedProducts_default["rebuy-recently-viewed-products-container"], children: [
|
10023
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
|
10024
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("ul", { className: RebuyRecentlyViewedProducts_default["product-grid"], children: products?.map((product) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
9952
10025
|
ProductCard,
|
9953
10026
|
{
|
9954
10027
|
addToCartBtnText,
|