@lime-bundles/widget 1.0.0 → 2.1.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/README.md +76 -72
- package/dist/index.cjs +2643 -344
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -50
- package/dist/index.d.ts +22 -50
- package/dist/index.js +2654 -352
- package/dist/index.js.map +1 -1
- package/dist/lime-bundle.global.js +1243 -86
- package/dist/lime-bundle.global.js.map +1 -1
- package/docs/README.md +81 -0
- package/docs/css-variables.md +158 -0
- package/docs/hydrogen.md +185 -0
- package/docs/react-nextjs.md +379 -0
- package/docs/web-component.md +282 -0
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -27,358 +27,2565 @@ module.exports = __toCommonJS(index_exports);
|
|
|
27
27
|
// src/lime-bundle.ts
|
|
28
28
|
var import_core4 = require("@lime-bundles/core");
|
|
29
29
|
|
|
30
|
-
// src/renderers/
|
|
30
|
+
// src/renderers/pricing.ts
|
|
31
31
|
var import_core = require("@lime-bundles/core");
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
// src/renderers/countdown.ts
|
|
34
|
+
var import_core2 = require("@lime-bundles/core");
|
|
35
|
+
function renderCountdown(endsAtIso) {
|
|
36
|
+
const parsed = parseIso(endsAtIso);
|
|
37
|
+
if (parsed === null) return null;
|
|
38
|
+
if (parsed <= Date.now()) return null;
|
|
39
|
+
const target = parsed;
|
|
40
|
+
const wrap = document.createElement("div");
|
|
41
|
+
wrap.className = "lb-bundle-countdown";
|
|
42
|
+
wrap.setAttribute("data-countdown", "");
|
|
43
|
+
const labelWrap = document.createElement("div");
|
|
44
|
+
labelWrap.className = "lb-bundle-countdown__label";
|
|
45
|
+
const labelText = document.createElement("span");
|
|
46
|
+
labelText.textContent = "Ends in";
|
|
47
|
+
labelWrap.appendChild(labelText);
|
|
48
|
+
wrap.appendChild(labelWrap);
|
|
49
|
+
const timer = document.createElement("span");
|
|
50
|
+
timer.className = "lb-bundle-countdown__timer";
|
|
51
|
+
timer.setAttribute("data-countdown-timer", "");
|
|
52
|
+
wrap.appendChild(timer);
|
|
53
|
+
let intervalId = null;
|
|
54
|
+
function tick() {
|
|
55
|
+
const msLeft = target - Date.now();
|
|
56
|
+
if (msLeft <= 0) {
|
|
57
|
+
wrap.style.display = "none";
|
|
58
|
+
stop();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
timer.textContent = (0, import_core2.formatCountdown)(msLeft);
|
|
62
|
+
}
|
|
63
|
+
function stop() {
|
|
64
|
+
if (intervalId !== null) {
|
|
65
|
+
clearInterval(intervalId);
|
|
66
|
+
intervalId = null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
tick();
|
|
70
|
+
intervalId = setInterval(tick, 1e3);
|
|
71
|
+
return { el: wrap, stop };
|
|
72
|
+
}
|
|
73
|
+
function parseIso(iso) {
|
|
74
|
+
const t = Date.parse(iso);
|
|
75
|
+
return Number.isFinite(t) ? t : null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/renderers/dom.ts
|
|
79
|
+
function el(tag, className, attrs = {}) {
|
|
80
|
+
const node = document.createElement(tag);
|
|
81
|
+
if (className) node.className = className;
|
|
82
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
83
|
+
node.setAttribute(k, v);
|
|
84
|
+
}
|
|
85
|
+
return node;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/renderers/image.ts
|
|
89
|
+
var import_core3 = require("@lime-bundles/core");
|
|
90
|
+
|
|
91
|
+
// src/renderers/fixed.ts
|
|
92
|
+
var PLACEHOLDER_THUMB_SVG = `
|
|
93
|
+
<svg class="lb-bundle-placeholder-icon" viewBox="0 0 28 28" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
|
|
94
|
+
<rect x="4" y="4" width="20" height="20" rx="3"></rect>
|
|
95
|
+
<line x1="4" y1="20" x2="24" y2="20"></line>
|
|
96
|
+
<circle cx="10" cy="12" r="2"></circle>
|
|
97
|
+
</svg>`;
|
|
98
|
+
function renderFixedBundle(container, bundle, onAddToCart, onCleanup) {
|
|
99
|
+
const wc = bundle.widgetConfig;
|
|
100
|
+
const qtyFor = (productId, variantId) => {
|
|
101
|
+
const vq = bundle.variantQuantities[variantId];
|
|
102
|
+
if (vq !== void 0) return vq;
|
|
103
|
+
return bundle.productQuantities[productId] ?? 1;
|
|
104
|
+
};
|
|
105
|
+
const rows = [];
|
|
106
|
+
let oosCount = 0;
|
|
107
|
+
bundle.products.forEach((product, idx) => {
|
|
108
|
+
const row = buildRowState(bundle, product, idx);
|
|
109
|
+
if (row.qty === 0) return;
|
|
110
|
+
if (row.isOos) {
|
|
111
|
+
oosCount++;
|
|
112
|
+
if (wc.outOfStockBehavior === "hide") return;
|
|
113
|
+
}
|
|
114
|
+
rows.push(row);
|
|
115
|
+
});
|
|
116
|
+
if (rows.length === 0) return;
|
|
33
117
|
const currency = bundle.products[0]?.priceRange.minVariantPrice.currencyCode ?? "USD";
|
|
34
|
-
const
|
|
35
|
-
|
|
118
|
+
const root = el("div", "lb-fixed", {
|
|
119
|
+
"data-discount-type": bundle.discountConfig.discountType,
|
|
120
|
+
"data-discount-value": String(bundle.discountConfig.discountValue)
|
|
121
|
+
});
|
|
122
|
+
const headerHandle = renderHeader(bundle, currency);
|
|
123
|
+
root.appendChild(headerHandle.el);
|
|
124
|
+
if (wc.countdown.showCountdown && bundle.endsAt) {
|
|
125
|
+
const countdown = renderCountdown(bundle.endsAt);
|
|
126
|
+
if (countdown) {
|
|
127
|
+
root.appendChild(countdown.el);
|
|
128
|
+
onCleanup?.(countdown.stop);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const list = el("div", "lb-fixed__products");
|
|
132
|
+
const rowHandles = [];
|
|
133
|
+
rows.forEach((rowState) => {
|
|
134
|
+
const handle = renderProductRow(rowState, currency, qtyFor, () => {
|
|
135
|
+
updatePricing();
|
|
136
|
+
});
|
|
137
|
+
rowHandles.push(handle);
|
|
138
|
+
list.appendChild(handle.el);
|
|
139
|
+
});
|
|
140
|
+
root.appendChild(list);
|
|
141
|
+
root.appendChild(el("div", "lb-bundle-divider"));
|
|
142
|
+
const pricingHandle = renderPricingRow(bundle);
|
|
143
|
+
root.appendChild(pricingHandle.el);
|
|
144
|
+
const savingsBarHandle = wc.savingsBar.visible ? renderSavingsBar() : null;
|
|
145
|
+
if (savingsBarHandle) root.appendChild(savingsBarHandle.el);
|
|
146
|
+
const cta = renderCta(bundle, oosCount, () => {
|
|
147
|
+
const lines = rows.filter((r) => r.selected).map((r) => ({
|
|
148
|
+
merchandiseId: r.selected.id,
|
|
149
|
+
quantity: r.qty,
|
|
150
|
+
attributes: [
|
|
151
|
+
{ key: "_lime_bundle_gid", value: bundle.id },
|
|
152
|
+
{ key: "_lime_bundle_type", value: bundle.bundleType }
|
|
153
|
+
]
|
|
154
|
+
}));
|
|
155
|
+
if (lines.length === 0) return;
|
|
156
|
+
onAddToCart(lines);
|
|
157
|
+
});
|
|
158
|
+
root.appendChild(cta);
|
|
159
|
+
root.appendChild(
|
|
160
|
+
el("p", "lb-bundle-error", { "data-error": "", "aria-live": "polite" })
|
|
161
|
+
);
|
|
162
|
+
root.appendChild(
|
|
163
|
+
el("span", "lb-visually-hidden", {
|
|
164
|
+
"data-status": "",
|
|
165
|
+
"aria-live": "polite"
|
|
166
|
+
})
|
|
167
|
+
);
|
|
168
|
+
container.appendChild(root);
|
|
169
|
+
updatePricing();
|
|
170
|
+
function updatePricing() {
|
|
171
|
+
const totalCents = rows.reduce((sum, r) => {
|
|
172
|
+
if (!r.selected) return sum;
|
|
173
|
+
const unit = (0, import_core.parseCents)(r.selected.price.amount);
|
|
174
|
+
return sum + unit * r.qty;
|
|
175
|
+
}, 0);
|
|
176
|
+
const saleCents = computeSale(totalCents, bundle.discountConfig, rows);
|
|
177
|
+
const savingsCents = Math.max(0, totalCents - saleCents);
|
|
178
|
+
pricingHandle.update({ totalCents, saleCents, savingsCents, currency });
|
|
179
|
+
if (savingsBarHandle) {
|
|
180
|
+
savingsBarHandle.update({ savingsCents, currency });
|
|
181
|
+
}
|
|
182
|
+
headerHandle.refresh(
|
|
183
|
+
deriveHeaderBadge(bundle, totalCents, saleCents, currency)
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function buildRowState(bundle, product, productIndex) {
|
|
188
|
+
const selectedVariantIds = bundle.selectedVariantIds?.[productIndex] ?? null;
|
|
189
|
+
const available = product.variants.nodes.filter(
|
|
190
|
+
(v) => v.availableForSale
|
|
191
|
+
);
|
|
192
|
+
const eligibleVariants = selectedVariantIds && selectedVariantIds.length > 0 ? available.filter((v) => selectedVariantIds.includes(v.id)) : available;
|
|
193
|
+
const isOos = eligibleVariants.length === 0;
|
|
194
|
+
const selected = eligibleVariants[0] ?? null;
|
|
195
|
+
const productQty = bundle.productQuantities[product.id] ?? 1;
|
|
196
|
+
const variantQty = selected ? bundle.variantQuantities[selected.id] : void 0;
|
|
197
|
+
const qty = variantQty ?? productQty;
|
|
198
|
+
return { product, eligibleVariants, selected, qty, isOos };
|
|
199
|
+
}
|
|
200
|
+
function renderHeader(bundle, currency) {
|
|
201
|
+
const wc = bundle.widgetConfig;
|
|
202
|
+
const header = el("div", "lb-bundle-header");
|
|
203
|
+
const content = el("div", "lb-bundle-header__content");
|
|
204
|
+
const title = el("h3", "lb-bundle-title");
|
|
36
205
|
title.textContent = bundle.title;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
206
|
+
content.appendChild(title);
|
|
207
|
+
if (bundle.description) {
|
|
208
|
+
const subtitle = el("p", "lb-bundle-subtitle");
|
|
209
|
+
subtitle.textContent = bundle.description;
|
|
210
|
+
content.appendChild(subtitle);
|
|
211
|
+
}
|
|
212
|
+
header.appendChild(content);
|
|
213
|
+
const badgeEl = el("span", "lb-bundle-header__badge", {
|
|
214
|
+
"data-header-badge": ""
|
|
215
|
+
});
|
|
216
|
+
header.appendChild(badgeEl);
|
|
217
|
+
const initialPricing = (0, import_core.computeFixedPricing)(
|
|
218
|
+
bundle,
|
|
219
|
+
bundle.productQuantities,
|
|
220
|
+
wc.pricing.showSaveBadge
|
|
221
|
+
);
|
|
222
|
+
if (initialPricing.headerBadge) {
|
|
223
|
+
badgeEl.textContent = initialPricing.headerBadge;
|
|
224
|
+
} else {
|
|
225
|
+
badgeEl.style.display = "none";
|
|
226
|
+
}
|
|
227
|
+
void currency;
|
|
228
|
+
return {
|
|
229
|
+
el: header,
|
|
230
|
+
refresh(badgeText) {
|
|
231
|
+
if (!wc.pricing.showSaveBadge) {
|
|
232
|
+
badgeEl.style.display = "none";
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (badgeText) {
|
|
236
|
+
badgeEl.textContent = badgeText;
|
|
237
|
+
badgeEl.style.display = "";
|
|
238
|
+
} else {
|
|
239
|
+
badgeEl.style.display = "none";
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function deriveHeaderBadge(bundle, totalCents, saleCents, currency) {
|
|
245
|
+
if (!bundle.widgetConfig.pricing.showSaveBadge) return "";
|
|
246
|
+
const savings = totalCents - saleCents;
|
|
247
|
+
if (savings <= 0) return "";
|
|
248
|
+
const dc = bundle.discountConfig;
|
|
249
|
+
if (dc.discountType === "percentage" && dc.discountValue > 0) {
|
|
250
|
+
return `-${Math.round(dc.discountValue)}%`;
|
|
251
|
+
}
|
|
252
|
+
if (dc.discountType === "fixed_amount" && dc.discountValue > 0) {
|
|
253
|
+
return `-${(0, import_core.formatCents)(Math.round(dc.discountValue * 100), currency)}`;
|
|
254
|
+
}
|
|
255
|
+
return `-${(0, import_core.formatCents)(savings, currency)}`;
|
|
256
|
+
}
|
|
257
|
+
function renderProductRow(state, currency, qtyFor, onVariantChange) {
|
|
258
|
+
const rowEl = el(
|
|
259
|
+
"div",
|
|
260
|
+
state.isOos ? "lb-bundle-product-row lb-bundle-product-row--oos" : "lb-bundle-product-row",
|
|
261
|
+
{
|
|
262
|
+
"data-product-id": state.product.id.replace(/^.*\//, ""),
|
|
263
|
+
...state.isOos ? { "aria-disabled": "true" } : {}
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
const thumb = el("div", "lb-bundle-thumbnail", { "data-thumbnail": "" });
|
|
267
|
+
if (state.product.featuredImage) {
|
|
268
|
+
const img = document.createElement("img");
|
|
269
|
+
img.src = (0, import_core3.transformImageUrl)(state.product.featuredImage.url, {
|
|
270
|
+
width: import_core3.THUMB_PX,
|
|
271
|
+
height: import_core3.THUMB_PX,
|
|
272
|
+
crop: "center"
|
|
273
|
+
});
|
|
274
|
+
img.alt = state.product.featuredImage.altText ?? state.product.title;
|
|
275
|
+
img.width = import_core3.THUMB_PX;
|
|
276
|
+
img.height = import_core3.THUMB_PX;
|
|
277
|
+
img.loading = "lazy";
|
|
278
|
+
thumb.appendChild(img);
|
|
279
|
+
} else {
|
|
280
|
+
thumb.insertAdjacentHTML("beforeend", PLACEHOLDER_THUMB_SVG);
|
|
281
|
+
}
|
|
282
|
+
let qtyBadgeRef = null;
|
|
283
|
+
if (!state.isOos) {
|
|
284
|
+
qtyBadgeRef = el("span", "lb-bundle-qty-badge", {
|
|
285
|
+
"data-qty-badge": ""
|
|
286
|
+
});
|
|
287
|
+
qtyBadgeRef.textContent = String(state.qty);
|
|
288
|
+
thumb.appendChild(qtyBadgeRef);
|
|
289
|
+
}
|
|
290
|
+
rowEl.appendChild(thumb);
|
|
291
|
+
const info = el("div", "lb-bundle-product-info");
|
|
292
|
+
const name = document.createElement("a");
|
|
293
|
+
name.className = "lb-bundle-product-name";
|
|
294
|
+
name.href = `/products/${state.product.handle}`;
|
|
295
|
+
name.textContent = state.product.title;
|
|
296
|
+
info.appendChild(name);
|
|
297
|
+
if (state.isOos) {
|
|
298
|
+
const oosLabel = el("span", "lb-bundle-oos-label");
|
|
299
|
+
oosLabel.textContent = "Out of stock";
|
|
300
|
+
info.appendChild(oosLabel);
|
|
301
|
+
} else if (state.selected) {
|
|
302
|
+
const prices = el("span", "lb-bundle-product-prices");
|
|
303
|
+
const compare = el("span", "lb-bundle-product-compare-price", {
|
|
304
|
+
"data-product-compare-price": ""
|
|
305
|
+
});
|
|
306
|
+
const priceEl = el("span", "lb-bundle-product-price", {
|
|
307
|
+
"data-product-price": ""
|
|
308
|
+
});
|
|
309
|
+
prices.appendChild(compare);
|
|
310
|
+
prices.appendChild(priceEl);
|
|
311
|
+
info.appendChild(prices);
|
|
312
|
+
const applyVariantToRow = (variant) => {
|
|
313
|
+
const unit = (0, import_core.parseCents)(variant.price.amount);
|
|
314
|
+
priceEl.textContent = (0, import_core.formatCents)(unit, currency);
|
|
315
|
+
if (variant.compareAtPrice) {
|
|
316
|
+
const cmp = (0, import_core.parseCents)(variant.compareAtPrice.amount);
|
|
317
|
+
if (cmp > unit) {
|
|
318
|
+
compare.textContent = (0, import_core.formatCents)(cmp, currency);
|
|
319
|
+
compare.removeAttribute("hidden");
|
|
320
|
+
} else {
|
|
321
|
+
compare.setAttribute("hidden", "");
|
|
322
|
+
}
|
|
323
|
+
} else {
|
|
324
|
+
compare.setAttribute("hidden", "");
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
applyVariantToRow(state.selected);
|
|
328
|
+
if (state.eligibleVariants.length > 1) {
|
|
329
|
+
const select = document.createElement("select");
|
|
330
|
+
select.className = "lb-bundle-variant-select";
|
|
331
|
+
select.setAttribute("data-variant-select", "");
|
|
332
|
+
select.setAttribute(
|
|
333
|
+
"aria-label",
|
|
334
|
+
`Select variant for ${state.product.title}`
|
|
335
|
+
);
|
|
336
|
+
state.eligibleVariants.forEach((variant) => {
|
|
337
|
+
const opt = document.createElement("option");
|
|
338
|
+
opt.value = variant.id;
|
|
339
|
+
opt.textContent = variant.title;
|
|
340
|
+
if (variant.id === state.selected?.id) opt.selected = true;
|
|
341
|
+
select.appendChild(opt);
|
|
342
|
+
});
|
|
343
|
+
select.addEventListener("change", () => {
|
|
344
|
+
const variant = state.eligibleVariants.find(
|
|
345
|
+
(v) => v.id === select.value
|
|
346
|
+
);
|
|
347
|
+
if (!variant) return;
|
|
348
|
+
state.selected = variant;
|
|
349
|
+
state.qty = qtyFor(state.product.id, variant.id);
|
|
350
|
+
if (qtyBadgeRef) qtyBadgeRef.textContent = String(state.qty);
|
|
351
|
+
applyVariantToRow(variant);
|
|
352
|
+
onVariantChange();
|
|
353
|
+
});
|
|
354
|
+
info.appendChild(select);
|
|
355
|
+
} else if (state.eligibleVariants.length === 1 && state.product.variants.nodes.length > 1) {
|
|
356
|
+
const badge = el("span", "lb-bundle-variant-badge");
|
|
357
|
+
badge.textContent = state.eligibleVariants[0].title;
|
|
358
|
+
info.appendChild(badge);
|
|
359
|
+
}
|
|
67
360
|
}
|
|
68
|
-
|
|
361
|
+
rowEl.appendChild(info);
|
|
362
|
+
return { el: rowEl, state };
|
|
363
|
+
}
|
|
364
|
+
function renderPricingRow(bundle) {
|
|
365
|
+
const row = el("div", "lb-bundle-pricing");
|
|
366
|
+
const label = el("span", "lb-bundle-pricing__label");
|
|
367
|
+
label.textContent = "Bundle price";
|
|
368
|
+
row.appendChild(label);
|
|
369
|
+
const prices = el("span", "lb-bundle-pricing__prices");
|
|
370
|
+
const compare = el("span", "lb-bundle-compare-price", {
|
|
371
|
+
"data-compare-price": ""
|
|
372
|
+
});
|
|
373
|
+
compare.style.display = "none";
|
|
374
|
+
prices.appendChild(compare);
|
|
375
|
+
const sale = el("span", "lb-bundle-sale-price", {
|
|
376
|
+
"data-sale-price": ""
|
|
377
|
+
});
|
|
378
|
+
prices.appendChild(sale);
|
|
379
|
+
row.appendChild(prices);
|
|
380
|
+
return {
|
|
381
|
+
el: row,
|
|
382
|
+
update({ totalCents, saleCents, savingsCents, currency }) {
|
|
383
|
+
sale.textContent = (0, import_core.formatCents)(saleCents, currency);
|
|
384
|
+
if (bundle.widgetConfig.pricing.showCompareAtPrice && savingsCents > 0) {
|
|
385
|
+
compare.textContent = (0, import_core.formatCents)(totalCents, currency);
|
|
386
|
+
compare.style.display = "";
|
|
387
|
+
} else {
|
|
388
|
+
compare.style.display = "none";
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function renderSavingsBar() {
|
|
394
|
+
const bar = el("div", "lb-bundle-savings-bar", {
|
|
395
|
+
"data-savings-bar": ""
|
|
396
|
+
});
|
|
397
|
+
const label = document.createElement("span");
|
|
398
|
+
label.textContent = "You save";
|
|
399
|
+
bar.appendChild(label);
|
|
400
|
+
const amount = el("span", "", { "data-savings-amount": "" });
|
|
401
|
+
bar.appendChild(amount);
|
|
402
|
+
return {
|
|
403
|
+
el: bar,
|
|
404
|
+
update({ savingsCents, currency }) {
|
|
405
|
+
if (savingsCents <= 0) {
|
|
406
|
+
bar.style.display = "none";
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
bar.style.display = "";
|
|
410
|
+
amount.textContent = (0, import_core.formatCents)(savingsCents, currency);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
function renderCta(bundle, oosCount, onClick) {
|
|
69
415
|
const button = document.createElement("button");
|
|
70
|
-
button.
|
|
71
|
-
button.
|
|
72
|
-
button.setAttribute("
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
416
|
+
button.type = "button";
|
|
417
|
+
button.className = "lb-bundle-cta";
|
|
418
|
+
button.setAttribute("data-add-bundle", "");
|
|
419
|
+
if (oosCount > 0) {
|
|
420
|
+
button.disabled = true;
|
|
421
|
+
button.textContent = `${oosCount} item${oosCount === 1 ? "" : "s"} out of stock`;
|
|
422
|
+
} else {
|
|
423
|
+
button.textContent = bundle.widgetConfig.cta.ctaText || "Add to cart";
|
|
424
|
+
button.addEventListener("click", () => {
|
|
425
|
+
if (button.disabled) return;
|
|
426
|
+
onClick();
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
return button;
|
|
430
|
+
}
|
|
431
|
+
function computeSale(totalCents, discount, rows) {
|
|
432
|
+
if (discount.discountType === "percentage") {
|
|
433
|
+
let saleCents = 0;
|
|
434
|
+
for (const r of rows) {
|
|
435
|
+
if (!r.selected) continue;
|
|
436
|
+
const unit = (0, import_core.parseCents)(r.selected.price.amount);
|
|
437
|
+
const off = Math.floor(unit * discount.discountValue / 100);
|
|
438
|
+
const perUnit = Math.max(0, unit - off);
|
|
439
|
+
saleCents += perUnit * r.qty;
|
|
440
|
+
}
|
|
441
|
+
return saleCents;
|
|
442
|
+
}
|
|
443
|
+
return Math.max(0, totalCents - Math.round(discount.discountValue * 100));
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// src/renderers/mix-match.ts
|
|
447
|
+
var PLACEHOLDER_THUMB_SVG2 = `
|
|
448
|
+
<svg class="lb-bundle-placeholder-icon" viewBox="0 0 28 28" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
|
|
449
|
+
<rect x="4" y="4" width="20" height="20" rx="3"></rect>
|
|
450
|
+
<line x1="4" y1="20" x2="24" y2="20"></line>
|
|
451
|
+
<circle cx="10" cy="12" r="2"></circle>
|
|
452
|
+
</svg>`;
|
|
453
|
+
var PLUS_ICON_SVG = `
|
|
454
|
+
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
455
|
+
<line x1="9" y1="3" x2="9" y2="15" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
456
|
+
<line x1="3" y1="9" x2="15" y2="9" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
457
|
+
</svg>`;
|
|
458
|
+
var CLOSE_ICON_SVG = `
|
|
459
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
460
|
+
<line x1="5" y1="5" x2="15" y2="15" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
461
|
+
<line x1="15" y1="5" x2="5" y2="15" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
462
|
+
</svg>`;
|
|
463
|
+
var SEARCH_CLEAR_ICON_SVG = `
|
|
464
|
+
<svg width="16" height="16" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
465
|
+
<path d="M14.348 5.652a.5.5 0 0 0-.707 0L10 9.293 6.36 5.652a.5.5 0 1 0-.708.707L9.293 10l-3.641 3.641a.5.5 0 0 0 .708.707L10 10.707l3.641 3.641a.5.5 0 0 0 .707-.707L10.707 10l3.641-3.641a.5.5 0 0 0 0-.707z"/>
|
|
466
|
+
</svg>`;
|
|
467
|
+
function renderMixMatchBundle(container, bundle, onAddToCart, onCleanup) {
|
|
468
|
+
const wc = bundle.widgetConfig;
|
|
469
|
+
const currency = bundle.products[0]?.priceRange.minVariantPrice.currencyCode ?? "USD";
|
|
470
|
+
const requiredQty = bundle.minQuantity ?? 1;
|
|
471
|
+
const maxQty = bundle.maxQuantity ?? requiredQty;
|
|
472
|
+
const eligible = buildEligibleProducts(bundle, wc.outOfStockBehavior);
|
|
473
|
+
const inStockCount = eligible.filter((e) => !e.isOos).length;
|
|
474
|
+
if (inStockCount < requiredQty) return;
|
|
475
|
+
const selections = [];
|
|
476
|
+
const root = el("div", "lb-mix-match", {
|
|
477
|
+
"data-required-quantity": String(requiredQty),
|
|
478
|
+
"data-max-quantity": String(maxQty)
|
|
479
|
+
});
|
|
480
|
+
const header = renderHeader2(bundle);
|
|
481
|
+
root.appendChild(header);
|
|
482
|
+
if (wc.countdown.showCountdown && bundle.endsAt) {
|
|
483
|
+
const countdown = renderCountdown(bundle.endsAt);
|
|
484
|
+
if (countdown) {
|
|
485
|
+
root.appendChild(countdown.el);
|
|
486
|
+
onCleanup?.(countdown.stop);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
const progress = renderProgress(requiredQty);
|
|
490
|
+
root.appendChild(progress.el);
|
|
491
|
+
const slotsContainer = el("div", "lb-mix-match__slots", {
|
|
492
|
+
"data-selection-slots": ""
|
|
493
|
+
});
|
|
494
|
+
root.appendChild(slotsContainer);
|
|
495
|
+
root.appendChild(el("div", "lb-bundle-divider"));
|
|
496
|
+
const pricingSection = renderPricingSection(wc.pricing.showCompareAtPrice);
|
|
497
|
+
root.appendChild(pricingSection.el);
|
|
498
|
+
const savingsBar = wc.savingsBar.visible ? renderSavingsBar2() : null;
|
|
499
|
+
if (savingsBar) root.appendChild(savingsBar.el);
|
|
500
|
+
const placeholder = el("div", "lb-mix-match__price-placeholder", {
|
|
501
|
+
"data-price-placeholder": ""
|
|
502
|
+
});
|
|
503
|
+
const placeholderText = el(
|
|
504
|
+
"span",
|
|
505
|
+
"lb-mix-match__price-placeholder-text"
|
|
506
|
+
);
|
|
507
|
+
placeholderText.textContent = `Select ${requiredQty} items to see price`;
|
|
508
|
+
placeholder.appendChild(placeholderText);
|
|
509
|
+
root.appendChild(placeholder);
|
|
510
|
+
const modal = renderModal(bundle, eligible, currency, {
|
|
511
|
+
showSearch: wc.showSearch,
|
|
512
|
+
onAdd: (product, variant) => addSelection(product, variant),
|
|
513
|
+
onRemove: (productId, variantId) => removeSelection(productId, variantId),
|
|
514
|
+
countFor: (productId, variantId) => selections.filter(
|
|
515
|
+
(s) => s.productId === productId && s.variantId === variantId
|
|
516
|
+
).length,
|
|
517
|
+
isOverMax: () => selections.length >= maxQty
|
|
518
|
+
});
|
|
519
|
+
root.appendChild(modal.el);
|
|
520
|
+
const cta = document.createElement("button");
|
|
521
|
+
cta.type = "button";
|
|
522
|
+
cta.className = "lb-bundle-cta";
|
|
523
|
+
cta.setAttribute("data-add-bundle", "");
|
|
524
|
+
cta.disabled = true;
|
|
525
|
+
cta.textContent = `Select ${requiredQty} items to unlock`;
|
|
526
|
+
cta.addEventListener("click", () => {
|
|
527
|
+
if (cta.disabled) return;
|
|
528
|
+
const lines = selections.map((s) => ({
|
|
529
|
+
merchandiseId: s.variantId,
|
|
530
|
+
quantity: 1,
|
|
531
|
+
attributes: [
|
|
532
|
+
{ key: "_lime_bundle_gid", value: bundle.id },
|
|
533
|
+
{ key: "_lime_bundle_type", value: bundle.bundleType }
|
|
534
|
+
]
|
|
535
|
+
}));
|
|
536
|
+
onAddToCart(lines);
|
|
537
|
+
});
|
|
538
|
+
root.appendChild(cta);
|
|
539
|
+
root.appendChild(
|
|
540
|
+
el("p", "lb-bundle-error", { "data-error": "", "aria-live": "polite" })
|
|
541
|
+
);
|
|
542
|
+
root.appendChild(
|
|
543
|
+
el("span", "lb-visually-hidden", {
|
|
544
|
+
"data-status": "",
|
|
545
|
+
"aria-live": "polite"
|
|
546
|
+
})
|
|
547
|
+
);
|
|
548
|
+
container.appendChild(root);
|
|
549
|
+
const firstEligible = eligible.find((ep) => !ep.isOos);
|
|
550
|
+
const firstVariant = firstEligible?.firstAvailableVariant ?? firstEligible?.variants[0];
|
|
551
|
+
if (firstEligible && firstVariant) {
|
|
552
|
+
selections.push({
|
|
553
|
+
productId: firstEligible.product.id,
|
|
554
|
+
productTitle: firstEligible.product.title,
|
|
555
|
+
variantId: firstVariant.id,
|
|
556
|
+
variantTitle: firstVariant.title,
|
|
557
|
+
imageUrl: firstEligible.product.featuredImage?.url ?? null,
|
|
558
|
+
priceCents: (0, import_core.parseCents)(firstVariant.price.amount),
|
|
559
|
+
compareCents: firstVariant.compareAtPrice ? (0, import_core.parseCents)(firstVariant.compareAtPrice.amount) : null
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
afterMutation();
|
|
563
|
+
function addSelection(product, variant) {
|
|
564
|
+
if (selections.length >= maxQty) return;
|
|
565
|
+
selections.push({
|
|
566
|
+
productId: product.id,
|
|
567
|
+
productTitle: product.title,
|
|
568
|
+
variantId: variant.id,
|
|
569
|
+
variantTitle: variant.title,
|
|
570
|
+
imageUrl: product.featuredImage?.url ?? null,
|
|
571
|
+
priceCents: (0, import_core.parseCents)(variant.price.amount),
|
|
572
|
+
compareCents: variant.compareAtPrice ? (0, import_core.parseCents)(variant.compareAtPrice.amount) : null
|
|
573
|
+
});
|
|
574
|
+
afterMutation();
|
|
575
|
+
}
|
|
576
|
+
function removeSelection(productId, variantId) {
|
|
577
|
+
const idx = selections.findIndex(
|
|
578
|
+
(s) => s.productId === productId && s.variantId === variantId
|
|
579
|
+
);
|
|
580
|
+
if (idx === -1) return;
|
|
581
|
+
selections.splice(idx, 1);
|
|
582
|
+
afterMutation();
|
|
583
|
+
}
|
|
584
|
+
function removeSlotAt(index) {
|
|
585
|
+
if (index < 0 || index >= selections.length) return;
|
|
586
|
+
selections.splice(index, 1);
|
|
587
|
+
afterMutation();
|
|
588
|
+
}
|
|
589
|
+
function afterMutation() {
|
|
590
|
+
renderSlots();
|
|
591
|
+
progress.update(selections.length);
|
|
592
|
+
pricingSection.update(selections, bundle, currency);
|
|
593
|
+
if (savingsBar) savingsBar.update(selections, bundle, currency);
|
|
594
|
+
placeholder.style.display = selections.length === 0 ? "" : "none";
|
|
595
|
+
modal.refreshCounts();
|
|
596
|
+
updateCta();
|
|
597
|
+
}
|
|
598
|
+
function renderSlots() {
|
|
599
|
+
slotsContainer.innerHTML = "";
|
|
600
|
+
const totalSlots = Math.max(requiredQty, selections.length);
|
|
601
|
+
for (let i = 0; i < totalSlots; i++) {
|
|
602
|
+
const selection = selections[i];
|
|
603
|
+
if (selection) {
|
|
604
|
+
slotsContainer.appendChild(
|
|
605
|
+
renderFilledSlot(selection, i, currency, () => removeSlotAt(i))
|
|
606
|
+
);
|
|
607
|
+
} else {
|
|
608
|
+
slotsContainer.appendChild(
|
|
609
|
+
renderEmptySlot(i, () => modal.open())
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
function updateCta() {
|
|
615
|
+
const count = selections.length;
|
|
616
|
+
if (count < requiredQty) {
|
|
617
|
+
cta.disabled = true;
|
|
618
|
+
cta.textContent = `Select ${requiredQty - count} more to unlock`;
|
|
619
|
+
} else {
|
|
620
|
+
cta.disabled = false;
|
|
621
|
+
cta.textContent = wc.cta.ctaText || "Add to cart";
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
function renderHeader2(bundle) {
|
|
626
|
+
const wc = bundle.widgetConfig;
|
|
627
|
+
const header = el("div", "lb-bundle-header");
|
|
628
|
+
const content = el("div", "lb-bundle-header__content");
|
|
629
|
+
const title = el("h3", "lb-bundle-title");
|
|
630
|
+
title.textContent = bundle.title;
|
|
631
|
+
content.appendChild(title);
|
|
632
|
+
header.appendChild(content);
|
|
633
|
+
if (wc.pricing.showSaveBadge) {
|
|
634
|
+
const { discountType, discountValue } = bundle.discountConfig;
|
|
635
|
+
let label = null;
|
|
636
|
+
if (discountType === "percentage" && discountValue > 0) {
|
|
637
|
+
label = `-${Math.round(discountValue)}%`;
|
|
638
|
+
} else if (discountType === "fixed_amount" && discountValue > 0) {
|
|
639
|
+
label = `-${(0, import_core.formatCents)(
|
|
640
|
+
Math.round(discountValue * 100),
|
|
641
|
+
bundle.products[0]?.priceRange.minVariantPrice.currencyCode ?? "USD"
|
|
642
|
+
)}`;
|
|
643
|
+
}
|
|
644
|
+
if (label) {
|
|
645
|
+
const badge = el("span", "lb-bundle-header__badge");
|
|
646
|
+
badge.textContent = label;
|
|
647
|
+
header.appendChild(badge);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return header;
|
|
651
|
+
}
|
|
652
|
+
function renderProgress(requiredQty) {
|
|
653
|
+
const wrap = el("div", "lb-mix-match__progress");
|
|
654
|
+
const labels = el("div", "lb-mix-match__progress-labels");
|
|
655
|
+
const count = el("span", "lb-mix-match__progress-count", {
|
|
656
|
+
"data-progress-count": ""
|
|
657
|
+
});
|
|
658
|
+
count.textContent = `0 of ${requiredQty} selected`;
|
|
659
|
+
labels.appendChild(count);
|
|
660
|
+
const remaining = el("span", "lb-mix-match__progress-remaining", {
|
|
661
|
+
"data-progress-remaining": ""
|
|
662
|
+
});
|
|
663
|
+
remaining.textContent = `${requiredQty} more to go`;
|
|
664
|
+
labels.appendChild(remaining);
|
|
665
|
+
wrap.appendChild(labels);
|
|
666
|
+
const track = el("div", "lb-mix-match__progress-track", {
|
|
667
|
+
role: "progressbar",
|
|
668
|
+
"aria-valuenow": "0",
|
|
669
|
+
"aria-valuemin": "0",
|
|
670
|
+
"aria-valuemax": String(requiredQty)
|
|
671
|
+
});
|
|
672
|
+
const fill = el("div", "lb-mix-match__progress-fill", {
|
|
673
|
+
"data-progress-fill": ""
|
|
674
|
+
});
|
|
675
|
+
fill.style.width = "0%";
|
|
676
|
+
track.appendChild(fill);
|
|
677
|
+
wrap.appendChild(track);
|
|
678
|
+
function update(selected) {
|
|
679
|
+
const pct = Math.min(100, selected / requiredQty * 100);
|
|
680
|
+
count.textContent = `${selected} of ${requiredQty} selected`;
|
|
681
|
+
if (selected >= requiredQty) {
|
|
682
|
+
remaining.textContent = "Complete";
|
|
683
|
+
} else {
|
|
684
|
+
remaining.textContent = `${requiredQty - selected} more to go`;
|
|
685
|
+
}
|
|
686
|
+
fill.style.width = `${pct}%`;
|
|
687
|
+
track.setAttribute("aria-valuenow", String(Math.min(selected, requiredQty)));
|
|
688
|
+
}
|
|
689
|
+
return { el: wrap, update };
|
|
690
|
+
}
|
|
691
|
+
function renderEmptySlot(index, onClick) {
|
|
692
|
+
const slot = el(
|
|
693
|
+
"div",
|
|
694
|
+
"lb-bundle-product-row lb-mix-match__slot lb-mix-match__slot--empty",
|
|
695
|
+
{
|
|
696
|
+
"data-slot": String(index + 1),
|
|
697
|
+
tabindex: "0",
|
|
698
|
+
role: "button",
|
|
699
|
+
"aria-label": "Add a product to the bundle"
|
|
700
|
+
}
|
|
701
|
+
);
|
|
702
|
+
const thumb = el("div", "lb-mix-match__empty-thumb");
|
|
703
|
+
thumb.innerHTML = PLUS_ICON_SVG;
|
|
704
|
+
slot.appendChild(thumb);
|
|
705
|
+
const text = el("span", "lb-mix-match__empty-text");
|
|
706
|
+
text.textContent = "Choose an item";
|
|
707
|
+
slot.appendChild(text);
|
|
708
|
+
slot.addEventListener("click", onClick);
|
|
709
|
+
slot.addEventListener("keydown", (e) => {
|
|
710
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
711
|
+
e.preventDefault();
|
|
712
|
+
onClick();
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
return slot;
|
|
716
|
+
}
|
|
717
|
+
function renderFilledSlot(selection, index, currency, onRemove) {
|
|
718
|
+
const slot = el(
|
|
719
|
+
"div",
|
|
720
|
+
"lb-bundle-product-row lb-mix-match__slot lb-mix-match__slot--filled",
|
|
721
|
+
{ "data-slot": String(index + 1) }
|
|
722
|
+
);
|
|
723
|
+
const thumb = el("div", "lb-bundle-thumbnail", { "data-thumbnail": "" });
|
|
724
|
+
if (selection.imageUrl) {
|
|
725
|
+
const img = document.createElement("img");
|
|
726
|
+
img.src = (0, import_core3.transformImageUrl)(selection.imageUrl, {
|
|
727
|
+
width: import_core3.THUMB_PX,
|
|
728
|
+
height: import_core3.THUMB_PX,
|
|
729
|
+
crop: "center"
|
|
730
|
+
});
|
|
731
|
+
img.alt = selection.productTitle;
|
|
732
|
+
img.width = import_core3.THUMB_PX;
|
|
733
|
+
img.height = import_core3.THUMB_PX;
|
|
734
|
+
img.loading = "lazy";
|
|
735
|
+
thumb.appendChild(img);
|
|
736
|
+
} else {
|
|
737
|
+
thumb.insertAdjacentHTML("beforeend", PLACEHOLDER_THUMB_SVG2);
|
|
738
|
+
}
|
|
739
|
+
slot.appendChild(thumb);
|
|
740
|
+
const info = el("div", "lb-mix-match__filled-info");
|
|
741
|
+
const title = el("span", "lb-mix-match__filled-title");
|
|
742
|
+
title.textContent = selection.productTitle;
|
|
743
|
+
info.appendChild(title);
|
|
744
|
+
if (selection.variantTitle && selection.variantTitle !== "Default Title") {
|
|
745
|
+
const variant = el("span", "lb-mix-match__filled-variant");
|
|
746
|
+
variant.textContent = selection.variantTitle;
|
|
747
|
+
info.appendChild(variant);
|
|
748
|
+
}
|
|
749
|
+
const priceWrap = el("span", "lb-mix-match__filled-price");
|
|
750
|
+
if (selection.compareCents && selection.compareCents > selection.priceCents) {
|
|
751
|
+
const compare = el("span", "lb-mix-match__filled-compare");
|
|
752
|
+
compare.textContent = (0, import_core.formatCents)(selection.compareCents, currency);
|
|
753
|
+
priceWrap.appendChild(compare);
|
|
754
|
+
}
|
|
755
|
+
const priceEl = document.createElement("span");
|
|
756
|
+
priceEl.textContent = (0, import_core.formatCents)(selection.priceCents, currency);
|
|
757
|
+
priceWrap.appendChild(priceEl);
|
|
758
|
+
info.appendChild(priceWrap);
|
|
759
|
+
slot.appendChild(info);
|
|
760
|
+
const remove = document.createElement("button");
|
|
761
|
+
remove.type = "button";
|
|
762
|
+
remove.className = "lb-mix-match__slot-remove";
|
|
763
|
+
remove.setAttribute("aria-label", `Remove ${selection.productTitle}`);
|
|
764
|
+
remove.innerHTML = CLOSE_ICON_SVG;
|
|
765
|
+
remove.addEventListener("click", (e) => {
|
|
766
|
+
e.stopPropagation();
|
|
767
|
+
onRemove();
|
|
768
|
+
});
|
|
769
|
+
slot.appendChild(remove);
|
|
770
|
+
return slot;
|
|
771
|
+
}
|
|
772
|
+
function renderPricingSection(showCompareAtPrice) {
|
|
773
|
+
const wrap = el("div", "lb-bundle-pricing", { "data-pricing-section": "" });
|
|
774
|
+
wrap.style.display = "none";
|
|
775
|
+
const label = el("span", "lb-bundle-pricing__label");
|
|
776
|
+
label.textContent = "Bundle price";
|
|
777
|
+
wrap.appendChild(label);
|
|
778
|
+
const prices = el("span", "lb-bundle-pricing__prices");
|
|
779
|
+
const compare = el("span", "lb-bundle-compare-price", {
|
|
780
|
+
"data-compare-price": ""
|
|
781
|
+
});
|
|
782
|
+
if (showCompareAtPrice) prices.appendChild(compare);
|
|
783
|
+
const sale = el("span", "lb-bundle-sale-price", { "data-sale-price": "" });
|
|
784
|
+
prices.appendChild(sale);
|
|
785
|
+
wrap.appendChild(prices);
|
|
786
|
+
function update(selections, bundle, currency) {
|
|
787
|
+
if (selections.length === 0) {
|
|
788
|
+
wrap.style.display = "none";
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
wrap.style.display = "";
|
|
792
|
+
const totalCents = selections.reduce((s, sel) => s + sel.priceCents, 0);
|
|
793
|
+
const saleCents = (0, import_core.computeBundleSaleCents)(totalCents, bundle.discountConfig);
|
|
794
|
+
if (showCompareAtPrice && totalCents > saleCents) {
|
|
795
|
+
compare.textContent = (0, import_core.formatCents)(totalCents, currency);
|
|
796
|
+
compare.style.display = "";
|
|
797
|
+
} else {
|
|
798
|
+
compare.style.display = "none";
|
|
799
|
+
}
|
|
800
|
+
sale.textContent = (0, import_core.formatCents)(saleCents, currency);
|
|
801
|
+
}
|
|
802
|
+
return { el: wrap, update };
|
|
803
|
+
}
|
|
804
|
+
function renderSavingsBar2() {
|
|
805
|
+
const wrap = el("div", "lb-bundle-savings-bar", {
|
|
806
|
+
"data-savings-bar": ""
|
|
807
|
+
});
|
|
808
|
+
wrap.style.display = "none";
|
|
809
|
+
const labelEl = document.createElement("span");
|
|
810
|
+
labelEl.textContent = "You save";
|
|
811
|
+
wrap.appendChild(labelEl);
|
|
812
|
+
const amount = el("span", "", { "data-savings-amount": "" });
|
|
813
|
+
wrap.appendChild(amount);
|
|
814
|
+
function update(selections, bundle, currency) {
|
|
815
|
+
if (selections.length === 0) {
|
|
816
|
+
wrap.style.display = "none";
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
const totalCents = selections.reduce((s, sel) => s + sel.priceCents, 0);
|
|
820
|
+
const saleCents = (0, import_core.computeBundleSaleCents)(totalCents, bundle.discountConfig);
|
|
821
|
+
const savings = Math.max(0, totalCents - saleCents);
|
|
822
|
+
if (savings <= 0) {
|
|
823
|
+
wrap.style.display = "none";
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
wrap.style.display = "";
|
|
827
|
+
amount.textContent = (0, import_core.formatCents)(savings, currency);
|
|
828
|
+
}
|
|
829
|
+
return { el: wrap, update };
|
|
830
|
+
}
|
|
831
|
+
function renderModal(bundle, eligible, currency, handlers) {
|
|
832
|
+
const overlay = el("div", "lb-mix-match__modal-overlay", {
|
|
833
|
+
"data-modal-overlay": "",
|
|
834
|
+
"data-bundle-gid": bundle.id
|
|
835
|
+
});
|
|
836
|
+
overlay.style.display = "none";
|
|
837
|
+
const modal = el("div", "lb-mix-match__modal", {
|
|
838
|
+
role: "dialog",
|
|
839
|
+
"aria-modal": "true",
|
|
840
|
+
"aria-labelledby": `lb-modal-title-${sanitizeId(bundle.id)}`,
|
|
841
|
+
tabindex: "-1"
|
|
842
|
+
});
|
|
843
|
+
const modalHeader = el("div", "lb-mix-match__modal-header");
|
|
844
|
+
const modalTitle = el("h4", "lb-mix-match__modal-title", {
|
|
845
|
+
id: `lb-modal-title-${sanitizeId(bundle.id)}`
|
|
846
|
+
});
|
|
847
|
+
modalTitle.textContent = "Pick an item";
|
|
848
|
+
modalHeader.appendChild(modalTitle);
|
|
849
|
+
const closeBtn = document.createElement("button");
|
|
850
|
+
closeBtn.type = "button";
|
|
851
|
+
closeBtn.className = "lb-mix-match__modal-close";
|
|
852
|
+
closeBtn.setAttribute("data-modal-close", "");
|
|
853
|
+
closeBtn.setAttribute("aria-label", "Close");
|
|
854
|
+
closeBtn.innerHTML = CLOSE_ICON_SVG;
|
|
855
|
+
closeBtn.addEventListener("click", close);
|
|
856
|
+
modalHeader.appendChild(closeBtn);
|
|
857
|
+
modal.appendChild(modalHeader);
|
|
858
|
+
let searchInput = null;
|
|
859
|
+
let searchClearBtn = null;
|
|
860
|
+
if (handlers.showSearch) {
|
|
861
|
+
const searchWrap = el("div", "lb-mix-match__modal-search");
|
|
862
|
+
searchInput = document.createElement("input");
|
|
863
|
+
searchInput.type = "text";
|
|
864
|
+
searchInput.className = "lb-mix-match__modal-search-input";
|
|
865
|
+
searchInput.setAttribute("data-modal-search", "");
|
|
866
|
+
searchInput.setAttribute("role", "searchbox");
|
|
867
|
+
searchInput.setAttribute("aria-label", "Search products");
|
|
868
|
+
searchInput.setAttribute("placeholder", "Search products");
|
|
869
|
+
searchInput.autocomplete = "off";
|
|
870
|
+
searchInput.addEventListener("input", () => applySearch());
|
|
871
|
+
searchWrap.appendChild(searchInput);
|
|
872
|
+
searchClearBtn = document.createElement("button");
|
|
873
|
+
searchClearBtn.type = "button";
|
|
874
|
+
searchClearBtn.className = "lb-mix-match__modal-search-clear";
|
|
875
|
+
searchClearBtn.setAttribute("data-modal-search-clear", "");
|
|
876
|
+
searchClearBtn.setAttribute("aria-label", "Clear search");
|
|
877
|
+
searchClearBtn.style.display = "none";
|
|
878
|
+
searchClearBtn.innerHTML = SEARCH_CLEAR_ICON_SVG;
|
|
879
|
+
searchClearBtn.addEventListener("click", () => {
|
|
880
|
+
if (!searchInput) return;
|
|
881
|
+
searchInput.value = "";
|
|
882
|
+
applySearch();
|
|
883
|
+
searchInput.focus();
|
|
884
|
+
});
|
|
885
|
+
searchWrap.appendChild(searchClearBtn);
|
|
886
|
+
modal.appendChild(searchWrap);
|
|
887
|
+
}
|
|
888
|
+
const list = el("div", "lb-mix-match__modal-list", {
|
|
889
|
+
"data-modal-list": ""
|
|
890
|
+
});
|
|
891
|
+
modal.appendChild(list);
|
|
892
|
+
const empty = el("div", "lb-mix-match__modal-empty", {
|
|
893
|
+
"data-modal-empty": ""
|
|
894
|
+
});
|
|
895
|
+
empty.style.display = "none";
|
|
896
|
+
const emptyText = document.createElement("p");
|
|
897
|
+
emptyText.textContent = "No products match your search.";
|
|
898
|
+
empty.appendChild(emptyText);
|
|
899
|
+
modal.appendChild(empty);
|
|
900
|
+
const live = el("span", "lb-visually-hidden", {
|
|
901
|
+
"data-modal-live": "",
|
|
902
|
+
"aria-live": "polite"
|
|
903
|
+
});
|
|
904
|
+
modal.appendChild(live);
|
|
905
|
+
overlay.appendChild(modal);
|
|
906
|
+
let rowsBuilt = false;
|
|
907
|
+
const productRows = [];
|
|
908
|
+
function buildRows() {
|
|
909
|
+
if (rowsBuilt) return;
|
|
910
|
+
rowsBuilt = true;
|
|
911
|
+
list.innerHTML = "";
|
|
912
|
+
eligible.forEach((ep) => {
|
|
913
|
+
const variant = ep.firstAvailableVariant ?? ep.variants[0];
|
|
914
|
+
if (!variant) return;
|
|
915
|
+
const productEl = el(
|
|
916
|
+
"div",
|
|
917
|
+
ep.isOos ? "lb-mix-match__modal-product lb-mix-match__modal-product--sold-out" : "lb-mix-match__modal-product",
|
|
918
|
+
{ "data-product-id": ep.product.id.replace(/^.*\//, "") }
|
|
919
|
+
);
|
|
920
|
+
const thumb = el("div", "lb-mix-match__modal-product-thumb");
|
|
921
|
+
if (ep.product.featuredImage) {
|
|
922
|
+
const img = document.createElement("img");
|
|
923
|
+
img.src = (0, import_core3.transformImageUrl)(ep.product.featuredImage.url, {
|
|
924
|
+
width: import_core3.THUMB_PX,
|
|
925
|
+
height: import_core3.THUMB_PX,
|
|
926
|
+
crop: "center"
|
|
927
|
+
});
|
|
928
|
+
img.alt = ep.product.featuredImage.altText ?? ep.product.title;
|
|
929
|
+
img.width = import_core3.THUMB_PX;
|
|
930
|
+
img.height = import_core3.THUMB_PX;
|
|
931
|
+
img.loading = "lazy";
|
|
932
|
+
thumb.appendChild(img);
|
|
933
|
+
} else {
|
|
934
|
+
thumb.insertAdjacentHTML("beforeend", PLACEHOLDER_THUMB_SVG2);
|
|
935
|
+
}
|
|
936
|
+
productEl.appendChild(thumb);
|
|
937
|
+
const info = el("div", "lb-mix-match__modal-product-info");
|
|
938
|
+
const title = el("span", "lb-mix-match__modal-product-title");
|
|
939
|
+
title.textContent = ep.product.title;
|
|
940
|
+
info.appendChild(title);
|
|
941
|
+
const price = el("span", "lb-mix-match__modal-product-price");
|
|
942
|
+
price.textContent = (0, import_core.formatCents)((0, import_core.parseCents)(variant.price.amount), currency);
|
|
943
|
+
info.appendChild(price);
|
|
944
|
+
if (ep.isOos) {
|
|
945
|
+
const soldOut = el("span", "lb-mix-match__modal-sold-out-label");
|
|
946
|
+
soldOut.textContent = "Sold out";
|
|
947
|
+
info.appendChild(soldOut);
|
|
948
|
+
}
|
|
949
|
+
productEl.appendChild(info);
|
|
950
|
+
if (!ep.isOos) {
|
|
951
|
+
const addBtn = document.createElement("button");
|
|
952
|
+
addBtn.type = "button";
|
|
953
|
+
addBtn.className = "lb-mix-match__modal-add";
|
|
954
|
+
addBtn.setAttribute("aria-label", `Add ${ep.product.title}`);
|
|
955
|
+
addBtn.innerHTML = PLUS_ICON_SVG;
|
|
956
|
+
const countBadge = el("span", "lb-bundle-qty-badge");
|
|
957
|
+
countBadge.style.display = "none";
|
|
958
|
+
addBtn.appendChild(countBadge);
|
|
959
|
+
addBtn.addEventListener("click", () => {
|
|
960
|
+
if (handlers.isOverMax()) return;
|
|
961
|
+
handlers.onAdd(ep.product, variant);
|
|
962
|
+
});
|
|
963
|
+
productEl.appendChild(addBtn);
|
|
964
|
+
const removeBtn = document.createElement("button");
|
|
965
|
+
removeBtn.type = "button";
|
|
966
|
+
removeBtn.className = "lb-mix-match__slot-remove";
|
|
967
|
+
removeBtn.setAttribute("aria-label", `Remove one ${ep.product.title}`);
|
|
968
|
+
removeBtn.style.display = "none";
|
|
969
|
+
removeBtn.innerHTML = CLOSE_ICON_SVG;
|
|
970
|
+
removeBtn.addEventListener("click", (e) => {
|
|
971
|
+
e.stopPropagation();
|
|
972
|
+
handlers.onRemove(ep.product.id, variant.id);
|
|
973
|
+
});
|
|
974
|
+
productEl.appendChild(removeBtn);
|
|
975
|
+
productRows.push({
|
|
976
|
+
el: productEl,
|
|
977
|
+
product: ep.product,
|
|
978
|
+
variant,
|
|
979
|
+
updateCount: () => {
|
|
980
|
+
const count = handlers.countFor(ep.product.id, variant.id);
|
|
981
|
+
if (count > 0) {
|
|
982
|
+
countBadge.textContent = String(count);
|
|
983
|
+
countBadge.style.display = "";
|
|
984
|
+
removeBtn.style.display = "";
|
|
985
|
+
} else {
|
|
986
|
+
countBadge.style.display = "none";
|
|
987
|
+
removeBtn.style.display = "none";
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
} else {
|
|
992
|
+
productRows.push({
|
|
993
|
+
el: productEl,
|
|
994
|
+
product: ep.product,
|
|
995
|
+
variant,
|
|
996
|
+
updateCount: () => {
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
list.appendChild(productEl);
|
|
1001
|
+
});
|
|
1002
|
+
refreshCounts();
|
|
1003
|
+
}
|
|
1004
|
+
function applySearch() {
|
|
1005
|
+
if (!searchInput) return;
|
|
1006
|
+
const query = searchInput.value.trim().toLowerCase();
|
|
1007
|
+
if (searchClearBtn) {
|
|
1008
|
+
searchClearBtn.style.display = query ? "" : "none";
|
|
1009
|
+
}
|
|
1010
|
+
let visibleCount = 0;
|
|
1011
|
+
productRows.forEach((row) => {
|
|
1012
|
+
const match = !query || row.product.title.toLowerCase().includes(query);
|
|
1013
|
+
row.el.style.display = match ? "" : "none";
|
|
1014
|
+
if (match) visibleCount++;
|
|
1015
|
+
});
|
|
1016
|
+
empty.style.display = visibleCount === 0 && query ? "" : "none";
|
|
1017
|
+
}
|
|
1018
|
+
let lastFocused = null;
|
|
1019
|
+
function onKeydown(e) {
|
|
1020
|
+
if (e.key === "Escape") {
|
|
1021
|
+
e.preventDefault();
|
|
1022
|
+
close();
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
if (e.key === "Tab") {
|
|
1026
|
+
trapFocus(e, modal);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
let isOpen = false;
|
|
1030
|
+
function open() {
|
|
1031
|
+
if (isOpen) return;
|
|
1032
|
+
if (handlers.isOverMax()) return;
|
|
1033
|
+
isOpen = true;
|
|
1034
|
+
buildRows();
|
|
1035
|
+
lastFocused = overlay.getRootNode().activeElement;
|
|
1036
|
+
overlay.style.display = "";
|
|
1037
|
+
overlay.classList.add("lb-mix-match__modal-overlay--open");
|
|
1038
|
+
modal.focus();
|
|
1039
|
+
document.addEventListener("keydown", onKeydown);
|
|
1040
|
+
overlay.addEventListener("click", onOverlayClick);
|
|
1041
|
+
}
|
|
1042
|
+
function close() {
|
|
1043
|
+
if (!isOpen) return;
|
|
1044
|
+
isOpen = false;
|
|
1045
|
+
overlay.classList.remove("lb-mix-match__modal-overlay--open");
|
|
1046
|
+
overlay.style.display = "none";
|
|
1047
|
+
document.removeEventListener("keydown", onKeydown);
|
|
1048
|
+
overlay.removeEventListener("click", onOverlayClick);
|
|
1049
|
+
if (lastFocused instanceof HTMLElement) {
|
|
1050
|
+
lastFocused.focus();
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
function onOverlayClick(e) {
|
|
1054
|
+
if (e.target === overlay) close();
|
|
1055
|
+
}
|
|
1056
|
+
function refreshCounts() {
|
|
1057
|
+
productRows.forEach((r) => r.updateCount());
|
|
1058
|
+
}
|
|
1059
|
+
return { el: overlay, open, close, refreshCounts };
|
|
1060
|
+
}
|
|
1061
|
+
function buildEligibleProducts(bundle, oosBehavior) {
|
|
1062
|
+
const result = [];
|
|
1063
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1064
|
+
for (const product of bundle.products) {
|
|
1065
|
+
if (seen.has(product.id)) continue;
|
|
1066
|
+
seen.add(product.id);
|
|
1067
|
+
const available = product.variants.nodes.filter((v) => v.availableForSale);
|
|
1068
|
+
const isOos = available.length === 0;
|
|
1069
|
+
if (isOos && oosBehavior === "hide") continue;
|
|
1070
|
+
result.push({
|
|
1071
|
+
product,
|
|
1072
|
+
variants: product.variants.nodes,
|
|
1073
|
+
firstAvailableVariant: available[0] ?? null,
|
|
1074
|
+
isOos
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
return result;
|
|
1078
|
+
}
|
|
1079
|
+
function trapFocus(e, container) {
|
|
1080
|
+
const focusables = container.querySelectorAll(
|
|
1081
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
1082
|
+
);
|
|
1083
|
+
if (focusables.length === 0) return;
|
|
1084
|
+
const first = focusables[0];
|
|
1085
|
+
const last = focusables[focusables.length - 1];
|
|
1086
|
+
const active = container.getRootNode().activeElement;
|
|
1087
|
+
if (e.shiftKey && active === first) {
|
|
1088
|
+
e.preventDefault();
|
|
1089
|
+
last.focus();
|
|
1090
|
+
} else if (!e.shiftKey && active === last) {
|
|
1091
|
+
e.preventDefault();
|
|
1092
|
+
first.focus();
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
function sanitizeId(gid) {
|
|
1096
|
+
return gid.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// src/renderers/volume.ts
|
|
1100
|
+
function renderVolumeBundle(container, bundle, onAddToCart, onCleanup) {
|
|
1101
|
+
const wc = bundle.widgetConfig;
|
|
1102
|
+
const product = bundle.products[0];
|
|
1103
|
+
const variant = product?.variants.nodes.find((v) => v.availableForSale);
|
|
1104
|
+
if (!variant && wc.outOfStockBehavior === "hide") return;
|
|
1105
|
+
const basePriceCents = variant ? (0, import_core.parseCents)(variant.price.amount) : 0;
|
|
1106
|
+
const currency = variant?.price.currencyCode ?? "USD";
|
|
1107
|
+
const discountType = bundle.discountConfig.discountType;
|
|
1108
|
+
const resolved = bundle.volumeTiers.map((tier, index) => {
|
|
1109
|
+
let perUnit;
|
|
1110
|
+
if (discountType === "fixed_amount") {
|
|
1111
|
+
const amt = Math.round((tier.amount ?? 0) * 100);
|
|
1112
|
+
perUnit = Math.max(0, basePriceCents - amt);
|
|
1113
|
+
} else {
|
|
1114
|
+
const pct = tier.percentage ?? 0;
|
|
1115
|
+
const discount = Math.floor(basePriceCents * pct / 100);
|
|
1116
|
+
perUnit = Math.max(0, basePriceCents - discount);
|
|
1117
|
+
}
|
|
1118
|
+
return {
|
|
1119
|
+
tier,
|
|
1120
|
+
index,
|
|
1121
|
+
qty: tier.minQuantity,
|
|
1122
|
+
pricePerUnitCents: perUnit,
|
|
1123
|
+
basePricePerUnitCents: basePriceCents
|
|
1124
|
+
};
|
|
1125
|
+
});
|
|
1126
|
+
const bestTierIndex = pickBestTierIndex(resolved);
|
|
1127
|
+
let selectedIndex = wc.defaultTier === "best_value" ? bestTierIndex : 0;
|
|
1128
|
+
if (typeof wc.defaultTier === "number") {
|
|
1129
|
+
selectedIndex = clamp(wc.defaultTier, 0, resolved.length - 1);
|
|
1130
|
+
}
|
|
1131
|
+
const popularIndex = wc.popularBadge.tierIndex !== void 0 ? clamp(wc.popularBadge.tierIndex, 0, resolved.length - 1) : bestTierIndex;
|
|
1132
|
+
const root = el("div", "lb-volume");
|
|
1133
|
+
root.appendChild(
|
|
1134
|
+
renderHeader3(bundle, resolved, selectedIndex, currency, discountType)
|
|
1135
|
+
);
|
|
1136
|
+
if (wc.countdown.showCountdown && bundle.endsAt) {
|
|
1137
|
+
const countdown = renderCountdown(bundle.endsAt);
|
|
1138
|
+
if (countdown) {
|
|
1139
|
+
root.appendChild(countdown.el);
|
|
1140
|
+
onCleanup?.(countdown.stop);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
const tierGroup = el("div", "lb-volume__tiers", {
|
|
1144
|
+
role: "radiogroup",
|
|
1145
|
+
"aria-label": "Quantity tiers",
|
|
1146
|
+
"data-tier-group": ""
|
|
1147
|
+
});
|
|
1148
|
+
resolved.forEach((r) => {
|
|
1149
|
+
const tierEl = renderTierCard(
|
|
1150
|
+
r,
|
|
1151
|
+
r.index === selectedIndex,
|
|
1152
|
+
currency,
|
|
1153
|
+
wc.popularBadge.visible && r.index === popularIndex ? wc.popularBadge.text : null,
|
|
1154
|
+
wc.pricing.showComparePrice,
|
|
1155
|
+
wc.pricing.showPerUnitPrice
|
|
1156
|
+
);
|
|
1157
|
+
tierEl.addEventListener("click", () => selectTier(r.index));
|
|
1158
|
+
tierEl.addEventListener("keydown", (e) => {
|
|
1159
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1160
|
+
e.preventDefault();
|
|
1161
|
+
selectTier(r.index);
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
if (e.key === "ArrowDown" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowLeft") {
|
|
1165
|
+
e.preventDefault();
|
|
1166
|
+
const delta = e.key === "ArrowDown" || e.key === "ArrowRight" ? 1 : -1;
|
|
1167
|
+
const next = (r.index + delta + resolved.length) % resolved.length;
|
|
1168
|
+
selectTier(next);
|
|
1169
|
+
const target = tierGroup.children[next];
|
|
1170
|
+
target?.focus();
|
|
1171
|
+
}
|
|
1172
|
+
});
|
|
1173
|
+
tierGroup.appendChild(tierEl);
|
|
1174
|
+
});
|
|
1175
|
+
root.appendChild(tierGroup);
|
|
1176
|
+
root.appendChild(el("div", "lb-bundle-divider"));
|
|
1177
|
+
let pricingEl = renderPricingRow2(
|
|
1178
|
+
resolved,
|
|
1179
|
+
selectedIndex,
|
|
1180
|
+
currency,
|
|
1181
|
+
wc.pricing.showItemCount,
|
|
1182
|
+
wc.pricing.showCompareAtPrice
|
|
1183
|
+
);
|
|
1184
|
+
root.appendChild(pricingEl);
|
|
1185
|
+
let savingsBarEl = wc.savingsBar.visible ? renderSavingsBar3(resolved, selectedIndex, currency) : null;
|
|
1186
|
+
if (savingsBarEl) root.appendChild(savingsBarEl);
|
|
1187
|
+
const cta = renderCta2(bundle, () => {
|
|
1188
|
+
if (!variant) return;
|
|
1189
|
+
const r = resolved[selectedIndex];
|
|
1190
|
+
if (!r) return;
|
|
1191
|
+
onAddToCart([
|
|
1192
|
+
{
|
|
77
1193
|
merchandiseId: variant.id,
|
|
78
|
-
quantity:
|
|
1194
|
+
quantity: r.qty,
|
|
79
1195
|
attributes: [
|
|
80
1196
|
{ key: "_lime_bundle_gid", value: bundle.id },
|
|
81
1197
|
{ key: "_lime_bundle_type", value: bundle.bundleType }
|
|
82
1198
|
]
|
|
83
|
-
}
|
|
1199
|
+
}
|
|
1200
|
+
]);
|
|
1201
|
+
});
|
|
1202
|
+
root.appendChild(cta);
|
|
1203
|
+
root.appendChild(
|
|
1204
|
+
el("p", "lb-bundle-error", { "data-error": "", "aria-live": "polite" })
|
|
1205
|
+
);
|
|
1206
|
+
root.appendChild(
|
|
1207
|
+
el("span", "lb-visually-hidden", {
|
|
1208
|
+
"data-status": "",
|
|
1209
|
+
"aria-live": "polite"
|
|
1210
|
+
})
|
|
1211
|
+
);
|
|
1212
|
+
container.appendChild(root);
|
|
1213
|
+
function selectTier(idx) {
|
|
1214
|
+
if (idx === selectedIndex || idx < 0 || idx >= resolved.length) return;
|
|
1215
|
+
selectedIndex = idx;
|
|
1216
|
+
Array.from(tierGroup.children).forEach((card, i) => {
|
|
1217
|
+
card.setAttribute("aria-checked", String(i === idx));
|
|
1218
|
+
card.tabIndex = i === idx ? 0 : -1;
|
|
84
1219
|
});
|
|
85
|
-
|
|
86
|
-
|
|
1220
|
+
const newPricing = renderPricingRow2(
|
|
1221
|
+
resolved,
|
|
1222
|
+
idx,
|
|
1223
|
+
currency,
|
|
1224
|
+
wc.pricing.showItemCount,
|
|
1225
|
+
wc.pricing.showCompareAtPrice
|
|
1226
|
+
);
|
|
1227
|
+
pricingEl.replaceWith(newPricing);
|
|
1228
|
+
pricingEl = newPricing;
|
|
1229
|
+
if (savingsBarEl) {
|
|
1230
|
+
const newBar = renderSavingsBar3(resolved, idx, currency);
|
|
1231
|
+
savingsBarEl.replaceWith(newBar);
|
|
1232
|
+
savingsBarEl = newBar;
|
|
1233
|
+
}
|
|
1234
|
+
const badgeEl = root.querySelector("[data-header-badge]");
|
|
1235
|
+
if (badgeEl) {
|
|
1236
|
+
const label = badgeFor(resolved[idx], currency, discountType);
|
|
1237
|
+
if (label) {
|
|
1238
|
+
badgeEl.textContent = label;
|
|
1239
|
+
badgeEl.style.display = "";
|
|
1240
|
+
} else {
|
|
1241
|
+
badgeEl.style.display = "none";
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
function renderHeader3(bundle, resolved, selectedIndex, currency, discountType) {
|
|
1247
|
+
const wc = bundle.widgetConfig;
|
|
1248
|
+
const header = el("div", "lb-bundle-header");
|
|
1249
|
+
const content = el("div", "lb-bundle-header__content");
|
|
1250
|
+
const title = el("h3", "lb-bundle-title");
|
|
1251
|
+
title.textContent = bundle.title;
|
|
1252
|
+
content.appendChild(title);
|
|
1253
|
+
header.appendChild(content);
|
|
1254
|
+
if (wc.pricing.showSaveBadge) {
|
|
1255
|
+
const badge = badgeFor(resolved[selectedIndex], currency, discountType);
|
|
1256
|
+
if (badge) {
|
|
1257
|
+
const badgeEl = el("span", "lb-bundle-header__badge", {
|
|
1258
|
+
"data-header-badge": ""
|
|
1259
|
+
});
|
|
1260
|
+
badgeEl.textContent = badge;
|
|
1261
|
+
header.appendChild(badgeEl);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
return header;
|
|
1265
|
+
}
|
|
1266
|
+
function renderTierCard(r, isSelected, currency, popularLabel, showComparePrice, showPerUnitPrice) {
|
|
1267
|
+
const tier = el("div", "lb-volume__tier", {
|
|
1268
|
+
role: "radio",
|
|
1269
|
+
"aria-checked": String(isSelected),
|
|
1270
|
+
tabindex: isSelected ? "0" : "-1",
|
|
1271
|
+
"data-tier-index": String(r.index),
|
|
1272
|
+
"data-tier-qty": String(r.qty)
|
|
1273
|
+
});
|
|
1274
|
+
const radio = el("span", "lb-volume__radio");
|
|
1275
|
+
radio.appendChild(el("span", "lb-volume__radio-dot"));
|
|
1276
|
+
tier.appendChild(radio);
|
|
1277
|
+
const grid = el("span", "lb-volume__tier-grid");
|
|
1278
|
+
const label = el("span", "lb-volume__tier-label");
|
|
1279
|
+
label.textContent = `Buy ${r.qty}`;
|
|
1280
|
+
grid.appendChild(label);
|
|
1281
|
+
const price = el("span", "lb-volume__tier-price");
|
|
1282
|
+
if (showComparePrice && r.pricePerUnitCents < r.basePricePerUnitCents) {
|
|
1283
|
+
const compare = el("span", "lb-volume__tier-compare");
|
|
1284
|
+
compare.textContent = (0, import_core.formatCents)(r.basePricePerUnitCents, currency);
|
|
1285
|
+
price.appendChild(compare);
|
|
1286
|
+
}
|
|
1287
|
+
if (showPerUnitPrice) {
|
|
1288
|
+
const each = document.createElement("span");
|
|
1289
|
+
each.setAttribute("data-tier-price-each", "");
|
|
1290
|
+
each.textContent = (0, import_core.formatCents)(r.pricePerUnitCents, currency);
|
|
1291
|
+
price.appendChild(each);
|
|
1292
|
+
const unit = el("span", "lb-volume__tier-unit");
|
|
1293
|
+
unit.textContent = " each";
|
|
1294
|
+
price.appendChild(unit);
|
|
1295
|
+
}
|
|
1296
|
+
grid.appendChild(price);
|
|
1297
|
+
tier.appendChild(grid);
|
|
1298
|
+
const badge = el("span", "lb-volume__tier-badge");
|
|
1299
|
+
if (popularLabel) {
|
|
1300
|
+
badge.textContent = popularLabel;
|
|
1301
|
+
} else {
|
|
1302
|
+
badge.style.display = "none";
|
|
1303
|
+
}
|
|
1304
|
+
tier.appendChild(badge);
|
|
1305
|
+
return tier;
|
|
1306
|
+
}
|
|
1307
|
+
function renderPricingRow2(resolved, selectedIndex, currency, showItemCount, showCompareAtPrice) {
|
|
1308
|
+
const r = resolved[selectedIndex];
|
|
1309
|
+
const totalCents = r ? r.pricePerUnitCents * r.qty : 0;
|
|
1310
|
+
const undiscountedCents = r ? r.basePricePerUnitCents * r.qty : 0;
|
|
1311
|
+
const savings = Math.max(0, undiscountedCents - totalCents);
|
|
1312
|
+
const row = el("div", "lb-bundle-pricing");
|
|
1313
|
+
const label = el("span", "lb-bundle-pricing__label", {
|
|
1314
|
+
"data-total-label": ""
|
|
1315
|
+
});
|
|
1316
|
+
label.textContent = "Total";
|
|
1317
|
+
if (showItemCount && r) {
|
|
1318
|
+
const count = document.createElement("span");
|
|
1319
|
+
count.setAttribute("data-item-count", "");
|
|
1320
|
+
count.textContent = ` (${r.qty} item${r.qty === 1 ? "" : "s"})`;
|
|
1321
|
+
label.appendChild(count);
|
|
1322
|
+
}
|
|
1323
|
+
row.appendChild(label);
|
|
1324
|
+
const prices = el("span", "lb-bundle-pricing__prices");
|
|
1325
|
+
if (showCompareAtPrice && savings > 0) {
|
|
1326
|
+
const compare = el("span", "lb-bundle-compare-price", {
|
|
1327
|
+
"data-compare-price": ""
|
|
1328
|
+
});
|
|
1329
|
+
compare.textContent = (0, import_core.formatCents)(undiscountedCents, currency);
|
|
1330
|
+
prices.appendChild(compare);
|
|
1331
|
+
}
|
|
1332
|
+
const sale = el("span", "lb-bundle-sale-price", { "data-total-price": "" });
|
|
1333
|
+
sale.textContent = (0, import_core.formatCents)(totalCents, currency);
|
|
1334
|
+
prices.appendChild(sale);
|
|
1335
|
+
row.appendChild(prices);
|
|
1336
|
+
return row;
|
|
1337
|
+
}
|
|
1338
|
+
function renderSavingsBar3(resolved, selectedIndex, currency) {
|
|
1339
|
+
const r = resolved[selectedIndex];
|
|
1340
|
+
const totalCents = r ? r.pricePerUnitCents * r.qty : 0;
|
|
1341
|
+
const undiscountedCents = r ? r.basePricePerUnitCents * r.qty : 0;
|
|
1342
|
+
const savings = Math.max(0, undiscountedCents - totalCents);
|
|
1343
|
+
const bar = el("div", "lb-bundle-savings-bar", { "data-savings-bar": "" });
|
|
1344
|
+
if (savings <= 0) bar.style.display = "none";
|
|
1345
|
+
const labelEl = document.createElement("span");
|
|
1346
|
+
labelEl.textContent = "You save";
|
|
1347
|
+
bar.appendChild(labelEl);
|
|
1348
|
+
const amount = el("span", "", { "data-savings-amount": "" });
|
|
1349
|
+
amount.textContent = (0, import_core.formatCents)(savings, currency);
|
|
1350
|
+
bar.appendChild(amount);
|
|
1351
|
+
return bar;
|
|
1352
|
+
}
|
|
1353
|
+
function renderCta2(bundle, onClick) {
|
|
1354
|
+
const product = bundle.products[0];
|
|
1355
|
+
const isAvailable = product?.variants.nodes.some((v) => v.availableForSale);
|
|
1356
|
+
const button = document.createElement("button");
|
|
1357
|
+
button.type = "button";
|
|
1358
|
+
button.className = "lb-bundle-cta";
|
|
1359
|
+
button.setAttribute("data-add-bundle", "");
|
|
1360
|
+
if (!isAvailable) button.disabled = true;
|
|
1361
|
+
button.textContent = isAvailable ? bundle.widgetConfig.cta.ctaText || "Add to cart" : "Sold out";
|
|
1362
|
+
button.addEventListener("click", () => {
|
|
1363
|
+
if (button.disabled) return;
|
|
1364
|
+
onClick();
|
|
1365
|
+
});
|
|
1366
|
+
return button;
|
|
1367
|
+
}
|
|
1368
|
+
function badgeFor(resolved, currency, discountType) {
|
|
1369
|
+
if (!resolved) return null;
|
|
1370
|
+
const { tier } = resolved;
|
|
1371
|
+
if (discountType === "fixed_amount") {
|
|
1372
|
+
const amount = tier.amount ?? 0;
|
|
1373
|
+
if (amount > 0) return `-${(0, import_core.formatCents)(Math.round(amount * 100), currency)}`;
|
|
1374
|
+
return null;
|
|
1375
|
+
}
|
|
1376
|
+
if (discountType === "percentage") {
|
|
1377
|
+
const pct = tier.percentage ?? 0;
|
|
1378
|
+
if (pct > 0) return `-${Math.round(pct)}%`;
|
|
1379
|
+
return null;
|
|
1380
|
+
}
|
|
1381
|
+
return null;
|
|
1382
|
+
}
|
|
1383
|
+
function pickBestTierIndex(resolved) {
|
|
1384
|
+
let bestSavings = 0;
|
|
1385
|
+
let bestIndex = 0;
|
|
1386
|
+
resolved.forEach((r, i) => {
|
|
1387
|
+
const savings = r.basePricePerUnitCents - r.pricePerUnitCents;
|
|
1388
|
+
if (savings > bestSavings) {
|
|
1389
|
+
bestSavings = savings;
|
|
1390
|
+
bestIndex = i;
|
|
1391
|
+
}
|
|
87
1392
|
});
|
|
88
|
-
|
|
1393
|
+
return bestIndex;
|
|
1394
|
+
}
|
|
1395
|
+
function clamp(n, min, max) {
|
|
1396
|
+
return Math.max(min, Math.min(max, n));
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
// src/lime-bundle.ts
|
|
1400
|
+
var import_core5 = require("@lime-bundles/core");
|
|
1401
|
+
|
|
1402
|
+
// src/styles/bundle-css.ts
|
|
1403
|
+
var BUNDLE_BASE_CSS = `/* Lime Bundles \u2014 shared base styles for all bundle widget types */
|
|
1404
|
+
|
|
1405
|
+
.lb-bundle-widget.lb-bundle-widget,
|
|
1406
|
+
.lb-bundle-widget.lb-bundle-widget * {
|
|
1407
|
+
line-height: normal;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
.lb-bundle-widget {
|
|
1411
|
+
/* Internal CSS-only vars (not merchant-configurable). */
|
|
1412
|
+
--lb-text-muted: #666666;
|
|
1413
|
+
--lb-thumbnail-bg: #F0F0F0;
|
|
1414
|
+
--lb-widget-pad: 20px;
|
|
1415
|
+
--lb-progress-color: var(--lb-primary-color);
|
|
1416
|
+
|
|
1417
|
+
font-family: inherit;
|
|
1418
|
+
font-size: 16px;
|
|
1419
|
+
background: var(--lb-bg);
|
|
1420
|
+
border: var(--lb-border-width) solid var(--lb-border);
|
|
1421
|
+
border-radius: var(--lb-radius);
|
|
1422
|
+
padding: var(--lb-widget-pad) var(--lb-widget-pad) 20px;
|
|
1423
|
+
box-sizing: border-box;
|
|
1424
|
+
/* Cap the widget at a comfortable reading width on desktop. Below
|
|
1425
|
+
440px viewports the container is already narrower than the cap,
|
|
1426
|
+
so the rule is inert on mobile. */
|
|
1427
|
+
max-width: 440px;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
/* Countdown timer bar \u2014 sits below the gradient header */
|
|
1431
|
+
.lb-bundle-countdown {
|
|
1432
|
+
margin: 0 calc(-1 * var(--lb-widget-pad)) 20px;
|
|
1433
|
+
padding: 12px 20px;
|
|
1434
|
+
background: var(--lb-countdown-bg);
|
|
1435
|
+
border-top: 1px solid rgba(0, 0, 0, 0.06);
|
|
1436
|
+
display: flex;
|
|
1437
|
+
align-items: center;
|
|
1438
|
+
justify-content: space-between;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
.lb-bundle-countdown__label {
|
|
1442
|
+
display: flex;
|
|
1443
|
+
align-items: center;
|
|
1444
|
+
gap: 8px;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
.lb-bundle-countdown__label svg {
|
|
1448
|
+
width: 16px;
|
|
1449
|
+
height: 16px;
|
|
1450
|
+
flex-shrink: 0;
|
|
1451
|
+
color: var(--lb-countdown-text);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
.lb-bundle-countdown__label span {
|
|
1455
|
+
font-size: 12px;
|
|
1456
|
+
font-weight: 500;
|
|
1457
|
+
line-height: 1;
|
|
1458
|
+
color: var(--lb-countdown-text);
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
.lb-bundle-countdown__timer {
|
|
1462
|
+
font-family: 'SF Mono', 'Roboto Mono', ui-monospace, monospace;
|
|
1463
|
+
font-size: 12px;
|
|
1464
|
+
font-weight: 600;
|
|
1465
|
+
line-height: 1;
|
|
1466
|
+
color: var(--lb-countdown-text);
|
|
1467
|
+
letter-spacing: 0.02em;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
/* Hide wrapper when the inner snippet rendered nothing (product OOS / unfulfillable) */
|
|
1471
|
+
.lb-bundle-widget:not(:has(.lb-fixed, .lb-mix-match, .lb-volume)) {
|
|
1472
|
+
display: none;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
/* Adjacent widget spacing \u2014 separates multiple bundles on the same product page */
|
|
1476
|
+
.lb-bundle-widget + .lb-bundle-widget {
|
|
1477
|
+
margin-top: 24px;
|
|
1478
|
+
padding-top: 24px;
|
|
1479
|
+
border-top: 1px solid var(--lb-border);
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
/* Header \u2014 gradient banner with title + savings badge */
|
|
1483
|
+
.lb-bundle-header {
|
|
1484
|
+
margin: calc(-1 * var(--lb-widget-pad)) calc(-1 * var(--lb-widget-pad)) 20px;
|
|
1485
|
+
padding: 20px 20px;
|
|
1486
|
+
background: var(--lb-header-bg);
|
|
1487
|
+
/* Match the widget's inner border curve so there's no background gap at the top corners. */
|
|
1488
|
+
border-radius: max(0px, calc(var(--lb-radius) - var(--lb-border-width))) max(0px, calc(var(--lb-radius) - var(--lb-border-width))) 0 0;
|
|
1489
|
+
display: flex;
|
|
1490
|
+
align-items: center;
|
|
1491
|
+
justify-content: space-between;
|
|
1492
|
+
gap: 16px;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
/* When countdown follows header, remove header bottom margin */
|
|
1496
|
+
.lb-bundle-header:has(+ .lb-bundle-countdown) {
|
|
1497
|
+
margin-bottom: 0;
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
.lb-bundle-header__content {
|
|
1501
|
+
flex: 1;
|
|
1502
|
+
min-width: 0;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
.lb-bundle-title {
|
|
1506
|
+
font-size: 20px;
|
|
1507
|
+
font-weight: 700;
|
|
1508
|
+
line-height: 28px;
|
|
1509
|
+
letter-spacing: -0.02em;
|
|
1510
|
+
color: var(--lb-text);
|
|
1511
|
+
margin: 0;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
.lb-bundle-header .lb-bundle-title {
|
|
1515
|
+
color: var(--lb-header-text);
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
.lb-bundle-subtitle {
|
|
1519
|
+
font-size: 16px;
|
|
1520
|
+
font-weight: 400;
|
|
1521
|
+
line-height: 20px;
|
|
1522
|
+
color: var(--lb-text-muted);
|
|
1523
|
+
margin: 4px 0 0;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
.lb-bundle-header .lb-bundle-subtitle {
|
|
1527
|
+
color: var(--lb-header-text);
|
|
1528
|
+
opacity: 0.85;
|
|
1529
|
+
margin-top: 8px;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
.lb-bundle-header:has(.lb-bundle-subtitle) {
|
|
1533
|
+
align-items: flex-start;
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
.lb-bundle-header__badge {
|
|
1537
|
+
background: var(--lb-save-badge-bg);
|
|
1538
|
+
color: var(--lb-save-badge-text);
|
|
1539
|
+
border: var(--lb-save-badge-border-width) solid var(--lb-save-badge-border-color);
|
|
1540
|
+
font-size: 16px;
|
|
1541
|
+
font-weight: 700;
|
|
1542
|
+
line-height: 1;
|
|
1543
|
+
padding: 4px 12px;
|
|
1544
|
+
border-radius: var(--lb-save-badge-radius);
|
|
1545
|
+
white-space: nowrap;
|
|
1546
|
+
flex-shrink: 0;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
/* Override Dawn's \`div:empty { display: none }\` reset for decorative elements */
|
|
1550
|
+
.lb-bundle-divider:empty,
|
|
1551
|
+
.lb-mix-match__progress-fill:empty {
|
|
1552
|
+
display: block;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
/* Divider */
|
|
1556
|
+
.lb-bundle-divider {
|
|
1557
|
+
height: 1px;
|
|
1558
|
+
background: color-mix(in srgb, var(--lb-text) 7%, transparent);
|
|
1559
|
+
margin: 16px 0;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
/* Product rows */
|
|
1563
|
+
.lb-bundle-product-row {
|
|
1564
|
+
display: flex;
|
|
1565
|
+
gap: 12px;
|
|
1566
|
+
padding: 12px 0;
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
.lb-bundle-thumbnail {
|
|
1570
|
+
position: relative;
|
|
1571
|
+
width: 48px;
|
|
1572
|
+
height: 48px;
|
|
1573
|
+
min-width: 48px;
|
|
1574
|
+
background: var(--lb-thumbnail-bg);
|
|
1575
|
+
border-radius: 8px;
|
|
1576
|
+
overflow: hidden;
|
|
1577
|
+
display: flex;
|
|
1578
|
+
align-items: center;
|
|
1579
|
+
justify-content: center;
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
.lb-bundle-thumbnail img {
|
|
1583
|
+
width: 100%;
|
|
1584
|
+
height: 100%;
|
|
1585
|
+
object-fit: cover;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
.lb-bundle-thumbnail svg {
|
|
1589
|
+
width: 28px;
|
|
1590
|
+
height: 28px;
|
|
1591
|
+
color: #BBBBBB;
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
.lb-bundle-product-info {
|
|
1595
|
+
flex: 1;
|
|
1596
|
+
min-width: 0;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
.lb-bundle-product-name {
|
|
1600
|
+
font-size: 16px;
|
|
1601
|
+
font-weight: 700;
|
|
1602
|
+
line-height: 20px;
|
|
1603
|
+
color: var(--lb-text);
|
|
1604
|
+
margin: 0;
|
|
1605
|
+
text-decoration: none;
|
|
1606
|
+
display: block;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
.lb-bundle-product-name:hover {
|
|
1610
|
+
text-decoration: underline;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
.lb-bundle-product-price {
|
|
1614
|
+
/* --lb-product-price-display fallback is the "on" branch; Liquid sets 'none' when merchant disables. */
|
|
1615
|
+
display: var(--lb-product-price-display, block);
|
|
1616
|
+
font-size: 12px;
|
|
1617
|
+
font-weight: 400;
|
|
1618
|
+
line-height: 20px;
|
|
1619
|
+
color: var(--lb-text);
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
.lb-bundle-product-prices {
|
|
1623
|
+
display: flex;
|
|
1624
|
+
align-items: baseline;
|
|
1625
|
+
gap: 6px;
|
|
1626
|
+
flex-wrap: wrap;
|
|
1627
|
+
margin-top: 2px;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
.lb-bundle-product-compare-price {
|
|
1631
|
+
/* --lb-product-compare-display fallback is the "on" branch; Liquid sets 'none' when merchant disables. */
|
|
1632
|
+
display: var(--lb-product-compare-display, inline);
|
|
1633
|
+
font-size: 12px;
|
|
1634
|
+
font-weight: 400;
|
|
1635
|
+
line-height: 20px;
|
|
1636
|
+
color: color-mix(in srgb, var(--lb-text) 60%, transparent);
|
|
1637
|
+
text-decoration: line-through;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
/* Setting \`display\` above outranks the UA [hidden] rule \u2014 restore it so rows
|
|
1641
|
+
without a compare-at price don't leave a phantom flex item + gap. */
|
|
1642
|
+
.lb-bundle-product-compare-price[hidden] {
|
|
1643
|
+
display: none;
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
.lb-bundle-variant-badge {
|
|
1647
|
+
display: inline-block;
|
|
1648
|
+
border: var(--lb-variant-border-width) solid var(--lb-variant-border-color);
|
|
1649
|
+
border-radius: var(--lb-variant-radius);
|
|
1650
|
+
padding: 8px 12px;
|
|
1651
|
+
font-size: 12px;
|
|
1652
|
+
line-height: 16px;
|
|
1653
|
+
color: var(--lb-text-muted);
|
|
1654
|
+
margin-top: 8px;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
.lb-bundle-quantity {
|
|
1658
|
+
font-size: 12px;
|
|
1659
|
+
line-height: 16px;
|
|
1660
|
+
color: var(--lb-text-muted);
|
|
1661
|
+
margin-left: 8px;
|
|
1662
|
+
white-space: nowrap;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
/* Pricing row \u2014 label left, prices right */
|
|
1666
|
+
.lb-bundle-pricing {
|
|
1667
|
+
display: flex;
|
|
1668
|
+
align-items: baseline;
|
|
1669
|
+
justify-content: space-between;
|
|
1670
|
+
padding: 4px 0 8px;
|
|
1671
|
+
gap: 12px;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
.lb-bundle-pricing__label {
|
|
1675
|
+
font-size: 16px;
|
|
1676
|
+
font-weight: 400;
|
|
1677
|
+
line-height: 20px;
|
|
1678
|
+
color: var(--lb-text);
|
|
1679
|
+
white-space: nowrap;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
.lb-bundle-pricing__prices {
|
|
1683
|
+
display: flex;
|
|
1684
|
+
align-items: baseline;
|
|
1685
|
+
gap: 8px;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
.lb-bundle-sale-price {
|
|
1689
|
+
font-size: 20px;
|
|
1690
|
+
font-weight: 700;
|
|
1691
|
+
line-height: 1;
|
|
1692
|
+
letter-spacing: -0.02em;
|
|
1693
|
+
color: var(--lb-text);
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
.lb-bundle-compare-price {
|
|
1697
|
+
font-size: 16px;
|
|
1698
|
+
font-weight: 400;
|
|
1699
|
+
line-height: 20px;
|
|
1700
|
+
color: color-mix(in srgb, var(--lb-text) 60%, transparent);
|
|
1701
|
+
text-decoration: line-through;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
/* Savings bar \u2014 green banner below pricing */
|
|
1705
|
+
.lb-bundle-savings-bar {
|
|
1706
|
+
display: flex;
|
|
1707
|
+
align-items: center;
|
|
1708
|
+
justify-content: space-between;
|
|
1709
|
+
background: var(--lb-savings-bar-bg);
|
|
1710
|
+
color: var(--lb-savings-bar-text);
|
|
1711
|
+
border: var(--lb-savings-bar-border-width) solid var(--lb-savings-bar-border-color);
|
|
1712
|
+
font-size: 16px;
|
|
1713
|
+
font-weight: 600;
|
|
1714
|
+
line-height: 20px;
|
|
1715
|
+
padding: 12px 16px;
|
|
1716
|
+
border-radius: var(--lb-savings-bar-radius);
|
|
1717
|
+
margin-bottom: 12px;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
/* Quantity badge \u2014 overlay on thumbnail top-right */
|
|
1721
|
+
.lb-bundle-qty-badge.lb-bundle-qty-badge {
|
|
1722
|
+
position: absolute;
|
|
1723
|
+
top: -8px;
|
|
1724
|
+
right: -8px;
|
|
1725
|
+
/* --lb-qty-badge-display fallback is the "on" branch; Liquid sets 'none' when merchant disables. */
|
|
1726
|
+
display: var(--lb-qty-badge-display, flex);
|
|
1727
|
+
align-items: center;
|
|
1728
|
+
justify-content: center;
|
|
1729
|
+
width: 24px;
|
|
1730
|
+
height: 24px;
|
|
1731
|
+
border-radius: 50%;
|
|
1732
|
+
background: var(--lb-qty-badge-bg);
|
|
1733
|
+
border: var(--lb-image-border-width) solid var(--lb-image-border-color);
|
|
1734
|
+
color: var(--lb-qty-badge-color);
|
|
1735
|
+
font-size: 12px;
|
|
1736
|
+
font-weight: 700;
|
|
1737
|
+
line-height: 0;
|
|
1738
|
+
text-align: center;
|
|
1739
|
+
z-index: 1;
|
|
1740
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
/* Override Dawn's \`div:empty\` for savings bar when hidden */
|
|
1744
|
+
.lb-bundle-savings-bar:empty {
|
|
1745
|
+
display: none;
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
/* CTA button */
|
|
1749
|
+
.lb-bundle-cta {
|
|
1750
|
+
display: block;
|
|
1751
|
+
width: 100%;
|
|
1752
|
+
padding: 16px;
|
|
1753
|
+
border: var(--lb-cta-border-width) solid var(--lb-cta-border-color);
|
|
1754
|
+
border-radius: var(--lb-cta-radius);
|
|
1755
|
+
font-size: 16px;
|
|
1756
|
+
font-weight: 600;
|
|
1757
|
+
line-height: 20px;
|
|
1758
|
+
cursor: pointer;
|
|
1759
|
+
text-align: center;
|
|
1760
|
+
transition: opacity 0.15s ease;
|
|
1761
|
+
font-family: inherit;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
.lb-bundle-cta:not(:disabled) {
|
|
1765
|
+
background: var(--lb-primary-color);
|
|
1766
|
+
color: var(--lb-btn-text);
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
.lb-bundle-cta:not(:disabled):hover {
|
|
1770
|
+
opacity: 0.9;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
.lb-bundle-cta:disabled {
|
|
1774
|
+
background: color-mix(in srgb, var(--lb-primary-color) 35%, var(--lb-bg));
|
|
1775
|
+
color: color-mix(in srgb, var(--lb-btn-text) 85%, transparent);
|
|
1776
|
+
cursor: not-allowed;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
.lb-bundle-cta[data-loading="true"] {
|
|
1780
|
+
opacity: 0.7;
|
|
1781
|
+
cursor: wait;
|
|
1782
|
+
pointer-events: none;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
/* Error message */
|
|
1786
|
+
.lb-bundle-error {
|
|
1787
|
+
font-size: 16px;
|
|
1788
|
+
color: #D72C0D;
|
|
1789
|
+
margin-top: 8px;
|
|
1790
|
+
display: none;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
.lb-bundle-error[data-visible="true"] {
|
|
1794
|
+
display: block;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
/* Visually hidden \u2014 accessible to screen readers only */
|
|
1798
|
+
.lb-visually-hidden {
|
|
1799
|
+
position: absolute !important;
|
|
1800
|
+
width: 1px !important;
|
|
1801
|
+
height: 1px !important;
|
|
1802
|
+
padding: 0 !important;
|
|
1803
|
+
margin: -1px !important;
|
|
1804
|
+
overflow: hidden !important;
|
|
1805
|
+
clip-path: inset(50%) !important;
|
|
1806
|
+
white-space: nowrap !important;
|
|
1807
|
+
border: 0 !important;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
/* Placeholder SVG icon for missing images */
|
|
1811
|
+
.lb-bundle-placeholder-icon {
|
|
1812
|
+
width: 28px;
|
|
1813
|
+
height: 28px;
|
|
1814
|
+
stroke: #BBBBBB;
|
|
1815
|
+
stroke-width: 1.5;
|
|
1816
|
+
fill: none;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
/* Out-of-stock product row */
|
|
1820
|
+
.lb-bundle-product-row--oos {
|
|
1821
|
+
opacity: 0.5;
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
.lb-bundle-oos-label {
|
|
1825
|
+
font-size: 12px;
|
|
1826
|
+
font-weight: 500;
|
|
1827
|
+
color: #D72C0D;
|
|
1828
|
+
white-space: nowrap;
|
|
1829
|
+
margin-left: auto;
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
/* A/B test: hide save badge until JS swaps the label (prevents flash of default) */
|
|
1833
|
+
.lb-ab-pending {
|
|
1834
|
+
visibility: hidden;
|
|
89
1835
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
1836
|
+
`;
|
|
1837
|
+
var BUNDLE_FIXED_CSS = `/* Lime Bundles \u2014 Fixed bundle styles */
|
|
1838
|
+
|
|
1839
|
+
.lb-fixed__products {
|
|
1840
|
+
display: flex;
|
|
1841
|
+
flex-direction: column;
|
|
1842
|
+
gap: 0;
|
|
1843
|
+
margin: 0;
|
|
94
1844
|
}
|
|
95
1845
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1846
|
+
/* Fixed bundles: product rows */
|
|
1847
|
+
.lb-fixed .lb-bundle-product-row {
|
|
1848
|
+
gap: 16px;
|
|
1849
|
+
align-items: center;
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
/* Fixed bundles: larger thumbnails */
|
|
1853
|
+
.lb-fixed .lb-bundle-thumbnail {
|
|
1854
|
+
width: 60px;
|
|
1855
|
+
height: 60px;
|
|
1856
|
+
min-width: 60px;
|
|
1857
|
+
border-radius: var(--lb-image-border-radius);
|
|
1858
|
+
border: var(--lb-image-border-width) solid var(--lb-image-border-color);
|
|
1859
|
+
box-sizing: border-box;
|
|
1860
|
+
overflow: visible;
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
.lb-fixed .lb-bundle-thumbnail img {
|
|
1864
|
+
border-radius: max(0px, calc(var(--lb-image-border-radius) - var(--lb-image-border-width)));
|
|
1865
|
+
border: none;
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
/* Variant picker select \u2014 styled to match the variant badge aesthetic */
|
|
1869
|
+
.lb-bundle-variant-select {
|
|
1870
|
+
margin-top: 8px;
|
|
1871
|
+
display: inline-block;
|
|
1872
|
+
border: var(--lb-variant-border-width) solid var(--lb-variant-border-color);
|
|
1873
|
+
border-radius: var(--lb-variant-radius);
|
|
1874
|
+
padding: 8px 32px 8px 12px;
|
|
1875
|
+
font-size: 12px;
|
|
1876
|
+
line-height: 16px;
|
|
1877
|
+
color: var(--lb-text);
|
|
1878
|
+
background: var(--lb-bg);
|
|
1879
|
+
font-family: inherit;
|
|
1880
|
+
cursor: pointer;
|
|
1881
|
+
appearance: none;
|
|
1882
|
+
-webkit-appearance: none;
|
|
1883
|
+
background-image: var(--lb-variant-chevron);
|
|
1884
|
+
background-repeat: no-repeat;
|
|
1885
|
+
background-position: right 8px center;
|
|
1886
|
+
background-size: 12px;
|
|
1887
|
+
max-width: 100%;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
.lb-bundle-variant-select:focus-visible {
|
|
1891
|
+
outline: 2px solid var(--lb-primary-color);
|
|
1892
|
+
outline-offset: 2px;
|
|
1893
|
+
}
|
|
1894
|
+
`;
|
|
1895
|
+
var BUNDLE_MIX_MATCH_CSS = `/* Lime Bundles \u2014 Mix & Match styles */
|
|
1896
|
+
|
|
1897
|
+
/* === Progress Bar === */
|
|
1898
|
+
.lb-mix-match__progress {
|
|
1899
|
+
margin-bottom: 16px;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
.lb-mix-match__progress-labels {
|
|
1903
|
+
display: flex;
|
|
1904
|
+
justify-content: space-between;
|
|
1905
|
+
margin-bottom: 8px;
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
.lb-mix-match__progress-count {
|
|
1909
|
+
font-size: 12px;
|
|
1910
|
+
font-weight: 500;
|
|
1911
|
+
line-height: 16px;
|
|
1912
|
+
color: color-mix(in srgb, var(--lb-text) 60%, transparent);
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
.lb-mix-match__progress-remaining {
|
|
1916
|
+
font-size: 12px;
|
|
1917
|
+
font-weight: 500;
|
|
1918
|
+
line-height: 16px;
|
|
1919
|
+
color: var(--lb-text);
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
.lb-mix-match__progress-track {
|
|
1923
|
+
width: 100%;
|
|
1924
|
+
height: 4px;
|
|
1925
|
+
background: color-mix(in srgb, var(--lb-text) 10%, transparent);
|
|
1926
|
+
border-radius: 4px;
|
|
1927
|
+
overflow: hidden;
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
.lb-mix-match__progress-fill {
|
|
1931
|
+
height: 100%;
|
|
1932
|
+
background: var(--lb-text);
|
|
1933
|
+
border-radius: 4px;
|
|
1934
|
+
transition: width 0.3s ease;
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
/* === Slots === */
|
|
1938
|
+
.lb-mix-match__slot {
|
|
1939
|
+
cursor: pointer;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
.lb-mix-match .lb-bundle-product-row {
|
|
1943
|
+
align-items: center;
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
.lb-mix-match__slot--empty:focus-visible {
|
|
1947
|
+
outline: 2px solid var(--lb-primary-color);
|
|
1948
|
+
outline-offset: 2px;
|
|
1949
|
+
border-radius: 8px;
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
.lb-mix-match__slot--empty .lb-mix-match__empty-thumb {
|
|
1953
|
+
width: 60px;
|
|
1954
|
+
height: 60px;
|
|
1955
|
+
min-width: 60px;
|
|
1956
|
+
border: var(--lb-image-border-width) dashed color-mix(in srgb, var(--lb-text) 20%, transparent);
|
|
1957
|
+
border-radius: var(--lb-image-border-radius);
|
|
1958
|
+
box-sizing: border-box;
|
|
1959
|
+
display: flex;
|
|
1960
|
+
align-items: center;
|
|
1961
|
+
justify-content: center;
|
|
1962
|
+
color: color-mix(in srgb, var(--lb-text) 35%, transparent);
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
.lb-mix-match__empty-text {
|
|
1966
|
+
font-size: 16px;
|
|
1967
|
+
line-height: 20px;
|
|
1968
|
+
color: color-mix(in srgb, var(--lb-text) 45%, transparent);
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
/* Filled slot */
|
|
1972
|
+
.lb-mix-match__slot--filled {
|
|
1973
|
+
cursor: default;
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
.lb-mix-match .lb-bundle-thumbnail {
|
|
1977
|
+
width: 60px;
|
|
1978
|
+
height: 60px;
|
|
1979
|
+
min-width: 60px;
|
|
1980
|
+
border-radius: var(--lb-image-border-radius);
|
|
1981
|
+
border: var(--lb-image-border-width) solid var(--lb-image-border-color);
|
|
1982
|
+
box-sizing: border-box;
|
|
1983
|
+
overflow: visible;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
.lb-mix-match .lb-bundle-thumbnail img {
|
|
1987
|
+
border-radius: max(0px, calc(var(--lb-image-border-radius) - var(--lb-image-border-width)));
|
|
1988
|
+
border: none;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
.lb-mix-match__slot--filled .lb-mix-match__filled-info {
|
|
1992
|
+
flex: 1;
|
|
1993
|
+
min-width: 0;
|
|
1994
|
+
display: flex;
|
|
1995
|
+
flex-direction: column;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
.lb-mix-match__slot--filled .lb-mix-match__filled-title {
|
|
1999
|
+
font-size: 16px;
|
|
2000
|
+
font-weight: 700;
|
|
2001
|
+
line-height: 20px;
|
|
2002
|
+
color: var(--lb-text);
|
|
2003
|
+
text-decoration: none;
|
|
2004
|
+
overflow-wrap: break-word;
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
.lb-mix-match__slot--filled a.lb-mix-match__filled-title:hover {
|
|
2008
|
+
text-decoration: underline;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
.lb-mix-match__slot--filled .lb-mix-match__filled-variant {
|
|
2012
|
+
font-size: 12px;
|
|
2013
|
+
line-height: 20px;
|
|
2014
|
+
margin-top: 2px;
|
|
2015
|
+
color: color-mix(in srgb, var(--lb-text) 60%, transparent);
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
.lb-mix-match__filled-price {
|
|
2019
|
+
/* --lb-product-price-display fallback is the "on" branch; Liquid sets 'none' when merchant disables. */
|
|
2020
|
+
display: var(--lb-product-price-display, block);
|
|
2021
|
+
font-size: 12px;
|
|
2022
|
+
line-height: 20px;
|
|
2023
|
+
margin-top: 4px;
|
|
2024
|
+
color: var(--lb-text);
|
|
2025
|
+
font-weight: 500;
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
.lb-mix-match__filled-compare {
|
|
2029
|
+
/* --lb-product-compare-display fallback is the "on" branch; Liquid sets 'none' when merchant disables. */
|
|
2030
|
+
display: var(--lb-product-compare-display, inline);
|
|
2031
|
+
font-size: 12px;
|
|
2032
|
+
font-weight: 400;
|
|
2033
|
+
color: color-mix(in srgb, var(--lb-text) 60%, transparent);
|
|
2034
|
+
text-decoration: line-through;
|
|
2035
|
+
margin-right: 4px;
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
.lb-mix-match__slot-remove {
|
|
2039
|
+
min-width: 44px;
|
|
2040
|
+
min-height: 44px;
|
|
2041
|
+
display: flex;
|
|
2042
|
+
align-items: center;
|
|
2043
|
+
justify-content: center;
|
|
2044
|
+
background: none;
|
|
2045
|
+
border: none;
|
|
2046
|
+
cursor: pointer;
|
|
2047
|
+
color: var(--lb-text);
|
|
2048
|
+
padding: 0;
|
|
2049
|
+
margin-left: auto;
|
|
2050
|
+
border-radius: 8px;
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
.lb-mix-match__slot-remove:hover {
|
|
2054
|
+
color: var(--lb-text);
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
.lb-mix-match__slot-remove:focus-visible {
|
|
2058
|
+
outline: 2px solid var(--lb-primary-color);
|
|
2059
|
+
outline-offset: 2px;
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
/* Price placeholder */
|
|
2063
|
+
.lb-mix-match__price-placeholder {
|
|
2064
|
+
padding: 4px 0 16px;
|
|
2065
|
+
text-align: center;
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
.lb-mix-match__price-placeholder-text {
|
|
2069
|
+
font-size: 16px;
|
|
2070
|
+
color: var(--lb-text);
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
/* === Modal Overlay === */
|
|
2074
|
+
.lb-mix-match__modal-overlay {
|
|
2075
|
+
position: fixed;
|
|
2076
|
+
top: 0;
|
|
2077
|
+
left: 0;
|
|
2078
|
+
right: 0;
|
|
2079
|
+
bottom: 0;
|
|
2080
|
+
background: rgba(0, 0, 0, 0.5);
|
|
2081
|
+
z-index: 9999;
|
|
2082
|
+
display: flex;
|
|
2083
|
+
align-items: center;
|
|
2084
|
+
justify-content: center;
|
|
2085
|
+
opacity: 0;
|
|
2086
|
+
transition: opacity 0.2s ease-out;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
.lb-mix-match__modal-overlay--open {
|
|
2090
|
+
opacity: 1;
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
/* === Modal Panel === */
|
|
2094
|
+
.lb-mix-match__modal {
|
|
2095
|
+
background: var(--lb-picker-bg);
|
|
2096
|
+
color: var(--lb-picker-text);
|
|
2097
|
+
border-radius: var(--lb-picker-radius);
|
|
2098
|
+
border: var(--lb-picker-border-width) solid var(--lb-picker-border-color);
|
|
2099
|
+
box-sizing: border-box;
|
|
2100
|
+
width: 100%;
|
|
2101
|
+
max-width: 480px;
|
|
2102
|
+
max-height: 70vh;
|
|
2103
|
+
display: flex;
|
|
2104
|
+
flex-direction: column;
|
|
2105
|
+
overflow: hidden;
|
|
2106
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
|
|
2107
|
+
transform: translateY(24px);
|
|
2108
|
+
transition: transform 0.25s ease-out;
|
|
2109
|
+
will-change: transform;
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
.lb-mix-match__modal-overlay--open .lb-mix-match__modal {
|
|
2113
|
+
transform: translateY(0);
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
/* === Modal Header === */
|
|
2117
|
+
.lb-mix-match__modal-header {
|
|
2118
|
+
display: flex;
|
|
2119
|
+
align-items: center;
|
|
2120
|
+
justify-content: space-between;
|
|
2121
|
+
padding: 20px 20px 12px;
|
|
2122
|
+
flex-shrink: 0;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
.lb-mix-match__modal-title {
|
|
2126
|
+
font-size: 20px;
|
|
2127
|
+
font-weight: 600;
|
|
2128
|
+
line-height: 24px;
|
|
2129
|
+
margin: 0;
|
|
2130
|
+
color: inherit;
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
.lb-mix-match__modal-close {
|
|
2134
|
+
min-width: 44px;
|
|
2135
|
+
min-height: 44px;
|
|
2136
|
+
display: flex;
|
|
2137
|
+
align-items: center;
|
|
2138
|
+
justify-content: center;
|
|
2139
|
+
background: none;
|
|
2140
|
+
border: none;
|
|
2141
|
+
cursor: pointer;
|
|
2142
|
+
color: var(--lb-picker-text);
|
|
2143
|
+
border-radius: 8px;
|
|
2144
|
+
padding: 0;
|
|
2145
|
+
margin: -12px -12px -12px 0;
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
.lb-mix-match__modal-close:focus-visible {
|
|
2149
|
+
outline: 2px solid var(--lb-primary-color);
|
|
2150
|
+
outline-offset: 2px;
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
/* === Modal Search === */
|
|
2154
|
+
.lb-mix-match__modal-search {
|
|
2155
|
+
padding: 0 20px 12px;
|
|
2156
|
+
position: relative;
|
|
2157
|
+
flex-shrink: 0;
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
.lb-mix-match__modal-search-input {
|
|
2161
|
+
width: 100%;
|
|
2162
|
+
padding: 12px 40px 12px 16px;
|
|
2163
|
+
border: var(--lb-picker-search-border-width) solid var(--lb-picker-search-border-color);
|
|
2164
|
+
border-radius: var(--lb-picker-search-radius);
|
|
2165
|
+
font-size: 16px;
|
|
2166
|
+
line-height: 20px;
|
|
2167
|
+
color: var(--lb-picker-text);
|
|
2168
|
+
background: var(--lb-picker-bg);
|
|
2169
|
+
box-sizing: border-box;
|
|
2170
|
+
-webkit-appearance: none;
|
|
2171
|
+
appearance: none;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
.lb-mix-match__modal-search-input::placeholder {
|
|
2175
|
+
color: color-mix(in srgb, var(--lb-picker-text) 50%, transparent);
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
.lb-mix-match__modal-search-input:focus {
|
|
2179
|
+
outline: none;
|
|
2180
|
+
box-shadow: 0 0 0 1px var(--lb-primary-color);
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
.lb-mix-match__modal-search-clear {
|
|
2184
|
+
position: absolute;
|
|
2185
|
+
right: 32px;
|
|
2186
|
+
/* Anchor to the input area only \u2014 parent has padding-bottom: 12px which would
|
|
2187
|
+
otherwise push a top:50% center down by 6px. */
|
|
2188
|
+
top: 0;
|
|
2189
|
+
bottom: 12px;
|
|
2190
|
+
min-width: 32px;
|
|
2191
|
+
min-height: 32px;
|
|
2192
|
+
display: flex;
|
|
2193
|
+
align-items: center;
|
|
2194
|
+
justify-content: center;
|
|
2195
|
+
background: none;
|
|
2196
|
+
border: none;
|
|
2197
|
+
cursor: pointer;
|
|
2198
|
+
color: var(--lb-picker-text);
|
|
2199
|
+
padding: 0;
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
/* === Modal Product List === */
|
|
2203
|
+
.lb-mix-match__modal-list {
|
|
2204
|
+
overflow-y: auto;
|
|
2205
|
+
flex: 1;
|
|
2206
|
+
padding: 0 20px;
|
|
2207
|
+
-webkit-overflow-scrolling: touch;
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
.lb-mix-match__modal-product {
|
|
2211
|
+
display: flex;
|
|
2212
|
+
align-items: center;
|
|
2213
|
+
gap: 12px;
|
|
2214
|
+
padding: 12px 0;
|
|
2215
|
+
border-bottom: 1px solid color-mix(in srgb, var(--lb-picker-text) 7%, transparent);
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
.lb-mix-match__modal-product:last-child {
|
|
2219
|
+
border-bottom: none;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
.lb-mix-match__modal-product-thumb {
|
|
2223
|
+
position: relative;
|
|
2224
|
+
width: 48px;
|
|
2225
|
+
height: 48px;
|
|
2226
|
+
min-width: 48px;
|
|
2227
|
+
border-radius: var(--lb-picker-product-radius);
|
|
2228
|
+
border: var(--lb-picker-product-border-width) solid var(--lb-picker-product-border-color);
|
|
2229
|
+
box-sizing: border-box;
|
|
2230
|
+
overflow: visible;
|
|
2231
|
+
background: #F0F0F0;
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
/* Qty badge inside the picker modal inherits picker-product border (width + color) plus
|
|
2235
|
+
inverted picker bg/text for clear contrast against the modal \u2014 always stays round
|
|
2236
|
+
(the badge shape is independent of the thumbnail shape). */
|
|
2237
|
+
.lb-mix-match__modal-product-thumb .lb-bundle-qty-badge.lb-bundle-qty-badge {
|
|
2238
|
+
/* --lb-picker-qty-badge-display fallback is the "on" branch; Liquid sets 'none' when merchant disables. */
|
|
2239
|
+
display: var(--lb-picker-qty-badge-display, flex);
|
|
2240
|
+
background: var(--lb-picker-qty-badge-bg);
|
|
2241
|
+
color: var(--lb-picker-qty-badge-color);
|
|
2242
|
+
border: var(--lb-picker-product-border-width) solid var(--lb-picker-product-border-color);
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
.lb-mix-match__modal-product-thumb img {
|
|
2246
|
+
width: 100%;
|
|
2247
|
+
height: 100%;
|
|
2248
|
+
object-fit: cover;
|
|
2249
|
+
border-radius: max(0px, calc(var(--lb-picker-product-radius) - var(--lb-picker-product-border-width)));
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
.lb-mix-match__modal-product-info {
|
|
2253
|
+
flex: 1;
|
|
2254
|
+
min-width: 0;
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
.lb-mix-match__modal-product-title {
|
|
2258
|
+
font-size: 16px;
|
|
2259
|
+
font-weight: 700;
|
|
2260
|
+
line-height: 20px;
|
|
2261
|
+
color: inherit;
|
|
2262
|
+
margin: 0;
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
.lb-mix-match__modal-product-price {
|
|
2266
|
+
font-size: 12px;
|
|
2267
|
+
line-height: 20px;
|
|
2268
|
+
color: inherit;
|
|
2269
|
+
margin: 4px 0 0;
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
.lb-mix-match__variant-select {
|
|
2273
|
+
font-size: 12px;
|
|
2274
|
+
margin: 4px 0 0;
|
|
2275
|
+
padding: 4px 24px 4px 8px;
|
|
2276
|
+
border: var(--lb-picker-variant-border-width) solid var(--lb-picker-variant-border-color);
|
|
2277
|
+
border-radius: var(--lb-picker-variant-radius);
|
|
2278
|
+
background-color: var(--lb-picker-bg);
|
|
2279
|
+
background-image: var(--lb-picker-variant-chevron);
|
|
2280
|
+
background-repeat: no-repeat;
|
|
2281
|
+
background-position: right 6px center;
|
|
2282
|
+
background-size: 12px;
|
|
2283
|
+
color: var(--lb-picker-text);
|
|
2284
|
+
font-family: inherit;
|
|
2285
|
+
min-height: 32px;
|
|
2286
|
+
cursor: pointer;
|
|
2287
|
+
max-width: 120px;
|
|
2288
|
+
appearance: none;
|
|
2289
|
+
-webkit-appearance: none;
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
.lb-mix-match__variant-select:focus-visible {
|
|
2293
|
+
outline: 2px solid var(--lb-primary-color);
|
|
2294
|
+
outline-offset: 2px;
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
.lb-mix-match__modal-add {
|
|
2298
|
+
padding: 8px 20px;
|
|
2299
|
+
background: var(--lb-picker-add-bg);
|
|
2300
|
+
color: var(--lb-picker-add-label);
|
|
2301
|
+
border: var(--lb-picker-add-border-width) solid var(--lb-picker-add-border-color);
|
|
2302
|
+
border-radius: var(--lb-picker-add-radius);
|
|
2303
|
+
box-sizing: border-box;
|
|
2304
|
+
font-size: 12px;
|
|
2305
|
+
font-weight: 600;
|
|
2306
|
+
cursor: pointer;
|
|
2307
|
+
white-space: nowrap;
|
|
2308
|
+
flex-shrink: 0;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
.lb-mix-match__modal-add:hover {
|
|
2312
|
+
opacity: 0.9;
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
.lb-mix-match__modal-add:focus-visible {
|
|
2316
|
+
outline: 2px solid var(--lb-primary-color);
|
|
2317
|
+
outline-offset: 2px;
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
.lb-mix-match__modal-add:disabled {
|
|
2321
|
+
background: color-mix(in srgb, var(--lb-picker-add-bg) 35%, var(--lb-picker-bg));
|
|
2322
|
+
color: color-mix(in srgb, var(--lb-picker-add-label) 85%, transparent);
|
|
2323
|
+
cursor: not-allowed;
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
/* Sold out product row */
|
|
2327
|
+
.lb-mix-match__modal-product--sold-out {
|
|
2328
|
+
opacity: 0.5;
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
.lb-mix-match__modal-product--sold-out .lb-mix-match__modal-sold-out-label {
|
|
2332
|
+
font-size: 12px;
|
|
2333
|
+
color: inherit;
|
|
2334
|
+
font-weight: 500;
|
|
2335
|
+
white-space: nowrap;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
/* === Modal Empty State === */
|
|
2339
|
+
.lb-mix-match__modal-empty {
|
|
2340
|
+
padding: 32px 20px;
|
|
2341
|
+
text-align: center;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
.lb-mix-match__modal-empty p {
|
|
2345
|
+
margin: 0;
|
|
2346
|
+
font-size: 16px;
|
|
2347
|
+
color: var(--lb-picker-text);
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
/* Hidden utility for search filtering */
|
|
2351
|
+
.lb-hidden {
|
|
2352
|
+
display: none !important;
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
/* === Mobile Full-Screen Modal === */
|
|
2356
|
+
@media (max-width: 767px) {
|
|
2357
|
+
.lb-mix-match__modal-overlay {
|
|
2358
|
+
align-items: flex-end;
|
|
151
2359
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const total = Array.from(selections.values()).reduce(
|
|
163
|
-
(s, v) => s + v.quantity,
|
|
164
|
-
0
|
|
165
|
-
);
|
|
166
|
-
const validation = (0, import_core2.validateQuantity)(
|
|
167
|
-
total,
|
|
168
|
-
bundle.minQuantity,
|
|
169
|
-
bundle.maxQuantity
|
|
170
|
-
);
|
|
171
|
-
button.disabled = !validation.valid;
|
|
172
|
-
button.textContent = bundle.widgetConfig.ctaText ?? `Add ${total} Items to Cart`;
|
|
173
|
-
validationEl.textContent = validation.message ?? "";
|
|
2360
|
+
|
|
2361
|
+
.lb-mix-match__modal {
|
|
2362
|
+
max-width: 100%;
|
|
2363
|
+
max-height: 90vh;
|
|
2364
|
+
border-radius: 16px 16px 0 0;
|
|
2365
|
+
transform: translateY(100%);
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
.lb-mix-match__modal-overlay--open .lb-mix-match__modal {
|
|
2369
|
+
transform: translateY(0);
|
|
174
2370
|
}
|
|
175
|
-
updateCta();
|
|
176
|
-
button.addEventListener("click", () => {
|
|
177
|
-
const lines = Array.from(selections.values()).map((s) => ({
|
|
178
|
-
merchandiseId: s.variantId,
|
|
179
|
-
quantity: s.quantity,
|
|
180
|
-
attributes: [
|
|
181
|
-
{ key: "_lime_bundle_gid", value: bundle.id },
|
|
182
|
-
{ key: "_lime_bundle_type", value: bundle.bundleType }
|
|
183
|
-
]
|
|
184
|
-
}));
|
|
185
|
-
if (lines.length === 0) return;
|
|
186
|
-
onAddToCart(lines);
|
|
187
|
-
});
|
|
188
2371
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
2372
|
+
|
|
2373
|
+
/* === Reduced Motion === */
|
|
2374
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2375
|
+
.lb-mix-match__modal-overlay,
|
|
2376
|
+
.lb-mix-match__modal,
|
|
2377
|
+
.lb-mix-match__progress-fill {
|
|
2378
|
+
transition: none;
|
|
2379
|
+
}
|
|
193
2380
|
}
|
|
2381
|
+
`;
|
|
2382
|
+
var BUNDLE_VOLUME_CSS = `/* Lime Bundles \u2014 Volume / Quantity Breaks styles */
|
|
194
2383
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const minusBtn = document.createElement("button");
|
|
239
|
-
minusBtn.textContent = "\u2212";
|
|
240
|
-
minusBtn.setAttribute("aria-label", "Decrease quantity");
|
|
241
|
-
const qtyInput = document.createElement("input");
|
|
242
|
-
qtyInput.type = "number";
|
|
243
|
-
qtyInput.min = "1";
|
|
244
|
-
qtyInput.value = "1";
|
|
245
|
-
qtyInput.className = "lb-bundle__quantity-input";
|
|
246
|
-
const plusBtn = document.createElement("button");
|
|
247
|
-
plusBtn.textContent = "+";
|
|
248
|
-
plusBtn.setAttribute("aria-label", "Increase quantity");
|
|
249
|
-
qtyControl.append(minusBtn, qtyInput, plusBtn);
|
|
250
|
-
qtyWrapper.appendChild(qtyControl);
|
|
251
|
-
container.appendChild(qtyWrapper);
|
|
252
|
-
const button = document.createElement("button");
|
|
253
|
-
button.className = "lb-bundle__cta";
|
|
254
|
-
button.setAttribute("part", "button");
|
|
255
|
-
container.appendChild(button);
|
|
256
|
-
function updateTiers() {
|
|
257
|
-
const savings = (0, import_core3.calculateTierSavings)(
|
|
258
|
-
bundle.volumeTiers,
|
|
259
|
-
basePrice,
|
|
260
|
-
quantity
|
|
261
|
-
);
|
|
262
|
-
tiersDiv.innerHTML = "";
|
|
263
|
-
for (const ts of savings) {
|
|
264
|
-
const row = document.createElement("div");
|
|
265
|
-
row.className = `lb-bundle__tier${ts.isActive ? " lb-bundle__tier--active" : ""}`;
|
|
266
|
-
row.setAttribute("role", "row");
|
|
267
|
-
row.innerHTML = `
|
|
268
|
-
<span class="lb-bundle__tier-quantity" role="cell">${ts.tier.minQuantity}+ items</span>
|
|
269
|
-
<span class="lb-bundle__tier-price" role="cell">${escapeHtml3((0, import_core3.formatMoney)(ts.unitPrice, currency))} each</span>
|
|
270
|
-
<span class="lb-bundle__tier-savings" role="cell">Save ${ts.savingsPercent.toFixed(0)}%</span>
|
|
271
|
-
${ts.tier.label ? `<span class="lb-bundle__tier-label" role="cell">${escapeHtml3(ts.tier.label)}</span>` : ""}
|
|
272
|
-
`;
|
|
273
|
-
tiersDiv.appendChild(row);
|
|
274
|
-
}
|
|
275
|
-
button.textContent = bundle.widgetConfig.ctaText ?? `Add ${quantity} to Cart`;
|
|
276
|
-
}
|
|
277
|
-
updateTiers();
|
|
278
|
-
minusBtn.addEventListener("click", () => {
|
|
279
|
-
if (quantity > 1) {
|
|
280
|
-
quantity--;
|
|
281
|
-
qtyInput.value = String(quantity);
|
|
282
|
-
updateTiers();
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
plusBtn.addEventListener("click", () => {
|
|
286
|
-
quantity++;
|
|
287
|
-
qtyInput.value = String(quantity);
|
|
288
|
-
updateTiers();
|
|
289
|
-
});
|
|
290
|
-
qtyInput.addEventListener("change", () => {
|
|
291
|
-
const val = parseInt(qtyInput.value, 10);
|
|
292
|
-
if (!isNaN(val) && val > 0) {
|
|
293
|
-
quantity = val;
|
|
294
|
-
updateTiers();
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
button.addEventListener("click", () => {
|
|
298
|
-
const variant = product.variants.nodes.find((v) => v.availableForSale);
|
|
299
|
-
if (!variant) return;
|
|
300
|
-
onAddToCart([
|
|
301
|
-
{
|
|
302
|
-
merchandiseId: variant.id,
|
|
303
|
-
quantity,
|
|
304
|
-
attributes: [
|
|
305
|
-
{ key: "_lime_bundle_gid", value: bundle.id },
|
|
306
|
-
{ key: "_lime_bundle_type", value: bundle.bundleType }
|
|
307
|
-
]
|
|
308
|
-
}
|
|
309
|
-
]);
|
|
310
|
-
});
|
|
2384
|
+
.lb-volume__tiers {
|
|
2385
|
+
display: flex;
|
|
2386
|
+
flex-direction: column;
|
|
2387
|
+
gap: 12px;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
.lb-volume__tier {
|
|
2391
|
+
display: flex;
|
|
2392
|
+
align-items: center;
|
|
2393
|
+
gap: 12px;
|
|
2394
|
+
border: var(--lb-tier-border-width) solid var(--lb-tier-border-color);
|
|
2395
|
+
border-radius: var(--lb-tier-radius);
|
|
2396
|
+
padding: 12px 16px;
|
|
2397
|
+
cursor: pointer;
|
|
2398
|
+
position: relative;
|
|
2399
|
+
transition: border-color 0.15s ease;
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
.lb-volume__tier:hover {
|
|
2403
|
+
border-color: color-mix(in srgb, var(--lb-tier-border-color) 50%, black);
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
.lb-volume__tier:focus-visible {
|
|
2407
|
+
outline: 2px solid var(--lb-primary-color);
|
|
2408
|
+
outline-offset: 2px;
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
.lb-volume__tier[aria-checked="true"] {
|
|
2412
|
+
border-color: var(--lb-tier-selected-border-color);
|
|
2413
|
+
outline: var(--lb-tier-selected-border-width) solid var(--lb-tier-selected-border-color);
|
|
2414
|
+
outline-offset: calc(-1 * var(--lb-tier-selected-border-width));
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
.lb-volume__radio {
|
|
2418
|
+
width: 20px;
|
|
2419
|
+
height: 20px;
|
|
2420
|
+
min-width: 20px;
|
|
2421
|
+
border: 2px solid var(--lb-text);
|
|
2422
|
+
border-radius: 50%;
|
|
2423
|
+
display: flex;
|
|
2424
|
+
align-items: center;
|
|
2425
|
+
justify-content: center;
|
|
2426
|
+
transition: border-color 0.15s ease;
|
|
311
2427
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
2428
|
+
|
|
2429
|
+
.lb-volume__tier[aria-checked="true"] .lb-volume__radio {
|
|
2430
|
+
border-color: var(--lb-text);
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
.lb-volume__radio-dot {
|
|
2434
|
+
width: 12px;
|
|
2435
|
+
height: 12px;
|
|
2436
|
+
border-radius: 50%;
|
|
2437
|
+
background: transparent;
|
|
2438
|
+
transition: background 0.15s ease;
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
.lb-volume__tier[aria-checked="true"] .lb-volume__radio-dot {
|
|
2442
|
+
background: var(--lb-text);
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
/* Tier content: 2x2 grid layout */
|
|
2446
|
+
.lb-volume__tier-grid {
|
|
2447
|
+
flex: 1;
|
|
2448
|
+
display: grid;
|
|
2449
|
+
row-gap: 4px;
|
|
2450
|
+
align-items: center;
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
.lb-volume__tier-label {
|
|
2454
|
+
font-size: 16px;
|
|
2455
|
+
font-weight: 700;
|
|
2456
|
+
color: var(--lb-text);
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2459
|
+
.lb-volume__tier-badge {
|
|
2460
|
+
flex-shrink: 0;
|
|
2461
|
+
font-size: 12px;
|
|
2462
|
+
line-height: 16px;
|
|
2463
|
+
color: var(--lb-popular-badge-text);
|
|
2464
|
+
background: var(--lb-popular-badge-bg);
|
|
2465
|
+
border: var(--lb-popular-badge-border-width) solid var(--lb-popular-badge-border-color);
|
|
2466
|
+
border-radius: var(--lb-popular-badge-radius);
|
|
2467
|
+
padding: 4px 8px;
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
.lb-volume__tier-price {
|
|
2471
|
+
grid-column: 1 / -1;
|
|
2472
|
+
font-size: 12px;
|
|
2473
|
+
font-weight: 500;
|
|
2474
|
+
color: var(--lb-text);
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
.lb-volume__tier-unit {
|
|
2478
|
+
font-size: 12px;
|
|
2479
|
+
color: var(--lb-text);
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
/* Compare-at (strikethrough) price */
|
|
2483
|
+
.lb-volume__tier-compare {
|
|
2484
|
+
font-size: 12px;
|
|
2485
|
+
line-height: 16px;
|
|
2486
|
+
color: color-mix(in srgb, var(--lb-text) 60%, transparent);
|
|
2487
|
+
text-decoration: line-through;
|
|
2488
|
+
margin-right: 4px;
|
|
316
2489
|
}
|
|
317
2490
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
2491
|
+
|
|
2492
|
+
`;
|
|
2493
|
+
var BUNDLE_SKELETON_CSS = `/* Lime Bundles \u2014 web-component loading skeleton (not mirrored to theme assets) */
|
|
2494
|
+
|
|
2495
|
+
.lb-bundle-widget--loading {
|
|
321
2496
|
display: block;
|
|
322
|
-
--lb-
|
|
323
|
-
--lb-
|
|
324
|
-
--lb-
|
|
325
|
-
--lb-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
.lb-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
.lb-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
.lb-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
.lb-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
.lb-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
2497
|
+
padding: var(--lb-widget-pad, 20px);
|
|
2498
|
+
border: 1px solid var(--lb-border, #E5E5E5);
|
|
2499
|
+
border-radius: var(--lb-radius, 12px);
|
|
2500
|
+
background: var(--lb-bg, #FFFFFF);
|
|
2501
|
+
/* Contain layout/paint so the skeleton doesn't influence ancestor
|
|
2502
|
+
layout once the real content swaps in. */
|
|
2503
|
+
contain: layout paint;
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
.lb-bundle-widget--loading .lb-skeleton {
|
|
2507
|
+
background: linear-gradient(
|
|
2508
|
+
90deg,
|
|
2509
|
+
rgba(0, 0, 0, 0.06) 0%,
|
|
2510
|
+
rgba(0, 0, 0, 0.10) 50%,
|
|
2511
|
+
rgba(0, 0, 0, 0.06) 100%
|
|
2512
|
+
);
|
|
2513
|
+
background-size: 200% 100%;
|
|
2514
|
+
border-radius: 6px;
|
|
2515
|
+
animation: lb-skeleton-pulse 1.4s ease-in-out infinite;
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2518
|
+
.lb-bundle-widget--loading .lb-skeleton--title {
|
|
2519
|
+
height: 28px;
|
|
2520
|
+
width: 60%;
|
|
2521
|
+
margin-bottom: 16px;
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
.lb-bundle-widget--loading .lb-skeleton--products {
|
|
2525
|
+
display: grid;
|
|
2526
|
+
gap: 12px;
|
|
2527
|
+
margin-bottom: 16px;
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
.lb-bundle-widget--loading .lb-skeleton--row {
|
|
2531
|
+
display: grid;
|
|
2532
|
+
grid-template-columns: 56px 1fr 60px;
|
|
2533
|
+
gap: 12px;
|
|
2534
|
+
align-items: center;
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
.lb-bundle-widget--loading .lb-skeleton--thumb {
|
|
2538
|
+
height: 56px;
|
|
2539
|
+
width: 56px;
|
|
2540
|
+
border-radius: 8px;
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
.lb-bundle-widget--loading .lb-skeleton--line {
|
|
2544
|
+
height: 14px;
|
|
2545
|
+
border-radius: 4px;
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
.lb-bundle-widget--loading .lb-skeleton--line + .lb-skeleton--line {
|
|
2549
|
+
margin-top: 8px;
|
|
2550
|
+
width: 70%;
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
.lb-bundle-widget--loading .lb-skeleton--price {
|
|
2554
|
+
height: 20px;
|
|
2555
|
+
width: 60px;
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
.lb-bundle-widget--loading .lb-skeleton--footer {
|
|
2559
|
+
margin-top: 16px;
|
|
2560
|
+
padding-top: 16px;
|
|
2561
|
+
border-top: 1px solid var(--lb-border, #E5E5E5);
|
|
2562
|
+
display: grid;
|
|
2563
|
+
grid-template-columns: 1fr auto;
|
|
2564
|
+
gap: 12px;
|
|
2565
|
+
align-items: center;
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
.lb-bundle-widget--loading .lb-skeleton--total {
|
|
2569
|
+
height: 24px;
|
|
2570
|
+
width: 40%;
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
.lb-bundle-widget--loading .lb-skeleton--cta {
|
|
2574
|
+
height: 44px;
|
|
2575
|
+
width: 140px;
|
|
2576
|
+
border-radius: var(--lb-cta-radius, 8px);
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
@keyframes lb-skeleton-pulse {
|
|
2580
|
+
0% { background-position: 0% 50%; }
|
|
2581
|
+
100% { background-position: -200% 50%; }
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2585
|
+
.lb-bundle-widget--loading .lb-skeleton {
|
|
2586
|
+
animation: none;
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
382
2589
|
`;
|
|
383
2590
|
|
|
384
2591
|
// src/lime-bundle.ts
|
|
@@ -411,22 +2618,38 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
411
2618
|
bundles = [];
|
|
412
2619
|
abortController = null;
|
|
413
2620
|
impressionCleanups = [];
|
|
2621
|
+
/**
|
|
2622
|
+
* Tick / observer / listener cleanups registered by individual renderers
|
|
2623
|
+
* (e.g. countdown setInterval handles). Flushed in disconnectedCallback
|
|
2624
|
+
* so we never leak timers or event listeners when the widget is removed.
|
|
2625
|
+
*/
|
|
2626
|
+
renderCleanups = [];
|
|
2627
|
+
/**
|
|
2628
|
+
* Merchant custom CSS fetched from the shop metafield. Injected inside
|
|
2629
|
+
* the shadow root alongside the bundle stylesheets so selectors like
|
|
2630
|
+
* `.lb-bundle-widget { ... }` reach the widget's DOM.
|
|
2631
|
+
*/
|
|
2632
|
+
shopCustomCss = null;
|
|
414
2633
|
constructor() {
|
|
415
2634
|
super();
|
|
416
2635
|
this.shadow = this.attachShadow({ mode: "open" });
|
|
417
2636
|
}
|
|
418
2637
|
connectedCallback() {
|
|
419
|
-
this.render();
|
|
420
2638
|
this.fetchBundle();
|
|
421
2639
|
}
|
|
422
2640
|
disconnectedCallback() {
|
|
423
2641
|
this.abortController?.abort();
|
|
424
2642
|
this.teardownImpressions();
|
|
2643
|
+
this.teardownRenderers();
|
|
425
2644
|
}
|
|
426
2645
|
teardownImpressions() {
|
|
427
2646
|
for (const cleanup of this.impressionCleanups) cleanup();
|
|
428
2647
|
this.impressionCleanups = [];
|
|
429
2648
|
}
|
|
2649
|
+
teardownRenderers() {
|
|
2650
|
+
for (const cleanup of this.renderCleanups) cleanup();
|
|
2651
|
+
this.renderCleanups = [];
|
|
2652
|
+
}
|
|
430
2653
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
431
2654
|
if (oldValue === newValue || !this.isConnected) return;
|
|
432
2655
|
if (name === "bundle-gid" || name === "product-handle" || name === "shop-domain" || name === "storefront-token") {
|
|
@@ -502,7 +2725,10 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
502
2725
|
const css = await cssPromise;
|
|
503
2726
|
if (css?.shop?.metafield?.value) {
|
|
504
2727
|
(0, import_core4.injectCustomCss)(this.shopDomain, css.shop.metafield.value);
|
|
2728
|
+
const sanitized = (0, import_core4.sanitizeCustomCss)(css.shop.metafield.value);
|
|
2729
|
+
if (sanitized.ok) this.shopCustomCss = sanitized.css;
|
|
505
2730
|
}
|
|
2731
|
+
await this.applyABVariants();
|
|
506
2732
|
this.renderBundles();
|
|
507
2733
|
} catch (err) {
|
|
508
2734
|
if (controller.signal.aborted) return;
|
|
@@ -513,6 +2739,40 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
513
2739
|
);
|
|
514
2740
|
}
|
|
515
2741
|
}
|
|
2742
|
+
/**
|
|
2743
|
+
* Resolve the visitor's A/B bucket for every bundle with an active test
|
|
2744
|
+
* and merge Variant B overrides where applicable. Runs in parallel; any
|
|
2745
|
+
* assignment failure logs internally but still renders Variant A (safe
|
|
2746
|
+
* default). The `getABTestAssignment` helper also persists the bucket
|
|
2747
|
+
* via a first-party cookie + POSTs to /api/ab-assign for server-side
|
|
2748
|
+
* analytics.
|
|
2749
|
+
*/
|
|
2750
|
+
async applyABVariants() {
|
|
2751
|
+
if (!this.appUrl || this.bundles.length === 0) return;
|
|
2752
|
+
const results = await Promise.all(
|
|
2753
|
+
this.bundles.map(async (bundle) => {
|
|
2754
|
+
if (!bundle.abTestId || !bundle.abVariantB) return bundle;
|
|
2755
|
+
try {
|
|
2756
|
+
const assignment = await (0, import_core4.getABTestAssignment)(
|
|
2757
|
+
this.appUrl,
|
|
2758
|
+
this.shopDomain,
|
|
2759
|
+
bundle.abTestId,
|
|
2760
|
+
bundle.id
|
|
2761
|
+
);
|
|
2762
|
+
if (assignment?.variant === "B") {
|
|
2763
|
+
return (0, import_core4.applyABVariantB)(bundle);
|
|
2764
|
+
}
|
|
2765
|
+
} catch (err) {
|
|
2766
|
+
console.warn(
|
|
2767
|
+
`[lime-bundle] A/B assignment failed for bundle ${bundle.id}; falling back to Variant A.`,
|
|
2768
|
+
err
|
|
2769
|
+
);
|
|
2770
|
+
}
|
|
2771
|
+
return bundle;
|
|
2772
|
+
})
|
|
2773
|
+
);
|
|
2774
|
+
this.bundles = results;
|
|
2775
|
+
}
|
|
516
2776
|
async fetchSingleBundle(client, signal) {
|
|
517
2777
|
const data = await client.query(
|
|
518
2778
|
import_core4.BUNDLE_METAOBJECT_QUERY,
|
|
@@ -657,29 +2917,41 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
657
2917
|
}
|
|
658
2918
|
renderBundles() {
|
|
659
2919
|
this.teardownImpressions();
|
|
2920
|
+
this.teardownRenderers();
|
|
660
2921
|
this.shadow.innerHTML = "";
|
|
661
2922
|
const style = document.createElement("style");
|
|
662
|
-
style.textContent =
|
|
2923
|
+
style.textContent = [
|
|
2924
|
+
BUNDLE_BASE_CSS,
|
|
2925
|
+
BUNDLE_FIXED_CSS,
|
|
2926
|
+
BUNDLE_MIX_MATCH_CSS,
|
|
2927
|
+
BUNDLE_VOLUME_CSS
|
|
2928
|
+
].join("\n");
|
|
663
2929
|
this.shadow.appendChild(style);
|
|
2930
|
+
if (this.shopCustomCss) {
|
|
2931
|
+
const customStyle = document.createElement("style");
|
|
2932
|
+
customStyle.setAttribute("data-lime-bundles", "shop-custom-css");
|
|
2933
|
+
customStyle.textContent = this.shopCustomCss;
|
|
2934
|
+
this.shadow.appendChild(customStyle);
|
|
2935
|
+
}
|
|
664
2936
|
for (const bundle of this.bundles) {
|
|
665
2937
|
const container = document.createElement("div");
|
|
666
|
-
container.className = "lb-bundle";
|
|
2938
|
+
container.className = "lb-bundle-widget";
|
|
667
2939
|
container.setAttribute("role", "region");
|
|
668
2940
|
container.setAttribute("aria-label", bundle.title);
|
|
2941
|
+
container.setAttribute("data-bundle-type", bundle.bundleType);
|
|
2942
|
+
container.setAttribute("data-bundle-gid", bundle.id);
|
|
2943
|
+
(0, import_core5.applyWidgetConfigVars)(container, bundle.widgetConfig);
|
|
669
2944
|
const dispatch = (lines) => this.handleAddToCart(bundle, lines);
|
|
2945
|
+
const registerCleanup = (fn) => this.renderCleanups.push(fn);
|
|
670
2946
|
switch (bundle.bundleType) {
|
|
671
2947
|
case "fixed":
|
|
672
|
-
renderFixedBundle(container, bundle, dispatch);
|
|
2948
|
+
renderFixedBundle(container, bundle, dispatch, registerCleanup);
|
|
673
2949
|
break;
|
|
674
2950
|
case "mix_match":
|
|
675
|
-
renderMixMatchBundle(
|
|
676
|
-
container,
|
|
677
|
-
bundle,
|
|
678
|
-
dispatch
|
|
679
|
-
);
|
|
2951
|
+
renderMixMatchBundle(container, bundle, dispatch, registerCleanup);
|
|
680
2952
|
break;
|
|
681
2953
|
case "volume":
|
|
682
|
-
renderVolumeBundle(container, bundle, dispatch);
|
|
2954
|
+
renderVolumeBundle(container, bundle, dispatch, registerCleanup);
|
|
683
2955
|
break;
|
|
684
2956
|
}
|
|
685
2957
|
this.shadow.appendChild(container);
|
|
@@ -716,10 +2988,40 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
716
2988
|
}
|
|
717
2989
|
renderLoading() {
|
|
718
2990
|
this.shadow.innerHTML = `
|
|
719
|
-
<style>${
|
|
720
|
-
<
|
|
2991
|
+
<style>${BUNDLE_BASE_CSS}</style>
|
|
2992
|
+
<style>${BUNDLE_SKELETON_CSS}</style>
|
|
2993
|
+
<div class="lb-bundle-widget lb-bundle-widget--loading" aria-busy="true" aria-label="Loading bundle">
|
|
721
2994
|
<div class="lb-skeleton lb-skeleton--title"></div>
|
|
722
|
-
<div class="lb-skeleton
|
|
2995
|
+
<div class="lb-skeleton--products">
|
|
2996
|
+
<div class="lb-skeleton--row">
|
|
2997
|
+
<div class="lb-skeleton lb-skeleton--thumb"></div>
|
|
2998
|
+
<div>
|
|
2999
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
3000
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
3001
|
+
</div>
|
|
3002
|
+
<div class="lb-skeleton lb-skeleton--price"></div>
|
|
3003
|
+
</div>
|
|
3004
|
+
<div class="lb-skeleton--row">
|
|
3005
|
+
<div class="lb-skeleton lb-skeleton--thumb"></div>
|
|
3006
|
+
<div>
|
|
3007
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
3008
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
3009
|
+
</div>
|
|
3010
|
+
<div class="lb-skeleton lb-skeleton--price"></div>
|
|
3011
|
+
</div>
|
|
3012
|
+
<div class="lb-skeleton--row">
|
|
3013
|
+
<div class="lb-skeleton lb-skeleton--thumb"></div>
|
|
3014
|
+
<div>
|
|
3015
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
3016
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
3017
|
+
</div>
|
|
3018
|
+
<div class="lb-skeleton lb-skeleton--price"></div>
|
|
3019
|
+
</div>
|
|
3020
|
+
</div>
|
|
3021
|
+
<div class="lb-skeleton--footer">
|
|
3022
|
+
<div class="lb-skeleton lb-skeleton--total"></div>
|
|
3023
|
+
<div class="lb-skeleton lb-skeleton--cta"></div>
|
|
3024
|
+
</div>
|
|
723
3025
|
</div>
|
|
724
3026
|
`;
|
|
725
3027
|
}
|
|
@@ -733,9 +3035,6 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
733
3035
|
})
|
|
734
3036
|
);
|
|
735
3037
|
}
|
|
736
|
-
render() {
|
|
737
|
-
this.shadow.innerHTML = `<style>${WIDGET_STYLES}</style>`;
|
|
738
|
-
}
|
|
739
3038
|
};
|
|
740
3039
|
|
|
741
3040
|
// src/index.ts
|