@develemit/storefront 0.7.0 → 0.9.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/CHANGELOG.md +16 -0
- package/dist/components/add-to-cart-button/add-to-cart-button.d.ts +1 -0
- package/dist/components/cart-summary/cart-summary.d.ts +3 -1
- package/dist/components/checkout-success/labels.d.ts +1 -0
- package/dist/index.js +180 -157
- package/dist/index.js.map +1 -1
- package/dist/styles.css +58 -3
- package/dist/views/product-detail-view.d.ts +3 -1
- package/docs/cart.md +9 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { n as e, t } from "./sort-for-display-Cj6GMeCY.js";
|
|
3
3
|
import { createContext as n, useCallback as r, useContext as i, useEffect as a, useMemo as o, useReducer as s, useRef as c, useState as l } from "react";
|
|
4
4
|
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
5
|
-
import { cartLineSchema as p } from "@develemit/commerce-contracts";
|
|
5
|
+
import { cartLineSchema as p, formatOrderRef as m } from "@develemit/commerce-contracts";
|
|
6
6
|
// src/lib/theme.ts
|
|
7
|
-
var
|
|
7
|
+
var h = {
|
|
8
8
|
colorBg: "--sf-color-bg",
|
|
9
9
|
colorSurface: "--sf-color-surface",
|
|
10
10
|
colorFg: "--sf-color-fg",
|
|
@@ -18,16 +18,16 @@ var m = {
|
|
|
18
18
|
fontBody: "--sf-font-body",
|
|
19
19
|
spaceUnit: "--sf-space-unit"
|
|
20
20
|
};
|
|
21
|
-
function
|
|
21
|
+
function g(e) {
|
|
22
22
|
let t = {};
|
|
23
|
-
for (let n of Object.keys(
|
|
23
|
+
for (let n of Object.keys(h)) {
|
|
24
24
|
let r = e[n];
|
|
25
|
-
r !== void 0 && (t[
|
|
25
|
+
r !== void 0 && (t[h[n]] = r);
|
|
26
26
|
}
|
|
27
27
|
return t;
|
|
28
28
|
}
|
|
29
29
|
// src/lib/provider.tsx
|
|
30
|
-
var
|
|
30
|
+
var _ = {
|
|
31
31
|
renderLink: ({ href: e, children: t, className: n }) => /* @__PURE__ */ d("a", {
|
|
32
32
|
href: e,
|
|
33
33
|
className: n,
|
|
@@ -47,27 +47,27 @@ var g = {
|
|
|
47
47
|
product: (e) => `/shop/${e}`,
|
|
48
48
|
category: (e) => `/shop?category=${e}`
|
|
49
49
|
}
|
|
50
|
-
},
|
|
51
|
-
function
|
|
50
|
+
}, v = n(_);
|
|
51
|
+
function y({ children: e, hrefs: t, ...n }) {
|
|
52
52
|
let r = {
|
|
53
|
-
...
|
|
53
|
+
..._,
|
|
54
54
|
...n,
|
|
55
55
|
hrefs: {
|
|
56
|
-
...
|
|
56
|
+
..._.hrefs,
|
|
57
57
|
...t
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
-
return /* @__PURE__ */ d(
|
|
60
|
+
return /* @__PURE__ */ d(v.Provider, {
|
|
61
61
|
value: r,
|
|
62
62
|
children: e
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
return i(
|
|
65
|
+
function b() {
|
|
66
|
+
return i(v);
|
|
67
67
|
}
|
|
68
68
|
// src/components/price-tag/price-tag.tsx
|
|
69
|
-
function
|
|
70
|
-
let { locale: a } =
|
|
69
|
+
function x({ priceCents: t, currency: n, sold: r = !1, className: i }) {
|
|
70
|
+
let { locale: a } = b(), o = [
|
|
71
71
|
"sf-price",
|
|
72
72
|
r && "sf-price--sold",
|
|
73
73
|
i
|
|
@@ -78,15 +78,15 @@ function b({ priceCents: t, currency: n, sold: r = !1, className: i }) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
// src/components/availability-badge/availability-badge.tsx
|
|
81
|
-
var
|
|
81
|
+
var S = {
|
|
82
82
|
oneOfAKind: "One of a kind",
|
|
83
83
|
sold: "Sold",
|
|
84
84
|
reserved: "On hold",
|
|
85
85
|
available: "Available"
|
|
86
86
|
};
|
|
87
|
-
function
|
|
87
|
+
function C({ availability: e, quantity: t, labels: n, className: r }) {
|
|
88
88
|
let i = {
|
|
89
|
-
...
|
|
89
|
+
...S,
|
|
90
90
|
...n
|
|
91
91
|
}, a, o;
|
|
92
92
|
e === "sold" ? (a = "sold", o = i.sold) : e === "reserved" ? (a = "reserved", o = i.reserved) : t === 1 ? (a = "unique", o = i.oneOfAKind) : (a = "available", o = i.available);
|
|
@@ -102,8 +102,8 @@ function S({ availability: e, quantity: t, labels: n, className: r }) {
|
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
// src/components/product-card/product-card.tsx
|
|
105
|
-
function
|
|
106
|
-
let { renderLink: i, renderImage: a, hrefs: o } =
|
|
105
|
+
function w({ product: e, labels: t, sizes: n, priority: r }) {
|
|
106
|
+
let { renderLink: i, renderImage: a, hrefs: o } = b(), s = e.availability === "sold", c = e.images[0], l = ["sf-card", s && "sf-card--sold"].filter(Boolean).join(" ");
|
|
107
107
|
return /* @__PURE__ */ d("article", {
|
|
108
108
|
className: l,
|
|
109
109
|
children: i({
|
|
@@ -128,12 +128,12 @@ function C({ product: e, labels: t, sizes: n, priority: r }) {
|
|
|
128
128
|
className: "sf-card__title",
|
|
129
129
|
children: e.name
|
|
130
130
|
}),
|
|
131
|
-
/* @__PURE__ */ d(
|
|
131
|
+
/* @__PURE__ */ d(x, {
|
|
132
132
|
priceCents: e.priceCents,
|
|
133
133
|
currency: e.currency,
|
|
134
134
|
sold: s
|
|
135
135
|
}),
|
|
136
|
-
/* @__PURE__ */ d(
|
|
136
|
+
/* @__PURE__ */ d(C, {
|
|
137
137
|
availability: e.availability,
|
|
138
138
|
quantity: e.quantity,
|
|
139
139
|
labels: t
|
|
@@ -144,7 +144,7 @@ function C({ product: e, labels: t, sizes: n, priority: r }) {
|
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
// src/components/product-grid/product-grid.tsx
|
|
147
|
-
function
|
|
147
|
+
function T({ products: e, emptyState: t, labels: n, priorityCount: r = 0 }) {
|
|
148
148
|
return e.length === 0 ? /* @__PURE__ */ d("div", {
|
|
149
149
|
className: "sf-grid-empty",
|
|
150
150
|
children: t ?? "No products found."
|
|
@@ -152,7 +152,7 @@ function w({ products: e, emptyState: t, labels: n, priorityCount: r = 0 }) {
|
|
|
152
152
|
className: "sf-grid",
|
|
153
153
|
children: e.map((e, t) => /* @__PURE__ */ d("li", {
|
|
154
154
|
className: "sf-grid__item",
|
|
155
|
-
children: /* @__PURE__ */ d(
|
|
155
|
+
children: /* @__PURE__ */ d(w, {
|
|
156
156
|
product: e,
|
|
157
157
|
labels: n,
|
|
158
158
|
priority: t < r
|
|
@@ -161,8 +161,8 @@ function w({ products: e, emptyState: t, labels: n, priorityCount: r = 0 }) {
|
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
// src/components/category-filter/category-filter.tsx
|
|
164
|
-
function
|
|
165
|
-
let { renderLink: s, hrefs: c } =
|
|
164
|
+
function E({ categories: e, selected: t, onSelect: n, allLabel: r = "All", label: i = "Categories", formatLabel: a, sortCategories: o }) {
|
|
165
|
+
let { renderLink: s, hrefs: c } = b(), l = o ? [...e].sort(o) : e, u = n !== void 0, p = (e, r, i) => {
|
|
166
166
|
let a = t === e, o = `sf-filter__item${a ? " sf-filter__item--active" : ""}`;
|
|
167
167
|
return /* @__PURE__ */ d("li", { children: u ? /* @__PURE__ */ d("button", {
|
|
168
168
|
type: "button",
|
|
@@ -186,8 +186,8 @@ function T({ categories: e, selected: t, onSelect: n, allLabel: r = "All", label
|
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
// src/components/product-gallery/product-gallery.tsx
|
|
189
|
-
function
|
|
190
|
-
let { renderImage: n } =
|
|
189
|
+
function D({ images: e, sizes: t }) {
|
|
190
|
+
let { renderImage: n } = b(), [r, i] = l(0);
|
|
191
191
|
return e.length === 0 ? null : /* @__PURE__ */ f("div", {
|
|
192
192
|
className: "sf-gallery",
|
|
193
193
|
role: "group",
|
|
@@ -233,21 +233,21 @@ function E({ images: e, sizes: t }) {
|
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
235
|
// src/views/shop-view.tsx
|
|
236
|
-
function
|
|
237
|
-
let { renderLink: p } =
|
|
236
|
+
function O({ products: e, categories: n, activeCategory: r, slots: i = {}, labels: a, allLabel: o, formatCategoryLabel: s, sortCategories: c, nextHref: l, loadMoreLabel: u = "Load more" }) {
|
|
237
|
+
let { renderLink: p } = b();
|
|
238
238
|
return /* @__PURE__ */ f("div", {
|
|
239
239
|
className: "sf-shop",
|
|
240
240
|
children: [
|
|
241
241
|
i.header,
|
|
242
242
|
i.intro,
|
|
243
|
-
/* @__PURE__ */ d(
|
|
243
|
+
/* @__PURE__ */ d(E, {
|
|
244
244
|
categories: n,
|
|
245
245
|
selected: r,
|
|
246
246
|
allLabel: o,
|
|
247
247
|
formatLabel: s,
|
|
248
248
|
sortCategories: c
|
|
249
249
|
}),
|
|
250
|
-
/* @__PURE__ */ d(
|
|
250
|
+
/* @__PURE__ */ d(T, {
|
|
251
251
|
products: t(e),
|
|
252
252
|
emptyState: i.emptyState,
|
|
253
253
|
labels: a,
|
|
@@ -265,50 +265,59 @@ function D({ products: e, categories: n, activeCategory: r, slots: i = {}, label
|
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
267
|
// src/views/product-detail-view.tsx
|
|
268
|
-
function
|
|
268
|
+
function k({ product: e, slots: t = {}, labels: n, backHref: r, backLabel: i = "Back to the shop" }) {
|
|
269
|
+
let { renderLink: a } = b(), o = e.availability === "sold";
|
|
269
270
|
return /* @__PURE__ */ f("article", {
|
|
270
|
-
className: "sf-detail",
|
|
271
|
-
children: [
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
271
|
+
className: o ? "sf-detail sf-detail--sold" : "sf-detail",
|
|
272
|
+
children: [
|
|
273
|
+
r && a({
|
|
274
|
+
href: r,
|
|
275
|
+
className: "sf-detail__back",
|
|
276
|
+
children: i
|
|
277
|
+
}),
|
|
278
|
+
/* @__PURE__ */ d(D, { images: e.images }),
|
|
279
|
+
/* @__PURE__ */ f("div", {
|
|
280
|
+
className: "sf-detail__body",
|
|
281
|
+
children: [
|
|
282
|
+
/* @__PURE__ */ d("h1", {
|
|
283
|
+
className: "sf-detail__title",
|
|
284
|
+
children: e.name
|
|
285
|
+
}),
|
|
286
|
+
/* @__PURE__ */ d(x, {
|
|
287
|
+
priceCents: e.priceCents,
|
|
288
|
+
currency: e.currency
|
|
289
|
+
}),
|
|
290
|
+
/* @__PURE__ */ d(C, {
|
|
291
|
+
availability: e.availability,
|
|
292
|
+
quantity: e.quantity,
|
|
293
|
+
labels: n
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ d("p", {
|
|
296
|
+
className: "sf-detail__description",
|
|
297
|
+
children: e.description
|
|
298
|
+
}),
|
|
299
|
+
(e.materials || e.dimensions) && /* @__PURE__ */ f("dl", {
|
|
300
|
+
className: "sf-detail__specs",
|
|
301
|
+
children: [e.materials && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("dt", { children: "Materials" }), /* @__PURE__ */ d("dd", { children: e.materials })] }), e.dimensions && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("dt", { children: "Dimensions" }), /* @__PURE__ */ d("dd", { children: e.dimensions })] })]
|
|
302
|
+
}),
|
|
303
|
+
t.actions && /* @__PURE__ */ d("div", {
|
|
304
|
+
className: "sf-detail__actions",
|
|
305
|
+
children: t.actions
|
|
306
|
+
}),
|
|
307
|
+
t.afterDetails
|
|
308
|
+
]
|
|
309
|
+
})
|
|
310
|
+
]
|
|
302
311
|
});
|
|
303
312
|
}
|
|
304
313
|
// src/views/featured-products.tsx
|
|
305
|
-
function
|
|
314
|
+
function A({ products: e, heading: t = "Featured", labels: n }) {
|
|
306
315
|
return e.length === 0 ? null : /* @__PURE__ */ f("section", {
|
|
307
316
|
className: "sf-featured",
|
|
308
317
|
children: [/* @__PURE__ */ d("h2", {
|
|
309
318
|
className: "sf-featured__heading",
|
|
310
319
|
children: t
|
|
311
|
-
}), /* @__PURE__ */ d(
|
|
320
|
+
}), /* @__PURE__ */ d(T, {
|
|
312
321
|
products: e,
|
|
313
322
|
labels: n,
|
|
314
323
|
priorityCount: 6
|
|
@@ -316,8 +325,8 @@ function k({ products: e, heading: t = "Featured", labels: n }) {
|
|
|
316
325
|
});
|
|
317
326
|
}
|
|
318
327
|
// src/cart/cart-reducer.ts
|
|
319
|
-
var
|
|
320
|
-
function
|
|
328
|
+
var j = { lines: [] };
|
|
329
|
+
function M(e, t) {
|
|
321
330
|
let n = e.lines[0];
|
|
322
331
|
if (n && n.currency !== t.currency) return {
|
|
323
332
|
state: e,
|
|
@@ -352,42 +361,42 @@ function j(e, t) {
|
|
|
352
361
|
capped: r.quantity + t.quantity > r.maxQuantity
|
|
353
362
|
};
|
|
354
363
|
}
|
|
355
|
-
function
|
|
364
|
+
function N(e, t) {
|
|
356
365
|
switch (t.type) {
|
|
357
|
-
case "add": return
|
|
366
|
+
case "add": return M(e, t.line).state;
|
|
358
367
|
case "remove": return { lines: e.lines.filter((e) => e.productId !== t.productId) };
|
|
359
|
-
case "setQuantity": return t.quantity <= 0 ?
|
|
368
|
+
case "setQuantity": return t.quantity <= 0 ? N(e, {
|
|
360
369
|
type: "remove",
|
|
361
370
|
productId: t.productId
|
|
362
371
|
}) : { lines: e.lines.map((e) => e.productId === t.productId ? {
|
|
363
372
|
...e,
|
|
364
373
|
quantity: Math.min(t.quantity, e.maxQuantity)
|
|
365
374
|
} : e) };
|
|
366
|
-
case "clear": return
|
|
375
|
+
case "clear": return j;
|
|
367
376
|
case "hydrate": return t.state;
|
|
368
377
|
}
|
|
369
378
|
}
|
|
370
|
-
function
|
|
379
|
+
function P(e) {
|
|
371
380
|
return e.lines.reduce((e, t) => e + t.priceCents * t.quantity, 0);
|
|
372
381
|
}
|
|
373
|
-
function
|
|
382
|
+
function F(e) {
|
|
374
383
|
return e.lines.reduce((e, t) => e + t.quantity, 0);
|
|
375
384
|
}
|
|
376
385
|
// src/cart/cart-storage.ts
|
|
377
|
-
function
|
|
386
|
+
function I(e = "sf-cart") {
|
|
378
387
|
return {
|
|
379
388
|
load() {
|
|
380
|
-
if (typeof window > "u") return
|
|
389
|
+
if (typeof window > "u") return j;
|
|
381
390
|
try {
|
|
382
391
|
let t = window.localStorage.getItem(e);
|
|
383
|
-
if (!t) return
|
|
392
|
+
if (!t) return j;
|
|
384
393
|
let n = JSON.parse(t);
|
|
385
394
|
return { lines: (Array.isArray(n?.lines) ? n.lines : []).flatMap((e) => {
|
|
386
395
|
let t = p.safeParse(e);
|
|
387
396
|
return t.success ? [t.data] : [];
|
|
388
397
|
}) };
|
|
389
398
|
} catch {
|
|
390
|
-
return
|
|
399
|
+
return j;
|
|
391
400
|
}
|
|
392
401
|
},
|
|
393
402
|
save(t) {
|
|
@@ -398,9 +407,9 @@ function F(e = "sf-cart") {
|
|
|
398
407
|
};
|
|
399
408
|
}
|
|
400
409
|
// src/cart/cart-provider.tsx
|
|
401
|
-
var
|
|
402
|
-
function
|
|
403
|
-
let [n, i] = s(
|
|
410
|
+
var L = n(null), R = I();
|
|
411
|
+
function z({ storage: e = R, children: t }) {
|
|
412
|
+
let [n, i] = s(N, j), [u, f] = l(!1), [p, m] = l(!1), h = c(n);
|
|
404
413
|
a(() => {
|
|
405
414
|
h.current = n;
|
|
406
415
|
}, [n]), a(() => {
|
|
@@ -421,15 +430,15 @@ function ee({ storage: e = L, children: t }) {
|
|
|
421
430
|
e
|
|
422
431
|
]);
|
|
423
432
|
let g = r((e) => {
|
|
424
|
-
let t =
|
|
433
|
+
let t = M(h.current, e);
|
|
425
434
|
return t.added && (h.current = t.state, i({
|
|
426
435
|
type: "add",
|
|
427
436
|
line: e
|
|
428
437
|
})), t;
|
|
429
438
|
}, []), _ = o(() => ({
|
|
430
439
|
lines: n.lines,
|
|
431
|
-
itemCount:
|
|
432
|
-
subtotalCents:
|
|
440
|
+
itemCount: F(n),
|
|
441
|
+
subtotalCents: P(n),
|
|
433
442
|
currency: n.lines[0]?.currency ?? null,
|
|
434
443
|
hydrated: u,
|
|
435
444
|
isOpen: p,
|
|
@@ -452,18 +461,18 @@ function ee({ storage: e = L, children: t }) {
|
|
|
452
461
|
p,
|
|
453
462
|
g
|
|
454
463
|
]);
|
|
455
|
-
return /* @__PURE__ */ d(
|
|
464
|
+
return /* @__PURE__ */ d(L.Provider, {
|
|
456
465
|
value: _,
|
|
457
466
|
children: t
|
|
458
467
|
});
|
|
459
468
|
}
|
|
460
|
-
function
|
|
461
|
-
let e = i(
|
|
469
|
+
function B() {
|
|
470
|
+
let e = i(L);
|
|
462
471
|
if (!e) throw Error("useCart must be used inside <CartProvider>");
|
|
463
472
|
return e;
|
|
464
473
|
}
|
|
465
474
|
// src/components/cart-summary/discount-types.ts
|
|
466
|
-
var
|
|
475
|
+
var V = {
|
|
467
476
|
toggle: "Have a code?",
|
|
468
477
|
field: "Discount code",
|
|
469
478
|
apply: "Apply",
|
|
@@ -480,17 +489,17 @@ var z = {
|
|
|
480
489
|
currency: "That code does not apply to this cart."
|
|
481
490
|
}
|
|
482
491
|
};
|
|
483
|
-
function
|
|
484
|
-
return t?.[e] ??
|
|
492
|
+
function H(e, t) {
|
|
493
|
+
return t?.[e] ?? V.reasons[e];
|
|
485
494
|
}
|
|
486
495
|
// src/cart/use-checkout.ts
|
|
487
|
-
var
|
|
496
|
+
var U = {
|
|
488
497
|
outOfStock: "Some items just sold or are on hold, so we removed them from your cart.",
|
|
489
498
|
unavailable: "Checkout is unavailable right now. Please try again."
|
|
490
|
-
},
|
|
491
|
-
function
|
|
492
|
-
let a =
|
|
493
|
-
...
|
|
499
|
+
}, W = (e) => window.location.assign(e);
|
|
500
|
+
function G({ startCheckout: e, onRedirect: t = W, onDiscountInvalid: n, labels: i }) {
|
|
501
|
+
let a = B(), [o, s] = l(!1), [c, u] = l(null), { lines: d, remove: f } = a, p = {
|
|
502
|
+
...U,
|
|
494
503
|
...i
|
|
495
504
|
};
|
|
496
505
|
return {
|
|
@@ -505,7 +514,7 @@ function ne({ startCheckout: e, onRedirect: t = te, onDiscountInvalid: n, labels
|
|
|
505
514
|
t(i.url);
|
|
506
515
|
return;
|
|
507
516
|
}
|
|
508
|
-
i.error === "discount_invalid" ? (u(
|
|
517
|
+
i.error === "discount_invalid" ? (u(H(i.reason, p.discountReasons)), n?.(i.reason)) : (i.productIds.forEach(f), u(p.outOfStock));
|
|
509
518
|
} catch {
|
|
510
519
|
u(p.unavailable);
|
|
511
520
|
}
|
|
@@ -524,17 +533,18 @@ function ne({ startCheckout: e, onRedirect: t = te, onDiscountInvalid: n, labels
|
|
|
524
533
|
};
|
|
525
534
|
}
|
|
526
535
|
// src/components/add-to-cart-button/add-to-cart-button.tsx
|
|
527
|
-
var
|
|
536
|
+
var K = {
|
|
528
537
|
add: "Add to cart",
|
|
529
538
|
inCart: "In your cart",
|
|
530
|
-
unavailable: "Unavailable"
|
|
539
|
+
unavailable: "Unavailable",
|
|
540
|
+
sold: "Sold"
|
|
531
541
|
};
|
|
532
|
-
function
|
|
533
|
-
let i =
|
|
534
|
-
...
|
|
542
|
+
function q({ product: e, labels: t, openOnAdd: n = !0, className: r }) {
|
|
543
|
+
let i = B(), a = {
|
|
544
|
+
...K,
|
|
535
545
|
...t
|
|
536
|
-
}, o = i.lines.find((t) => t.productId === e.id)?.quantity ?? 0, s = e.availability !== "available",
|
|
537
|
-
function
|
|
546
|
+
}, o = i.lines.find((t) => t.productId === e.id)?.quantity ?? 0, s = e.availability === "sold", c = e.availability !== "available", l = o >= e.quantity, u = !i.hydrated || c || l, f = c ? a.unavailable : l ? a.inCart : a.add;
|
|
547
|
+
function p() {
|
|
538
548
|
i.add({
|
|
539
549
|
productId: e.id,
|
|
540
550
|
slug: e.slug,
|
|
@@ -546,22 +556,25 @@ function U({ product: e, labels: t, openOnAdd: n = !0, className: r }) {
|
|
|
546
556
|
maxQuantity: e.quantity
|
|
547
557
|
}).added && n && i.open();
|
|
548
558
|
}
|
|
549
|
-
return /* @__PURE__ */ d("
|
|
559
|
+
return s ? /* @__PURE__ */ d("span", {
|
|
560
|
+
className: ["sf-sold-note", r].filter(Boolean).join(" "),
|
|
561
|
+
children: a.sold
|
|
562
|
+
}) : /* @__PURE__ */ d("button", {
|
|
550
563
|
type: "button",
|
|
551
564
|
className: ["sf-button", r].filter(Boolean).join(" "),
|
|
552
|
-
disabled:
|
|
553
|
-
onClick:
|
|
554
|
-
children:
|
|
565
|
+
disabled: u,
|
|
566
|
+
onClick: p,
|
|
567
|
+
children: f
|
|
555
568
|
});
|
|
556
569
|
}
|
|
557
570
|
// src/components/cart-line-item/cart-line-item.tsx
|
|
558
|
-
var
|
|
571
|
+
var J = {
|
|
559
572
|
remove: "Remove",
|
|
560
573
|
quantity: "Quantity"
|
|
561
574
|
};
|
|
562
|
-
function
|
|
563
|
-
let { remove: r, setQuantity: i } =
|
|
564
|
-
...
|
|
575
|
+
function Y({ line: t, labels: n }) {
|
|
576
|
+
let { remove: r, setQuantity: i } = B(), { locale: a, renderLink: o, renderImage: s, hrefs: c } = b(), l = {
|
|
577
|
+
...J,
|
|
565
578
|
...n
|
|
566
579
|
}, u = t.maxQuantity > 1;
|
|
567
580
|
return /* @__PURE__ */ f("li", {
|
|
@@ -605,17 +618,17 @@ function G({ line: t, labels: n }) {
|
|
|
605
618
|
});
|
|
606
619
|
}
|
|
607
620
|
// src/lib/parse-duration.ts
|
|
608
|
-
function
|
|
621
|
+
function ee(e) {
|
|
609
622
|
let t = /^\s*(-?\d*\.?\d+)\s*(ms|s)\s*$/.exec(e);
|
|
610
623
|
if (!t) return 0;
|
|
611
624
|
let n = Number(t[1]);
|
|
612
625
|
return Math.max(0, t[2] === "s" ? n * 1e3 : n);
|
|
613
626
|
}
|
|
614
627
|
// src/components/cart-drawer/use-drawer-presence.ts
|
|
615
|
-
function
|
|
628
|
+
function te(e, t) {
|
|
616
629
|
let [n, r] = l(0), [i, o] = l(e), [s, c] = l(!1);
|
|
617
630
|
return i !== e && (o(e), c(!e && n > 0)), a(() => {
|
|
618
|
-
e && t.current && r(
|
|
631
|
+
e && t.current && r(ee(getComputedStyle(t.current).getPropertyValue("--sf-motion-duration")));
|
|
619
632
|
}, [e, t]), a(() => {
|
|
620
633
|
if (!s) return;
|
|
621
634
|
let e = setTimeout(() => c(!1), n);
|
|
@@ -626,7 +639,7 @@ function q(e, t) {
|
|
|
626
639
|
};
|
|
627
640
|
}
|
|
628
641
|
// src/components/cart-summary/discount-field.tsx
|
|
629
|
-
function
|
|
642
|
+
function ne({ labels: t, applied: n, error: r, pending: i, currency: a, locale: o, onApply: s, onRemove: c }) {
|
|
630
643
|
let [u, p] = l(!1), [m, h] = l("");
|
|
631
644
|
function g(e) {
|
|
632
645
|
e.preventDefault();
|
|
@@ -684,8 +697,8 @@ function J({ labels: t, applied: n, error: r, pending: i, currency: a, locale: o
|
|
|
684
697
|
});
|
|
685
698
|
}
|
|
686
699
|
// src/components/cart-summary/use-discount.ts
|
|
687
|
-
function
|
|
688
|
-
let { lines: t } =
|
|
700
|
+
function re(e) {
|
|
701
|
+
let { lines: t } = B(), n = t.map((e) => ({
|
|
689
702
|
productId: e.productId,
|
|
690
703
|
quantity: e.quantity
|
|
691
704
|
})), i = n.map((e) => `${e.productId}:${e.quantity}`).join(","), [o, s] = l(null), [u, d] = l(null), [f, p] = l(!1), m = c({
|
|
@@ -744,12 +757,12 @@ function Y(e) {
|
|
|
744
757
|
};
|
|
745
758
|
}
|
|
746
759
|
// src/components/cart-summary/cart-summary.tsx
|
|
747
|
-
function X({ onCheckout: t, checkoutLabel: n = "Checkout", checkoutDisabled: r = !1, labels: i, discount: a }) {
|
|
748
|
-
let
|
|
749
|
-
...
|
|
760
|
+
function X({ onCheckout: t, checkoutLabel: n = "Checkout", checkoutDisabled: r = !1, labels: i, discount: a, showTaxNote: o = !1 }) {
|
|
761
|
+
let s = B(), { locale: c } = b(), l = i?.subtotal ?? "Subtotal", u = i?.taxNote ?? "Tax calculated at checkout", p = re(a), m = {
|
|
762
|
+
...V,
|
|
750
763
|
...i?.discount,
|
|
751
764
|
reasons: {
|
|
752
|
-
...
|
|
765
|
+
...V.reasons,
|
|
753
766
|
...i?.discount?.reasons
|
|
754
767
|
}
|
|
755
768
|
};
|
|
@@ -758,25 +771,29 @@ function X({ onCheckout: t, checkoutLabel: n = "Checkout", checkoutDisabled: r =
|
|
|
758
771
|
children: [
|
|
759
772
|
/* @__PURE__ */ f("p", {
|
|
760
773
|
className: "sf-cart-summary__row",
|
|
761
|
-
children: [/* @__PURE__ */ d("span", { children:
|
|
774
|
+
children: [/* @__PURE__ */ d("span", { children: l }), /* @__PURE__ */ d("span", {
|
|
762
775
|
className: "sf-price",
|
|
763
|
-
children: e(
|
|
776
|
+
children: e(s.subtotalCents, s.currency ?? "USD", c)
|
|
764
777
|
})]
|
|
765
778
|
}),
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
779
|
+
o && s.lines.length > 0 && /* @__PURE__ */ d("p", {
|
|
780
|
+
className: "sf-cart-summary__tax-note",
|
|
781
|
+
children: u
|
|
782
|
+
}),
|
|
783
|
+
a && s.lines.length > 0 && /* @__PURE__ */ d(ne, {
|
|
784
|
+
labels: m,
|
|
785
|
+
currency: s.currency ?? "USD",
|
|
786
|
+
locale: c,
|
|
787
|
+
onApply: (e) => void p.apply(e),
|
|
788
|
+
onRemove: p.remove,
|
|
789
|
+
applied: p.applied,
|
|
790
|
+
error: p.error,
|
|
791
|
+
pending: p.pending
|
|
775
792
|
}),
|
|
776
793
|
/* @__PURE__ */ d("button", {
|
|
777
794
|
type: "button",
|
|
778
795
|
className: "sf-button",
|
|
779
|
-
disabled: r || !t ||
|
|
796
|
+
disabled: r || !t || s.lines.length === 0,
|
|
780
797
|
onClick: t,
|
|
781
798
|
children: n
|
|
782
799
|
})
|
|
@@ -789,11 +806,11 @@ var Z = {
|
|
|
789
806
|
close: "Close",
|
|
790
807
|
empty: "Your cart is empty."
|
|
791
808
|
}, Q = "a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
792
|
-
function
|
|
793
|
-
let r =
|
|
809
|
+
function ie({ labels: e, summary: t, slots: n }) {
|
|
810
|
+
let r = B(), i = {
|
|
794
811
|
...Z,
|
|
795
812
|
...e
|
|
796
|
-
}, o = c(null), s = c(null), { isOpen: l } = r, p =
|
|
813
|
+
}, o = c(null), s = c(null), { isOpen: l } = r, p = te(l, s);
|
|
797
814
|
if (a(() => {
|
|
798
815
|
if (!l) return;
|
|
799
816
|
let e = document.activeElement;
|
|
@@ -846,7 +863,7 @@ function re({ labels: e, summary: t, slots: n }) {
|
|
|
846
863
|
}) : /* @__PURE__ */ f(u, { children: [
|
|
847
864
|
/* @__PURE__ */ d("ul", {
|
|
848
865
|
className: "sf-drawer__lines",
|
|
849
|
-
children: r.lines.map((e) => /* @__PURE__ */ d(
|
|
866
|
+
children: r.lines.map((e) => /* @__PURE__ */ d(Y, { line: e }, e.productId))
|
|
850
867
|
}),
|
|
851
868
|
/* @__PURE__ */ d(X, { ...t }),
|
|
852
869
|
n?.summaryNote && /* @__PURE__ */ d("div", {
|
|
@@ -858,8 +875,8 @@ function re({ labels: e, summary: t, slots: n }) {
|
|
|
858
875
|
});
|
|
859
876
|
}
|
|
860
877
|
// src/components/cart-button/cart-button.tsx
|
|
861
|
-
function
|
|
862
|
-
let a =
|
|
878
|
+
function ae({ label: e = "Cart", className: t, icon: n, labelHidden: r = !1, hideZeroCount: i = !1 }) {
|
|
879
|
+
let a = B(), o = a.hydrated ? a.itemCount : 0, s = !(i && o === 0), c = s ? r ? `${e}, ${a.itemCount} items` : void 0 : `${e}, empty`;
|
|
863
880
|
return /* @__PURE__ */ f("button", {
|
|
864
881
|
type: "button",
|
|
865
882
|
className: ["sf-cart-button", t].filter(Boolean).join(" "),
|
|
@@ -889,6 +906,7 @@ var $ = {
|
|
|
889
906
|
subtotal: "Subtotal",
|
|
890
907
|
discount: "Discount",
|
|
891
908
|
shipping: "Shipping",
|
|
909
|
+
tax: "Tax",
|
|
892
910
|
total: "Total",
|
|
893
911
|
shipTo: "Ship to",
|
|
894
912
|
tracking: "Track",
|
|
@@ -903,7 +921,7 @@ var $ = {
|
|
|
903
921
|
}
|
|
904
922
|
};
|
|
905
923
|
// src/components/checkout-success/checkout-success-view.tsx
|
|
906
|
-
function
|
|
924
|
+
function oe(e) {
|
|
907
925
|
let t = [
|
|
908
926
|
e.city,
|
|
909
927
|
e.state,
|
|
@@ -917,7 +935,7 @@ function ae(e) {
|
|
|
917
935
|
e.country
|
|
918
936
|
].filter((e) => !!e);
|
|
919
937
|
}
|
|
920
|
-
function
|
|
938
|
+
function se({ order: t, locale: n, labels: r, className: i, slots: a, showReference: o, showSummaryHeading: s, continueHref: c, renderLink: l }) {
|
|
921
939
|
let u = {
|
|
922
940
|
...$,
|
|
923
941
|
...r,
|
|
@@ -925,11 +943,11 @@ function oe({ order: t, locale: n, labels: r, className: i, slots: a, showRefere
|
|
|
925
943
|
...$.status,
|
|
926
944
|
...r?.status
|
|
927
945
|
}
|
|
928
|
-
}, p = (r) => e(r, t.currency, n),
|
|
946
|
+
}, p = (r) => e(r, t.currency, n), h = t.shippingAddress ? oe(t.shippingAddress) : [], { fulfillment: g } = t, _ = {
|
|
929
947
|
href: c ?? "",
|
|
930
948
|
className: "sf-checkout-success__continue",
|
|
931
949
|
children: u.continue
|
|
932
|
-
},
|
|
950
|
+
}, v = c ? l ? l(_) : /* @__PURE__ */ d("a", { ..._ }) : null, y = a?.actions ?? v;
|
|
933
951
|
return /* @__PURE__ */ f("section", {
|
|
934
952
|
className: ["sf-checkout-success", i].filter(Boolean).join(" "),
|
|
935
953
|
"data-status": t.status,
|
|
@@ -940,7 +958,7 @@ function oe({ order: t, locale: n, labels: r, className: i, slots: a, showRefere
|
|
|
940
958
|
}),
|
|
941
959
|
o && /* @__PURE__ */ d("p", {
|
|
942
960
|
className: "sf-checkout-success__reference",
|
|
943
|
-
children: u.reference.replace("{id}", t.id)
|
|
961
|
+
children: u.reference.replace("{id}", m(t.id))
|
|
944
962
|
}),
|
|
945
963
|
a?.header,
|
|
946
964
|
/* @__PURE__ */ d("p", {
|
|
@@ -984,6 +1002,11 @@ function oe({ order: t, locale: n, labels: r, className: i, slots: a, showRefere
|
|
|
984
1002
|
")"
|
|
985
1003
|
] }), /* @__PURE__ */ d("dd", { children: p(t.shippingCents) })]
|
|
986
1004
|
}),
|
|
1005
|
+
t.taxCents > 0 && /* @__PURE__ */ f("div", {
|
|
1006
|
+
className: "sf-checkout-success__row",
|
|
1007
|
+
"data-tax": !0,
|
|
1008
|
+
children: [/* @__PURE__ */ d("dt", { children: u.tax }), /* @__PURE__ */ d("dd", { children: p(t.taxCents) })]
|
|
1009
|
+
}),
|
|
987
1010
|
/* @__PURE__ */ f("div", {
|
|
988
1011
|
className: "sf-checkout-success__row sf-checkout-success__row--total",
|
|
989
1012
|
children: [/* @__PURE__ */ d("dt", { children: u.total }), /* @__PURE__ */ d("dd", { children: p(t.totalCents) })]
|
|
@@ -991,35 +1014,35 @@ function oe({ order: t, locale: n, labels: r, className: i, slots: a, showRefere
|
|
|
991
1014
|
]
|
|
992
1015
|
}),
|
|
993
1016
|
a?.afterTotals,
|
|
994
|
-
|
|
1017
|
+
h.length > 0 && /* @__PURE__ */ f("address", {
|
|
995
1018
|
className: "sf-checkout-success__address",
|
|
996
|
-
children: [/* @__PURE__ */ d("strong", { children: u.shipTo }),
|
|
1019
|
+
children: [/* @__PURE__ */ d("strong", { children: u.shipTo }), h.map((e) => /* @__PURE__ */ d("span", { children: e }, e))]
|
|
997
1020
|
}),
|
|
998
|
-
|
|
1021
|
+
g?.trackingNumber && /* @__PURE__ */ f("p", {
|
|
999
1022
|
className: "sf-checkout-success__tracking",
|
|
1000
|
-
children: [
|
|
1001
|
-
href:
|
|
1023
|
+
children: [g.carrier && `${g.carrier} · `, g.trackingUrl ? /* @__PURE__ */ f("a", {
|
|
1024
|
+
href: g.trackingUrl,
|
|
1002
1025
|
children: [
|
|
1003
1026
|
u.tracking,
|
|
1004
1027
|
" ",
|
|
1005
|
-
|
|
1028
|
+
g.trackingNumber
|
|
1006
1029
|
]
|
|
1007
|
-
}) :
|
|
1030
|
+
}) : g.trackingNumber]
|
|
1008
1031
|
}),
|
|
1009
|
-
|
|
1032
|
+
y && /* @__PURE__ */ d("div", {
|
|
1010
1033
|
className: "sf-checkout-success__actions",
|
|
1011
|
-
children:
|
|
1034
|
+
children: y
|
|
1012
1035
|
})
|
|
1013
1036
|
]
|
|
1014
1037
|
});
|
|
1015
1038
|
}
|
|
1016
1039
|
// src/cart/clear-cart-on-mount.tsx
|
|
1017
|
-
function
|
|
1018
|
-
let { hydrated: e, clear: t } =
|
|
1040
|
+
function ce() {
|
|
1041
|
+
let { hydrated: e, clear: t } = B(), n = c(!1);
|
|
1019
1042
|
return a(() => {
|
|
1020
1043
|
e && !n.current && (n.current = !0, t());
|
|
1021
1044
|
}, [e, t]), null;
|
|
1022
1045
|
}
|
|
1023
|
-
export {
|
|
1046
|
+
export { q as AddToCartButton, C as AvailabilityBadge, ae as CartButton, ie as CartDrawer, Y as CartLineItem, z as CartProvider, X as CartSummary, E as CategoryFilter, se as CheckoutSuccessView, ce as ClearCartOnMount, A as FeaturedProducts, x as PriceTag, w as ProductCard, k as ProductDetailView, D as ProductGallery, T as ProductGrid, O as ShopView, y as StorefrontProvider, M as addLine, N as cartReducer, K as defaultAddToCartLabels, S as defaultAvailabilityLabels, Z as defaultCartDrawerLabels, J as defaultCartLineItemLabels, U as defaultCheckoutLabels, $ as defaultCheckoutSuccessLabels, H as discountReasonMessage, j as emptyCart, e as formatPrice, F as itemCount, I as localStorageCartStorage, t as sortForDisplay, P as subtotalCents, g as themeToCssVars, B as useCart, G as useCheckout, b as useStorefront };
|
|
1024
1047
|
|
|
1025
1048
|
//# sourceMappingURL=index.js.map
|