@develemit/storefront 0.6.0 → 0.8.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 +100 -0
- package/README.md +17 -95
- package/dist/components/add-to-cart-button/add-to-cart-button.d.ts +1 -0
- package/dist/components/checkout-success/checkout-success-view.d.ts +16 -1
- package/dist/components/checkout-success/labels.d.ts +3 -0
- package/dist/index.js +186 -151
- package/dist/index.js.map +1 -1
- package/dist/styles.css +71 -3
- package/dist/views/product-detail-view.d.ts +3 -1
- package/docs/cart.md +111 -0
- package/package.json +12 -3
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({
|
|
@@ -745,11 +758,11 @@ function Y(e) {
|
|
|
745
758
|
}
|
|
746
759
|
// src/components/cart-summary/cart-summary.tsx
|
|
747
760
|
function X({ onCheckout: t, checkoutLabel: n = "Checkout", checkoutDisabled: r = !1, labels: i, discount: a }) {
|
|
748
|
-
let o =
|
|
749
|
-
...
|
|
761
|
+
let o = B(), { locale: s } = b(), c = i?.subtotal ?? "Subtotal", l = re(a), u = {
|
|
762
|
+
...V,
|
|
750
763
|
...i?.discount,
|
|
751
764
|
reasons: {
|
|
752
|
-
...
|
|
765
|
+
...V.reasons,
|
|
753
766
|
...i?.discount?.reasons
|
|
754
767
|
}
|
|
755
768
|
};
|
|
@@ -763,7 +776,7 @@ function X({ onCheckout: t, checkoutLabel: n = "Checkout", checkoutDisabled: r =
|
|
|
763
776
|
children: e(o.subtotalCents, o.currency ?? "USD", s)
|
|
764
777
|
})]
|
|
765
778
|
}),
|
|
766
|
-
a && o.lines.length > 0 && /* @__PURE__ */ d(
|
|
779
|
+
a && o.lines.length > 0 && /* @__PURE__ */ d(ne, {
|
|
767
780
|
labels: u,
|
|
768
781
|
currency: o.currency ?? "USD",
|
|
769
782
|
locale: s,
|
|
@@ -789,11 +802,11 @@ var Z = {
|
|
|
789
802
|
close: "Close",
|
|
790
803
|
empty: "Your cart is empty."
|
|
791
804
|
}, Q = "a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
792
|
-
function
|
|
793
|
-
let r =
|
|
805
|
+
function ie({ labels: e, summary: t, slots: n }) {
|
|
806
|
+
let r = B(), i = {
|
|
794
807
|
...Z,
|
|
795
808
|
...e
|
|
796
|
-
}, o = c(null), s = c(null), { isOpen: l } = r, p =
|
|
809
|
+
}, o = c(null), s = c(null), { isOpen: l } = r, p = te(l, s);
|
|
797
810
|
if (a(() => {
|
|
798
811
|
if (!l) return;
|
|
799
812
|
let e = document.activeElement;
|
|
@@ -846,7 +859,7 @@ function re({ labels: e, summary: t, slots: n }) {
|
|
|
846
859
|
}) : /* @__PURE__ */ f(u, { children: [
|
|
847
860
|
/* @__PURE__ */ d("ul", {
|
|
848
861
|
className: "sf-drawer__lines",
|
|
849
|
-
children: r.lines.map((e) => /* @__PURE__ */ d(
|
|
862
|
+
children: r.lines.map((e) => /* @__PURE__ */ d(Y, { line: e }, e.productId))
|
|
850
863
|
}),
|
|
851
864
|
/* @__PURE__ */ d(X, { ...t }),
|
|
852
865
|
n?.summaryNote && /* @__PURE__ */ d("div", {
|
|
@@ -858,8 +871,8 @@ function re({ labels: e, summary: t, slots: n }) {
|
|
|
858
871
|
});
|
|
859
872
|
}
|
|
860
873
|
// src/components/cart-button/cart-button.tsx
|
|
861
|
-
function
|
|
862
|
-
let a =
|
|
874
|
+
function ae({ label: e = "Cart", className: t, icon: n, labelHidden: r = !1, hideZeroCount: i = !1 }) {
|
|
875
|
+
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
876
|
return /* @__PURE__ */ f("button", {
|
|
864
877
|
type: "button",
|
|
865
878
|
className: ["sf-cart-button", t].filter(Boolean).join(" "),
|
|
@@ -883,6 +896,9 @@ function ie({ label: e = "Cart", className: t, icon: n, labelHidden: r = !1, hid
|
|
|
883
896
|
// src/components/checkout-success/labels.ts
|
|
884
897
|
var $ = {
|
|
885
898
|
heading: "Order received",
|
|
899
|
+
summaryHeading: "Order summary",
|
|
900
|
+
reference: "Order {id}",
|
|
901
|
+
continue: "Continue shopping",
|
|
886
902
|
subtotal: "Subtotal",
|
|
887
903
|
discount: "Discount",
|
|
888
904
|
shipping: "Shipping",
|
|
@@ -900,7 +916,7 @@ var $ = {
|
|
|
900
916
|
}
|
|
901
917
|
};
|
|
902
918
|
// src/components/checkout-success/checkout-success-view.tsx
|
|
903
|
-
function
|
|
919
|
+
function oe(e) {
|
|
904
920
|
let t = [
|
|
905
921
|
e.city,
|
|
906
922
|
e.state,
|
|
@@ -914,27 +930,41 @@ function ae(e) {
|
|
|
914
930
|
e.country
|
|
915
931
|
].filter((e) => !!e);
|
|
916
932
|
}
|
|
917
|
-
function
|
|
918
|
-
let
|
|
933
|
+
function se({ order: t, locale: n, labels: r, className: i, slots: a, showReference: o, showSummaryHeading: s, continueHref: c, renderLink: l }) {
|
|
934
|
+
let u = {
|
|
919
935
|
...$,
|
|
920
936
|
...r,
|
|
921
937
|
status: {
|
|
922
938
|
...$.status,
|
|
923
939
|
...r?.status
|
|
924
940
|
}
|
|
925
|
-
},
|
|
941
|
+
}, p = (r) => e(r, t.currency, n), h = t.shippingAddress ? oe(t.shippingAddress) : [], { fulfillment: g } = t, _ = {
|
|
942
|
+
href: c ?? "",
|
|
943
|
+
className: "sf-checkout-success__continue",
|
|
944
|
+
children: u.continue
|
|
945
|
+
}, v = c ? l ? l(_) : /* @__PURE__ */ d("a", { ..._ }) : null, y = a?.actions ?? v;
|
|
926
946
|
return /* @__PURE__ */ f("section", {
|
|
927
947
|
className: ["sf-checkout-success", i].filter(Boolean).join(" "),
|
|
928
948
|
"data-status": t.status,
|
|
929
949
|
children: [
|
|
930
950
|
/* @__PURE__ */ d("h1", {
|
|
931
951
|
className: "sf-checkout-success__heading",
|
|
932
|
-
children:
|
|
952
|
+
children: u.heading
|
|
953
|
+
}),
|
|
954
|
+
o && /* @__PURE__ */ d("p", {
|
|
955
|
+
className: "sf-checkout-success__reference",
|
|
956
|
+
children: u.reference.replace("{id}", m(t.id))
|
|
933
957
|
}),
|
|
958
|
+
a?.header,
|
|
934
959
|
/* @__PURE__ */ d("p", {
|
|
935
960
|
className: "sf-checkout-success__status",
|
|
936
|
-
children:
|
|
961
|
+
children: u.status[t.status]
|
|
937
962
|
}),
|
|
963
|
+
s && /* @__PURE__ */ d("h2", {
|
|
964
|
+
className: "sf-checkout-success__summary-heading",
|
|
965
|
+
children: u.summaryHeading
|
|
966
|
+
}),
|
|
967
|
+
a?.beforeLines,
|
|
938
968
|
/* @__PURE__ */ d("ul", {
|
|
939
969
|
className: "sf-checkout-success__lines",
|
|
940
970
|
children: t.items.map((e) => /* @__PURE__ */ f("li", {
|
|
@@ -943,7 +973,7 @@ function oe({ order: t, locale: n, labels: r, className: i }) {
|
|
|
943
973
|
e.name,
|
|
944
974
|
" × ",
|
|
945
975
|
e.quantity
|
|
946
|
-
] }), /* @__PURE__ */ d("span", { children:
|
|
976
|
+
] }), /* @__PURE__ */ d("span", { children: p(e.priceCents * e.quantity) })]
|
|
947
977
|
}, e.productId))
|
|
948
978
|
}),
|
|
949
979
|
/* @__PURE__ */ f("dl", {
|
|
@@ -951,53 +981,58 @@ function oe({ order: t, locale: n, labels: r, className: i }) {
|
|
|
951
981
|
children: [
|
|
952
982
|
/* @__PURE__ */ f("div", {
|
|
953
983
|
className: "sf-checkout-success__row",
|
|
954
|
-
children: [/* @__PURE__ */ d("dt", { children:
|
|
984
|
+
children: [/* @__PURE__ */ d("dt", { children: u.subtotal }), /* @__PURE__ */ d("dd", { children: p(t.subtotalCents) })]
|
|
955
985
|
}),
|
|
956
986
|
t.discountCents > 0 && /* @__PURE__ */ f("div", {
|
|
957
987
|
className: "sf-checkout-success__row sf-checkout-success__row--discount",
|
|
958
988
|
"data-discount": !0,
|
|
959
|
-
children: [/* @__PURE__ */ f("dt", { children: [
|
|
989
|
+
children: [/* @__PURE__ */ f("dt", { children: [u.discount, t.discountCode && ` (${t.discountCode})`] }), /* @__PURE__ */ f("dd", { children: ["−", p(t.discountCents)] })]
|
|
960
990
|
}),
|
|
961
991
|
t.shippingLabel && /* @__PURE__ */ f("div", {
|
|
962
992
|
className: "sf-checkout-success__row",
|
|
963
993
|
children: [/* @__PURE__ */ f("dt", { children: [
|
|
964
|
-
|
|
994
|
+
u.shipping,
|
|
965
995
|
" (",
|
|
966
996
|
t.shippingLabel,
|
|
967
997
|
")"
|
|
968
|
-
] }), /* @__PURE__ */ d("dd", { children:
|
|
998
|
+
] }), /* @__PURE__ */ d("dd", { children: p(t.shippingCents) })]
|
|
969
999
|
}),
|
|
970
1000
|
/* @__PURE__ */ f("div", {
|
|
971
1001
|
className: "sf-checkout-success__row sf-checkout-success__row--total",
|
|
972
|
-
children: [/* @__PURE__ */ d("dt", { children:
|
|
1002
|
+
children: [/* @__PURE__ */ d("dt", { children: u.total }), /* @__PURE__ */ d("dd", { children: p(t.totalCents) })]
|
|
973
1003
|
})
|
|
974
1004
|
]
|
|
975
1005
|
}),
|
|
976
|
-
|
|
1006
|
+
a?.afterTotals,
|
|
1007
|
+
h.length > 0 && /* @__PURE__ */ f("address", {
|
|
977
1008
|
className: "sf-checkout-success__address",
|
|
978
|
-
children: [/* @__PURE__ */ d("strong", { children:
|
|
1009
|
+
children: [/* @__PURE__ */ d("strong", { children: u.shipTo }), h.map((e) => /* @__PURE__ */ d("span", { children: e }, e))]
|
|
979
1010
|
}),
|
|
980
|
-
|
|
1011
|
+
g?.trackingNumber && /* @__PURE__ */ f("p", {
|
|
981
1012
|
className: "sf-checkout-success__tracking",
|
|
982
|
-
children: [
|
|
983
|
-
href:
|
|
1013
|
+
children: [g.carrier && `${g.carrier} · `, g.trackingUrl ? /* @__PURE__ */ f("a", {
|
|
1014
|
+
href: g.trackingUrl,
|
|
984
1015
|
children: [
|
|
985
|
-
|
|
1016
|
+
u.tracking,
|
|
986
1017
|
" ",
|
|
987
|
-
|
|
1018
|
+
g.trackingNumber
|
|
988
1019
|
]
|
|
989
|
-
}) :
|
|
1020
|
+
}) : g.trackingNumber]
|
|
1021
|
+
}),
|
|
1022
|
+
y && /* @__PURE__ */ d("div", {
|
|
1023
|
+
className: "sf-checkout-success__actions",
|
|
1024
|
+
children: y
|
|
990
1025
|
})
|
|
991
1026
|
]
|
|
992
1027
|
});
|
|
993
1028
|
}
|
|
994
1029
|
// src/cart/clear-cart-on-mount.tsx
|
|
995
|
-
function
|
|
996
|
-
let { hydrated: e, clear: t } =
|
|
1030
|
+
function ce() {
|
|
1031
|
+
let { hydrated: e, clear: t } = B(), n = c(!1);
|
|
997
1032
|
return a(() => {
|
|
998
1033
|
e && !n.current && (n.current = !0, t());
|
|
999
1034
|
}, [e, t]), null;
|
|
1000
1035
|
}
|
|
1001
|
-
export {
|
|
1036
|
+
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 };
|
|
1002
1037
|
|
|
1003
1038
|
//# sourceMappingURL=index.js.map
|