@lime-bundles/widget 2.5.0 → 2.6.0
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 +160 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +145 -37
- package/dist/index.js.map +1 -1
- package/dist/lime-bundle.global.js +82 -40
- package/dist/lime-bundle.global.js.map +1 -1
- package/docs/css-variables.md +11 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
28
|
// src/lime-bundle.ts
|
|
29
|
-
var
|
|
29
|
+
var import_core8 = require("@lime-bundles/core");
|
|
30
30
|
|
|
31
31
|
// src/renderers/fixed.ts
|
|
32
32
|
var import_core5 = require("@lime-bundles/core");
|
|
@@ -534,9 +534,18 @@ function renderFixedBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
534
534
|
const list = el("div", "lb-fixed__products");
|
|
535
535
|
const rowHandles = [];
|
|
536
536
|
rows.forEach((rowState) => {
|
|
537
|
-
const handle = renderProductRow(
|
|
538
|
-
|
|
539
|
-
|
|
537
|
+
const handle = renderProductRow(
|
|
538
|
+
rowState,
|
|
539
|
+
currency,
|
|
540
|
+
qtyFor,
|
|
541
|
+
{
|
|
542
|
+
enabled: wc.showLowStockBadge,
|
|
543
|
+
threshold: wc.lowStockThreshold
|
|
544
|
+
},
|
|
545
|
+
() => {
|
|
546
|
+
updatePricing();
|
|
547
|
+
}
|
|
548
|
+
);
|
|
540
549
|
rowHandles.push(handle);
|
|
541
550
|
list.appendChild(handle.el);
|
|
542
551
|
});
|
|
@@ -592,7 +601,9 @@ function renderFixedBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
592
601
|
function buildRowState(bundle, product, productIndex) {
|
|
593
602
|
const selectedVariantIds = bundle.selectedVariantIds?.[productIndex] ?? null;
|
|
594
603
|
const merchantScoped = selectedVariantIds && selectedVariantIds.length > 0 ? product.variants.nodes.filter((v) => selectedVariantIds.includes(v.id)) : product.variants.nodes;
|
|
595
|
-
const firstInStock = merchantScoped.find(
|
|
604
|
+
const firstInStock = merchantScoped.find(
|
|
605
|
+
(v) => (0, import_core5.isVariantFulfillable)(v, (0, import_core5.resolveBundleQty)(bundle, product.id, v.id))
|
|
606
|
+
) ?? null;
|
|
596
607
|
const eligibleVariants = merchantScoped;
|
|
597
608
|
const isOos = !firstInStock;
|
|
598
609
|
const selected = firstInStock ?? merchantScoped[0] ?? null;
|
|
@@ -656,7 +667,7 @@ function deriveHeaderBadge(bundle, totalCents, saleCents, currency) {
|
|
|
656
667
|
}
|
|
657
668
|
return `-${(0, import_core2.formatCents)(savings, currency)}`;
|
|
658
669
|
}
|
|
659
|
-
function renderProductRow(state, currency, qtyFor, onVariantChange) {
|
|
670
|
+
function renderProductRow(state, currency, qtyFor, lowStock, onVariantChange) {
|
|
660
671
|
const rowEl = el(
|
|
661
672
|
"div",
|
|
662
673
|
state.isOos ? "lb-bundle-product-row lb-bundle-product-row--oos" : "lb-bundle-product-row",
|
|
@@ -703,6 +714,12 @@ function renderProductRow(state, currency, qtyFor, onVariantChange) {
|
|
|
703
714
|
oosLabel.textContent = "Out of stock";
|
|
704
715
|
info.appendChild(oosLabel);
|
|
705
716
|
} else if (state.selected) {
|
|
717
|
+
const isSinglePinnedVariant = state.eligibleVariants.length === 1 && state.product.variants.nodes.length > 1;
|
|
718
|
+
if (isSinglePinnedVariant) {
|
|
719
|
+
const badge = el("span", "lb-bundle-variant-badge");
|
|
720
|
+
badge.textContent = state.eligibleVariants[0].title;
|
|
721
|
+
info.appendChild(badge);
|
|
722
|
+
}
|
|
706
723
|
const prices = el("span", "lb-bundle-product-prices");
|
|
707
724
|
const compare = el("span", "lb-bundle-product-compare-price", {
|
|
708
725
|
"data-product-compare-price": ""
|
|
@@ -718,6 +735,11 @@ function renderProductRow(state, currency, qtyFor, onVariantChange) {
|
|
|
718
735
|
});
|
|
719
736
|
unitPriceEl.setAttribute("hidden", "");
|
|
720
737
|
info.appendChild(unitPriceEl);
|
|
738
|
+
const lowStockEl = el("span", "lb-bundle-low-stock-badge", {
|
|
739
|
+
"data-low-stock-badge": ""
|
|
740
|
+
});
|
|
741
|
+
lowStockEl.setAttribute("hidden", "");
|
|
742
|
+
info.appendChild(lowStockEl);
|
|
721
743
|
const applyVariantToRow = (variant) => {
|
|
722
744
|
const unit = (0, import_core2.parseCents)(variant.price.amount);
|
|
723
745
|
priceEl.textContent = (0, import_core2.formatCents)(unit, currency);
|
|
@@ -752,6 +774,18 @@ function renderProductRow(state, currency, qtyFor, onVariantChange) {
|
|
|
752
774
|
});
|
|
753
775
|
thumbImg.alt = nextImage.altText ?? state.product.title;
|
|
754
776
|
}
|
|
777
|
+
const required = qtyFor(state.product.id, variant.id);
|
|
778
|
+
if ((0, import_core5.shouldShowLowStockBadge)(
|
|
779
|
+
variant,
|
|
780
|
+
required,
|
|
781
|
+
lowStock.threshold,
|
|
782
|
+
lowStock.enabled
|
|
783
|
+
)) {
|
|
784
|
+
lowStockEl.textContent = `Only ${variant.quantityAvailable} left`;
|
|
785
|
+
lowStockEl.removeAttribute("hidden");
|
|
786
|
+
} else {
|
|
787
|
+
lowStockEl.setAttribute("hidden", "");
|
|
788
|
+
}
|
|
755
789
|
};
|
|
756
790
|
applyVariantToRow(state.selected);
|
|
757
791
|
if (state.eligibleVariants.length > 1) {
|
|
@@ -770,7 +804,7 @@ function renderProductRow(state, currency, qtyFor, onVariantChange) {
|
|
|
770
804
|
});
|
|
771
805
|
};
|
|
772
806
|
const isValueAvailable = (optionIndex, value, selected) => state.eligibleVariants.some((v) => {
|
|
773
|
-
if (!v.
|
|
807
|
+
if (!(0, import_core5.isVariantFulfillable)(v, qtyFor(state.product.id, v.id))) return false;
|
|
774
808
|
if (v.selectedOptions[optionIndex]?.value !== value) return false;
|
|
775
809
|
return v.selectedOptions.every(
|
|
776
810
|
(o, i) => i === optionIndex || o.value === selected[i]
|
|
@@ -834,10 +868,6 @@ function renderProductRow(state, currency, qtyFor, onVariantChange) {
|
|
|
834
868
|
if (state.selected) {
|
|
835
869
|
recomputeDisabled(state.selected.selectedOptions.map((o) => o.value));
|
|
836
870
|
}
|
|
837
|
-
} else if (state.eligibleVariants.length === 1 && state.product.variants.nodes.length > 1) {
|
|
838
|
-
const badge = el("span", "lb-bundle-variant-badge");
|
|
839
|
-
badge.textContent = state.eligibleVariants[0].title;
|
|
840
|
-
info.appendChild(badge);
|
|
841
871
|
}
|
|
842
872
|
}
|
|
843
873
|
rowEl.appendChild(info);
|
|
@@ -1412,7 +1442,9 @@ function renderModal(bundle, eligible, currency, handlers) {
|
|
|
1412
1442
|
list.innerHTML = "";
|
|
1413
1443
|
eligible.forEach((ep) => {
|
|
1414
1444
|
const availableVariants = ep.variants;
|
|
1415
|
-
const firstAvailVariant = ep.variants.find(
|
|
1445
|
+
const firstAvailVariant = ep.variants.find(
|
|
1446
|
+
(v) => (0, import_core6.isVariantFulfillable)(v, (0, import_core6.resolveBundleQty)(bundle, ep.product.id, v.id))
|
|
1447
|
+
) ?? ep.firstAvailableVariant ?? ep.variants[0];
|
|
1416
1448
|
if (!firstAvailVariant) return;
|
|
1417
1449
|
let currentVariant = firstAvailVariant;
|
|
1418
1450
|
const productEl = el(
|
|
@@ -1421,7 +1453,9 @@ function renderModal(bundle, eligible, currency, handlers) {
|
|
|
1421
1453
|
{ "data-product-id": ep.product.id.replace(/^.*\//, "") }
|
|
1422
1454
|
);
|
|
1423
1455
|
const thumb = el("div", "lb-mix-match__modal-product-thumb");
|
|
1424
|
-
const initialThumbVariant = ep.variants.find(
|
|
1456
|
+
const initialThumbVariant = ep.variants.find(
|
|
1457
|
+
(v) => (0, import_core6.isVariantFulfillable)(v, (0, import_core6.resolveBundleQty)(bundle, ep.product.id, v.id))
|
|
1458
|
+
) ?? ep.variants[0] ?? null;
|
|
1425
1459
|
const initialThumbImage = initialThumbVariant?.image ?? ep.product.featuredImage ?? null;
|
|
1426
1460
|
let thumbImg = null;
|
|
1427
1461
|
if (initialThumbImage) {
|
|
@@ -1470,6 +1504,26 @@ function renderModal(bundle, eligible, currency, handlers) {
|
|
|
1470
1504
|
unitPrice.hidden = true;
|
|
1471
1505
|
}
|
|
1472
1506
|
info.appendChild(unitPrice);
|
|
1507
|
+
const lowStockBadge = el("span", "lb-bundle-low-stock-badge", {
|
|
1508
|
+
"data-low-stock-badge": ""
|
|
1509
|
+
});
|
|
1510
|
+
lowStockBadge.hidden = true;
|
|
1511
|
+
info.appendChild(lowStockBadge);
|
|
1512
|
+
const refreshLowStockBadge = (variant) => {
|
|
1513
|
+
const required = (0, import_core6.resolveBundleQty)(bundle, ep.product.id, variant.id);
|
|
1514
|
+
if ((0, import_core6.shouldShowLowStockBadge)(
|
|
1515
|
+
variant,
|
|
1516
|
+
required,
|
|
1517
|
+
bundle.widgetConfig.lowStockThreshold,
|
|
1518
|
+
bundle.widgetConfig.showLowStockBadge
|
|
1519
|
+
)) {
|
|
1520
|
+
lowStockBadge.textContent = `Only ${variant.quantityAvailable} left`;
|
|
1521
|
+
lowStockBadge.hidden = false;
|
|
1522
|
+
} else {
|
|
1523
|
+
lowStockBadge.hidden = true;
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1526
|
+
refreshLowStockBadge(currentVariant);
|
|
1473
1527
|
const row = {
|
|
1474
1528
|
el: productEl,
|
|
1475
1529
|
product: ep.product,
|
|
@@ -1493,7 +1547,7 @@ function renderModal(bundle, eligible, currency, handlers) {
|
|
|
1493
1547
|
});
|
|
1494
1548
|
};
|
|
1495
1549
|
const isValueAvailable = (optionIndex, value, selected) => availableVariants.some((v) => {
|
|
1496
|
-
if (!v.
|
|
1550
|
+
if (!(0, import_core6.isVariantFulfillable)(v, (0, import_core6.resolveBundleQty)(bundle, ep.product.id, v.id))) return false;
|
|
1497
1551
|
if (v.selectedOptions[optionIndex]?.value !== value) return false;
|
|
1498
1552
|
return v.selectedOptions.every(
|
|
1499
1553
|
(o, i) => i === optionIndex || o.value === selected[i]
|
|
@@ -1549,6 +1603,7 @@ function renderModal(bundle, eligible, currency, handlers) {
|
|
|
1549
1603
|
thumbImg.alt = nextImage.altText ?? ep.product.title;
|
|
1550
1604
|
}
|
|
1551
1605
|
recomputeDisabled(next.selectedOptions.map((o) => o.value));
|
|
1606
|
+
refreshLowStockBadge(currentVariant);
|
|
1552
1607
|
rowUpdateCount();
|
|
1553
1608
|
};
|
|
1554
1609
|
const groupsContainer = el("div", "lb-bundle-variant-option-groups");
|
|
@@ -1684,7 +1739,9 @@ function buildEligibleProducts(bundle, oosBehavior) {
|
|
|
1684
1739
|
for (const product of bundle.products) {
|
|
1685
1740
|
if (seen.has(product.id)) continue;
|
|
1686
1741
|
seen.add(product.id);
|
|
1687
|
-
const available = product.variants.nodes.filter(
|
|
1742
|
+
const available = product.variants.nodes.filter(
|
|
1743
|
+
(v) => (0, import_core6.isVariantFulfillable)(v, (0, import_core6.resolveBundleQty)(bundle, product.id, v.id))
|
|
1744
|
+
);
|
|
1688
1745
|
const isOos = available.length === 0;
|
|
1689
1746
|
if (isOos && oosBehavior === "hide") continue;
|
|
1690
1747
|
result.push({
|
|
@@ -1717,10 +1774,14 @@ function sanitizeId(gid) {
|
|
|
1717
1774
|
}
|
|
1718
1775
|
|
|
1719
1776
|
// src/renderers/volume.ts
|
|
1777
|
+
var import_core7 = require("@lime-bundles/core");
|
|
1720
1778
|
function renderVolumeBundle(container, bundle, onAddToCart, onCleanup) {
|
|
1721
1779
|
const wc = bundle.widgetConfig;
|
|
1722
1780
|
const product = bundle.products[0];
|
|
1723
|
-
const
|
|
1781
|
+
const minTierQty = bundle.volumeTiers[0]?.minQuantity ?? 1;
|
|
1782
|
+
const variant = product?.variants.nodes.find(
|
|
1783
|
+
(v) => (0, import_core7.isVariantFulfillable)(v, minTierQty)
|
|
1784
|
+
);
|
|
1724
1785
|
if (!variant && wc.outOfStockBehavior === "hide") return;
|
|
1725
1786
|
const basePriceCents = variant ? (0, import_core2.parseCents)(variant.price.amount) : 0;
|
|
1726
1787
|
const currency = variant?.price.currencyCode ?? "USD";
|
|
@@ -1819,6 +1880,18 @@ function renderVolumeBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
1819
1880
|
}
|
|
1820
1881
|
]);
|
|
1821
1882
|
});
|
|
1883
|
+
if (variant && (0, import_core7.shouldShowLowStockBadge)(
|
|
1884
|
+
variant,
|
|
1885
|
+
minTierQty,
|
|
1886
|
+
wc.lowStockThreshold,
|
|
1887
|
+
wc.showLowStockBadge
|
|
1888
|
+
)) {
|
|
1889
|
+
const lowStock = el("span", "lb-bundle-low-stock-badge", {
|
|
1890
|
+
"data-low-stock-badge": ""
|
|
1891
|
+
});
|
|
1892
|
+
lowStock.textContent = `Only ${variant.quantityAvailable} left`;
|
|
1893
|
+
root.appendChild(lowStock);
|
|
1894
|
+
}
|
|
1822
1895
|
root.appendChild(cta);
|
|
1823
1896
|
root.appendChild(
|
|
1824
1897
|
el("p", "lb-bundle-error", { "data-error": "", "aria-live": "polite" })
|
|
@@ -1972,7 +2045,10 @@ function renderSavingsBar3(resolved, selectedIndex, currency) {
|
|
|
1972
2045
|
}
|
|
1973
2046
|
function renderCta2(bundle, onClick) {
|
|
1974
2047
|
const product = bundle.products[0];
|
|
1975
|
-
const
|
|
2048
|
+
const minTierQty = bundle.volumeTiers[0]?.minQuantity ?? 1;
|
|
2049
|
+
const isAvailable = product?.variants.nodes.some(
|
|
2050
|
+
(v) => (0, import_core7.isVariantFulfillable)(v, minTierQty)
|
|
2051
|
+
);
|
|
1976
2052
|
const label = isAvailable ? bundle.widgetConfig.cta.ctaText || "Add to cart" : "Sold out";
|
|
1977
2053
|
const button = buildCtaButton(label);
|
|
1978
2054
|
if (!isAvailable) button.disabled = true;
|
|
@@ -2014,7 +2090,7 @@ function clamp(n, min, max) {
|
|
|
2014
2090
|
}
|
|
2015
2091
|
|
|
2016
2092
|
// src/lime-bundle.ts
|
|
2017
|
-
var
|
|
2093
|
+
var import_core9 = require("@lime-bundles/core");
|
|
2018
2094
|
|
|
2019
2095
|
// src/utils/input-mode.ts
|
|
2020
2096
|
var NAV_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -2349,15 +2425,19 @@ var BUNDLE_BASE_CSS = `/* Lime Bundles \u2014 shared base styles for all bundle
|
|
|
2349
2425
|
display: none;
|
|
2350
2426
|
}
|
|
2351
2427
|
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2428
|
+
/* Read-only variant text shown below the product title when only one
|
|
2429
|
+
variant is in scope (single-variant product, or merchant pinned a
|
|
2430
|
+
single variant). Same visual treatment as the mix-match filled
|
|
2431
|
+
slot's variant text \u2014 see .lb-mix-match__filled-variant in
|
|
2432
|
+
bundle-mix-match.css. Both share this rule via the comma selector
|
|
2433
|
+
so the storefront UX stays consistent across bundle types. */
|
|
2434
|
+
.lb-bundle-variant-badge,
|
|
2435
|
+
.lb-mix-match__slot--filled .lb-mix-match__filled-variant {
|
|
2436
|
+
display: block;
|
|
2357
2437
|
font-size: 12px;
|
|
2358
|
-
line-height:
|
|
2438
|
+
line-height: 20px;
|
|
2439
|
+
margin-top: 2px;
|
|
2359
2440
|
color: color-mix(in srgb, var(--lb-text) 60%, transparent);
|
|
2360
|
-
margin-top: 8px;
|
|
2361
2441
|
}
|
|
2362
2442
|
|
|
2363
2443
|
/* Per-option variant pickers. Each option's label + select sit inside a
|
|
@@ -2401,10 +2481,10 @@ var BUNDLE_BASE_CSS = `/* Lime Bundles \u2014 shared base styles for all bundle
|
|
|
2401
2481
|
click-to-focus doesn't leave a keyboard-style ring. The modal overlay
|
|
2402
2482
|
gets its own selector because the Liquid path reparents it to body,
|
|
2403
2483
|
outside the widget root. */
|
|
2404
|
-
.using-mouse .lb-bundle-widget :focus,
|
|
2405
|
-
.using-mouse .lb-bundle-widget :focus-visible,
|
|
2406
|
-
.using-mouse .lb-mix-match__modal-overlay :focus,
|
|
2407
|
-
.using-mouse .lb-mix-match__modal-overlay :focus-visible {
|
|
2484
|
+
.using-mouse .lb-bundle-widget :focus:not([aria-checked="true"]),
|
|
2485
|
+
.using-mouse .lb-bundle-widget :focus-visible:not([aria-checked="true"]),
|
|
2486
|
+
.using-mouse .lb-mix-match__modal-overlay :focus:not([aria-checked="true"]),
|
|
2487
|
+
.using-mouse .lb-mix-match__modal-overlay :focus-visible:not([aria-checked="true"]) {
|
|
2408
2488
|
outline: none;
|
|
2409
2489
|
outline-offset: 0;
|
|
2410
2490
|
box-shadow: none;
|
|
@@ -2631,6 +2711,24 @@ var BUNDLE_BASE_CSS = `/* Lime Bundles \u2014 shared base styles for all bundle
|
|
|
2631
2711
|
margin-left: auto;
|
|
2632
2712
|
}
|
|
2633
2713
|
|
|
2714
|
+
/* "Only X left" low-stock badge \u2014 appears alongside product/variant
|
|
2715
|
+
info when ProductVariant.quantityAvailable falls at or below
|
|
2716
|
+
wc.lowStockThreshold. Hidden when quantityAvailable is unknown
|
|
2717
|
+
(Storefront token without read_product_inventory). */
|
|
2718
|
+
.lb-bundle-low-stock-badge {
|
|
2719
|
+
display: inline-flex;
|
|
2720
|
+
align-items: center;
|
|
2721
|
+
gap: 4px;
|
|
2722
|
+
padding: 2px 8px;
|
|
2723
|
+
font-size: 11px;
|
|
2724
|
+
font-weight: 600;
|
|
2725
|
+
line-height: 1.4;
|
|
2726
|
+
color: var(--lb-low-stock-text);
|
|
2727
|
+
background-color: var(--lb-low-stock-bg);
|
|
2728
|
+
border-radius: 4px;
|
|
2729
|
+
white-space: nowrap;
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2634
2732
|
/* A/B test: hide save badge until JS swaps the label (prevents flash of default) */
|
|
2635
2733
|
.lb-ab-pending {
|
|
2636
2734
|
visibility: hidden;
|
|
@@ -2854,12 +2952,9 @@ var BUNDLE_MIX_MATCH_CSS = `/* Lime Bundles \u2014 Mix & Match styles */
|
|
|
2854
2952
|
text-decoration: underline;
|
|
2855
2953
|
}
|
|
2856
2954
|
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
margin-top: 2px;
|
|
2861
|
-
color: color-mix(in srgb, var(--lb-text) 60%, transparent);
|
|
2862
|
-
}
|
|
2955
|
+
/* .lb-mix-match__filled-variant \u2014 styled jointly with
|
|
2956
|
+
.lb-bundle-variant-badge above to keep the variant text consistent
|
|
2957
|
+
across mix-match and fixed bundle widgets. */
|
|
2863
2958
|
|
|
2864
2959
|
.lb-mix-match__filled-price {
|
|
2865
2960
|
/* --lb-product-price-display fallback is the "on" branch; Liquid sets 'none' when merchant disables. */
|
|
@@ -3283,10 +3378,21 @@ var BUNDLE_VOLUME_CSS = `/* Lime Bundles \u2014 Volume / Quantity Breaks styles
|
|
|
3283
3378
|
}
|
|
3284
3379
|
|
|
3285
3380
|
.lb-volume__tier:hover {
|
|
3286
|
-
border-color:
|
|
3381
|
+
border-color: var(--lb-tier-selected-border-color);
|
|
3382
|
+
}
|
|
3383
|
+
|
|
3384
|
+
/* Suppress the UA default focus outline so a freshly-clicked selected
|
|
3385
|
+
tier doesn't briefly show the 1px focus ring on top of (or in place of)
|
|
3386
|
+
the custom selected-state outline below. Keyboard focus is still
|
|
3387
|
+
indicated by the :focus-visible rule. */
|
|
3388
|
+
.lb-volume__tier:focus {
|
|
3389
|
+
outline: none;
|
|
3287
3390
|
}
|
|
3288
3391
|
|
|
3289
|
-
|
|
3392
|
+
/* Keyboard focus indicator \u2014 explicitly excludes the selected tier so
|
|
3393
|
+
the selected-state outline rule below has full ownership of the
|
|
3394
|
+
outline property when both states apply at once. */
|
|
3395
|
+
.lb-volume__tier:focus-visible:not([aria-checked="true"]) {
|
|
3290
3396
|
outline: 2px solid var(--lb-primary-color);
|
|
3291
3397
|
outline-offset: 2px;
|
|
3292
3398
|
}
|
|
@@ -3823,7 +3929,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
3823
3929
|
const controller = new AbortController();
|
|
3824
3930
|
this.abortController = controller;
|
|
3825
3931
|
this.renderLoading();
|
|
3826
|
-
const client = (0,
|
|
3932
|
+
const client = (0, import_core8.createStorefrontClient)({
|
|
3827
3933
|
shopDomain: this.shopDomain,
|
|
3828
3934
|
accessToken: this.storefrontToken
|
|
3829
3935
|
});
|
|
@@ -3848,7 +3954,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
3848
3954
|
handle
|
|
3849
3955
|
);
|
|
3850
3956
|
}
|
|
3851
|
-
const cssPromise = client.query(
|
|
3957
|
+
const cssPromise = client.query(import_core8.SHOP_CUSTOM_CSS_QUERY, void 0, {
|
|
3852
3958
|
signal: controller.signal
|
|
3853
3959
|
}).catch(() => null);
|
|
3854
3960
|
await bundlePromise;
|
|
@@ -3860,8 +3966,8 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
3860
3966
|
}
|
|
3861
3967
|
const css = await cssPromise;
|
|
3862
3968
|
if (css?.shop?.metafield?.value) {
|
|
3863
|
-
(0,
|
|
3864
|
-
const sanitized = (0,
|
|
3969
|
+
(0, import_core8.injectCustomCss)(this.shopDomain, css.shop.metafield.value);
|
|
3970
|
+
const sanitized = (0, import_core8.sanitizeCustomCss)(css.shop.metafield.value);
|
|
3865
3971
|
if (sanitized.ok) this.shopCustomCss = sanitized.css;
|
|
3866
3972
|
}
|
|
3867
3973
|
await this.applyABVariants();
|
|
@@ -3889,14 +3995,14 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
3889
3995
|
this.bundles.map(async (bundle) => {
|
|
3890
3996
|
if (!bundle.abTestId || !bundle.abVariantB) return bundle;
|
|
3891
3997
|
try {
|
|
3892
|
-
const assignment = await (0,
|
|
3998
|
+
const assignment = await (0, import_core8.getABTestAssignment)(
|
|
3893
3999
|
this.appUrl,
|
|
3894
4000
|
this.shopDomain,
|
|
3895
4001
|
bundle.abTestId,
|
|
3896
4002
|
bundle.id
|
|
3897
4003
|
);
|
|
3898
4004
|
if (assignment?.variant === "B") {
|
|
3899
|
-
return (0,
|
|
4005
|
+
return (0, import_core8.applyABVariantB)(bundle);
|
|
3900
4006
|
}
|
|
3901
4007
|
} catch (err) {
|
|
3902
4008
|
console.warn(
|
|
@@ -3911,7 +4017,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
3911
4017
|
}
|
|
3912
4018
|
async fetchSingleBundle(client, signal) {
|
|
3913
4019
|
const data = await client.query(
|
|
3914
|
-
|
|
4020
|
+
import_core8.BUNDLE_METAOBJECT_QUERY,
|
|
3915
4021
|
{ id: this.bundleGid },
|
|
3916
4022
|
{ signal }
|
|
3917
4023
|
);
|
|
@@ -3919,7 +4025,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
3919
4025
|
this.bundles = [];
|
|
3920
4026
|
return;
|
|
3921
4027
|
}
|
|
3922
|
-
const parsed = (0,
|
|
4028
|
+
const parsed = (0, import_core8.parseMetaobjectBundle)(
|
|
3923
4029
|
data.metaobject.id,
|
|
3924
4030
|
data.metaobject.fields
|
|
3925
4031
|
);
|
|
@@ -3927,7 +4033,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
3927
4033
|
}
|
|
3928
4034
|
async fetchProductBundles(client, signal, productHandle) {
|
|
3929
4035
|
const data = await client.query(
|
|
3930
|
-
|
|
4036
|
+
import_core8.BUNDLES_FOR_PRODUCT_QUERY,
|
|
3931
4037
|
{ handle: productHandle },
|
|
3932
4038
|
{ signal }
|
|
3933
4039
|
);
|
|
@@ -3938,7 +4044,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
3938
4044
|
const refs = data.product.metafield?.references?.nodes ?? [];
|
|
3939
4045
|
const bundles = [];
|
|
3940
4046
|
for (const ref of refs) {
|
|
3941
|
-
const parsed = (0,
|
|
4047
|
+
const parsed = (0, import_core8.parseMetaobjectBundle)(ref.id, ref.fields);
|
|
3942
4048
|
if (parsed) bundles.push(parsed);
|
|
3943
4049
|
}
|
|
3944
4050
|
this.bundles = bundles;
|
|
@@ -3971,7 +4077,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
3971
4077
|
*/
|
|
3972
4078
|
async defaultAddToCart(lines) {
|
|
3973
4079
|
if (typeof window === "undefined") return;
|
|
3974
|
-
const client = (0,
|
|
4080
|
+
const client = (0, import_core8.createStorefrontClient)({
|
|
3975
4081
|
shopDomain: this.shopDomain,
|
|
3976
4082
|
accessToken: this.storefrontToken
|
|
3977
4083
|
});
|
|
@@ -3982,7 +4088,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
3982
4088
|
let checkoutUrl = null;
|
|
3983
4089
|
if (existingCartId) {
|
|
3984
4090
|
const res = await client.query(
|
|
3985
|
-
|
|
4091
|
+
import_core8.CART_LINES_ADD_MUTATION,
|
|
3986
4092
|
{ cartId: existingCartId, lines }
|
|
3987
4093
|
);
|
|
3988
4094
|
const payload = res.cartLinesAdd;
|
|
@@ -3994,7 +4100,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
3994
4100
|
}
|
|
3995
4101
|
if (!checkoutUrl) {
|
|
3996
4102
|
const res = await client.query(
|
|
3997
|
-
|
|
4103
|
+
import_core8.CART_CREATE_MUTATION,
|
|
3998
4104
|
{ input: { lines } }
|
|
3999
4105
|
);
|
|
4000
4106
|
const payload = res.cartCreate;
|
|
@@ -4040,7 +4146,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
4040
4146
|
const price = variant ? parseFloat(variant.price.amount) : 0;
|
|
4041
4147
|
return sum + price * line.quantity;
|
|
4042
4148
|
}, 0);
|
|
4043
|
-
(0,
|
|
4149
|
+
(0, import_core8.reportAddToCart)(
|
|
4044
4150
|
{ shopDomain: this.shopDomain, appUrl: this.appUrl },
|
|
4045
4151
|
{
|
|
4046
4152
|
bundleGid: bundle.id,
|
|
@@ -4077,7 +4183,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
4077
4183
|
container.setAttribute("aria-label", bundle.title);
|
|
4078
4184
|
container.setAttribute("data-bundle-type", bundle.bundleType);
|
|
4079
4185
|
container.setAttribute("data-bundle-gid", bundle.id);
|
|
4080
|
-
(0,
|
|
4186
|
+
(0, import_core9.applyWidgetConfigVars)(container, bundle.widgetConfig);
|
|
4081
4187
|
this.renderCleanups.push(trackInputMode(container));
|
|
4082
4188
|
const dispatch = (lines) => this.handleAddToCart(bundle, lines);
|
|
4083
4189
|
const registerCleanup = (fn) => this.renderCleanups.push(fn);
|
|
@@ -4113,8 +4219,8 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
4113
4219
|
}
|
|
4114
4220
|
setupImpressionFor(bundle, element) {
|
|
4115
4221
|
if (!this.analyticsEnabled || !this.appUrl) return;
|
|
4116
|
-
const cleanup = (0,
|
|
4117
|
-
(0,
|
|
4222
|
+
const cleanup = (0, import_core8.observeImpression)(element, () => {
|
|
4223
|
+
(0, import_core8.reportImpression)(
|
|
4118
4224
|
{ shopDomain: this.shopDomain, appUrl: this.appUrl },
|
|
4119
4225
|
{
|
|
4120
4226
|
bundleGid: bundle.id,
|