@lime-bundles/react 2.2.0 → 2.3.1
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/dist/index.cjs +115 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +54 -18
- package/dist/index.js.map +1 -1
- package/docs/css-variables.md +6 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -20,53 +20,56 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
BUNDLES_FOR_PRODUCT_QUERY: () =>
|
|
24
|
-
BUNDLE_METAOBJECT_QUERY: () =>
|
|
25
|
-
BundleParseError: () =>
|
|
23
|
+
BUNDLES_FOR_PRODUCT_QUERY: () => import_core11.BUNDLES_FOR_PRODUCT_QUERY,
|
|
24
|
+
BUNDLE_METAOBJECT_QUERY: () => import_core11.BUNDLE_METAOBJECT_QUERY,
|
|
25
|
+
BundleParseError: () => import_core10.BundleParseError,
|
|
26
26
|
FixedBundle: () => FixedBundle,
|
|
27
27
|
MixMatchBundle: () => MixMatchBundle,
|
|
28
|
-
SHOP_CUSTOM_CSS_QUERY: () =>
|
|
29
|
-
StorefrontApiError: () =>
|
|
28
|
+
SHOP_CUSTOM_CSS_QUERY: () => import_core11.SHOP_CUSTOM_CSS_QUERY,
|
|
29
|
+
StorefrontApiError: () => import_core10.StorefrontApiError,
|
|
30
30
|
VolumeBundle: () => VolumeBundle,
|
|
31
|
-
WIDGET_CONFIG_DEFAULTS: () =>
|
|
32
|
-
applyABVariantB: () =>
|
|
33
|
-
applyWidgetConfigVars: () =>
|
|
34
|
-
calculateDiscount: () =>
|
|
35
|
-
calculateTierSavings: () =>
|
|
36
|
-
computeBundleSaleCents: () =>
|
|
37
|
-
computeFixedPricing: () =>
|
|
38
|
-
createStorefrontClient: () =>
|
|
31
|
+
WIDGET_CONFIG_DEFAULTS: () => import_core11.WIDGET_CONFIG_DEFAULTS,
|
|
32
|
+
applyABVariantB: () => import_core11.applyABVariantB,
|
|
33
|
+
applyWidgetConfigVars: () => import_core11.applyWidgetConfigVars,
|
|
34
|
+
calculateDiscount: () => import_core11.calculateDiscount,
|
|
35
|
+
calculateTierSavings: () => import_core11.calculateTierSavings,
|
|
36
|
+
computeBundleSaleCents: () => import_core11.computeBundleSaleCents,
|
|
37
|
+
computeFixedPricing: () => import_core11.computeFixedPricing,
|
|
38
|
+
createStorefrontClient: () => import_core11.createStorefrontClient,
|
|
39
39
|
fetchBundleData: () => fetchBundleData,
|
|
40
|
-
fetchBundlesForProduct: () =>
|
|
40
|
+
fetchBundlesForProduct: () => import_core11.fetchBundlesForProduct,
|
|
41
41
|
fetchShopCustomCss: () => fetchShopCustomCss,
|
|
42
|
-
formatCents: () =>
|
|
43
|
-
formatCountdown: () =>
|
|
44
|
-
formatMoney: () =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
42
|
+
formatCents: () => import_core11.formatCents,
|
|
43
|
+
formatCountdown: () => import_core11.formatCountdown,
|
|
44
|
+
formatMoney: () => import_core11.formatMoney,
|
|
45
|
+
formatUnitPrice: () => import_core11.formatUnitPrice,
|
|
46
|
+
getABTestAssignment: () => import_core11.getABTestAssignment,
|
|
47
|
+
getActiveTier: () => import_core11.getActiveTier,
|
|
48
|
+
hasConsent: () => import_core11.hasConsent,
|
|
49
|
+
injectCustomCss: () => import_core11.injectCustomCss,
|
|
50
|
+
mergeWidgetConfig: () => import_core11.mergeWidgetConfig,
|
|
51
|
+
observeImpression: () => import_core11.observeImpression,
|
|
52
|
+
parseCents: () => import_core11.parseCents,
|
|
53
|
+
parseMetaobjectBundle: () => import_core11.parseMetaobjectBundle,
|
|
54
|
+
parseMetaobjectBundleStrict: () => import_core11.parseMetaobjectBundleStrict,
|
|
55
|
+
percentageDiscountUnit: () => import_core11.percentageDiscountUnit,
|
|
56
|
+
reportAddToCart: () => import_core11.reportAddToCart,
|
|
57
|
+
reportImpression: () => import_core11.reportImpression,
|
|
58
|
+
sanitizeCustomCss: () => import_core11.sanitizeCustomCss,
|
|
59
|
+
setConsent: () => import_core11.setConsent,
|
|
60
|
+
thumbnailRatioVars: () => import_core11.thumbnailRatioVars,
|
|
61
|
+
transformImageUrl: () => import_core11.transformImageUrl,
|
|
60
62
|
useAnalytics: () => useAnalytics,
|
|
61
63
|
useBundleData: () => useBundleData,
|
|
62
64
|
useBundlesForProduct: () => useBundlesForProduct,
|
|
63
|
-
|
|
65
|
+
useWidgetConfigVars: () => useWidgetConfigVars,
|
|
66
|
+
validateQuantity: () => import_core11.validateQuantity
|
|
64
67
|
});
|
|
65
68
|
module.exports = __toCommonJS(index_exports);
|
|
66
69
|
|
|
67
70
|
// src/components/FixedBundle.tsx
|
|
68
|
-
var
|
|
69
|
-
var
|
|
71
|
+
var import_react4 = require("react");
|
|
72
|
+
var import_core6 = require("@lime-bundles/core");
|
|
70
73
|
|
|
71
74
|
// src/hooks/useBundleData.ts
|
|
72
75
|
var import_react = require("react");
|
|
@@ -238,6 +241,25 @@ function useAnalytics(options) {
|
|
|
238
241
|
return { elementRef, trackAddToCart };
|
|
239
242
|
}
|
|
240
243
|
|
|
244
|
+
// src/hooks/useWidgetConfigVars.ts
|
|
245
|
+
var import_react3 = require("react");
|
|
246
|
+
var import_core5 = require("@lime-bundles/core");
|
|
247
|
+
function useWidgetConfigVars(config) {
|
|
248
|
+
const elementRef = (0, import_react3.useRef)(null);
|
|
249
|
+
(0, import_react3.useEffect)(() => {
|
|
250
|
+
if (elementRef.current && config) {
|
|
251
|
+
(0, import_core5.applyWidgetConfigVars)(elementRef.current, config);
|
|
252
|
+
}
|
|
253
|
+
}, [config]);
|
|
254
|
+
return (0, import_react3.useCallback)(
|
|
255
|
+
(el) => {
|
|
256
|
+
elementRef.current = el;
|
|
257
|
+
if (el && config) (0, import_core5.applyWidgetConfigVars)(el, config);
|
|
258
|
+
},
|
|
259
|
+
[config]
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
241
263
|
// src/components/FixedBundle.tsx
|
|
242
264
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
243
265
|
function FixedBundle(props) {
|
|
@@ -263,10 +285,11 @@ function FixedBundle(props) {
|
|
|
263
285
|
bundleType: "fixed",
|
|
264
286
|
enabled: analyticsEnabled !== false
|
|
265
287
|
});
|
|
266
|
-
const [addingToCart, setAddingToCart] = (0,
|
|
267
|
-
const [cartError, setCartError] = (0,
|
|
288
|
+
const [addingToCart, setAddingToCart] = (0, import_react4.useState)(false);
|
|
289
|
+
const [cartError, setCartError] = (0, import_react4.useState)(null);
|
|
268
290
|
const bundle = result.status === "success" && result.bundle.bundleType === "fixed" ? result.bundle : null;
|
|
269
|
-
|
|
291
|
+
const setConfigVarsRef = useWidgetConfigVars(bundle?.widgetConfig);
|
|
292
|
+
(0, import_react4.useEffect)(() => {
|
|
270
293
|
if (result.status === "error") {
|
|
271
294
|
onError?.(result.error);
|
|
272
295
|
return;
|
|
@@ -279,14 +302,14 @@ function FixedBundle(props) {
|
|
|
279
302
|
);
|
|
280
303
|
}
|
|
281
304
|
}, [result, onError]);
|
|
282
|
-
const handleAddToCart = (0,
|
|
305
|
+
const handleAddToCart = (0, import_react4.useCallback)(async () => {
|
|
283
306
|
if (!bundle) return;
|
|
284
307
|
const bundleLines = bundle.products.filter((p) => p.variants.nodes.some((v) => v.availableForSale)).map((p) => {
|
|
285
308
|
const variant = p.variants.nodes.find((v) => v.availableForSale);
|
|
286
309
|
return {
|
|
287
310
|
productId: p.id,
|
|
288
311
|
variant,
|
|
289
|
-
quantity: (0,
|
|
312
|
+
quantity: (0, import_core6.resolveBundleQty)(bundle, p.id, variant.id)
|
|
290
313
|
};
|
|
291
314
|
}).filter((line) => line.quantity > 0);
|
|
292
315
|
if (bundleLines.length === 0) return;
|
|
@@ -304,7 +327,7 @@ function FixedBundle(props) {
|
|
|
304
327
|
await onAddToCart(lines);
|
|
305
328
|
const totalPrice = bundleLines.reduce((sum, line) => {
|
|
306
329
|
const price = parseFloat(line.variant.price.amount);
|
|
307
|
-
const discounted = (0,
|
|
330
|
+
const discounted = (0, import_core6.calculateDiscount)(
|
|
308
331
|
price,
|
|
309
332
|
bundle.discountConfig.discountType,
|
|
310
333
|
bundle.discountConfig.discountValue
|
|
@@ -339,7 +362,10 @@ function FixedBundle(props) {
|
|
|
339
362
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
340
363
|
"div",
|
|
341
364
|
{
|
|
342
|
-
ref:
|
|
365
|
+
ref: (el) => {
|
|
366
|
+
elementRef(el);
|
|
367
|
+
setConfigVarsRef(el);
|
|
368
|
+
},
|
|
343
369
|
className: `lb-bundle lb-bundle--fixed ${className ?? ""}`,
|
|
344
370
|
role: "region",
|
|
345
371
|
"aria-label": bundle.title,
|
|
@@ -348,11 +374,11 @@ function FixedBundle(props) {
|
|
|
348
374
|
bundle.discountLabel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "lb-bundle__discount-badge", children: bundle.discountLabel }),
|
|
349
375
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "lb-bundle__products", children: bundle.products.map((product) => {
|
|
350
376
|
const variant = product.variants.nodes.find((v) => v.availableForSale) ?? product.variants.nodes[0];
|
|
351
|
-
const priceText = variant ? (0,
|
|
377
|
+
const priceText = variant ? (0, import_core6.formatMoney)(variant.price.amount, currency) : (0, import_core6.formatMoney)(
|
|
352
378
|
product.priceRange.minVariantPrice.amount,
|
|
353
379
|
currency
|
|
354
380
|
);
|
|
355
|
-
const unitPriceText = variant ? (0,
|
|
381
|
+
const unitPriceText = variant ? (0, import_core6.formatUnitPrice)(
|
|
356
382
|
variant.unitPrice,
|
|
357
383
|
variant.unitPriceMeasurement,
|
|
358
384
|
currency
|
|
@@ -391,8 +417,8 @@ function FixedBundle(props) {
|
|
|
391
417
|
}
|
|
392
418
|
|
|
393
419
|
// src/components/MixMatchBundle.tsx
|
|
394
|
-
var
|
|
395
|
-
var
|
|
420
|
+
var import_react5 = require("react");
|
|
421
|
+
var import_core7 = require("@lime-bundles/core");
|
|
396
422
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
397
423
|
function MixMatchBundle(props) {
|
|
398
424
|
const {
|
|
@@ -417,13 +443,14 @@ function MixMatchBundle(props) {
|
|
|
417
443
|
bundleType: "mix_match",
|
|
418
444
|
enabled: analyticsEnabled !== false
|
|
419
445
|
});
|
|
420
|
-
const [selections, setSelections] = (0,
|
|
446
|
+
const [selections, setSelections] = (0, import_react5.useState)(
|
|
421
447
|
/* @__PURE__ */ new Map()
|
|
422
448
|
);
|
|
423
|
-
const [addingToCart, setAddingToCart] = (0,
|
|
424
|
-
const [cartError, setCartError] = (0,
|
|
449
|
+
const [addingToCart, setAddingToCart] = (0, import_react5.useState)(false);
|
|
450
|
+
const [cartError, setCartError] = (0, import_react5.useState)(null);
|
|
425
451
|
const bundle = result.status === "success" && result.bundle.bundleType === "mix_match" ? result.bundle : null;
|
|
426
|
-
|
|
452
|
+
const setConfigVarsRef = useWidgetConfigVars(bundle?.widgetConfig);
|
|
453
|
+
(0, import_react5.useEffect)(() => {
|
|
427
454
|
if (result.status === "error") {
|
|
428
455
|
onError?.(result.error);
|
|
429
456
|
return;
|
|
@@ -440,8 +467,8 @@ function MixMatchBundle(props) {
|
|
|
440
467
|
(sum, s) => sum + s.quantity,
|
|
441
468
|
0
|
|
442
469
|
);
|
|
443
|
-
const validation = bundle ? (0,
|
|
444
|
-
const toggleProduct = (0,
|
|
470
|
+
const validation = bundle ? (0, import_core7.validateQuantity)(totalQuantity, bundle.minQuantity, bundle.maxQuantity) : { valid: false, totalQuantity: 0, message: null };
|
|
471
|
+
const toggleProduct = (0, import_react5.useCallback)(
|
|
445
472
|
(productId, variant) => {
|
|
446
473
|
setSelections((prev) => {
|
|
447
474
|
const next = new Map(prev);
|
|
@@ -449,7 +476,7 @@ function MixMatchBundle(props) {
|
|
|
449
476
|
if (next.has(key)) {
|
|
450
477
|
next.delete(key);
|
|
451
478
|
} else {
|
|
452
|
-
const configuredQty = bundle ? (0,
|
|
479
|
+
const configuredQty = bundle ? (0, import_core7.resolveBundleQty)(bundle, productId, variant.id) : 1;
|
|
453
480
|
next.set(key, {
|
|
454
481
|
productId,
|
|
455
482
|
variantId: variant.id,
|
|
@@ -461,7 +488,7 @@ function MixMatchBundle(props) {
|
|
|
461
488
|
},
|
|
462
489
|
[bundle]
|
|
463
490
|
);
|
|
464
|
-
const updateQuantity = (0,
|
|
491
|
+
const updateQuantity = (0, import_react5.useCallback)(
|
|
465
492
|
(productId, variantId, quantity) => {
|
|
466
493
|
setSelections((prev) => {
|
|
467
494
|
const next = new Map(prev);
|
|
@@ -476,7 +503,7 @@ function MixMatchBundle(props) {
|
|
|
476
503
|
},
|
|
477
504
|
[]
|
|
478
505
|
);
|
|
479
|
-
const handleAddToCart = (0,
|
|
506
|
+
const handleAddToCart = (0, import_react5.useCallback)(async () => {
|
|
480
507
|
if (!bundle || !validation.valid) return;
|
|
481
508
|
const lines = Array.from(selections.values()).map((s) => ({
|
|
482
509
|
merchandiseId: s.variantId,
|
|
@@ -532,7 +559,10 @@ function MixMatchBundle(props) {
|
|
|
532
559
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
533
560
|
"div",
|
|
534
561
|
{
|
|
535
|
-
ref:
|
|
562
|
+
ref: (el) => {
|
|
563
|
+
elementRef(el);
|
|
564
|
+
setConfigVarsRef(el);
|
|
565
|
+
},
|
|
536
566
|
className: `lb-bundle lb-bundle--mix-match ${className ?? ""}`,
|
|
537
567
|
role: "region",
|
|
538
568
|
"aria-label": bundle.title,
|
|
@@ -561,9 +591,9 @@ function MixMatchBundle(props) {
|
|
|
561
591
|
),
|
|
562
592
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "lb-bundle__product-info", children: [
|
|
563
593
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "lb-bundle__product-title", children: product.title }),
|
|
564
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "lb-bundle__product-price", children: (0,
|
|
594
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "lb-bundle__product-price", children: (0, import_core7.formatMoney)(defaultVariant.price.amount, currency) }),
|
|
565
595
|
(() => {
|
|
566
|
-
const unitPriceText = (0,
|
|
596
|
+
const unitPriceText = (0, import_core7.formatUnitPrice)(
|
|
567
597
|
defaultVariant.unitPrice,
|
|
568
598
|
defaultVariant.unitPriceMeasurement,
|
|
569
599
|
currency
|
|
@@ -629,8 +659,8 @@ function MixMatchBundle(props) {
|
|
|
629
659
|
}
|
|
630
660
|
|
|
631
661
|
// src/components/VolumeBundle.tsx
|
|
632
|
-
var
|
|
633
|
-
var
|
|
662
|
+
var import_react6 = require("react");
|
|
663
|
+
var import_core8 = require("@lime-bundles/core");
|
|
634
664
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
635
665
|
function VolumeBundle(props) {
|
|
636
666
|
const {
|
|
@@ -655,11 +685,12 @@ function VolumeBundle(props) {
|
|
|
655
685
|
bundleType: "volume",
|
|
656
686
|
enabled: analyticsEnabled !== false
|
|
657
687
|
});
|
|
658
|
-
const [quantity, setQuantity] = (0,
|
|
659
|
-
const [addingToCart, setAddingToCart] = (0,
|
|
660
|
-
const [cartError, setCartError] = (0,
|
|
688
|
+
const [quantity, setQuantity] = (0, import_react6.useState)(1);
|
|
689
|
+
const [addingToCart, setAddingToCart] = (0, import_react6.useState)(false);
|
|
690
|
+
const [cartError, setCartError] = (0, import_react6.useState)(null);
|
|
661
691
|
const bundle = result.status === "success" && result.bundle.bundleType === "volume" ? result.bundle : null;
|
|
662
|
-
|
|
692
|
+
const setConfigVarsRef = useWidgetConfigVars(bundle?.widgetConfig);
|
|
693
|
+
(0, import_react6.useEffect)(() => {
|
|
663
694
|
if (result.status === "error") {
|
|
664
695
|
onError?.(result.error);
|
|
665
696
|
return;
|
|
@@ -675,14 +706,14 @@ function VolumeBundle(props) {
|
|
|
675
706
|
const product = bundle?.products[0];
|
|
676
707
|
const basePrice = product ? parseFloat(product.priceRange.minVariantPrice.amount) : 0;
|
|
677
708
|
const currency = product?.priceRange.minVariantPrice.currencyCode ?? "USD";
|
|
678
|
-
const tierSavings = bundle ? (0,
|
|
709
|
+
const tierSavings = bundle ? (0, import_core8.calculateTierSavings)(
|
|
679
710
|
bundle.volumeTiers,
|
|
680
711
|
basePrice,
|
|
681
712
|
quantity,
|
|
682
713
|
bundle.discountConfig.discountType
|
|
683
714
|
) : [];
|
|
684
|
-
const activeTier = bundle ? (0,
|
|
685
|
-
const handleAddToCart = (0,
|
|
715
|
+
const activeTier = bundle ? (0, import_core8.getActiveTier)(bundle.volumeTiers, quantity) : null;
|
|
716
|
+
const handleAddToCart = (0, import_react6.useCallback)(async () => {
|
|
686
717
|
if (!bundle || !product) return;
|
|
687
718
|
const variant = product.variants.nodes.find((v) => v.availableForSale);
|
|
688
719
|
if (!variant) return;
|
|
@@ -735,7 +766,10 @@ function VolumeBundle(props) {
|
|
|
735
766
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
736
767
|
"div",
|
|
737
768
|
{
|
|
738
|
-
ref:
|
|
769
|
+
ref: (el) => {
|
|
770
|
+
elementRef(el);
|
|
771
|
+
setConfigVarsRef(el);
|
|
772
|
+
},
|
|
739
773
|
className: `lb-bundle lb-bundle--volume ${className ?? ""}`,
|
|
740
774
|
role: "region",
|
|
741
775
|
"aria-label": bundle.title,
|
|
@@ -754,12 +788,12 @@ function VolumeBundle(props) {
|
|
|
754
788
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "lb-bundle__product-info", children: [
|
|
755
789
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "lb-bundle__product-title", children: product.title }),
|
|
756
790
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "lb-bundle__product-price", children: [
|
|
757
|
-
(0,
|
|
791
|
+
(0, import_core8.formatMoney)(basePrice, currency),
|
|
758
792
|
" each"
|
|
759
793
|
] }),
|
|
760
794
|
(() => {
|
|
761
795
|
const variant = product.variants.nodes.find((v) => v.availableForSale) ?? product.variants.nodes[0];
|
|
762
|
-
const unitPriceText = variant ? (0,
|
|
796
|
+
const unitPriceText = variant ? (0, import_core8.formatUnitPrice)(
|
|
763
797
|
variant.unitPrice,
|
|
764
798
|
variant.unitPriceMeasurement,
|
|
765
799
|
currency
|
|
@@ -785,7 +819,7 @@ function VolumeBundle(props) {
|
|
|
785
819
|
"+ items"
|
|
786
820
|
] }),
|
|
787
821
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "lb-bundle__tier-price", role: "cell", children: [
|
|
788
|
-
(0,
|
|
822
|
+
(0, import_core8.formatMoney)(ts.unitPrice, currency),
|
|
789
823
|
" each"
|
|
790
824
|
] }),
|
|
791
825
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "lb-bundle__tier-savings", role: "cell", children: [
|
|
@@ -851,21 +885,21 @@ function VolumeBundle(props) {
|
|
|
851
885
|
}
|
|
852
886
|
|
|
853
887
|
// src/hooks/useBundlesForProduct.ts
|
|
854
|
-
var
|
|
855
|
-
var
|
|
888
|
+
var import_react7 = require("react");
|
|
889
|
+
var import_core9 = require("@lime-bundles/core");
|
|
856
890
|
var INITIAL_STATE2 = {
|
|
857
891
|
status: "loading",
|
|
858
892
|
bundles: null,
|
|
859
893
|
error: null
|
|
860
894
|
};
|
|
861
895
|
function useBundlesForProduct(options) {
|
|
862
|
-
const [state, setState] = (0,
|
|
896
|
+
const [state, setState] = (0, import_react7.useState)(
|
|
863
897
|
INITIAL_STATE2
|
|
864
898
|
);
|
|
865
|
-
(0,
|
|
899
|
+
(0, import_react7.useEffect)(() => {
|
|
866
900
|
const controller = new AbortController();
|
|
867
901
|
setState(INITIAL_STATE2);
|
|
868
|
-
(0,
|
|
902
|
+
(0, import_core9.fetchBundlesForProduct)({
|
|
869
903
|
shopDomain: options.shopDomain,
|
|
870
904
|
storefrontAccessToken: options.storefrontAccessToken,
|
|
871
905
|
productHandle: options.productHandle,
|
|
@@ -888,7 +922,7 @@ function useBundlesForProduct(options) {
|
|
|
888
922
|
signal: controller.signal
|
|
889
923
|
}).then((css) => {
|
|
890
924
|
if (controller.signal.aborted) return;
|
|
891
|
-
(0,
|
|
925
|
+
(0, import_core9.injectCustomCss)(options.shopDomain, css);
|
|
892
926
|
}).catch(() => {
|
|
893
927
|
});
|
|
894
928
|
return () => {
|
|
@@ -904,8 +938,8 @@ function useBundlesForProduct(options) {
|
|
|
904
938
|
}
|
|
905
939
|
|
|
906
940
|
// src/index.ts
|
|
907
|
-
var import_core9 = require("@lime-bundles/core");
|
|
908
941
|
var import_core10 = require("@lime-bundles/core");
|
|
942
|
+
var import_core11 = require("@lime-bundles/core");
|
|
909
943
|
// Annotate the CommonJS export names for ESM import in node:
|
|
910
944
|
0 && (module.exports = {
|
|
911
945
|
BUNDLES_FOR_PRODUCT_QUERY,
|
|
@@ -930,6 +964,7 @@ var import_core10 = require("@lime-bundles/core");
|
|
|
930
964
|
formatCents,
|
|
931
965
|
formatCountdown,
|
|
932
966
|
formatMoney,
|
|
967
|
+
formatUnitPrice,
|
|
933
968
|
getABTestAssignment,
|
|
934
969
|
getActiveTier,
|
|
935
970
|
hasConsent,
|
|
@@ -944,10 +979,12 @@ var import_core10 = require("@lime-bundles/core");
|
|
|
944
979
|
reportImpression,
|
|
945
980
|
sanitizeCustomCss,
|
|
946
981
|
setConsent,
|
|
982
|
+
thumbnailRatioVars,
|
|
947
983
|
transformImageUrl,
|
|
948
984
|
useAnalytics,
|
|
949
985
|
useBundleData,
|
|
950
986
|
useBundlesForProduct,
|
|
987
|
+
useWidgetConfigVars,
|
|
951
988
|
validateQuantity
|
|
952
989
|
});
|
|
953
990
|
//# sourceMappingURL=index.cjs.map
|