@lime-bundles/widget 4.6.1 → 4.6.3
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 +61 -45
- package/dist/index.js +37 -20
- package/dist/lime-bundle.global.js +9 -7
- package/dist/lime-bundle.global.js.map +1 -1
- 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_core7 = require("@lime-bundles/core");
|
|
30
30
|
|
|
31
31
|
// ../render/src/host.ts
|
|
32
32
|
function intlFormatMoney(currencyCode) {
|
|
@@ -537,11 +537,13 @@ function buildWidgetShell(typeClass, opts) {
|
|
|
537
537
|
const countdown = box("div", "lb-bundle-countdown", {
|
|
538
538
|
"data-countdown": ""
|
|
539
539
|
});
|
|
540
|
-
const label2 = box("
|
|
541
|
-
|
|
540
|
+
const label2 = box("div", "lb-bundle-countdown__label");
|
|
541
|
+
const labelText = document.createElement("span");
|
|
542
|
+
labelText.textContent = opts.countdownLabel ?? "Limited time offer";
|
|
543
|
+
label2.appendChild(labelText);
|
|
542
544
|
countdown.appendChild(label2);
|
|
543
545
|
countdown.appendChild(
|
|
544
|
-
box("span", "lb-bundle-
|
|
546
|
+
box("span", "lb-bundle-countdown__timer", {
|
|
545
547
|
"data-countdown-timer": ""
|
|
546
548
|
})
|
|
547
549
|
);
|
|
@@ -761,7 +763,7 @@ var DEFAULT_STRINGS = {
|
|
|
761
763
|
allTypes: "All",
|
|
762
764
|
editSelection: "Edit selection",
|
|
763
765
|
addToCart: "Add to cart",
|
|
764
|
-
bundlePrice: "Bundle
|
|
766
|
+
bundlePrice: "Bundle total",
|
|
765
767
|
save: "Save",
|
|
766
768
|
complete: "Complete",
|
|
767
769
|
ofSelected: "__COUNT__ of __TOTAL__ added",
|
|
@@ -2297,6 +2299,7 @@ function buildSlotCard(item, trans, formatMoney, removable, onRemove, onEdit) {
|
|
|
2297
2299
|
}
|
|
2298
2300
|
|
|
2299
2301
|
// ../render/src/mix-match/slots.ts
|
|
2302
|
+
var import_core3 = require("@lime-bundles/core");
|
|
2300
2303
|
function updateSlotUI(cont, items, reqQty, d, deps) {
|
|
2301
2304
|
const trans = d.translations || {};
|
|
2302
2305
|
const slotsWrap = cont.querySelector("[data-selection-slots]");
|
|
@@ -2329,7 +2332,7 @@ function updateSlotUI(cont, items, reqQty, d, deps) {
|
|
|
2329
2332
|
}
|
|
2330
2333
|
}
|
|
2331
2334
|
}
|
|
2332
|
-
function updatePricing(cont, items, reqQty, d,
|
|
2335
|
+
function updatePricing(cont, items, reqQty, d, paint) {
|
|
2333
2336
|
const pricingSection = cont.querySelector(
|
|
2334
2337
|
"[data-pricing-section]"
|
|
2335
2338
|
);
|
|
@@ -2338,14 +2341,19 @@ function updatePricing(cont, items, reqQty, d, calcDiscount, paint) {
|
|
|
2338
2341
|
return;
|
|
2339
2342
|
}
|
|
2340
2343
|
if (pricingSection) pricingSection.style.display = "";
|
|
2344
|
+
const lines = items.map((item) => ({
|
|
2345
|
+
unitCents: item.price,
|
|
2346
|
+
quantity: item.quantity || 1
|
|
2347
|
+
}));
|
|
2341
2348
|
let totalPrice = 0;
|
|
2342
|
-
for (
|
|
2343
|
-
totalPrice += items[i].price * (items[i].quantity || 1);
|
|
2344
|
-
}
|
|
2349
|
+
for (const line of lines) totalPrice += line.unitCents * line.quantity;
|
|
2345
2350
|
if (totalPrice > 0 && d.discountType) {
|
|
2346
2351
|
paint(
|
|
2347
2352
|
cont,
|
|
2348
|
-
|
|
2353
|
+
(0, import_core3.bundleSaleCents)(lines, {
|
|
2354
|
+
discountType: d.discountType,
|
|
2355
|
+
discountValue: d.discountValue ?? 0
|
|
2356
|
+
}),
|
|
2349
2357
|
totalPrice
|
|
2350
2358
|
);
|
|
2351
2359
|
}
|
|
@@ -2384,9 +2392,6 @@ function updateProgress(cont, overlay, items, reqQty, trans) {
|
|
|
2384
2392
|
}
|
|
2385
2393
|
}
|
|
2386
2394
|
|
|
2387
|
-
// src/renderers/mix-match.ts
|
|
2388
|
-
var import_core3 = require("@lime-bundles/core");
|
|
2389
|
-
|
|
2390
2395
|
// src/renderers/pricing-paint.ts
|
|
2391
2396
|
function updatePricing2(formatMoney) {
|
|
2392
2397
|
return (container, salePrice, comparePrice) => {
|
|
@@ -2761,7 +2766,6 @@ function renderMixMatchBundle(container, bundle, onAddToCart, onCleanup, current
|
|
|
2761
2766
|
discountType: bundle.discountConfig.discountType,
|
|
2762
2767
|
discountValue: bundle.discountConfig.discountValue
|
|
2763
2768
|
},
|
|
2764
|
-
(total, type, value) => (0, import_core3.calculateDiscount)(total, type, value),
|
|
2765
2769
|
updatePricing2(formatMoney)
|
|
2766
2770
|
);
|
|
2767
2771
|
updateProgress(shell.root, modal.overlay, selectedItems, requiredQty, t);
|
|
@@ -3290,6 +3294,9 @@ function renderBogoBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
3290
3294
|
}
|
|
3291
3295
|
|
|
3292
3296
|
// src/renderers/multi-step.ts
|
|
3297
|
+
var import_core6 = require("@lime-bundles/core");
|
|
3298
|
+
|
|
3299
|
+
// ../render/src/multi-step/body.ts
|
|
3293
3300
|
var import_core5 = require("@lime-bundles/core");
|
|
3294
3301
|
|
|
3295
3302
|
// ../render/src/multi-step/i18n.ts
|
|
@@ -3489,7 +3496,7 @@ function updateDoor(deps) {
|
|
|
3489
3496
|
target.parentElement.insertBefore(door, target);
|
|
3490
3497
|
}
|
|
3491
3498
|
}
|
|
3492
|
-
function updatePricing3(deps, data,
|
|
3499
|
+
function updatePricing3(deps, data, paint) {
|
|
3493
3500
|
const { container, steps, selections } = deps;
|
|
3494
3501
|
const pricingSection = container.querySelector(
|
|
3495
3502
|
"[data-pricing-section]"
|
|
@@ -3499,14 +3506,22 @@ function updatePricing3(deps, data, calcDiscount, paint) {
|
|
|
3499
3506
|
return;
|
|
3500
3507
|
}
|
|
3501
3508
|
if (pricingSection) pricingSection.style.display = "";
|
|
3509
|
+
const lines = [];
|
|
3502
3510
|
let totalPrice = 0;
|
|
3503
3511
|
for (const step of selections) {
|
|
3504
|
-
for (const pick of step)
|
|
3512
|
+
for (const pick of step) {
|
|
3513
|
+
const line = { unitCents: pick.price, quantity: pick.quantity || 1 };
|
|
3514
|
+
lines.push(line);
|
|
3515
|
+
totalPrice += line.unitCents * line.quantity;
|
|
3516
|
+
}
|
|
3505
3517
|
}
|
|
3506
3518
|
if (totalPrice > 0 && data.discountType) {
|
|
3507
3519
|
paint(
|
|
3508
3520
|
container,
|
|
3509
|
-
|
|
3521
|
+
(0, import_core5.bundleSaleCents)(lines, {
|
|
3522
|
+
discountType: data.discountType,
|
|
3523
|
+
discountValue: data.discountValue ?? 0
|
|
3524
|
+
}),
|
|
3510
3525
|
totalPrice
|
|
3511
3526
|
);
|
|
3512
3527
|
}
|
|
@@ -4074,7 +4089,7 @@ function renderMultiStepBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
4074
4089
|
variantQuantities: bundle.variantQuantities
|
|
4075
4090
|
};
|
|
4076
4091
|
const pools = steps.map(
|
|
4077
|
-
(_, i) => (0,
|
|
4092
|
+
(_, i) => (0, import_core6.productsForStep)(bundle, i).map((product) => {
|
|
4078
4093
|
const p = adaptProduct(product, bundle.id, {
|
|
4079
4094
|
quantities,
|
|
4080
4095
|
allowedVariantIds: null
|
|
@@ -4219,7 +4234,6 @@ function renderMultiStepBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
4219
4234
|
discountType: bundle.discountConfig.discountType,
|
|
4220
4235
|
discountValue: bundle.discountConfig.discountValue
|
|
4221
4236
|
},
|
|
4222
|
-
(total, type, value) => (0, import_core5.calculateDiscount)(total, type, value),
|
|
4223
4237
|
updatePricing2(formatMoney)
|
|
4224
4238
|
);
|
|
4225
4239
|
updateProgress2(bodyDeps);
|
|
@@ -4288,7 +4302,7 @@ function renderMultiStepBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
4288
4302
|
}
|
|
4289
4303
|
|
|
4290
4304
|
// src/lime-bundle.ts
|
|
4291
|
-
var
|
|
4305
|
+
var import_core8 = require("@lime-bundles/core");
|
|
4292
4306
|
|
|
4293
4307
|
// src/utils/input-mode.ts
|
|
4294
4308
|
var NAV_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -4362,8 +4376,10 @@ var BUNDLE_BASE_CSS = `/* Lime Bundles \u2014 shared base styles for all bundle
|
|
|
4362
4376
|
internally (with the .lb-edge-fade treatment) when content exceeds
|
|
4363
4377
|
this. */
|
|
4364
4378
|
--lb-list-max-height: 360px;
|
|
4365
|
-
/* Depth of the soft fade at a scroll list's clipped edge.
|
|
4366
|
-
|
|
4379
|
+
/* Depth of the soft fade at a scroll list's clipped edge. Sized to dim
|
|
4380
|
+
roughly half of the peeking product row (~90px tall): at 20px shoppers
|
|
4381
|
+
read the cut as the end of the list and missed the products below. */
|
|
4382
|
+
--lb-edge-fade-size: 48px;
|
|
4367
4383
|
/* Derived "small" corner radius for chips and badges \u2014 the low-stock badge,
|
|
4368
4384
|
the volume tier badge, the multi-step count chip. Controls and media
|
|
4369
4385
|
(thumbnails, selects, steppers, buttons) take the full --lb-radius: they
|
|
@@ -7338,13 +7354,13 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7338
7354
|
* no buyer/country/language is set.
|
|
7339
7355
|
*/
|
|
7340
7356
|
wrapQueryForContext(query) {
|
|
7341
|
-
return (0,
|
|
7357
|
+
return (0, import_core7.hasInContext)({
|
|
7342
7358
|
shopDomain: this.shopDomain,
|
|
7343
7359
|
accessToken: this.storefrontToken,
|
|
7344
7360
|
country: this.country,
|
|
7345
7361
|
language: this.language,
|
|
7346
7362
|
buyer: this.buyer
|
|
7347
|
-
}) ? (0,
|
|
7363
|
+
}) ? (0, import_core7.withInContext)(query) : query;
|
|
7348
7364
|
}
|
|
7349
7365
|
/** Buyer resolved once per fetch so the market gate can read the
|
|
7350
7366
|
* company location without invoking a callback resolver twice. */
|
|
@@ -7358,7 +7374,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7358
7374
|
* locations (B2B markets), or a legacy `market-id` match.
|
|
7359
7375
|
*/
|
|
7360
7376
|
isMarketHidden(bundle) {
|
|
7361
|
-
return !(0,
|
|
7377
|
+
return !(0, import_core7.isVisibleToBuyer)(bundle, {
|
|
7362
7378
|
marketId: this.marketId,
|
|
7363
7379
|
countryCode: this.country,
|
|
7364
7380
|
companyLocationId: this.resolvedBuyer?.companyLocationId
|
|
@@ -7380,7 +7396,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7380
7396
|
} catch {
|
|
7381
7397
|
this.resolvedBuyer = void 0;
|
|
7382
7398
|
}
|
|
7383
|
-
const client = (0,
|
|
7399
|
+
const client = (0, import_core7.createStorefrontClient)({
|
|
7384
7400
|
shopDomain: this.shopDomain,
|
|
7385
7401
|
accessToken: this.storefrontToken,
|
|
7386
7402
|
country: this.country,
|
|
@@ -7409,7 +7425,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7409
7425
|
handle
|
|
7410
7426
|
);
|
|
7411
7427
|
}
|
|
7412
|
-
const shopSettingsPromise = client.query(
|
|
7428
|
+
const shopSettingsPromise = client.query(import_core7.SHOP_SETTINGS_QUERY, void 0, {
|
|
7413
7429
|
signal: controller.signal
|
|
7414
7430
|
}).catch(() => null);
|
|
7415
7431
|
await bundlePromise;
|
|
@@ -7422,8 +7438,8 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7422
7438
|
const shopSettings = await shopSettingsPromise;
|
|
7423
7439
|
const customCss = shopSettings?.shop?.customCss?.value;
|
|
7424
7440
|
if (customCss) {
|
|
7425
|
-
(0,
|
|
7426
|
-
const sanitized = (0,
|
|
7441
|
+
(0, import_core7.injectCustomCss)(this.shopDomain, customCss);
|
|
7442
|
+
const sanitized = (0, import_core7.sanitizeCustomCss)(customCss);
|
|
7427
7443
|
if (sanitized.ok) this.shopCustomCss = sanitized.css;
|
|
7428
7444
|
}
|
|
7429
7445
|
this.renderBundles();
|
|
@@ -7438,7 +7454,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7438
7454
|
}
|
|
7439
7455
|
async fetchSingleBundle(client, signal) {
|
|
7440
7456
|
const data = await client.query(
|
|
7441
|
-
this.wrapQueryForContext(
|
|
7457
|
+
this.wrapQueryForContext(import_core7.BUNDLE_METAOBJECT_QUERY),
|
|
7442
7458
|
{ id: this.bundleGid },
|
|
7443
7459
|
{ signal }
|
|
7444
7460
|
);
|
|
@@ -7446,15 +7462,15 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7446
7462
|
this.bundles = [];
|
|
7447
7463
|
return;
|
|
7448
7464
|
}
|
|
7449
|
-
const parsed = (0,
|
|
7465
|
+
const parsed = (0, import_core7.parseMetaobjectBundle)(
|
|
7450
7466
|
data.metaobject.id,
|
|
7451
7467
|
data.metaobject.fields
|
|
7452
7468
|
);
|
|
7453
|
-
this.bundles = parsed && !this.isMarketHidden(parsed) ? [(0,
|
|
7469
|
+
this.bundles = parsed && !this.isMarketHidden(parsed) ? [(0, import_core7.convertBundleToPresentment)(parsed, this.currencyRate)] : [];
|
|
7454
7470
|
}
|
|
7455
7471
|
async fetchProductBundles(client, signal, productHandle) {
|
|
7456
7472
|
const data = await client.query(
|
|
7457
|
-
this.wrapQueryForContext(
|
|
7473
|
+
this.wrapQueryForContext(import_core7.BUNDLES_FOR_PRODUCT_QUERY),
|
|
7458
7474
|
{ handle: productHandle },
|
|
7459
7475
|
{ signal }
|
|
7460
7476
|
);
|
|
@@ -7465,12 +7481,12 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7465
7481
|
const refs = data.product.metafield?.references?.nodes ?? [];
|
|
7466
7482
|
const bundles = [];
|
|
7467
7483
|
for (const ref of refs) {
|
|
7468
|
-
const parsed = (0,
|
|
7484
|
+
const parsed = (0, import_core7.parseMetaobjectBundle)(ref.id, ref.fields);
|
|
7469
7485
|
if (parsed && !this.isMarketHidden(parsed)) {
|
|
7470
|
-
bundles.push((0,
|
|
7486
|
+
bundles.push((0, import_core7.convertBundleToPresentment)(parsed, this.currencyRate));
|
|
7471
7487
|
}
|
|
7472
7488
|
}
|
|
7473
|
-
this.bundles = (0,
|
|
7489
|
+
this.bundles = (0, import_core7.resolveAbTests)(bundles, (0, import_core7.getVisitorId)());
|
|
7474
7490
|
}
|
|
7475
7491
|
/**
|
|
7476
7492
|
* Dispatch add-to-cart with a cancelable event, then — unless a listener
|
|
@@ -7500,7 +7516,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7500
7516
|
*/
|
|
7501
7517
|
async defaultAddToCart(lines) {
|
|
7502
7518
|
if (typeof window === "undefined") return;
|
|
7503
|
-
const client = (0,
|
|
7519
|
+
const client = (0, import_core7.createStorefrontClient)({
|
|
7504
7520
|
shopDomain: this.shopDomain,
|
|
7505
7521
|
accessToken: this.storefrontToken
|
|
7506
7522
|
});
|
|
@@ -7529,7 +7545,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7529
7545
|
}
|
|
7530
7546
|
if (cartId) {
|
|
7531
7547
|
const res = await client.query(
|
|
7532
|
-
|
|
7548
|
+
import_core7.CART_LINES_ADD_MUTATION,
|
|
7533
7549
|
{ cartId, lines }
|
|
7534
7550
|
);
|
|
7535
7551
|
const payload = res.cartLinesAdd;
|
|
@@ -7548,7 +7564,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7548
7564
|
}
|
|
7549
7565
|
if (!checkoutUrl) {
|
|
7550
7566
|
const res = await client.query(
|
|
7551
|
-
|
|
7567
|
+
import_core7.CART_CREATE_MUTATION,
|
|
7552
7568
|
{ input: { lines } }
|
|
7553
7569
|
);
|
|
7554
7570
|
const payload = res.cartCreate;
|
|
@@ -7598,7 +7614,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7598
7614
|
* checkout matches the shopper's current build.
|
|
7599
7615
|
*/
|
|
7600
7616
|
async clearAbandonedBundleLines(client, cartId, dropSavedCart) {
|
|
7601
|
-
const res = await client.query(
|
|
7617
|
+
const res = await client.query(import_core7.CART_LINES_QUERY, {
|
|
7602
7618
|
cartId
|
|
7603
7619
|
});
|
|
7604
7620
|
if (!res.cart) {
|
|
@@ -7610,7 +7626,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7610
7626
|
).map((line) => line.id);
|
|
7611
7627
|
if (abandonedLineIds.length === 0) return cartId;
|
|
7612
7628
|
const removal = await client.query(
|
|
7613
|
-
|
|
7629
|
+
import_core7.CART_LINES_REMOVE_MUTATION,
|
|
7614
7630
|
{ cartId, lineIds: abandonedLineIds }
|
|
7615
7631
|
);
|
|
7616
7632
|
if (removal.cartLinesRemove?.userErrors?.length) {
|
|
@@ -7632,7 +7648,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7632
7648
|
const price = variant ? parseFloat(variant.price.amount) : 0;
|
|
7633
7649
|
return sum + price * line.quantity;
|
|
7634
7650
|
}, 0);
|
|
7635
|
-
(0,
|
|
7651
|
+
(0, import_core7.reportAddToCart)(
|
|
7636
7652
|
{ shopDomain: this.shopDomain, appUrl: this.appUrl },
|
|
7637
7653
|
{
|
|
7638
7654
|
bundleGid: bundle.id,
|
|
@@ -7672,7 +7688,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7672
7688
|
container.setAttribute("data-bundle-type", bundle.bundleType);
|
|
7673
7689
|
container.setAttribute("data-bundle-gid", bundle.id);
|
|
7674
7690
|
if (bundle.endsAt) container.setAttribute("data-ends-at", bundle.endsAt);
|
|
7675
|
-
(0,
|
|
7691
|
+
(0, import_core8.applyWidgetConfigVars)(container, bundle.widgetConfig);
|
|
7676
7692
|
this.renderCleanups.push(trackInputMode(container));
|
|
7677
7693
|
const dispatch = (lines) => this.handleAddToCart(bundle, lines);
|
|
7678
7694
|
const registerCleanup = (fn) => this.renderCleanups.push(fn);
|
|
@@ -7723,8 +7739,8 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7723
7739
|
}
|
|
7724
7740
|
setupImpressionFor(bundle, element) {
|
|
7725
7741
|
if (!this.analyticsEnabled || !this.appUrl) return;
|
|
7726
|
-
const cleanup = (0,
|
|
7727
|
-
(0,
|
|
7742
|
+
const cleanup = (0, import_core7.observeImpression)(element, () => {
|
|
7743
|
+
(0, import_core7.reportImpression)(
|
|
7728
7744
|
{ shopDomain: this.shopDomain, appUrl: this.appUrl },
|
|
7729
7745
|
{
|
|
7730
7746
|
bundleGid: bundle.id,
|
package/dist/index.js
CHANGED
|
@@ -536,11 +536,13 @@ function buildWidgetShell(typeClass, opts) {
|
|
|
536
536
|
const countdown = box("div", "lb-bundle-countdown", {
|
|
537
537
|
"data-countdown": ""
|
|
538
538
|
});
|
|
539
|
-
const label2 = box("
|
|
540
|
-
|
|
539
|
+
const label2 = box("div", "lb-bundle-countdown__label");
|
|
540
|
+
const labelText = document.createElement("span");
|
|
541
|
+
labelText.textContent = opts.countdownLabel ?? "Limited time offer";
|
|
542
|
+
label2.appendChild(labelText);
|
|
541
543
|
countdown.appendChild(label2);
|
|
542
544
|
countdown.appendChild(
|
|
543
|
-
box("span", "lb-bundle-
|
|
545
|
+
box("span", "lb-bundle-countdown__timer", {
|
|
544
546
|
"data-countdown-timer": ""
|
|
545
547
|
})
|
|
546
548
|
);
|
|
@@ -760,7 +762,7 @@ var DEFAULT_STRINGS = {
|
|
|
760
762
|
allTypes: "All",
|
|
761
763
|
editSelection: "Edit selection",
|
|
762
764
|
addToCart: "Add to cart",
|
|
763
|
-
bundlePrice: "Bundle
|
|
765
|
+
bundlePrice: "Bundle total",
|
|
764
766
|
save: "Save",
|
|
765
767
|
complete: "Complete",
|
|
766
768
|
ofSelected: "__COUNT__ of __TOTAL__ added",
|
|
@@ -2296,6 +2298,7 @@ function buildSlotCard(item, trans, formatMoney, removable, onRemove, onEdit) {
|
|
|
2296
2298
|
}
|
|
2297
2299
|
|
|
2298
2300
|
// ../render/src/mix-match/slots.ts
|
|
2301
|
+
import { bundleSaleCents } from "@lime-bundles/core";
|
|
2299
2302
|
function updateSlotUI(cont, items, reqQty, d, deps) {
|
|
2300
2303
|
const trans = d.translations || {};
|
|
2301
2304
|
const slotsWrap = cont.querySelector("[data-selection-slots]");
|
|
@@ -2328,7 +2331,7 @@ function updateSlotUI(cont, items, reqQty, d, deps) {
|
|
|
2328
2331
|
}
|
|
2329
2332
|
}
|
|
2330
2333
|
}
|
|
2331
|
-
function updatePricing(cont, items, reqQty, d,
|
|
2334
|
+
function updatePricing(cont, items, reqQty, d, paint) {
|
|
2332
2335
|
const pricingSection = cont.querySelector(
|
|
2333
2336
|
"[data-pricing-section]"
|
|
2334
2337
|
);
|
|
@@ -2337,14 +2340,19 @@ function updatePricing(cont, items, reqQty, d, calcDiscount, paint) {
|
|
|
2337
2340
|
return;
|
|
2338
2341
|
}
|
|
2339
2342
|
if (pricingSection) pricingSection.style.display = "";
|
|
2343
|
+
const lines = items.map((item) => ({
|
|
2344
|
+
unitCents: item.price,
|
|
2345
|
+
quantity: item.quantity || 1
|
|
2346
|
+
}));
|
|
2340
2347
|
let totalPrice = 0;
|
|
2341
|
-
for (
|
|
2342
|
-
totalPrice += items[i].price * (items[i].quantity || 1);
|
|
2343
|
-
}
|
|
2348
|
+
for (const line of lines) totalPrice += line.unitCents * line.quantity;
|
|
2344
2349
|
if (totalPrice > 0 && d.discountType) {
|
|
2345
2350
|
paint(
|
|
2346
2351
|
cont,
|
|
2347
|
-
|
|
2352
|
+
bundleSaleCents(lines, {
|
|
2353
|
+
discountType: d.discountType,
|
|
2354
|
+
discountValue: d.discountValue ?? 0
|
|
2355
|
+
}),
|
|
2348
2356
|
totalPrice
|
|
2349
2357
|
);
|
|
2350
2358
|
}
|
|
@@ -2383,9 +2391,6 @@ function updateProgress(cont, overlay, items, reqQty, trans) {
|
|
|
2383
2391
|
}
|
|
2384
2392
|
}
|
|
2385
2393
|
|
|
2386
|
-
// src/renderers/mix-match.ts
|
|
2387
|
-
import { calculateDiscount } from "@lime-bundles/core";
|
|
2388
|
-
|
|
2389
2394
|
// src/renderers/pricing-paint.ts
|
|
2390
2395
|
function updatePricing2(formatMoney) {
|
|
2391
2396
|
return (container, salePrice, comparePrice) => {
|
|
@@ -2760,7 +2765,6 @@ function renderMixMatchBundle(container, bundle, onAddToCart, onCleanup, current
|
|
|
2760
2765
|
discountType: bundle.discountConfig.discountType,
|
|
2761
2766
|
discountValue: bundle.discountConfig.discountValue
|
|
2762
2767
|
},
|
|
2763
|
-
(total, type, value) => calculateDiscount(total, type, value),
|
|
2764
2768
|
updatePricing2(formatMoney)
|
|
2765
2769
|
);
|
|
2766
2770
|
updateProgress(shell.root, modal.overlay, selectedItems, requiredQty, t);
|
|
@@ -3297,10 +3301,14 @@ function renderBogoBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
3297
3301
|
|
|
3298
3302
|
// src/renderers/multi-step.ts
|
|
3299
3303
|
import {
|
|
3300
|
-
calculateDiscount as calculateDiscount2,
|
|
3301
3304
|
productsForStep
|
|
3302
3305
|
} from "@lime-bundles/core";
|
|
3303
3306
|
|
|
3307
|
+
// ../render/src/multi-step/body.ts
|
|
3308
|
+
import {
|
|
3309
|
+
bundleSaleCents as bundleSaleCents2
|
|
3310
|
+
} from "@lime-bundles/core";
|
|
3311
|
+
|
|
3304
3312
|
// ../render/src/multi-step/i18n.ts
|
|
3305
3313
|
function stepOfLabel(i, total, t) {
|
|
3306
3314
|
return fill(t.stepOf || "Step __STEP__ of __TOTAL__", {
|
|
@@ -3498,7 +3506,7 @@ function updateDoor(deps) {
|
|
|
3498
3506
|
target.parentElement.insertBefore(door, target);
|
|
3499
3507
|
}
|
|
3500
3508
|
}
|
|
3501
|
-
function updatePricing3(deps, data,
|
|
3509
|
+
function updatePricing3(deps, data, paint) {
|
|
3502
3510
|
const { container, steps, selections } = deps;
|
|
3503
3511
|
const pricingSection = container.querySelector(
|
|
3504
3512
|
"[data-pricing-section]"
|
|
@@ -3508,14 +3516,22 @@ function updatePricing3(deps, data, calcDiscount, paint) {
|
|
|
3508
3516
|
return;
|
|
3509
3517
|
}
|
|
3510
3518
|
if (pricingSection) pricingSection.style.display = "";
|
|
3519
|
+
const lines = [];
|
|
3511
3520
|
let totalPrice = 0;
|
|
3512
3521
|
for (const step of selections) {
|
|
3513
|
-
for (const pick of step)
|
|
3522
|
+
for (const pick of step) {
|
|
3523
|
+
const line = { unitCents: pick.price, quantity: pick.quantity || 1 };
|
|
3524
|
+
lines.push(line);
|
|
3525
|
+
totalPrice += line.unitCents * line.quantity;
|
|
3526
|
+
}
|
|
3514
3527
|
}
|
|
3515
3528
|
if (totalPrice > 0 && data.discountType) {
|
|
3516
3529
|
paint(
|
|
3517
3530
|
container,
|
|
3518
|
-
|
|
3531
|
+
bundleSaleCents2(lines, {
|
|
3532
|
+
discountType: data.discountType,
|
|
3533
|
+
discountValue: data.discountValue ?? 0
|
|
3534
|
+
}),
|
|
3519
3535
|
totalPrice
|
|
3520
3536
|
);
|
|
3521
3537
|
}
|
|
@@ -4228,7 +4244,6 @@ function renderMultiStepBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
4228
4244
|
discountType: bundle.discountConfig.discountType,
|
|
4229
4245
|
discountValue: bundle.discountConfig.discountValue
|
|
4230
4246
|
},
|
|
4231
|
-
(total, type, value) => calculateDiscount2(total, type, value),
|
|
4232
4247
|
updatePricing2(formatMoney)
|
|
4233
4248
|
);
|
|
4234
4249
|
updateProgress2(bodyDeps);
|
|
@@ -4371,8 +4386,10 @@ var BUNDLE_BASE_CSS = `/* Lime Bundles \u2014 shared base styles for all bundle
|
|
|
4371
4386
|
internally (with the .lb-edge-fade treatment) when content exceeds
|
|
4372
4387
|
this. */
|
|
4373
4388
|
--lb-list-max-height: 360px;
|
|
4374
|
-
/* Depth of the soft fade at a scroll list's clipped edge.
|
|
4375
|
-
|
|
4389
|
+
/* Depth of the soft fade at a scroll list's clipped edge. Sized to dim
|
|
4390
|
+
roughly half of the peeking product row (~90px tall): at 20px shoppers
|
|
4391
|
+
read the cut as the end of the list and missed the products below. */
|
|
4392
|
+
--lb-edge-fade-size: 48px;
|
|
4376
4393
|
/* Derived "small" corner radius for chips and badges \u2014 the low-stock badge,
|
|
4377
4394
|
the volume tier badge, the multi-step count chip. Controls and media
|
|
4378
4395
|
(thumbnails, selects, steppers, buttons) take the full --lb-radius: they
|