@usethrottle/storefront-react 0.0.0-stage → 0.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/CLAUDE.md +67 -0
- package/README.md +119 -2
- package/dist/StorefrontProvider-Br4wUHui.d.cts +559 -0
- package/dist/StorefrontProvider-DLEPEjg6.d.ts +559 -0
- package/dist/account/index.cjs +69 -0
- package/dist/account/index.cjs.map +1 -0
- package/dist/account/index.d.cts +23 -0
- package/dist/account/index.d.ts +23 -0
- package/dist/account/index.js +68 -0
- package/dist/account/index.js.map +1 -0
- package/dist/chunk-2LCPIY2P.cjs +16 -0
- package/dist/chunk-2LCPIY2P.cjs.map +1 -0
- package/dist/chunk-3A72UY6T.js +2126 -0
- package/dist/chunk-3A72UY6T.js.map +1 -0
- package/dist/chunk-3JMIVAHN.js +185 -0
- package/dist/chunk-3JMIVAHN.js.map +1 -0
- package/dist/chunk-4J6AGWNC.cjs +24 -0
- package/dist/chunk-4J6AGWNC.cjs.map +1 -0
- package/dist/chunk-4U6MYDZV.js +17 -0
- package/dist/chunk-4U6MYDZV.js.map +1 -0
- package/dist/chunk-66HDJVPS.js +22 -0
- package/dist/chunk-66HDJVPS.js.map +1 -0
- package/dist/chunk-6X2OZSNV.cjs +83 -0
- package/dist/chunk-6X2OZSNV.cjs.map +1 -0
- package/dist/chunk-6ZMMZ245.cjs +2127 -0
- package/dist/chunk-6ZMMZ245.cjs.map +1 -0
- package/dist/chunk-7R37CVAB.cjs +23 -0
- package/dist/chunk-7R37CVAB.cjs.map +1 -0
- package/dist/chunk-A3IFWQUV.js +368 -0
- package/dist/chunk-A3IFWQUV.js.map +1 -0
- package/dist/chunk-AYC2YK4E.cjs +95 -0
- package/dist/chunk-AYC2YK4E.cjs.map +1 -0
- package/dist/chunk-AZV5U7YB.cjs +18 -0
- package/dist/chunk-AZV5U7YB.cjs.map +1 -0
- package/dist/chunk-CE2SKNQP.cjs +71 -0
- package/dist/chunk-CE2SKNQP.cjs.map +1 -0
- package/dist/chunk-D76CRI4X.js +2175 -0
- package/dist/chunk-D76CRI4X.js.map +1 -0
- package/dist/chunk-DOAII637.cjs +186 -0
- package/dist/chunk-DOAII637.cjs.map +1 -0
- package/dist/chunk-DYHHAOMG.cjs +17 -0
- package/dist/chunk-DYHHAOMG.cjs.map +1 -0
- package/dist/chunk-EYSVU5SJ.js +196 -0
- package/dist/chunk-EYSVU5SJ.js.map +1 -0
- package/dist/chunk-HSUUDZWS.js +37 -0
- package/dist/chunk-HSUUDZWS.js.map +1 -0
- package/dist/chunk-HZ6VEN6Q.cjs +101 -0
- package/dist/chunk-HZ6VEN6Q.cjs.map +1 -0
- package/dist/chunk-IJOTLGPT.js +16 -0
- package/dist/chunk-IJOTLGPT.js.map +1 -0
- package/dist/chunk-ISDATHVC.js +219 -0
- package/dist/chunk-ISDATHVC.js.map +1 -0
- package/dist/chunk-LW2A6USV.js +100 -0
- package/dist/chunk-LW2A6USV.js.map +1 -0
- package/dist/chunk-M4YXSLRG.cjs +369 -0
- package/dist/chunk-M4YXSLRG.cjs.map +1 -0
- package/dist/chunk-NDUEJJLP.cjs +2176 -0
- package/dist/chunk-NDUEJJLP.cjs.map +1 -0
- package/dist/chunk-NNE4FYRT.js +820 -0
- package/dist/chunk-NNE4FYRT.js.map +1 -0
- package/dist/chunk-NW3EFHY2.js +15 -0
- package/dist/chunk-NW3EFHY2.js.map +1 -0
- package/dist/chunk-NZRUQUN5.js +167 -0
- package/dist/chunk-NZRUQUN5.js.map +1 -0
- package/dist/chunk-P6HHE57S.cjs +38 -0
- package/dist/chunk-P6HHE57S.cjs.map +1 -0
- package/dist/chunk-PHY7AY27.cjs +197 -0
- package/dist/chunk-PHY7AY27.cjs.map +1 -0
- package/dist/chunk-PNJOFFTL.cjs +128 -0
- package/dist/chunk-PNJOFFTL.cjs.map +1 -0
- package/dist/chunk-PXZQ4ONA.js +127 -0
- package/dist/chunk-PXZQ4ONA.js.map +1 -0
- package/dist/chunk-Q3VTUBPP.js +82 -0
- package/dist/chunk-Q3VTUBPP.js.map +1 -0
- package/dist/chunk-Q3XFD5UI.js +45 -0
- package/dist/chunk-Q3XFD5UI.js.map +1 -0
- package/dist/chunk-QM7KTT7F.js +94 -0
- package/dist/chunk-QM7KTT7F.js.map +1 -0
- package/dist/chunk-RLWZOLXL.js +70 -0
- package/dist/chunk-RLWZOLXL.js.map +1 -0
- package/dist/chunk-SV53BRP2.js +23 -0
- package/dist/chunk-SV53BRP2.js.map +1 -0
- package/dist/chunk-VWXJO427.cjs +821 -0
- package/dist/chunk-VWXJO427.cjs.map +1 -0
- package/dist/chunk-WIIOJDHR.cjs +220 -0
- package/dist/chunk-WIIOJDHR.cjs.map +1 -0
- package/dist/chunk-XQHGFWLG.cjs +46 -0
- package/dist/chunk-XQHGFWLG.cjs.map +1 -0
- package/dist/chunk-ZHCXI2ZZ.cjs +168 -0
- package/dist/chunk-ZHCXI2ZZ.cjs.map +1 -0
- package/dist/index-RSj2Rg62.d.cts +8 -0
- package/dist/index-RSj2Rg62.d.ts +8 -0
- package/dist/index.cjs +2829 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1718 -0
- package/dist/index.d.ts +1718 -0
- package/dist/index.js +2828 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata-QhKw-tvz.d.cts +188 -0
- package/dist/metadata-QhKw-tvz.d.ts +188 -0
- package/dist/next/client.cjs +84 -0
- package/dist/next/client.cjs.map +1 -0
- package/dist/next/client.d.cts +40 -0
- package/dist/next/client.d.ts +40 -0
- package/dist/next/client.js +83 -0
- package/dist/next/client.js.map +1 -0
- package/dist/next/index.cjs +1090 -0
- package/dist/next/index.cjs.map +1 -0
- package/dist/next/index.d.cts +218 -0
- package/dist/next/index.d.ts +218 -0
- package/dist/next/index.js +1049 -0
- package/dist/next/index.js.map +1 -0
- package/dist/server/index.cjs +994 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +229 -0
- package/dist/server/index.d.ts +229 -0
- package/dist/server/index.js +951 -0
- package/dist/server/index.js.map +1 -0
- package/dist/styles.css +2111 -0
- package/dist/use-part-DCfFk7kf.d.ts +24 -0
- package/dist/use-part-DgjPBL_O.d.cts +24 -0
- package/package.json +121 -3
|
@@ -0,0 +1,2176 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkM4YXSLRGcjs = require('./chunk-M4YXSLRG.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunk7R37CVABcjs = require('./chunk-7R37CVAB.cjs');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _chunkHZ6VEN6Qcjs = require('./chunk-HZ6VEN6Q.cjs');
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var _chunkDYHHAOMGcjs = require('./chunk-DYHHAOMG.cjs');
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _chunkP6HHE57Scjs = require('./chunk-P6HHE57S.cjs');
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var _chunkXQHGFWLGcjs = require('./chunk-XQHGFWLG.cjs');
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
var _chunkVWXJO427cjs = require('./chunk-VWXJO427.cjs');
|
|
37
|
+
|
|
38
|
+
// src/site/SlotOutlet.tsx
|
|
39
|
+
var _ui = require('@usethrottle/ui');
|
|
40
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
41
|
+
function SlotOutlet({ name, context }) {
|
|
42
|
+
const Renderer = _ui.useSlotOutlet.call(void 0, name);
|
|
43
|
+
const part = _chunkVWXJO427cjs.usePart.call(void 0, "slot-outlet");
|
|
44
|
+
if (!Renderer) return null;
|
|
45
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...part, "data-slot": name, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Renderer, { context }) });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/url/shop-query.ts
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
var _url = require('@usethrottle/catalog/url');
|
|
55
|
+
var enabledSorts = (settings) => new Set(settings.listing.sorts.filter((s) => s.enabled).map((s) => s.key));
|
|
56
|
+
function explicitSort(params, settings) {
|
|
57
|
+
const { sort } = _url.parseShopQuery.call(void 0, params);
|
|
58
|
+
return sort !== void 0 && enabledSorts(settings).has(sort) ? sort : null;
|
|
59
|
+
}
|
|
60
|
+
function parseShopQuery(params, settings, rangeKeys) {
|
|
61
|
+
const ranged = rangeKeys === void 0 ? null : new Set(rangeKeys);
|
|
62
|
+
const raw = _url.parseShopQuery.call(void 0, params);
|
|
63
|
+
const filters = {};
|
|
64
|
+
const ranges = {};
|
|
65
|
+
for (const key of Object.keys(_nullishCoalesce(raw.filters, () => ( {})))) {
|
|
66
|
+
if (_chunkM4YXSLRGcjs.isUnsafeKey.call(void 0, key)) continue;
|
|
67
|
+
for (const value of raw.filters[key]) {
|
|
68
|
+
const range = ranged === null || ranged.has(key) ? _url.parseRange.call(void 0, value) : null;
|
|
69
|
+
if (range) {
|
|
70
|
+
if (!Object.hasOwn(ranges, key)) ranges[key] = range;
|
|
71
|
+
} else (filters[key] ??= []).push(value);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (const key of Object.keys(filters)) filters[key] = [...new Set(filters[key])].sort();
|
|
75
|
+
const query = {
|
|
76
|
+
filters,
|
|
77
|
+
ranges,
|
|
78
|
+
sort: _nullishCoalesce(explicitSort(params, settings), () => ( settings.listing.defaultSort)),
|
|
79
|
+
page: raw.page !== void 0 && raw.page >= 1 ? raw.page : 1
|
|
80
|
+
};
|
|
81
|
+
if (raw.q) query.q = raw.q;
|
|
82
|
+
return query;
|
|
83
|
+
}
|
|
84
|
+
function toCatalogQuery(q, settings) {
|
|
85
|
+
const filters = {};
|
|
86
|
+
for (const key of Object.keys(q.filters)) filters[key] = [...q.filters[key]];
|
|
87
|
+
for (const key of Object.keys(q.ranges)) (filters[key] ??= []).push(_url.formatRange.call(void 0, q.ranges[key]));
|
|
88
|
+
for (const key of Object.keys(filters)) filters[key] = [...new Set(filters[key])].sort();
|
|
89
|
+
return {
|
|
90
|
+
...q.q ? { q: q.q } : {},
|
|
91
|
+
...Object.keys(filters).length > 0 ? { filters } : {},
|
|
92
|
+
...q.sort !== settings.listing.defaultSort ? { sort: q.sort } : {},
|
|
93
|
+
...q.page > 1 ? { page: q.page } : {}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function shopQueryToSearch(q, settings) {
|
|
97
|
+
return _url.serializeShopQuery.call(void 0, toCatalogQuery(q, settings));
|
|
98
|
+
}
|
|
99
|
+
function pageWindow(current, count) {
|
|
100
|
+
const pages = [.../* @__PURE__ */ new Set([1, current - 1, current, current + 1, count])].filter((p) => p >= 1 && p <= count).sort((a, b) => a - b);
|
|
101
|
+
const out = [];
|
|
102
|
+
for (const [i, p] of pages.entries()) {
|
|
103
|
+
if (i > 0 && p - pages[i - 1] > 1) out.push(null);
|
|
104
|
+
out.push(p);
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
function variantFromSearch(params, product) {
|
|
109
|
+
const value = params instanceof URLSearchParams ? params.get("variant") : params.variant;
|
|
110
|
+
const sku = Array.isArray(value) ? value[0] : value;
|
|
111
|
+
return sku !== void 0 && product.variants.some((v) => v.sku === sku) ? sku : null;
|
|
112
|
+
}
|
|
113
|
+
var filterValueCount = (q) => Object.values(q.filters).reduce((n, values) => n + values.length, 0) + Object.keys(q.ranges).length;
|
|
114
|
+
function robotsForShopQuery(q, settings) {
|
|
115
|
+
return { index: filterValueCount(q) <= 1 && q.sort === settings.listing.defaultSort && !q.q, follow: true };
|
|
116
|
+
}
|
|
117
|
+
function canonicalForShopQuery(baseUrl, pathname, q, settings, source) {
|
|
118
|
+
const first = [
|
|
119
|
+
...Object.entries(q.filters).flatMap(([key, values]) => values.map((value) => ({ key, value }))),
|
|
120
|
+
...Object.entries(q.ranges).map(([key, range]) => ({ key, value: _url.formatRange.call(void 0, range) }))
|
|
121
|
+
].sort((a, b) => a.key === b.key ? a.value.localeCompare(b.value) : a.key.localeCompare(b.key))[0];
|
|
122
|
+
const kept = {
|
|
123
|
+
filters: {},
|
|
124
|
+
ranges: {},
|
|
125
|
+
sort: settings.listing.defaultSort,
|
|
126
|
+
page: q.page,
|
|
127
|
+
...q.q && _optionalChain([source, 'optionalAccess', _ => _.kind]) === "search" ? { q: q.q } : {}
|
|
128
|
+
};
|
|
129
|
+
if (first) {
|
|
130
|
+
const range = _url.parseRange.call(void 0, first.value);
|
|
131
|
+
if (range) kept.ranges[first.key] = range;
|
|
132
|
+
else kept.filters[first.key] = [first.value];
|
|
133
|
+
}
|
|
134
|
+
const search = shopQueryToSearch(kept, settings);
|
|
135
|
+
return `${baseUrl.replace(/\/+$/u, "")}${pathname}${search ? `?${search}` : ""}`;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/seo/JsonLd.tsx
|
|
139
|
+
|
|
140
|
+
function JsonLd({ data }) {
|
|
141
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
142
|
+
"script",
|
|
143
|
+
{
|
|
144
|
+
type: "application/ld+json",
|
|
145
|
+
dangerouslySetInnerHTML: { __html: JSON.stringify(data).replace(/</gu, "\\u003c") }
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/seo/json-ld.ts
|
|
151
|
+
var _money = require('@usethrottle/money');
|
|
152
|
+
var SCHEMA = "https://schema.org";
|
|
153
|
+
var availabilityOf = (states) => {
|
|
154
|
+
if (states.includes("in_stock")) return `${SCHEMA}/InStock`;
|
|
155
|
+
if (states.includes("preorder")) return `${SCHEMA}/PreOrder`;
|
|
156
|
+
if (states.includes("backorder")) return `${SCHEMA}/BackOrder`;
|
|
157
|
+
return `${SCHEMA}/OutOfStock`;
|
|
158
|
+
};
|
|
159
|
+
function productJsonLd(product, o) {
|
|
160
|
+
const priced = product.variants.map((v) => ({ minor: _nullishCoalesce(v.salePriceMinor, () => ( v.priceMinor)), currency: _nullishCoalesce(v.currency, () => ( o.currency)) })).filter((p) => p.minor !== null && p.currency === o.currency);
|
|
161
|
+
const lowest = priced.sort((a, b) => a.minor - b.minor)[0];
|
|
162
|
+
const price = _nullishCoalesce(lowest, () => ( (product.priceRange ? { minor: product.priceRange.minMinor, currency: product.priceRange.currency } : null)));
|
|
163
|
+
const store = o.settings.brand.storeName.trim();
|
|
164
|
+
const description = _nullishCoalesce(product.shortDescription, () => ( product.description));
|
|
165
|
+
return {
|
|
166
|
+
"@context": SCHEMA,
|
|
167
|
+
"@type": "Product",
|
|
168
|
+
name: _nullishCoalesce(product.title, () => ( product.handle)),
|
|
169
|
+
...description ? { description } : {},
|
|
170
|
+
...product.images.length > 0 ? { image: product.images.map((i) => i.url) } : {},
|
|
171
|
+
...product.brand ? { brand: { "@type": "Brand", name: product.brand } } : {},
|
|
172
|
+
...product.variants[0] ? { sku: product.variants[0].sku } : {},
|
|
173
|
+
url: o.url,
|
|
174
|
+
offers: {
|
|
175
|
+
"@type": "Offer",
|
|
176
|
+
url: o.url,
|
|
177
|
+
...price ? { price: _money.toDecimalString.call(void 0, price.minor, price.currency), priceCurrency: price.currency } : {},
|
|
178
|
+
availability: availabilityOf(
|
|
179
|
+
product.variants.length > 0 ? product.variants.map((v) => v.availability) : [product.availability]
|
|
180
|
+
),
|
|
181
|
+
...store ? { seller: { "@type": "Organization", name: store } } : {}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function breadcrumbJsonLd(crumbs) {
|
|
186
|
+
return {
|
|
187
|
+
"@context": SCHEMA,
|
|
188
|
+
"@type": "BreadcrumbList",
|
|
189
|
+
itemListElement: crumbs.map((c, i) => ({ "@type": "ListItem", position: i + 1, name: c.name, item: c.url }))
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function itemListJsonLd(products, o) {
|
|
193
|
+
const base = o.baseUrl.replace(/\/+$/u, "");
|
|
194
|
+
return {
|
|
195
|
+
"@context": SCHEMA,
|
|
196
|
+
"@type": "ItemList",
|
|
197
|
+
itemListElement: products.map((p, i) => ({
|
|
198
|
+
"@type": "ListItem",
|
|
199
|
+
position: i + 1,
|
|
200
|
+
url: `${base}${_chunkHZ6VEN6Qcjs.routeHref.call(void 0, o.settings, "product", p.handle)}`,
|
|
201
|
+
...p.title ? { name: p.title } : {}
|
|
202
|
+
}))
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/seo/metadata.ts
|
|
207
|
+
var origin = (baseUrl) => baseUrl.replace(/\/+$/u, "");
|
|
208
|
+
var absolute = (baseUrl, path) => `${origin(baseUrl)}${path}`;
|
|
209
|
+
function pageTitle(template, store, page) {
|
|
210
|
+
const name = page.trim();
|
|
211
|
+
const shop = store.trim();
|
|
212
|
+
if (name === "") return shop;
|
|
213
|
+
if (shop === "") return name;
|
|
214
|
+
return template.split("{page}").join(name).split("{store}").join(shop);
|
|
215
|
+
}
|
|
216
|
+
function resolved(data, o) {
|
|
217
|
+
return _chunkM4YXSLRGcjs.resolveSiteDesign.call(void 0, { site: _nullishCoalesce(o.site, () => ( null)), settings: data.settings });
|
|
218
|
+
}
|
|
219
|
+
var nonEmpty = (value) => value && value.trim() ? value : void 0;
|
|
220
|
+
function openGraph(title, description, images) {
|
|
221
|
+
const urls = images.filter((u) => Boolean(u));
|
|
222
|
+
return { title, ...description ? { description } : {}, ...urls.length > 0 ? { images: urls } : {} };
|
|
223
|
+
}
|
|
224
|
+
function listingPath(settings, source) {
|
|
225
|
+
switch (source.kind) {
|
|
226
|
+
case "all":
|
|
227
|
+
return settings.routes.shop;
|
|
228
|
+
case "search":
|
|
229
|
+
return settings.routes.search.split("?")[0];
|
|
230
|
+
default:
|
|
231
|
+
return _chunkHZ6VEN6Qcjs.routeHref.call(void 0, settings, source.kind, source.handle);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function shopAllMetadata(data, o) {
|
|
235
|
+
const site = resolved(data, o);
|
|
236
|
+
const title = pageTitle(site.seo.titleTemplate, site.brand.storeName, _nullishCoalesce(data.seoTitle, () => ( data.title)));
|
|
237
|
+
const description = _nullishCoalesce(nonEmpty(data.description), () => ( nonEmpty(site.seo.defaultDescription)));
|
|
238
|
+
return {
|
|
239
|
+
title,
|
|
240
|
+
...description ? { description } : {},
|
|
241
|
+
alternates: {
|
|
242
|
+
canonical: canonicalForShopQuery(o.baseUrl, listingPath(data.settings, data.source), data.query, data.settings, data.source)
|
|
243
|
+
},
|
|
244
|
+
robots: robotsForShopQuery(data.query, data.settings),
|
|
245
|
+
openGraph: openGraph(title, description, [site.seo.shareImage])
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function searchMetadata(data, o) {
|
|
249
|
+
return { ...shopAllMetadata(data, o), robots: { index: false, follow: true } };
|
|
250
|
+
}
|
|
251
|
+
function productMetadata(data, o) {
|
|
252
|
+
const { product } = data;
|
|
253
|
+
const site = resolved(data, o);
|
|
254
|
+
const name = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(nonEmpty(product.seoTitle), () => ( nonEmpty(_optionalChain([product, 'access', _2 => _2.seo, 'optionalAccess', _3 => _3.title])))), () => ( product.title)), () => ( product.handle));
|
|
255
|
+
const title = pageTitle(site.seo.titleTemplate, site.brand.storeName, name);
|
|
256
|
+
const description = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(nonEmpty(product.seoDescription), () => ( nonEmpty(_optionalChain([product, 'access', _4 => _4.seo, 'optionalAccess', _5 => _5.description])))), () => ( nonEmpty(product.shortDescription))), () => ( nonEmpty(product.description))), () => ( nonEmpty(site.seo.defaultDescription)));
|
|
257
|
+
return {
|
|
258
|
+
title,
|
|
259
|
+
...description ? { description } : {},
|
|
260
|
+
alternates: { canonical: absolute(o.baseUrl, _chunkHZ6VEN6Qcjs.routeHref.call(void 0, data.settings, "product", product.handle)) },
|
|
261
|
+
openGraph: openGraph(title, description, [_nullishCoalesce(_optionalChain([product, 'access', _6 => _6.images, 'access', _7 => _7[0], 'optionalAccess', _8 => _8.url]), () => ( site.seo.shareImage))])
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/pieces/Badge.tsx
|
|
266
|
+
|
|
267
|
+
var KIND_BACKGROUND = {
|
|
268
|
+
sale: "var(--throttle-sf-sale)",
|
|
269
|
+
new: "var(--throttle-sf-accent)",
|
|
270
|
+
lowStock: "var(--throttle-sf-warning)"
|
|
271
|
+
};
|
|
272
|
+
function ink(hex) {
|
|
273
|
+
const [r, g, b] = _chunkM4YXSLRGcjs.parseHex.call(void 0, hex).map((c) => {
|
|
274
|
+
const v = c / 255;
|
|
275
|
+
return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
|
|
276
|
+
});
|
|
277
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b > 0.4 ? "#20150e" : "#ffffff";
|
|
278
|
+
}
|
|
279
|
+
function Badge({ kind, tone, children, classNames, className, unstyled }) {
|
|
280
|
+
const part = _chunkVWXJO427cjs.usePart.call(void 0, "product-badge", { classNames, className, unstyled });
|
|
281
|
+
const style = {};
|
|
282
|
+
if (_chunkM4YXSLRGcjs.isHexColor.call(void 0, tone)) {
|
|
283
|
+
style["--tsf-badge-bg"] = tone;
|
|
284
|
+
style["--tsf-badge-fg"] = ink(tone);
|
|
285
|
+
} else if (kind && KIND_BACKGROUND[kind]) {
|
|
286
|
+
style["--tsf-badge-bg"] = KIND_BACKGROUND[kind];
|
|
287
|
+
}
|
|
288
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...part, "data-badge": kind, style: Object.keys(style).length > 0 ? style : void 0, children });
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// src/pieces/badges.ts
|
|
292
|
+
var DAY_MS = 864e5;
|
|
293
|
+
function createdAtOf(product) {
|
|
294
|
+
const at = product.createdAt;
|
|
295
|
+
const time = typeof at === "string" ? Date.parse(at) : NaN;
|
|
296
|
+
return Number.isNaN(time) ? null : time;
|
|
297
|
+
}
|
|
298
|
+
function isNew(product, days, generatedAt) {
|
|
299
|
+
const created = createdAtOf(product);
|
|
300
|
+
const now = Date.parse(generatedAt);
|
|
301
|
+
if (created === null || Number.isNaN(now)) return _optionalChain([product, 'access', _9 => _9.badges, 'optionalAccess', _10 => _10.new]) === true;
|
|
302
|
+
return now - created <= days * DAY_MS;
|
|
303
|
+
}
|
|
304
|
+
function isSale(product) {
|
|
305
|
+
const range = product.priceRange;
|
|
306
|
+
if (!range) return _optionalChain([product, 'access', _11 => _11.badges, 'optionalAccess', _12 => _12.sale]) === true;
|
|
307
|
+
const compareAt = "compareAtMinMinor" in range ? range.compareAtMinMinor : null;
|
|
308
|
+
return typeof compareAt === "number" && compareAt > range.minMinor;
|
|
309
|
+
}
|
|
310
|
+
var toneOf = (colour, catalogDefault) => _chunkM4YXSLRGcjs.isHexColor.call(void 0, colour) && colour.toLowerCase() !== catalogDefault.toLowerCase() ? colour : void 0;
|
|
311
|
+
function cardBadges(settings, product, generatedAt) {
|
|
312
|
+
if (!settings.card.showBadges) return [];
|
|
313
|
+
const { badges } = settings;
|
|
314
|
+
const out = [];
|
|
315
|
+
const add = (kind, label, tone) => out.push(tone === void 0 ? { kind, label } : { kind, label, tone });
|
|
316
|
+
if (badges.new.enabled && isNew(product, badges.new.days, generatedAt))
|
|
317
|
+
add("new", badges.new.label, toneOf(badges.new.colour, _chunkM4YXSLRGcjs.DEFAULT_SETTINGS.badges.new.colour));
|
|
318
|
+
if (badges.sale.enabled && isSale(product))
|
|
319
|
+
add("sale", badges.sale.label, toneOf(badges.sale.colour, _chunkM4YXSLRGcjs.DEFAULT_SETTINGS.badges.sale.colour));
|
|
320
|
+
if (badges.lowStock.enabled && product.lowStock && product.availability !== "out_of_stock")
|
|
321
|
+
add("lowStock", badges.lowStock.label);
|
|
322
|
+
for (const custom of badges.custom)
|
|
323
|
+
if (_optionalChain([product, 'access', _13 => _13.tags, 'optionalAccess', _14 => _14.includes, 'call', _15 => _15(custom.tag)])) add("custom", custom.label, _chunkM4YXSLRGcjs.isHexColor.call(void 0, custom.colour) ? custom.colour : void 0);
|
|
324
|
+
return out;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// src/pieces/reserved.tsx
|
|
328
|
+
function WishlistButton(_props) {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
function BackInStock(_props) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
function FrequentlyBoughtTogether(_props) {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
function ReviewPhotos(_props) {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
function ReviewVotes(_props) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
function QuestionsAndAnswers(_props) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// src/pieces/Swatch.tsx
|
|
348
|
+
|
|
349
|
+
function Swatch({ value, hex, image, selected, disabled, classNames, className, unstyled }) {
|
|
350
|
+
const part = _chunkVWXJO427cjs.usePart.call(void 0, "swatch", { classNames, className, unstyled });
|
|
351
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
352
|
+
"span",
|
|
353
|
+
{
|
|
354
|
+
...part,
|
|
355
|
+
role: "img",
|
|
356
|
+
"aria-label": value,
|
|
357
|
+
"data-selected": selected ? "true" : void 0,
|
|
358
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
359
|
+
style: image ? { backgroundImage: `url(${JSON.stringify(image)})` } : _chunkM4YXSLRGcjs.isHexColor.call(void 0, hex) ? { backgroundColor: hex } : void 0
|
|
360
|
+
}
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// src/product/variant-logic.ts
|
|
365
|
+
var DROPDOWN_ABOVE = 8;
|
|
366
|
+
function pickerKind(option) {
|
|
367
|
+
const { values } = option;
|
|
368
|
+
if (values.length > 0 && values.every((v) => v.swatch !== void 0 && v.swatch !== null)) return "swatch";
|
|
369
|
+
return values.length > DROPDOWN_ABOVE ? "dropdown" : "buttons";
|
|
370
|
+
}
|
|
371
|
+
var optionsOf = (variant) => _nullishCoalesce(variant.options, () => ( {}));
|
|
372
|
+
var matches = (variant, selection) => {
|
|
373
|
+
const own = optionsOf(variant);
|
|
374
|
+
return Object.entries(selection).every(([name, value]) => own[name] === value);
|
|
375
|
+
};
|
|
376
|
+
var isSoldOut = (variant) => variant.availability === "out_of_stock" || !variant.purchasable;
|
|
377
|
+
function variantForSelection(product, selection) {
|
|
378
|
+
return product.variants.find((v) => matches(v, selection));
|
|
379
|
+
}
|
|
380
|
+
function pickVariant(product, sku) {
|
|
381
|
+
const { variants } = product;
|
|
382
|
+
return _nullishCoalesce(_nullishCoalesce(variants.find((v) => v.sku === sku), () => ( variants.find((v) => !isSoldOut(v)))), () => ( variants[0]));
|
|
383
|
+
}
|
|
384
|
+
function selectOption(product, current, name, value) {
|
|
385
|
+
const selection = { ...current, [name]: value };
|
|
386
|
+
const variant = variantForSelection(product, selection);
|
|
387
|
+
return { selection, sku: _nullishCoalesce(_optionalChain([variant, 'optionalAccess', _16 => _16.sku]), () => ( null)), soldOut: variant ? isSoldOut(variant) : false };
|
|
388
|
+
}
|
|
389
|
+
function nearestVariant(product, current, name, value) {
|
|
390
|
+
const others = Object.entries(current).filter(([k]) => k !== name);
|
|
391
|
+
let best;
|
|
392
|
+
for (const variant of product.variants) {
|
|
393
|
+
const own = optionsOf(variant);
|
|
394
|
+
if (own[name] !== value) continue;
|
|
395
|
+
const kept = others.filter(([k, v]) => own[k] === v).length;
|
|
396
|
+
const better = !best || kept > best.kept || kept === best.kept && isSoldOut(best.variant) && !isSoldOut(variant);
|
|
397
|
+
if (better) best = { variant, kept };
|
|
398
|
+
}
|
|
399
|
+
return _optionalChain([best, 'optionalAccess', _17 => _17.variant]);
|
|
400
|
+
}
|
|
401
|
+
function valueState(product, current, name, value) {
|
|
402
|
+
const result = selectOption(product, current, name, value);
|
|
403
|
+
if (result.sku === null) return "unavailable";
|
|
404
|
+
return result.soldOut ? "sold-out" : "available";
|
|
405
|
+
}
|
|
406
|
+
function stockOf(product, variant) {
|
|
407
|
+
if (product.availableInCurrency === false || variant.priceMinor === null) return "no_currency";
|
|
408
|
+
if (isSoldOut(variant)) return "out";
|
|
409
|
+
if (variant.availability === "preorder") return "preorder";
|
|
410
|
+
if (variant.availability === "backorder") return "backorder";
|
|
411
|
+
return variant.lowStock ? "low" : "in_stock";
|
|
412
|
+
}
|
|
413
|
+
function quantityBounds(variant) {
|
|
414
|
+
const max = _optionalChain([variant, 'optionalAccess', _18 => _18.maxOrderQuantity]);
|
|
415
|
+
return { min: 1, max: typeof max === "number" && max >= 1 ? Math.floor(max) : void 0 };
|
|
416
|
+
}
|
|
417
|
+
function clampQuantity(value, max) {
|
|
418
|
+
const whole = Number.isFinite(value) ? Math.floor(value) : 1;
|
|
419
|
+
return Math.min(_nullishCoalesce(max, () => ( Number.POSITIVE_INFINITY)), Math.max(1, whole));
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// src/product/use-product-page.ts
|
|
423
|
+
var _catalog = require('@usethrottle/catalog');
|
|
424
|
+
var _react = require('@usethrottle/catalog/react');
|
|
425
|
+
|
|
426
|
+
var _react3 = require('react');
|
|
427
|
+
var ProductPageContext = _react3.createContext.call(void 0, null);
|
|
428
|
+
function useProductPage() {
|
|
429
|
+
const value = _react3.useContext.call(void 0, ProductPageContext);
|
|
430
|
+
if (!value) throw new Error("useProductPage() was called outside <ProductPage.Root>.");
|
|
431
|
+
return value;
|
|
432
|
+
}
|
|
433
|
+
var decimal = (minor, currency) => Number(_money.toDecimalString.call(void 0, minor, currency));
|
|
434
|
+
function refusedLine(error, sku) {
|
|
435
|
+
if (!_catalog.isCatalogError.call(void 0, error)) return null;
|
|
436
|
+
const lines = error.lines;
|
|
437
|
+
if (!Array.isArray(lines)) return null;
|
|
438
|
+
return _nullishCoalesce(_nullishCoalesce(lines.find((l) => l.sku === sku), () => ( lines[0])), () => ( null));
|
|
439
|
+
}
|
|
440
|
+
function useProductPageState(input) {
|
|
441
|
+
const { product, priceContext, initialSku } = input;
|
|
442
|
+
const { router, currency: storeCurrency } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
443
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
444
|
+
const track = _chunkDYHHAOMGcjs.useTrack.call(void 0, );
|
|
445
|
+
const cart = _react.useCart.call(void 0, storeCurrency ? { currency: storeCurrency } : void 0);
|
|
446
|
+
const sectionsId = _react3.useId.call(void 0, );
|
|
447
|
+
const addToCartRef = _react3.useRef.call(void 0, null);
|
|
448
|
+
const revealSectionRef = _react3.useRef.call(void 0, null);
|
|
449
|
+
const urlSku = variantFromSearch(router.searchParams, product);
|
|
450
|
+
const [chosen, setChosen] = _react3.useState.call(void 0, null);
|
|
451
|
+
_react3.useEffect.call(void 0, () => {
|
|
452
|
+
setChosen(null);
|
|
453
|
+
}, [urlSku, product.handle]);
|
|
454
|
+
const variant = pickVariant(product, _nullishCoalesce(_nullishCoalesce(chosen, () => ( urlSku)), () => ( initialSku)));
|
|
455
|
+
const sku = _nullishCoalesce(_optionalChain([variant, 'optionalAccess', _19 => _19.sku]), () => ( null));
|
|
456
|
+
const selection = _react3.useMemo.call(void 0, () => ({ ..._nullishCoalesce(_optionalChain([variant, 'optionalAccess', _20 => _20.options]), () => ( {})) }), [variant]);
|
|
457
|
+
const stock = variant ? stockOf(product, variant) : null;
|
|
458
|
+
const selectOption2 = _react3.useCallback.call(void 0,
|
|
459
|
+
(name, value) => {
|
|
460
|
+
const result = selectOption(product, selection, name, value);
|
|
461
|
+
const next = _nullishCoalesce(_nullishCoalesce(result.sku, () => ( _optionalChain([nearestVariant, 'call', _21 => _21(product, selection, name, value), 'optionalAccess', _22 => _22.sku]))), () => ( null));
|
|
462
|
+
if (next === null) return;
|
|
463
|
+
setChosen(next);
|
|
464
|
+
const params = new URLSearchParams(router.searchParams.toString());
|
|
465
|
+
params.set("variant", next);
|
|
466
|
+
router.replace(`${router.pathname}?${params.toString()}`, { scroll: false });
|
|
467
|
+
},
|
|
468
|
+
[product, selection, router]
|
|
469
|
+
);
|
|
470
|
+
const maxQuantity = quantityBounds(variant).max;
|
|
471
|
+
const [wanted, setWanted] = _react3.useState.call(void 0, 1);
|
|
472
|
+
const quantity = clampQuantity(wanted, maxQuantity);
|
|
473
|
+
const setQuantity = _react3.useCallback.call(void 0, (n) => setWanted(clampQuantity(n, maxQuantity)), [maxQuantity]);
|
|
474
|
+
const eventCurrency = _nullishCoalesce(_nullishCoalesce(_optionalChain([variant, 'optionalAccess', _23 => _23.currency]), () => ( _optionalChain([product, 'access', _24 => _24.priceRange, 'optionalAccess', _25 => _25.currency]))), () => ( storeCurrency));
|
|
475
|
+
const unitMinor = variant ? _nullishCoalesce(variant.salePriceMinor, () => ( variant.priceMinor)) : null;
|
|
476
|
+
const seen = _react3.useRef.call(void 0, /* @__PURE__ */ new Set());
|
|
477
|
+
_react3.useEffect.call(void 0, () => {
|
|
478
|
+
if (!sku || !eventCurrency || seen.current.has(sku)) return;
|
|
479
|
+
seen.current.add(sku);
|
|
480
|
+
track("view_item", {
|
|
481
|
+
currency: eventCurrency,
|
|
482
|
+
...unitMinor !== null ? { value: decimal(unitMinor, eventCurrency) } : {},
|
|
483
|
+
items: [_chunkHZ6VEN6Qcjs.toGa4Item.call(void 0, product, { variantSku: sku })]
|
|
484
|
+
});
|
|
485
|
+
}, [sku, eventCurrency, unitMinor, product, track]);
|
|
486
|
+
const [adding, setAdding] = _react3.useState.call(void 0, false);
|
|
487
|
+
const [message, setMessage] = _react3.useState.call(void 0, null);
|
|
488
|
+
const title = _nullishCoalesce(product.title, () => ( product.handle));
|
|
489
|
+
const add = _react3.useCallback.call(void 0, async () => {
|
|
490
|
+
if (!sku || adding) return;
|
|
491
|
+
setAdding(true);
|
|
492
|
+
setMessage(null);
|
|
493
|
+
try {
|
|
494
|
+
await cart.add(sku, quantity);
|
|
495
|
+
if (eventCurrency) {
|
|
496
|
+
track("add_to_cart", {
|
|
497
|
+
currency: eventCurrency,
|
|
498
|
+
...unitMinor !== null ? { value: decimal(unitMinor * quantity, eventCurrency) } : {},
|
|
499
|
+
items: [_chunkHZ6VEN6Qcjs.toGa4Item.call(void 0, product, { variantSku: sku, quantity })]
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
setMessage({ tone: "ok", text: t("product.cartAdd.added", { quantity, title }) });
|
|
503
|
+
} catch (error) {
|
|
504
|
+
if (error instanceof DOMException && error.name === "AbortError") return;
|
|
505
|
+
const line = refusedLine(error, sku);
|
|
506
|
+
const left = _optionalChain([line, 'optionalAccess', _26 => _26.maxQuantity]);
|
|
507
|
+
setMessage({
|
|
508
|
+
tone: "refused",
|
|
509
|
+
text: left === 0 ? t("product.cartAdd.outOfStock") : typeof left === "number" ? t("product.cartAdd.onlyLeft", { count: left }) : t("product.cartAdd.failed")
|
|
510
|
+
});
|
|
511
|
+
} finally {
|
|
512
|
+
setAdding(false);
|
|
513
|
+
}
|
|
514
|
+
}, [sku, adding, cart, quantity, eventCurrency, unitMinor, product, title, track, t]);
|
|
515
|
+
return {
|
|
516
|
+
product,
|
|
517
|
+
priceContext,
|
|
518
|
+
selection,
|
|
519
|
+
sku,
|
|
520
|
+
variant,
|
|
521
|
+
stock,
|
|
522
|
+
selectOption: selectOption2,
|
|
523
|
+
quantity,
|
|
524
|
+
setQuantity,
|
|
525
|
+
maxQuantity,
|
|
526
|
+
add,
|
|
527
|
+
adding,
|
|
528
|
+
message,
|
|
529
|
+
layout: input.layout,
|
|
530
|
+
sectionsStyle: input.sectionsStyle,
|
|
531
|
+
reviewsLayout: _nullishCoalesce(input.reviewsLayout, () => ( "stack")),
|
|
532
|
+
related: input.related,
|
|
533
|
+
generatedAt: input.generatedAt,
|
|
534
|
+
baseUrl: input.baseUrl,
|
|
535
|
+
addToCartRef,
|
|
536
|
+
revealSectionRef,
|
|
537
|
+
initialReviews: input.reviews,
|
|
538
|
+
shippingPage: input.shippingPage,
|
|
539
|
+
sectionsId
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// src/product/AddToCart.tsx
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
function AddToCart({ classNames, className, unstyled }) {
|
|
547
|
+
const local = { classNames, unstyled };
|
|
548
|
+
const { add, adding, stock, sku, message, addToCartRef } = useProductPage();
|
|
549
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
550
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "add-to-cart", { ...local, className });
|
|
551
|
+
const button = _chunkVWXJO427cjs.usePart.call(void 0, "add-to-cart-button", local);
|
|
552
|
+
const status = _chunkVWXJO427cjs.usePart.call(void 0, "add-to-cart-message", local);
|
|
553
|
+
const cannot = !sku || stock === "out" || stock === "no_currency";
|
|
554
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...root, ref: (el) => {
|
|
555
|
+
addToCartRef.current = el;
|
|
556
|
+
}, children: [
|
|
557
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
558
|
+
"button",
|
|
559
|
+
{
|
|
560
|
+
...button,
|
|
561
|
+
type: "button",
|
|
562
|
+
disabled: cannot,
|
|
563
|
+
"aria-disabled": adding || void 0,
|
|
564
|
+
"aria-busy": adding || void 0,
|
|
565
|
+
"data-adding": adding ? "true" : void 0,
|
|
566
|
+
onClick: () => {
|
|
567
|
+
if (!adding) void add();
|
|
568
|
+
},
|
|
569
|
+
children: [
|
|
570
|
+
adding ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Spinner, {}) : null,
|
|
571
|
+
adding ? t("product.cartAdd.adding") : t("product.addToCart")
|
|
572
|
+
]
|
|
573
|
+
}
|
|
574
|
+
),
|
|
575
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...status, role: "status", "aria-live": "polite", "data-tone": _optionalChain([message, 'optionalAccess', _27 => _27.tone]), children: _optionalChain([message, 'optionalAccess', _28 => _28.text]) })
|
|
576
|
+
] });
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// src/product/Breadcrumbs.tsx
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
function productCrumbs(product, settings, homeLabel) {
|
|
583
|
+
return [
|
|
584
|
+
{ name: settings.brand.storeName.trim() || homeLabel, href: "/" },
|
|
585
|
+
...(_nullishCoalesce(product.breadcrumbs, () => ( []))).map((c) => ({ name: c.name, href: _chunkHZ6VEN6Qcjs.routeHref.call(void 0, settings, "category", c.handle) })),
|
|
586
|
+
{ name: _nullishCoalesce(product.title, () => ( product.handle)), href: _chunkHZ6VEN6Qcjs.routeHref.call(void 0, settings, "product", product.handle) }
|
|
587
|
+
];
|
|
588
|
+
}
|
|
589
|
+
function Breadcrumbs({ classNames, className, unstyled }) {
|
|
590
|
+
const local = { classNames, unstyled };
|
|
591
|
+
const { product } = useProductPage();
|
|
592
|
+
const { settings, Link: Anchor } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
593
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
594
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "product-breadcrumbs", { ...local, className });
|
|
595
|
+
const list = _chunkVWXJO427cjs.usePart.call(void 0, "product-breadcrumbs-list", local);
|
|
596
|
+
const item = _chunkVWXJO427cjs.usePart.call(void 0, "product-breadcrumbs-item", local);
|
|
597
|
+
const link = _chunkVWXJO427cjs.usePart.call(void 0, "product-breadcrumbs-link", local);
|
|
598
|
+
const current = _chunkVWXJO427cjs.usePart.call(void 0, "product-breadcrumbs-current", local);
|
|
599
|
+
const crumbs = productCrumbs(product, settings, t("product.crumbs.home"));
|
|
600
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "nav", { ...root, "aria-label": t("product.crumbs.label"), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { ...list, children: crumbs.map((crumb, i) => /* @__PURE__ */ _react3.createElement.call(void 0, "li", { ...item, key: `${crumb.href}-${i}` }, i === crumbs.length - 1 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...current, "aria-current": "page", children: crumb.name }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Anchor, { ...link, href: crumb.href, children: crumb.name }))) }) });
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// src/product/QuantityInput.tsx
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
function QuantityInput({ classNames, className, unstyled }) {
|
|
608
|
+
const local = { classNames, unstyled };
|
|
609
|
+
const { quantity, setQuantity, maxQuantity, stock } = useProductPage();
|
|
610
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
611
|
+
const id = _react3.useId.call(void 0, );
|
|
612
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "quantity-input", { ...local, className });
|
|
613
|
+
const decrease = _chunkVWXJO427cjs.usePart.call(void 0, "quantity-decrease", local);
|
|
614
|
+
const field = _chunkVWXJO427cjs.usePart.call(void 0, "quantity-field", local);
|
|
615
|
+
const increase = _chunkVWXJO427cjs.usePart.call(void 0, "quantity-increase", local);
|
|
616
|
+
const [text, setText] = _react3.useState.call(void 0, String(quantity));
|
|
617
|
+
_react3.useEffect.call(void 0, () => setText(String(quantity)), [quantity]);
|
|
618
|
+
const disabled = stock === "out" || stock === "no_currency";
|
|
619
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...root, children: [
|
|
620
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { htmlFor: id, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.VisuallyHidden, { children: t("product.quantity") }) }),
|
|
621
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
622
|
+
"button",
|
|
623
|
+
{
|
|
624
|
+
...decrease,
|
|
625
|
+
type: "button",
|
|
626
|
+
"aria-label": t("product.quantityInput.decrease"),
|
|
627
|
+
disabled,
|
|
628
|
+
"aria-disabled": quantity <= 1 || void 0,
|
|
629
|
+
onClick: () => quantity > 1 && setQuantity(quantity - 1),
|
|
630
|
+
children: "\u2212"
|
|
631
|
+
}
|
|
632
|
+
),
|
|
633
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
634
|
+
"input",
|
|
635
|
+
{
|
|
636
|
+
...field,
|
|
637
|
+
id,
|
|
638
|
+
type: "number",
|
|
639
|
+
inputMode: "numeric",
|
|
640
|
+
min: 1,
|
|
641
|
+
max: maxQuantity,
|
|
642
|
+
value: text,
|
|
643
|
+
disabled,
|
|
644
|
+
onChange: (e) => {
|
|
645
|
+
const raw = e.target.value;
|
|
646
|
+
if (raw === "") return setText("");
|
|
647
|
+
const n = Number.parseInt(raw, 10);
|
|
648
|
+
if (Number.isNaN(n)) return;
|
|
649
|
+
const held = clampQuantity(n, maxQuantity);
|
|
650
|
+
setText(String(held));
|
|
651
|
+
setQuantity(held);
|
|
652
|
+
},
|
|
653
|
+
onBlur: () => setText(String(quantity))
|
|
654
|
+
}
|
|
655
|
+
),
|
|
656
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
657
|
+
"button",
|
|
658
|
+
{
|
|
659
|
+
...increase,
|
|
660
|
+
type: "button",
|
|
661
|
+
"aria-label": t("product.quantityInput.increase"),
|
|
662
|
+
disabled,
|
|
663
|
+
"aria-disabled": maxQuantity !== void 0 && quantity >= maxQuantity || void 0,
|
|
664
|
+
onClick: () => (maxQuantity === void 0 || quantity < maxQuantity) && setQuantity(quantity + 1),
|
|
665
|
+
children: "+"
|
|
666
|
+
}
|
|
667
|
+
)
|
|
668
|
+
] });
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// src/product/StockStatus.tsx
|
|
672
|
+
|
|
673
|
+
var WORD_KEY = {
|
|
674
|
+
in_stock: "inStock",
|
|
675
|
+
low: "lowStock",
|
|
676
|
+
preorder: "preorder",
|
|
677
|
+
backorder: "backorder",
|
|
678
|
+
out: "outOfStock"
|
|
679
|
+
};
|
|
680
|
+
var ENGLISH = {
|
|
681
|
+
inStock: "In stock",
|
|
682
|
+
lowStock: "Only a few left",
|
|
683
|
+
outOfStock: "Out of stock",
|
|
684
|
+
backorder: "Available on backorder",
|
|
685
|
+
preorder: "Pre-order"
|
|
686
|
+
};
|
|
687
|
+
function stockWord(settings, key, count) {
|
|
688
|
+
const word = settings.stock.words[key].trim() || ENGLISH[key];
|
|
689
|
+
if (!word.includes("{count}")) return word;
|
|
690
|
+
if (count !== void 0) return word.split("{count}").join(String(count));
|
|
691
|
+
return settings.badges.lowStock.label.trim() || ENGLISH.lowStock;
|
|
692
|
+
}
|
|
693
|
+
function StockStatus({ classNames, className, unstyled }) {
|
|
694
|
+
const { stock, variant } = useProductPage();
|
|
695
|
+
const { settings, currency } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
696
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
697
|
+
const part = _chunkVWXJO427cjs.usePart.call(void 0, "stock-status", { classNames, className, unstyled });
|
|
698
|
+
const state = _nullishCoalesce(stock, () => ( "out"));
|
|
699
|
+
const shown = _nullishCoalesce(_optionalChain([variant, 'optionalAccess', _29 => _29.currency]), () => ( currency));
|
|
700
|
+
const text = state === "no_currency" ? shown ? t("product.stockStatus.noCurrency", { currency: shown }) : t("product.stockStatus.noCurrencyAny") : stockWord(settings, WORD_KEY[state]);
|
|
701
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...part, "data-state": state, "data-stock-words": state === "no_currency" ? void 0 : WORD_KEY[state], children: text });
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// src/product/VariantPicker.tsx
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
var swatchProps = (swatch) => !swatch ? {} : "color" in swatch ? { hex: swatch.color } : { image: swatch.url };
|
|
709
|
+
function OptionGroup({ option, kind, ...local }) {
|
|
710
|
+
const { product, selection, selectOption: selectOption2 } = useProductPage();
|
|
711
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
712
|
+
const group = _chunkVWXJO427cjs.usePart.call(void 0, "variant-option", local);
|
|
713
|
+
const legend = _chunkVWXJO427cjs.usePart.call(void 0, "variant-option-legend", local);
|
|
714
|
+
const nameOf = _chunkVWXJO427cjs.usePart.call(void 0, "variant-option-name", local);
|
|
715
|
+
const chosenOf = _chunkVWXJO427cjs.usePart.call(void 0, "variant-option-chosen", local);
|
|
716
|
+
const values = _chunkVWXJO427cjs.usePart.call(void 0, "variant-option-values", local);
|
|
717
|
+
const value = _chunkVWXJO427cjs.usePart.call(void 0, "variant-value", local);
|
|
718
|
+
const label = _chunkVWXJO427cjs.usePart.call(void 0, "variant-value-label", local);
|
|
719
|
+
const chosen = selection[option.name];
|
|
720
|
+
const others = Object.entries(selection).filter(([name]) => name !== option.name).map(([, v]) => v).join(" / ");
|
|
721
|
+
if (kind === "dropdown") {
|
|
722
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...group, "data-option-name": option.name, "data-picker": kind, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
723
|
+
_ui.Select,
|
|
724
|
+
{
|
|
725
|
+
label: option.name,
|
|
726
|
+
value: _nullishCoalesce(chosen, () => ( "")),
|
|
727
|
+
placeholder: chosen === void 0 ? t("product.options.chooseOne", { option: option.name }) : void 0,
|
|
728
|
+
options: option.values.map((v) => {
|
|
729
|
+
const state = valueState(product, selection, option.name, v.value);
|
|
730
|
+
return { value: v.value, label: state === "sold-out" ? `${v.value}${t("product.options.soldOut")}` : v.value };
|
|
731
|
+
}),
|
|
732
|
+
onChange: (next) => next !== "" && selectOption2(option.name, next)
|
|
733
|
+
}
|
|
734
|
+
) });
|
|
735
|
+
}
|
|
736
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "fieldset", { ...group, "data-option-name": option.name, "data-picker": kind, children: [
|
|
737
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "legend", { ...legend, children: [
|
|
738
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...nameOf, children: option.name }),
|
|
739
|
+
chosen ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...chosenOf, children: chosen }) : null
|
|
740
|
+
] }),
|
|
741
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...values, children: option.values.map((v) => {
|
|
742
|
+
const state = valueState(product, selection, option.name, v.value);
|
|
743
|
+
const pressed = chosen === v.value;
|
|
744
|
+
return /* @__PURE__ */ _react3.createElement.call(void 0,
|
|
745
|
+
"button",
|
|
746
|
+
{
|
|
747
|
+
...value,
|
|
748
|
+
key: v.value,
|
|
749
|
+
type: "button",
|
|
750
|
+
"data-value": v.value,
|
|
751
|
+
"data-kind": kind,
|
|
752
|
+
"aria-pressed": pressed,
|
|
753
|
+
"aria-disabled": false,
|
|
754
|
+
"data-sold-out": state === "sold-out" ? "" : void 0,
|
|
755
|
+
"data-unavailable": state === "unavailable" ? "" : void 0,
|
|
756
|
+
onClick: () => selectOption2(option.name, v.value)
|
|
757
|
+
},
|
|
758
|
+
kind === "swatch" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Swatch, { ...local, ...swatchProps(v.swatch), value: v.value, selected: pressed }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...label, children: v.value }),
|
|
759
|
+
state === "sold-out" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.VisuallyHidden, { children: t("product.options.soldOut") }) : null,
|
|
760
|
+
state === "unavailable" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.VisuallyHidden, { children: t("product.options.unavailableWith", { others: others || option.name }) }) : null
|
|
761
|
+
);
|
|
762
|
+
}) })
|
|
763
|
+
] });
|
|
764
|
+
}
|
|
765
|
+
function VariantPicker({ classNames, className, unstyled }) {
|
|
766
|
+
const { product } = useProductPage();
|
|
767
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "variant-picker", { classNames, className, unstyled });
|
|
768
|
+
const options = _nullishCoalesce(product.options, () => ( []));
|
|
769
|
+
if (options.length === 0) return null;
|
|
770
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...root, children: options.map((option) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, OptionGroup, { option, kind: pickerKind(option), classNames, unstyled }, option.name)) });
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// src/product/BuyBox.tsx
|
|
774
|
+
|
|
775
|
+
var DEFAULT_SLOTS = { Price: _chunkHZ6VEN6Qcjs.Price, VariantPicker, StockStatus, QuantityInput, AddToCart, WishlistButton, BackInStock };
|
|
776
|
+
function BuyBox({ slots, classNames, className, unstyled, headingLevel = 1 }) {
|
|
777
|
+
const Heading = `h${headingLevel}`;
|
|
778
|
+
const local = { classNames, unstyled };
|
|
779
|
+
const s = { ...DEFAULT_SLOTS, ...slots };
|
|
780
|
+
const { product, variant, priceContext, revealSectionRef, sectionsId } = useProductPage();
|
|
781
|
+
const { settings, currency } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
782
|
+
const { t, keyAttr } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
783
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "buy-box", { ...local, className });
|
|
784
|
+
const kicker = _chunkVWXJO427cjs.usePart.call(void 0, "buy-box-kicker", local);
|
|
785
|
+
const title = _chunkVWXJO427cjs.usePart.call(void 0, "buy-box-title", local);
|
|
786
|
+
const ratingLink = _chunkVWXJO427cjs.usePart.call(void 0, "buy-box-rating", local);
|
|
787
|
+
const summary = _chunkVWXJO427cjs.usePart.call(void 0, "buy-box-summary", local);
|
|
788
|
+
const priceRow = _chunkVWXJO427cjs.usePart.call(void 0, "buy-box-price", local);
|
|
789
|
+
const sku = _chunkVWXJO427cjs.usePart.call(void 0, "buy-box-sku", local);
|
|
790
|
+
const actions = _chunkVWXJO427cjs.usePart.call(void 0, "buy-box-actions", local);
|
|
791
|
+
const kickerText = [product.productType, product.brand].filter(Boolean).join(" \xB7 ");
|
|
792
|
+
const rating = product.rating;
|
|
793
|
+
const showRating = rating && rating.count > 0 && rating.average !== null && settings.product.sections.some((x) => x.key === "reviews" && x.enabled);
|
|
794
|
+
const now = variant ? _nullishCoalesce(variant.salePriceMinor, () => ( variant.priceMinor)) : null;
|
|
795
|
+
const was = variant ? variant.salePriceMinor !== null && variant.priceMinor !== null ? variant.priceMinor : _nullishCoalesce(variant.compareAtPriceMinor, () => ( void 0)) : void 0;
|
|
796
|
+
const priced = _nullishCoalesce(_optionalChain([variant, 'optionalAccess', _30 => _30.currency]), () => ( currency));
|
|
797
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...root, children: [
|
|
798
|
+
kickerText ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...kicker, children: kickerText }) : null,
|
|
799
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Heading, { ...title, children: _nullishCoalesce(product.title, () => ( product.handle)) }),
|
|
800
|
+
showRating ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
801
|
+
"a",
|
|
802
|
+
{
|
|
803
|
+
...ratingLink,
|
|
804
|
+
href: `#${sectionsId}-panel-reviews`,
|
|
805
|
+
onClick: (e) => {
|
|
806
|
+
if (_optionalChain([revealSectionRef, 'access', _31 => _31.current, 'optionalCall', _32 => _32("reviews")])) {
|
|
807
|
+
e.preventDefault();
|
|
808
|
+
requestAnimationFrame(() => _optionalChain([document, 'access', _33 => _33.getElementById, 'call', _34 => _34(`${sectionsId}-panel-reviews`), 'optionalAccess', _35 => _35.scrollIntoView, 'call', _36 => _36({ block: "start" })]));
|
|
809
|
+
}
|
|
810
|
+
},
|
|
811
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHZ6VEN6Qcjs.StarRating, { ...local, value: rating.average, count: rating.count })
|
|
812
|
+
}
|
|
813
|
+
) : null,
|
|
814
|
+
product.shortDescription ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...summary, children: product.shortDescription }) : null,
|
|
815
|
+
now !== null && priced ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...priceRow, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, s.Price, { ...local, minor: now, currency: priced, compareAtMinor: _nullishCoalesce(was, () => ( void 0)), priceContext }) }) : null,
|
|
816
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, s.VariantPicker, { ...local }),
|
|
817
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, s.StockStatus, { ...local }),
|
|
818
|
+
variant ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { ...sku, children: [
|
|
819
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...keyAttr("product.sku"), children: t("product.sku") }),
|
|
820
|
+
" ",
|
|
821
|
+
variant.sku
|
|
822
|
+
] }) : null,
|
|
823
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...actions, children: [
|
|
824
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, s.QuantityInput, { ...local }),
|
|
825
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, s.AddToCart, { ...local }),
|
|
826
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, s.WishlistButton, { ...local, product, variant }),
|
|
827
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, s.BackInStock, { ...local, product, variant })
|
|
828
|
+
] })
|
|
829
|
+
] });
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// src/product/CategoryList.tsx
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
function CategoryList({ classNames, className, unstyled }) {
|
|
836
|
+
const local = { classNames, unstyled };
|
|
837
|
+
const { product } = useProductPage();
|
|
838
|
+
const { settings, Link: Anchor } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
839
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "category-list", { ...local, className });
|
|
840
|
+
const item = _chunkVWXJO427cjs.usePart.call(void 0, "category-list-item", local);
|
|
841
|
+
const link = _chunkVWXJO427cjs.usePart.call(void 0, "category-list-link", local);
|
|
842
|
+
const categories = _nullishCoalesce(product.categories, () => ( []));
|
|
843
|
+
if (categories.length === 0) return null;
|
|
844
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { ...root, children: categories.map((category) => /* @__PURE__ */ _react3.createElement.call(void 0, "li", { ...item, key: category.id, "data-category-handle": category.handle }, /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Anchor, { ...link, href: _chunkHZ6VEN6Qcjs.routeHref.call(void 0, settings, "category", category.handle), children: category.name }))) });
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// src/product/Gallery.tsx
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
var Lightbox = _react3.lazy.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("./chunk-CE2SKNQP.cjs"))));
|
|
853
|
+
var SWIPE_PX = 40;
|
|
854
|
+
var STAGE_SIZES = "(min-width: 1024px) 50vw, 100vw";
|
|
855
|
+
function Gallery({ classNames, className, unstyled }) {
|
|
856
|
+
const local = { classNames, unstyled };
|
|
857
|
+
const { product, variant } = useProductPage();
|
|
858
|
+
const { dir } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
859
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
860
|
+
const items = _chunk7R37CVABcjs.galleryItems.call(void 0, product);
|
|
861
|
+
const count = items.length;
|
|
862
|
+
const title = _nullishCoalesce(product.title, () => ( product.handle));
|
|
863
|
+
const indexOfVariant = () => {
|
|
864
|
+
const url = _nullishCoalesce(_optionalChain([variant, 'optionalAccess', _37 => _37.image, 'optionalAccess', _38 => _38.url]), () => ( _optionalChain([variant, 'optionalAccess', _39 => _39.images, 'access', _40 => _40[0], 'optionalAccess', _41 => _41.url])));
|
|
865
|
+
const at = url ? items.findIndex((i) => i.url === url) : -1;
|
|
866
|
+
return at >= 0 ? at : 0;
|
|
867
|
+
};
|
|
868
|
+
const [active, setActive] = _react3.useState.call(void 0, indexOfVariant);
|
|
869
|
+
const [open, setOpen] = _react3.useState.call(void 0, false);
|
|
870
|
+
const [zoom, setZoom] = _react3.useState.call(void 0, null);
|
|
871
|
+
const start = _react3.useRef.call(void 0, null);
|
|
872
|
+
const zoomAt = _react3.useRef.call(void 0, null);
|
|
873
|
+
const frame = _react3.useRef.call(void 0, 0);
|
|
874
|
+
const stopZoom = () => {
|
|
875
|
+
cancelAnimationFrame(frame.current);
|
|
876
|
+
frame.current = 0;
|
|
877
|
+
zoomAt.current = null;
|
|
878
|
+
setZoom(null);
|
|
879
|
+
};
|
|
880
|
+
_react3.useEffect.call(void 0, () => () => cancelAnimationFrame(frame.current), []);
|
|
881
|
+
const first = _react3.useRef.call(void 0, true);
|
|
882
|
+
const sku = _optionalChain([variant, 'optionalAccess', _42 => _42.sku]);
|
|
883
|
+
_react3.useEffect.call(void 0, () => {
|
|
884
|
+
if (first.current) {
|
|
885
|
+
first.current = false;
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
setActive(indexOfVariant());
|
|
889
|
+
}, [sku]);
|
|
890
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "gallery", { ...local, className });
|
|
891
|
+
const stage = _chunkVWXJO427cjs.usePart.call(void 0, "gallery-stage", local);
|
|
892
|
+
const itemPart = _chunkVWXJO427cjs.usePart.call(void 0, "gallery-item", local);
|
|
893
|
+
const video = _chunkVWXJO427cjs.usePart.call(void 0, "gallery-video", local);
|
|
894
|
+
const placeholder = _chunkVWXJO427cjs.usePart.call(void 0, "gallery-placeholder", local);
|
|
895
|
+
const previous = _chunkVWXJO427cjs.usePart.call(void 0, "gallery-previous", local);
|
|
896
|
+
const next = _chunkVWXJO427cjs.usePart.call(void 0, "gallery-next", local);
|
|
897
|
+
const enlarge = _chunkVWXJO427cjs.usePart.call(void 0, "gallery-enlarge", local);
|
|
898
|
+
const counter = _chunkVWXJO427cjs.usePart.call(void 0, "gallery-counter", local);
|
|
899
|
+
const thumbs = _chunkVWXJO427cjs.usePart.call(void 0, "gallery-thumbs", local);
|
|
900
|
+
const thumbItem = _chunkVWXJO427cjs.usePart.call(void 0, "gallery-thumbs-item", local);
|
|
901
|
+
const thumb = _chunkVWXJO427cjs.usePart.call(void 0, "gallery-thumb", local);
|
|
902
|
+
const go = (delta) => count > 0 && setActive((a) => (a + delta + count) % count);
|
|
903
|
+
const current = items[active];
|
|
904
|
+
const onKeyDown = (e) => {
|
|
905
|
+
const forward = dir === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
906
|
+
const backward = dir === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
907
|
+
if (e.key === forward) go(1);
|
|
908
|
+
else if (e.key === backward) go(-1);
|
|
909
|
+
else if (e.key === "Home") setActive(0);
|
|
910
|
+
else if (e.key === "End") setActive(count - 1);
|
|
911
|
+
else return;
|
|
912
|
+
e.preventDefault();
|
|
913
|
+
};
|
|
914
|
+
const onPointerDown = (e) => {
|
|
915
|
+
start.current = { x: e.clientX, moved: false };
|
|
916
|
+
};
|
|
917
|
+
const onPointerMove = (e) => {
|
|
918
|
+
if (e.pointerType === "mouse" && current && !_chunk7R37CVABcjs.isVideo.call(void 0, current)) {
|
|
919
|
+
const box = e.currentTarget.getBoundingClientRect();
|
|
920
|
+
if (box.width > 0 && box.height > 0) {
|
|
921
|
+
zoomAt.current = { x: (e.clientX - box.left) / box.width * 100, y: (e.clientY - box.top) / box.height * 100 };
|
|
922
|
+
if (!frame.current) {
|
|
923
|
+
frame.current = requestAnimationFrame(() => {
|
|
924
|
+
frame.current = 0;
|
|
925
|
+
if (zoomAt.current) setZoom(zoomAt.current);
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
if (start.current && Math.abs(e.clientX - start.current.x) > 10) start.current.moved = true;
|
|
931
|
+
};
|
|
932
|
+
const onPointerUp = (e) => {
|
|
933
|
+
const from = start.current;
|
|
934
|
+
start.current = null;
|
|
935
|
+
if (!from) return;
|
|
936
|
+
const dx = e.clientX - from.x;
|
|
937
|
+
if (Math.abs(dx) >= SWIPE_PX) go((dir === "rtl" ? dx > 0 : dx < 0) ? 1 : -1);
|
|
938
|
+
};
|
|
939
|
+
const onClick = () => {
|
|
940
|
+
if (_optionalChain([start, 'access', _43 => _43.current, 'optionalAccess', _44 => _44.moved])) return;
|
|
941
|
+
if (current && !_chunk7R37CVABcjs.isVideo.call(void 0, current)) setOpen(true);
|
|
942
|
+
};
|
|
943
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "section", { ...root, "aria-label": t("product.gallery.label", { title }), children: [
|
|
944
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
945
|
+
"div",
|
|
946
|
+
{
|
|
947
|
+
...stage,
|
|
948
|
+
tabIndex: 0,
|
|
949
|
+
role: "group",
|
|
950
|
+
"aria-roledescription": "carousel",
|
|
951
|
+
"aria-label": t("product.gallery.label", { title }),
|
|
952
|
+
onKeyDown,
|
|
953
|
+
onPointerDown,
|
|
954
|
+
onPointerMove,
|
|
955
|
+
onPointerUp,
|
|
956
|
+
onPointerLeave: () => {
|
|
957
|
+
stopZoom();
|
|
958
|
+
start.current = null;
|
|
959
|
+
},
|
|
960
|
+
onClick,
|
|
961
|
+
children: [
|
|
962
|
+
current ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...itemPart, "data-index": active, "data-zoomed": zoom ? "true" : void 0, style: zoom ? { transformOrigin: `${zoom.x}% ${zoom.y}%` } : void 0, children: _chunk7R37CVABcjs.isVideo.call(void 0, current) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "video", { ...video, src: current.url, controls: true, playsInline: true, preload: "metadata", "aria-label": t("product.gallery.video", { title }) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
963
|
+
_chunkP6HHE57Scjs.Image,
|
|
964
|
+
{
|
|
965
|
+
...local,
|
|
966
|
+
src: current.url,
|
|
967
|
+
alt: _nullishCoalesce(current.altText, () => ( t("product.gallery.photoAlt", { title, n: active + 1 }))),
|
|
968
|
+
aspectRatio: _chunk7R37CVABcjs.ratioOf.call(void 0, current),
|
|
969
|
+
srcSet: _chunk7R37CVABcjs.srcSetOf.call(void 0, current),
|
|
970
|
+
sizes: STAGE_SIZES,
|
|
971
|
+
priority: active === 0
|
|
972
|
+
}
|
|
973
|
+
) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...placeholder }),
|
|
974
|
+
count > 1 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
975
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { ...previous, type: "button", "aria-label": t("product.gallery.previous"), onClick: (e) => {
|
|
976
|
+
e.stopPropagation();
|
|
977
|
+
go(-1);
|
|
978
|
+
}, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Icon, { name: "chevron-left", size: 20 }) }),
|
|
979
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { ...next, type: "button", "aria-label": t("product.gallery.next"), onClick: (e) => {
|
|
980
|
+
e.stopPropagation();
|
|
981
|
+
go(1);
|
|
982
|
+
}, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Icon, { name: "chevron-right", size: 20 }) }),
|
|
983
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...counter, "aria-live": "polite", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "bdi", { dir: "ltr", children: t("product.gallery.counter", { n: active + 1, count }) }) })
|
|
984
|
+
] }) : null,
|
|
985
|
+
current && !_chunk7R37CVABcjs.isVideo.call(void 0, current) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { ...enlarge, type: "button", "aria-label": t("product.gallery.enlarge"), onClick: (e) => {
|
|
986
|
+
e.stopPropagation();
|
|
987
|
+
setOpen(true);
|
|
988
|
+
}, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Icon, { name: "zoom", size: 18 }) }) : null
|
|
989
|
+
]
|
|
990
|
+
}
|
|
991
|
+
),
|
|
992
|
+
count > 1 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { ...thumbs, "aria-label": t("product.gallery.thumbs"), children: items.map((item, i) => /* @__PURE__ */ _react3.createElement.call(void 0, "li", { ...thumbItem, key: `${item.url}-${i}` }, /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
993
|
+
"button",
|
|
994
|
+
{
|
|
995
|
+
...thumb,
|
|
996
|
+
type: "button",
|
|
997
|
+
"aria-label": t("product.gallery.showPhoto", { n: i + 1, count }),
|
|
998
|
+
"aria-current": i === active ? "true" : void 0,
|
|
999
|
+
onClick: () => setActive(i),
|
|
1000
|
+
children: _chunk7R37CVABcjs.isVideo.call(void 0, item) && !item.posterUrl ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Icon, { name: "play", size: 20 }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkP6HHE57Scjs.Image, { ...local, src: _chunk7R37CVABcjs.isVideo.call(void 0, item) ? item.posterUrl : _nullishCoalesce(_optionalChain([item, 'access', _45 => _45.sizes, 'optionalAccess', _46 => _46["400"]]), () => ( item.url)), alt: "", aspectRatio: _chunk7R37CVABcjs.ratioOf.call(void 0, item) })
|
|
1001
|
+
}
|
|
1002
|
+
))) }) : null,
|
|
1003
|
+
open ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Lightbox, { ...local, open: true, items, index: active, title, onIndexChange: setActive, onClose: () => setOpen(false) }) }) : null
|
|
1004
|
+
] });
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
// src/pieces/RichText.tsx
|
|
1008
|
+
|
|
1009
|
+
var ALLOWED_TAGS = /* @__PURE__ */ new Set([
|
|
1010
|
+
"p",
|
|
1011
|
+
"br",
|
|
1012
|
+
"hr",
|
|
1013
|
+
"div",
|
|
1014
|
+
"span",
|
|
1015
|
+
"strong",
|
|
1016
|
+
"b",
|
|
1017
|
+
"em",
|
|
1018
|
+
"i",
|
|
1019
|
+
"u",
|
|
1020
|
+
"s",
|
|
1021
|
+
"del",
|
|
1022
|
+
"ins",
|
|
1023
|
+
"mark",
|
|
1024
|
+
"small",
|
|
1025
|
+
"sub",
|
|
1026
|
+
"sup",
|
|
1027
|
+
"blockquote",
|
|
1028
|
+
"pre",
|
|
1029
|
+
"code",
|
|
1030
|
+
"ul",
|
|
1031
|
+
"ol",
|
|
1032
|
+
"li",
|
|
1033
|
+
"dl",
|
|
1034
|
+
"dt",
|
|
1035
|
+
"dd",
|
|
1036
|
+
"h1",
|
|
1037
|
+
"h2",
|
|
1038
|
+
"h3",
|
|
1039
|
+
"h4",
|
|
1040
|
+
"h5",
|
|
1041
|
+
"h6",
|
|
1042
|
+
"a",
|
|
1043
|
+
"img",
|
|
1044
|
+
"figure",
|
|
1045
|
+
"figcaption",
|
|
1046
|
+
"table",
|
|
1047
|
+
"caption",
|
|
1048
|
+
"thead",
|
|
1049
|
+
"tbody",
|
|
1050
|
+
"tfoot",
|
|
1051
|
+
"tr",
|
|
1052
|
+
"th",
|
|
1053
|
+
"td"
|
|
1054
|
+
]);
|
|
1055
|
+
var VOID_TAGS = /* @__PURE__ */ new Set(["br", "hr", "img"]);
|
|
1056
|
+
var DROP_WITH_CONTENT = /* @__PURE__ */ new Set([
|
|
1057
|
+
"script",
|
|
1058
|
+
"style",
|
|
1059
|
+
"iframe",
|
|
1060
|
+
"object",
|
|
1061
|
+
"embed",
|
|
1062
|
+
"noscript",
|
|
1063
|
+
"template",
|
|
1064
|
+
"textarea",
|
|
1065
|
+
"title",
|
|
1066
|
+
"noembed",
|
|
1067
|
+
"noframes",
|
|
1068
|
+
"xmp",
|
|
1069
|
+
"svg",
|
|
1070
|
+
"math"
|
|
1071
|
+
]);
|
|
1072
|
+
var ALLOWED_ATTRS = {
|
|
1073
|
+
"*": ["title", "lang", "dir"],
|
|
1074
|
+
a: ["href", "target", "rel"],
|
|
1075
|
+
img: ["src", "alt", "width", "height", "loading"],
|
|
1076
|
+
th: ["colspan", "rowspan", "scope"],
|
|
1077
|
+
td: ["colspan", "rowspan"]
|
|
1078
|
+
};
|
|
1079
|
+
var URL_ATTRS = /* @__PURE__ */ new Set(["href", "src"]);
|
|
1080
|
+
var SAFE_SCHEME = /^(https?|mailto|tel):/i;
|
|
1081
|
+
var NAMED_ENTITIES = { colon: ":", tab: " ", newline: "\n", amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: " " };
|
|
1082
|
+
function decodeEntities(value) {
|
|
1083
|
+
return value.replace(/&(?:#x([0-9a-f]+)|#(\d+)|([a-z]+));?/gi, (whole, hex, dec, name) => {
|
|
1084
|
+
const code = hex ? Number.parseInt(hex, 16) : dec ? Number.parseInt(dec, 10) : NaN;
|
|
1085
|
+
if (!Number.isNaN(code)) return code > 0 && code <= 1114111 ? String.fromCodePoint(code) : "";
|
|
1086
|
+
return _nullishCoalesce(NAMED_ENTITIES[name.toLowerCase()], () => ( whole));
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
function safeUrl(raw) {
|
|
1090
|
+
const plain = decodeEntities(raw).replace(/[\u0000- \u007f-\u009f]/g, "");
|
|
1091
|
+
if (plain === "") return null;
|
|
1092
|
+
if (SAFE_SCHEME.test(plain)) return plain;
|
|
1093
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(plain) ? null : decodeEntities(raw).trim();
|
|
1094
|
+
}
|
|
1095
|
+
var escapeAttr = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
1096
|
+
var escapeText = (value) => value.replace(/</g, "<").replace(/>/g, ">");
|
|
1097
|
+
var TAG_NAME = /[a-z][a-z0-9-]*/iy;
|
|
1098
|
+
function readTag(html, start) {
|
|
1099
|
+
const attrs = [];
|
|
1100
|
+
let i = start;
|
|
1101
|
+
for (; ; ) {
|
|
1102
|
+
while (i < html.length && /[\s/]/.test(html[i])) i += 1;
|
|
1103
|
+
if (i >= html.length) return null;
|
|
1104
|
+
if (html[i] === ">") return { attrs, end: i + 1, selfClosing: /\/\s*$/.test(html.slice(start, i)) };
|
|
1105
|
+
let name = "";
|
|
1106
|
+
while (i < html.length && !/[\s=/>]/.test(html[i])) name += html[i++];
|
|
1107
|
+
while (i < html.length && /\s/.test(html[i])) i += 1;
|
|
1108
|
+
let value = "";
|
|
1109
|
+
if (html[i] === "=") {
|
|
1110
|
+
i += 1;
|
|
1111
|
+
while (i < html.length && /\s/.test(html[i])) i += 1;
|
|
1112
|
+
const quote = html[i];
|
|
1113
|
+
if (quote === '"' || quote === "'") {
|
|
1114
|
+
const close = html.indexOf(quote, i + 1);
|
|
1115
|
+
if (close === -1) return null;
|
|
1116
|
+
value = html.slice(i + 1, close);
|
|
1117
|
+
i = close + 1;
|
|
1118
|
+
} else {
|
|
1119
|
+
while (i < html.length && !/[\s>]/.test(html[i])) value += html[i++];
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
if (name) attrs.push({ name: name.toLowerCase(), value });
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
function sanitizeHtml(html, options = {}) {
|
|
1126
|
+
let out = "";
|
|
1127
|
+
const open = [];
|
|
1128
|
+
let i = 0;
|
|
1129
|
+
while (i < html.length) {
|
|
1130
|
+
const lt = html.indexOf("<", i);
|
|
1131
|
+
if (lt === -1) {
|
|
1132
|
+
out += escapeText(html.slice(i));
|
|
1133
|
+
break;
|
|
1134
|
+
}
|
|
1135
|
+
out += escapeText(html.slice(i, lt));
|
|
1136
|
+
i = lt;
|
|
1137
|
+
if (html.startsWith("<!--", i)) {
|
|
1138
|
+
const close = html.indexOf("-->", i + 4);
|
|
1139
|
+
i = close === -1 ? html.length : close + 3;
|
|
1140
|
+
continue;
|
|
1141
|
+
}
|
|
1142
|
+
const closing = html[i + 1] === "/";
|
|
1143
|
+
const nameStart = i + (closing ? 2 : 1);
|
|
1144
|
+
TAG_NAME.lastIndex = nameStart;
|
|
1145
|
+
const name = _optionalChain([TAG_NAME, 'access', _47 => _47.exec, 'call', _48 => _48(html), 'optionalAccess', _49 => _49[0], 'optionalAccess', _50 => _50.toLowerCase, 'call', _51 => _51()]);
|
|
1146
|
+
if (!name) {
|
|
1147
|
+
if (html[i + 1] === "!" || html[i + 1] === "?") {
|
|
1148
|
+
const close = html.indexOf(">", i);
|
|
1149
|
+
i = close === -1 ? html.length : close + 1;
|
|
1150
|
+
} else {
|
|
1151
|
+
out += "<";
|
|
1152
|
+
i += 1;
|
|
1153
|
+
}
|
|
1154
|
+
continue;
|
|
1155
|
+
}
|
|
1156
|
+
const tag = readTag(html, nameStart + name.length);
|
|
1157
|
+
if (!tag) break;
|
|
1158
|
+
i = tag.end;
|
|
1159
|
+
if (closing) {
|
|
1160
|
+
const at = open.lastIndexOf(name);
|
|
1161
|
+
if (at !== -1) {
|
|
1162
|
+
while (open.length > at) out += `</${open.pop()}>`;
|
|
1163
|
+
}
|
|
1164
|
+
continue;
|
|
1165
|
+
}
|
|
1166
|
+
if (DROP_WITH_CONTENT.has(name)) {
|
|
1167
|
+
if (!tag.selfClosing) {
|
|
1168
|
+
const close = new RegExp(`</${name}\\s*>`, "ig");
|
|
1169
|
+
close.lastIndex = i;
|
|
1170
|
+
const found = close.exec(html);
|
|
1171
|
+
i = found ? found.index + found[0].length : html.length;
|
|
1172
|
+
}
|
|
1173
|
+
continue;
|
|
1174
|
+
}
|
|
1175
|
+
if (!ALLOWED_TAGS.has(name)) continue;
|
|
1176
|
+
let attrs = "";
|
|
1177
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1178
|
+
const blank = name === "a" && tag.attrs.some((a) => a.name === "target" && a.value.trim().toLowerCase() === "_blank");
|
|
1179
|
+
for (const { name: attr, value } of tag.attrs) {
|
|
1180
|
+
if (blank && attr === "rel") continue;
|
|
1181
|
+
if (seen.has(attr) || !(ALLOWED_ATTRS["*"].includes(attr) || _optionalChain([ALLOWED_ATTRS, 'access', _52 => _52[name], 'optionalAccess', _53 => _53.includes, 'call', _54 => _54(attr)]))) continue;
|
|
1182
|
+
seen.add(attr);
|
|
1183
|
+
if (URL_ATTRS.has(attr)) {
|
|
1184
|
+
const url = safeUrl(value);
|
|
1185
|
+
if (url !== null) attrs += ` ${attr}="${escapeAttr(url)}"`;
|
|
1186
|
+
} else {
|
|
1187
|
+
attrs += ` ${attr}="${escapeAttr(decodeEntities(value))}"`;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
if (blank) attrs += ' rel="noopener noreferrer"';
|
|
1191
|
+
if (name === "a" && options.linkClass) attrs += ` class="${escapeAttr(options.linkClass)}"`;
|
|
1192
|
+
out += `<${name}${attrs}>`;
|
|
1193
|
+
if (!VOID_TAGS.has(name)) open.push(name);
|
|
1194
|
+
}
|
|
1195
|
+
while (open.length > 0) out += `</${open.pop()}>`;
|
|
1196
|
+
return out;
|
|
1197
|
+
}
|
|
1198
|
+
function RichText({ html, classNames, className, unstyled }) {
|
|
1199
|
+
const part = _chunkVWXJO427cjs.usePart.call(void 0, "rich-text", { classNames, className, unstyled });
|
|
1200
|
+
const ambient = _chunkVWXJO427cjs.useUnstyled.call(void 0, );
|
|
1201
|
+
const linkClass = _nullishCoalesce(unstyled, () => ( ambient)) ? void 0 : "tsf-rich-text-link";
|
|
1202
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...part, dangerouslySetInnerHTML: { __html: sanitizeHtml(html, { linkClass }) } });
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// src/product/RelatedProducts.tsx
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
|
|
1209
|
+
// src/pieces/ProductCard.tsx
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
var SIZES = "(min-width: 1280px) 300px, (min-width: 768px) 33vw, 50vw";
|
|
1214
|
+
var MAX_SWATCHES = 5;
|
|
1215
|
+
function srcSetOf2(image) {
|
|
1216
|
+
const entries = Object.entries(_nullishCoalesce(image.sizes, () => ( {}))).filter(([, url]) => typeof url === "string" && url !== "");
|
|
1217
|
+
return entries.length > 0 ? entries.map(([width, url]) => `${url} ${width}w`).join(", ") : void 0;
|
|
1218
|
+
}
|
|
1219
|
+
function swatchesOf(product) {
|
|
1220
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1221
|
+
const out = [];
|
|
1222
|
+
for (const option of _nullishCoalesce(product.optionSwatches, () => ( []))) {
|
|
1223
|
+
for (const v of option.values) {
|
|
1224
|
+
const swatch = v.swatch;
|
|
1225
|
+
if (!swatch) continue;
|
|
1226
|
+
const key = "color" in swatch ? swatch.color.toLowerCase() : swatch.url;
|
|
1227
|
+
if (seen.has(key)) continue;
|
|
1228
|
+
if ("color" in swatch) {
|
|
1229
|
+
if (!_chunkM4YXSLRGcjs.isHexColor.call(void 0, swatch.color)) continue;
|
|
1230
|
+
out.push({ value: v.label, hex: swatch.color });
|
|
1231
|
+
} else {
|
|
1232
|
+
out.push({ value: v.label, image: swatch.url });
|
|
1233
|
+
}
|
|
1234
|
+
seen.add(key);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
return out;
|
|
1238
|
+
}
|
|
1239
|
+
function CardTitle({ product, title, href, onSelect, classNames, unstyled }) {
|
|
1240
|
+
const { Link: Anchor } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
1241
|
+
const heading = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-title", { classNames, unstyled });
|
|
1242
|
+
const link = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-title-link", { classNames, unstyled });
|
|
1243
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { ...heading, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Anchor, { ...link, href, onClick: onSelect, children: title || product.handle }) });
|
|
1244
|
+
}
|
|
1245
|
+
function CardBadges({ badges, soldOut, classNames, unstyled }) {
|
|
1246
|
+
const part = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-badges", { classNames, unstyled });
|
|
1247
|
+
const { settings } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
1248
|
+
if (badges.length === 0 && !soldOut) return null;
|
|
1249
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...part, children: [
|
|
1250
|
+
badges.map((b, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Badge, { kind: b.kind, tone: b.tone, classNames, unstyled, children: b.label }, `${b.kind}-${i}`)),
|
|
1251
|
+
soldOut ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Badge, { kind: "soldOut", classNames, unstyled, children: settings.stock.words.outOfStock }) : null
|
|
1252
|
+
] });
|
|
1253
|
+
}
|
|
1254
|
+
var NoQuickAdd = () => null;
|
|
1255
|
+
var LoadedQuickAdd = _react3.lazy.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("./chunk-AZV5U7YB.cjs"))).then((m) => ({ default: m.QuickAdd })));
|
|
1256
|
+
var ShopperQuickAdd = (props) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LoadedQuickAdd, { ...props }) });
|
|
1257
|
+
var DEFAULT_SLOTS2 = {
|
|
1258
|
+
Image: _chunkP6HHE57Scjs.Image,
|
|
1259
|
+
Title: CardTitle,
|
|
1260
|
+
Price: _chunkHZ6VEN6Qcjs.Price,
|
|
1261
|
+
Rating: _chunkHZ6VEN6Qcjs.StarRating,
|
|
1262
|
+
Badges: CardBadges,
|
|
1263
|
+
QuickAdd: NoQuickAdd,
|
|
1264
|
+
WishlistButton
|
|
1265
|
+
};
|
|
1266
|
+
function CardMedia({ product, slots, badges, soldOut, aspectRatio, href, onSelect, classNames, unstyled }) {
|
|
1267
|
+
const { settings, Link: Anchor } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
1268
|
+
const local = { classNames, unstyled };
|
|
1269
|
+
const media = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-media", local);
|
|
1270
|
+
const link = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-media-link", local);
|
|
1271
|
+
const first = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-image", local);
|
|
1272
|
+
const alt = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-image-alt", local);
|
|
1273
|
+
const placeholder = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-placeholder", local);
|
|
1274
|
+
const actions = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-actions", local);
|
|
1275
|
+
const images = _nullishCoalesce(product.images, () => ( []));
|
|
1276
|
+
const primary = images[0];
|
|
1277
|
+
const second = settings.card.secondImageOnHover ? images[1] : void 0;
|
|
1278
|
+
const hasActions = slots.QuickAdd !== NoQuickAdd || slots.WishlistButton !== WishlistButton;
|
|
1279
|
+
const imageProps = (image) => ({
|
|
1280
|
+
src: image.url,
|
|
1281
|
+
// The title link already names the product; a second description would read twice.
|
|
1282
|
+
alt: "",
|
|
1283
|
+
aspectRatio,
|
|
1284
|
+
srcSet: srcSetOf2(image),
|
|
1285
|
+
sizes: SIZES,
|
|
1286
|
+
...local
|
|
1287
|
+
});
|
|
1288
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...media, children: [
|
|
1289
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Anchor, { ...link, href, tabIndex: -1, "aria-hidden": "true", onClick: onSelect, children: [
|
|
1290
|
+
primary ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...first, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, slots.Image, { ...imageProps(primary) }) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...placeholder, style: { aspectRatio } }),
|
|
1291
|
+
second ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...alt, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, slots.Image, { ...imageProps(second) }) }) : null
|
|
1292
|
+
] }),
|
|
1293
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, slots.Badges, { badges, soldOut, ...local }),
|
|
1294
|
+
hasActions ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...actions, children: [
|
|
1295
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, slots.QuickAdd, { product, ...local }),
|
|
1296
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, slots.WishlistButton, { product, ...local })
|
|
1297
|
+
] }) : null
|
|
1298
|
+
] });
|
|
1299
|
+
}
|
|
1300
|
+
function CardBody(props) {
|
|
1301
|
+
const { product, slots, href, title, priceContext, onSelect, classNames, unstyled } = props;
|
|
1302
|
+
const { settings, reviewsOnLists: providerReviewsOnLists } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
1303
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
1304
|
+
const local = { classNames, unstyled };
|
|
1305
|
+
const body = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-body", local);
|
|
1306
|
+
const brand = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-brand", local);
|
|
1307
|
+
const swatchesPart = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-swatches", local);
|
|
1308
|
+
const more = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-swatch-more", local);
|
|
1309
|
+
const ratingPart = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-rating", local);
|
|
1310
|
+
const pricePart = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-price", local);
|
|
1311
|
+
const from = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-from", local);
|
|
1312
|
+
const unpriced = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-unpriced", local);
|
|
1313
|
+
const { card } = settings;
|
|
1314
|
+
const metaText = props.meta === "category" ? product.productType : card.showBrand ? product.brand : null;
|
|
1315
|
+
const swatches = card.showSwatches ? swatchesOf(product) : [];
|
|
1316
|
+
const rating = product.rating;
|
|
1317
|
+
const reviewsOnLists = _nullishCoalesce(props.reviewsOnLists, () => ( providerReviewsOnLists));
|
|
1318
|
+
const showRating = card.showRating && reviewsOnLists && rating && rating.count > 0 && rating.average !== null;
|
|
1319
|
+
const range = _nullishCoalesce(product.priceRange, () => ( null));
|
|
1320
|
+
const compareAt = range && "compareAtMinMinor" in range && typeof range.compareAtMinMinor === "number" ? range.compareAtMinMinor : void 0;
|
|
1321
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...body, children: [
|
|
1322
|
+
metaText ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...brand, "data-meta": _nullishCoalesce(props.meta, () => ( "brand")), children: metaText }) : null,
|
|
1323
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, slots.Title, { product, title, href, onSelect, ...local }),
|
|
1324
|
+
swatches.length > 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "ul", { ...swatchesPart, "data-card-swatches": "", children: [
|
|
1325
|
+
swatches.slice(0, MAX_SWATCHES).map((s) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Swatch, { ...local, ...s }) }, _nullishCoalesce(s.hex, () => ( s.image)))),
|
|
1326
|
+
swatches.length > MAX_SWATCHES ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { ...more, children: [
|
|
1327
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "aria-hidden": "true", children: t("pieces.card.moreSwatches", { count: swatches.length - MAX_SWATCHES }) }),
|
|
1328
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.VisuallyHidden, { children: t("pieces.card.moreSwatchesLabel", { count: swatches.length - MAX_SWATCHES }) })
|
|
1329
|
+
] }) : null
|
|
1330
|
+
] }) : null,
|
|
1331
|
+
showRating ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...ratingPart, "data-card-rating": "", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, slots.Rating, { value: rating.average, count: rating.count, size: "sm", ...local }) }) : null,
|
|
1332
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...pricePart, children: range ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1333
|
+
range.minMinor !== range.maxMinor ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { ...from, children: [
|
|
1334
|
+
t("pieces.price.from"),
|
|
1335
|
+
" "
|
|
1336
|
+
] }) : null,
|
|
1337
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1338
|
+
slots.Price,
|
|
1339
|
+
{
|
|
1340
|
+
minor: range.minMinor,
|
|
1341
|
+
currency: range.currency,
|
|
1342
|
+
compareAtMinor: card.showCompareAt ? compareAt : void 0,
|
|
1343
|
+
priceContext,
|
|
1344
|
+
...local
|
|
1345
|
+
}
|
|
1346
|
+
)
|
|
1347
|
+
] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...unpriced, children: t("pieces.price.unavailable") }) })
|
|
1348
|
+
] });
|
|
1349
|
+
}
|
|
1350
|
+
function RowLayout({ children, classNames, unstyled }) {
|
|
1351
|
+
const row = _chunkVWXJO427cjs.usePart.call(void 0, "product-card-row", { classNames, unstyled });
|
|
1352
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...row, children });
|
|
1353
|
+
}
|
|
1354
|
+
function ProductCard(props) {
|
|
1355
|
+
const { product, position, listName, generatedAt, priceContext, onSelect, classNames, unstyled } = props;
|
|
1356
|
+
const { settings } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
1357
|
+
const variant = _nullishCoalesce(props.variant, () => ( settings.card.style));
|
|
1358
|
+
const quickAdd = _nullishCoalesce(props.quickAdd, () => ( settings.card.quickAdd));
|
|
1359
|
+
const slots = { ...DEFAULT_SLOTS2, ...quickAdd ? { QuickAdd: ShopperQuickAdd } : {}, ...props.slots };
|
|
1360
|
+
const local = { classNames, unstyled };
|
|
1361
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "product-card", local);
|
|
1362
|
+
const href = _chunkHZ6VEN6Qcjs.routeHref.call(void 0, settings, "product", product.handle);
|
|
1363
|
+
const select = onSelect ? () => onSelect(product) : void 0;
|
|
1364
|
+
const soldOut = product.availability === "out_of_stock";
|
|
1365
|
+
const inner = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1366
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1367
|
+
CardMedia,
|
|
1368
|
+
{
|
|
1369
|
+
product,
|
|
1370
|
+
slots,
|
|
1371
|
+
badges: cardBadges(settings, product, generatedAt),
|
|
1372
|
+
soldOut: settings.card.showBadges && soldOut,
|
|
1373
|
+
aspectRatio: variant === "row" ? 1 : 0.8,
|
|
1374
|
+
href,
|
|
1375
|
+
onSelect: select,
|
|
1376
|
+
...local
|
|
1377
|
+
}
|
|
1378
|
+
),
|
|
1379
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CardBody, { product, slots, href, title: _nullishCoalesce(product.title, () => ( product.handle)), priceContext, reviewsOnLists: props.reviewsOnLists, meta: props.meta, onSelect: select, ...local })
|
|
1380
|
+
] });
|
|
1381
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1382
|
+
"article",
|
|
1383
|
+
{
|
|
1384
|
+
...root,
|
|
1385
|
+
"data-product-card": "",
|
|
1386
|
+
"data-product-handle": product.handle,
|
|
1387
|
+
"data-variant": variant,
|
|
1388
|
+
"data-sold-out": soldOut ? "" : void 0,
|
|
1389
|
+
"data-position": position,
|
|
1390
|
+
"data-list-name": listName,
|
|
1391
|
+
children: variant === "row" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RowLayout, { ...local, children: inner }) : inner
|
|
1392
|
+
}
|
|
1393
|
+
);
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
// src/product/RelatedProducts.tsx
|
|
1397
|
+
|
|
1398
|
+
|
|
1399
|
+
var LIST_NAME = "related_products";
|
|
1400
|
+
function useRelatedProducts(active = true) {
|
|
1401
|
+
const { product, related } = useProductPage();
|
|
1402
|
+
const { settings } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
1403
|
+
const limit = settings.product.relatedLimit;
|
|
1404
|
+
const seeded = _react3.useMemo.call(void 0, () => related ? { products: related } : void 0, [related]);
|
|
1405
|
+
const query = _react.useRelated.call(void 0, product.handle, { limit, initialData: seeded, enabled: active || seeded !== void 0 });
|
|
1406
|
+
const products = (_nullishCoalesce(_nullishCoalesce(_optionalChain([query, 'access', _55 => _55.data, 'optionalAccess', _56 => _56.products]), () => ( related)), () => ( []))).slice(0, limit);
|
|
1407
|
+
return { products, priceContext: _optionalChain([query, 'access', _57 => _57.data, 'optionalAccess', _58 => _58.priceContext]) };
|
|
1408
|
+
}
|
|
1409
|
+
function RelatedProducts({ active = true, card, classNames, className, unstyled }) {
|
|
1410
|
+
const local = { classNames, unstyled };
|
|
1411
|
+
const { generatedAt } = useProductPage();
|
|
1412
|
+
const { products, priceContext } = useRelatedProducts(active);
|
|
1413
|
+
const track = _chunkDYHHAOMGcjs.useTrack.call(void 0, );
|
|
1414
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "related-products", { ...local, className });
|
|
1415
|
+
const item = _chunkVWXJO427cjs.usePart.call(void 0, "related-products-item", local);
|
|
1416
|
+
const at = _react3.useMemo.call(void 0, () => _nullishCoalesce(generatedAt, () => ( (/* @__PURE__ */ new Date()).toISOString())), [generatedAt]);
|
|
1417
|
+
if (products.length === 0) return null;
|
|
1418
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { ...root, children: products.map((p, position) => /* @__PURE__ */ _react3.createElement.call(void 0, "li", { ...item, key: p.handle }, /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1419
|
+
ProductCard,
|
|
1420
|
+
{
|
|
1421
|
+
...local,
|
|
1422
|
+
...card,
|
|
1423
|
+
product: p,
|
|
1424
|
+
position,
|
|
1425
|
+
listName: LIST_NAME,
|
|
1426
|
+
generatedAt: at,
|
|
1427
|
+
priceContext,
|
|
1428
|
+
onSelect: () => {
|
|
1429
|
+
const currency = _optionalChain([p, 'access', _59 => _59.priceRange, 'optionalAccess', _60 => _60.currency]);
|
|
1430
|
+
if (currency) track("select_item", { currency, item_list_name: LIST_NAME, items: [_chunkHZ6VEN6Qcjs.toGa4Item.call(void 0, p, { index: position, listName: LIST_NAME })] });
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
))) });
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
// src/product/ReviewForm.tsx
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
function ReviewForm({ handle, classNames, className, unstyled }) {
|
|
1443
|
+
const local = { classNames, unstyled };
|
|
1444
|
+
const page = useProductPage();
|
|
1445
|
+
const submit = _react.useSubmitReview.call(void 0, _nullishCoalesce(handle, () => ( page.product.handle)));
|
|
1446
|
+
const { t, keyAttr } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
1447
|
+
const id = _react3.useId.call(void 0, );
|
|
1448
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "review-form", { ...local, className });
|
|
1449
|
+
const heading = _chunkVWXJO427cjs.usePart.call(void 0, "review-form-title", local);
|
|
1450
|
+
const stars = _chunkVWXJO427cjs.usePart.call(void 0, "review-form-stars", local);
|
|
1451
|
+
const star = _chunkVWXJO427cjs.usePart.call(void 0, "review-form-star", local);
|
|
1452
|
+
const starInput = _chunkVWXJO427cjs.usePart.call(void 0, "review-form-star-input", local);
|
|
1453
|
+
const textarea = _chunkVWXJO427cjs.usePart.call(void 0, "review-form-textarea", local);
|
|
1454
|
+
const fieldPart = _chunkVWXJO427cjs.usePart.call(void 0, "review-form-field", local);
|
|
1455
|
+
const errorPart = _chunkVWXJO427cjs.usePart.call(void 0, "review-form-error", local);
|
|
1456
|
+
const submitPart = _chunkVWXJO427cjs.usePart.call(void 0, "review-form-submit", local);
|
|
1457
|
+
const thanksPart = _chunkVWXJO427cjs.usePart.call(void 0, "review-form-thanks", local);
|
|
1458
|
+
const [rating, setRating] = _react3.useState.call(void 0, 0);
|
|
1459
|
+
const [title, setTitle] = _react3.useState.call(void 0, "");
|
|
1460
|
+
const [body, setBody] = _react3.useState.call(void 0, "");
|
|
1461
|
+
const [displayName, setDisplayName] = _react3.useState.call(void 0, "");
|
|
1462
|
+
const [problems, setProblems] = _react3.useState.call(void 0, {});
|
|
1463
|
+
const formRef = _react3.useRef.call(void 0, null);
|
|
1464
|
+
const thanks = _react3.useRef.call(void 0, null);
|
|
1465
|
+
_react3.useEffect.call(void 0, () => {
|
|
1466
|
+
if (submit.status === "done") _optionalChain([thanks, 'access', _61 => _61.current, 'optionalAccess', _62 => _62.focus, 'call', _63 => _63()]);
|
|
1467
|
+
}, [submit.status]);
|
|
1468
|
+
if (submit.status === "done") {
|
|
1469
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...thanksPart, ref: thanks, role: "status", tabIndex: -1, children: _optionalChain([submit, 'access', _64 => _64.result, 'optionalAccess', _65 => _65.review, 'access', _66 => _66.status]) === "approved" ? t("product.reviewForm.thanksLive") : t("product.reviewForm.thanksPending") });
|
|
1470
|
+
}
|
|
1471
|
+
const busy = submit.status === "submitting";
|
|
1472
|
+
const failure = (code) => {
|
|
1473
|
+
switch (code) {
|
|
1474
|
+
case "ALREADY_REVIEWED":
|
|
1475
|
+
return t("product.reviewForm.errorAlready");
|
|
1476
|
+
case "NOT_VERIFIED_BUYER":
|
|
1477
|
+
case "PURCHASE_REFUNDED":
|
|
1478
|
+
return t("product.reviewForm.errorNotBuyer");
|
|
1479
|
+
case "EMAIL_NOT_VERIFIED":
|
|
1480
|
+
return t("product.reviewForm.errorEmail");
|
|
1481
|
+
case "RATE_LIMITED":
|
|
1482
|
+
case "REVIEW_QUEUE_FULL":
|
|
1483
|
+
return t("product.reviewForm.errorBusy");
|
|
1484
|
+
default:
|
|
1485
|
+
return t("product.reviewForm.errorGeneric");
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1488
|
+
const onSubmit = (event) => {
|
|
1489
|
+
event.preventDefault();
|
|
1490
|
+
if (busy) return;
|
|
1491
|
+
const found = {};
|
|
1492
|
+
if (rating < 1) found.rating = t("product.reviewForm.needRating");
|
|
1493
|
+
if (body.trim() === "") found.body = t("product.reviewForm.needBody");
|
|
1494
|
+
if (displayName.trim() === "") found.displayName = t("product.reviewForm.needName");
|
|
1495
|
+
setProblems(found);
|
|
1496
|
+
const first = ["rating", "body", "displayName"].find((f) => found[f]);
|
|
1497
|
+
if (first) {
|
|
1498
|
+
const selector = first === "rating" ? 'input[name="rating"]' : `[name="${first}"]`;
|
|
1499
|
+
_optionalChain([formRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.querySelector, 'call', _69 => _69(selector), 'optionalAccess', _70 => _70.focus, 'call', _71 => _71()]);
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
submit.submit({ rating, title: title.trim() || null, body: body.trim(), displayName: displayName.trim() }).catch(() => void 0);
|
|
1503
|
+
};
|
|
1504
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { ...root, ref: formRef, noValidate: true, "aria-busy": busy || void 0, onSubmit, children: [
|
|
1505
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...heading, ...keyAttr("product.writeReview"), children: t("product.writeReview") }),
|
|
1506
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "fieldset", { ...stars, "aria-describedby": problems.rating ? `${id}-rating-error` : void 0, children: [
|
|
1507
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "legend", { children: t("product.reviewForm.rating") }),
|
|
1508
|
+
[1, 2, 3, 4, 5].map((n) => /* @__PURE__ */ _react3.createElement.call(void 0, "label", { ...star, key: n, "data-on": n <= rating ? "true" : void 0 }, /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1509
|
+
"input",
|
|
1510
|
+
{
|
|
1511
|
+
...starInput,
|
|
1512
|
+
type: "radio",
|
|
1513
|
+
name: "rating",
|
|
1514
|
+
value: n,
|
|
1515
|
+
checked: rating === n,
|
|
1516
|
+
"aria-invalid": problems.rating ? true : void 0,
|
|
1517
|
+
onChange: () => {
|
|
1518
|
+
setRating(n);
|
|
1519
|
+
setProblems((p) => ({ ...p, rating: void 0 }));
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "aria-hidden": "true", children: "\u2605" }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.VisuallyHidden, { children: n === 1 ? t("product.reviewForm.starOne") : t("product.reviewForm.star", { n }) }))),
|
|
1523
|
+
problems.rating ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...errorPart, id: `${id}-rating-error`, role: "alert", children: problems.rating }) : null
|
|
1524
|
+
] }),
|
|
1525
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Field, { label: t("product.reviewForm.title"), name: "title", value: title, onChange: setTitle }),
|
|
1526
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...fieldPart, children: [
|
|
1527
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { htmlFor: `${id}-body`, children: t("product.reviewForm.body") }),
|
|
1528
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1529
|
+
"textarea",
|
|
1530
|
+
{
|
|
1531
|
+
...textarea,
|
|
1532
|
+
id: `${id}-body`,
|
|
1533
|
+
name: "body",
|
|
1534
|
+
rows: 4,
|
|
1535
|
+
maxLength: 4e3,
|
|
1536
|
+
value: body,
|
|
1537
|
+
"aria-invalid": problems.body ? true : void 0,
|
|
1538
|
+
"aria-describedby": problems.body ? `${id}-body-error` : void 0,
|
|
1539
|
+
onChange: (e) => {
|
|
1540
|
+
setBody(e.target.value);
|
|
1541
|
+
setProblems((p) => ({ ...p, body: void 0 }));
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
),
|
|
1545
|
+
problems.body ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...errorPart, id: `${id}-body-error`, role: "alert", children: problems.body }) : null
|
|
1546
|
+
] }),
|
|
1547
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1548
|
+
_ui.Field,
|
|
1549
|
+
{
|
|
1550
|
+
label: t("product.reviewForm.name"),
|
|
1551
|
+
name: "displayName",
|
|
1552
|
+
value: displayName,
|
|
1553
|
+
autoComplete: "given-name",
|
|
1554
|
+
error: problems.displayName,
|
|
1555
|
+
onChange: (v) => {
|
|
1556
|
+
setDisplayName(v);
|
|
1557
|
+
setProblems((p) => ({ ...p, displayName: void 0 }));
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
),
|
|
1561
|
+
submit.status === "error" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...errorPart, role: "alert", children: failure(_optionalChain([submit, 'access', _72 => _72.error, 'optionalAccess', _73 => _73.code])) }) : null,
|
|
1562
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { ...submitPart, type: "submit", "aria-disabled": busy || void 0, children: busy ? t("product.reviewForm.sending") : t("product.reviewForm.submit") })
|
|
1563
|
+
] });
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
// src/product/Reviews.tsx
|
|
1567
|
+
|
|
1568
|
+
var _extras = require('@usethrottle/catalog/react/extras');
|
|
1569
|
+
|
|
1570
|
+
|
|
1571
|
+
|
|
1572
|
+
// src/server/reviews-page.ts
|
|
1573
|
+
var REVIEWS_PAGE_SIZE = 10;
|
|
1574
|
+
|
|
1575
|
+
// src/product/Reviews.tsx
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
var SORTS = ["newest", "highest", "lowest"];
|
|
1579
|
+
var STARS = [5, 4, 3, 2, 1];
|
|
1580
|
+
var sortLabelKey = {
|
|
1581
|
+
newest: "product.reviewList.sortNewest",
|
|
1582
|
+
highest: "product.reviewList.sortHighest",
|
|
1583
|
+
lowest: "product.reviewList.sortLowest"
|
|
1584
|
+
};
|
|
1585
|
+
var gateKey = {
|
|
1586
|
+
reviews_disabled: "product.reviewList.gateReviewsDisabled",
|
|
1587
|
+
not_signed_in: "product.reviewList.gateSignIn",
|
|
1588
|
+
email_not_verified: "product.reviewList.gateEmailNotVerified",
|
|
1589
|
+
already_reviewed: "product.reviewList.gateAlreadyReviewed",
|
|
1590
|
+
not_verified_buyer: "product.reviewList.gateNotVerifiedBuyer"
|
|
1591
|
+
};
|
|
1592
|
+
function ReviewGate({ handle, ...local }) {
|
|
1593
|
+
const signedIn = _react.useCustomerKey.call(void 0, ) !== null;
|
|
1594
|
+
const eligibility = _extras.useReviewEligibility.call(void 0, handle);
|
|
1595
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
1596
|
+
const gate = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-gate", local);
|
|
1597
|
+
if (!signedIn) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...gate, children: t("product.reviewList.gateSignIn") });
|
|
1598
|
+
if (eligibility.error) {
|
|
1599
|
+
if (eligibility.error.code === "NOT_FOUND") return null;
|
|
1600
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...gate, children: t("product.reviewList.gateFailed") });
|
|
1601
|
+
}
|
|
1602
|
+
if (!eligibility.data) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Skeleton, {});
|
|
1603
|
+
if (eligibility.data.canReview) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ReviewForm, { ...local, handle });
|
|
1604
|
+
const reason = eligibility.data.reason;
|
|
1605
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...gate, "data-reason": reason, children: t(reason ? gateKey[reason] : "product.reviewList.gateUnknown") });
|
|
1606
|
+
}
|
|
1607
|
+
function ReviewItem({ review, ...local }) {
|
|
1608
|
+
const { locale } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
1609
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
1610
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "product-review", local);
|
|
1611
|
+
const head = _chunkVWXJO427cjs.usePart.call(void 0, "product-review-header", local);
|
|
1612
|
+
const date = _chunkVWXJO427cjs.usePart.call(void 0, "product-review-date", local);
|
|
1613
|
+
const title = _chunkVWXJO427cjs.usePart.call(void 0, "product-review-title", local);
|
|
1614
|
+
const body = _chunkVWXJO427cjs.usePart.call(void 0, "product-review-body", local);
|
|
1615
|
+
const author = _chunkVWXJO427cjs.usePart.call(void 0, "product-review-author", local);
|
|
1616
|
+
const reply = _chunkVWXJO427cjs.usePart.call(void 0, "product-review-reply", local);
|
|
1617
|
+
const when = new Date(review.createdAt);
|
|
1618
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { ...root, "data-review-id": review.id, children: [
|
|
1619
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...head, children: [
|
|
1620
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHZ6VEN6Qcjs.StarRating, { ...local, value: review.rating, size: "sm" }),
|
|
1621
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "time", { ...date, dateTime: review.createdAt, children: Number.isNaN(when.getTime()) ? "" : new Intl.DateTimeFormat(locale, { year: "numeric", month: "long", day: "numeric", timeZone: "UTC" }).format(when) })
|
|
1622
|
+
] }),
|
|
1623
|
+
review.title ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { ...title, children: review.title }) : null,
|
|
1624
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...body, children: review.body }),
|
|
1625
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { ...author, children: [
|
|
1626
|
+
review.displayName,
|
|
1627
|
+
review.verified ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Badge, { ...local, kind: "verified", children: t("product.reviewList.verified") }) : null
|
|
1628
|
+
] }),
|
|
1629
|
+
review.reply ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...reply, children: [
|
|
1630
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: t("product.reviewList.reply") }),
|
|
1631
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: review.reply.body })
|
|
1632
|
+
] }) : null
|
|
1633
|
+
] });
|
|
1634
|
+
}
|
|
1635
|
+
function Reviews({ active = true, initialData, layout, classNames, className, unstyled }) {
|
|
1636
|
+
const local = { classNames, unstyled };
|
|
1637
|
+
const { product, initialReviews, reviewsLayout } = useProductPage();
|
|
1638
|
+
const arrangement = _nullishCoalesce(layout, () => ( reviewsLayout));
|
|
1639
|
+
const handle = product.handle;
|
|
1640
|
+
const seed = _nullishCoalesce(_nullishCoalesce(initialData, () => ( initialReviews)), () => ( void 0));
|
|
1641
|
+
const client = _react.useCatalog.call(void 0, );
|
|
1642
|
+
const { t, keyAttr } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
1643
|
+
const [sort, setSort] = _react3.useState.call(void 0, "newest");
|
|
1644
|
+
const [rating, setRating] = _react3.useState.call(void 0, null);
|
|
1645
|
+
const [more, setMore] = _react3.useState.call(void 0, null);
|
|
1646
|
+
const [loadingMore, setLoadingMore] = _react3.useState.call(void 0, false);
|
|
1647
|
+
const [moreFailed, setMoreFailed] = _react3.useState.call(void 0, false);
|
|
1648
|
+
const ask = _react3.useRef.call(void 0, 0);
|
|
1649
|
+
const first = _react.useReviews.call(void 0, handle, {
|
|
1650
|
+
sort,
|
|
1651
|
+
...rating ? { rating } : {},
|
|
1652
|
+
limit: REVIEWS_PAGE_SIZE,
|
|
1653
|
+
enabled: active,
|
|
1654
|
+
keepPreviousData: true,
|
|
1655
|
+
...seed && sort === "newest" && rating === null ? { initialData: seed } : {}
|
|
1656
|
+
});
|
|
1657
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews", { ...local, className });
|
|
1658
|
+
const summaryPart = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-summary", local);
|
|
1659
|
+
const mainPart = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-main", local);
|
|
1660
|
+
const average = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-average", local);
|
|
1661
|
+
const histogram = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-histogram", local);
|
|
1662
|
+
const row = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-histogram-row", local);
|
|
1663
|
+
const bar = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-histogram-bar", local);
|
|
1664
|
+
const fill = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-histogram-fill", local);
|
|
1665
|
+
const count = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-histogram-count", local);
|
|
1666
|
+
const controls = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-controls", local);
|
|
1667
|
+
const clear = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-clear", local);
|
|
1668
|
+
const list = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-list", local);
|
|
1669
|
+
const empty = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-empty", local);
|
|
1670
|
+
const loadMore = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-load-more", local);
|
|
1671
|
+
const failed = _chunkVWXJO427cjs.usePart.call(void 0, "product-reviews-error", local);
|
|
1672
|
+
const change = (next) => {
|
|
1673
|
+
ask.current += 1;
|
|
1674
|
+
setMore(null);
|
|
1675
|
+
setMoreFailed(false);
|
|
1676
|
+
if (next.sort !== void 0) setSort(next.sort);
|
|
1677
|
+
if (next.rating !== void 0) setRating(next.rating);
|
|
1678
|
+
};
|
|
1679
|
+
const data = first.data && !("redirectTo" in first.data) ? first.data : void 0;
|
|
1680
|
+
if (first.error && first.error.code === "NOT_FOUND") return null;
|
|
1681
|
+
if (!data) {
|
|
1682
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...root, "aria-busy": first.isLoading || void 0, children: first.error ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...failed, children: t("product.reviewList.loadFailed") }) : active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Skeleton, { count: 2 }) : null });
|
|
1683
|
+
}
|
|
1684
|
+
const { summary } = data;
|
|
1685
|
+
const reviews = [...data.reviews, ..._nullishCoalesce(_optionalChain([more, 'optionalAccess', _74 => _74.reviews]), () => ( []))];
|
|
1686
|
+
const nextCursor = more ? more.nextCursor : data.nextCursor;
|
|
1687
|
+
const loadNext = async () => {
|
|
1688
|
+
if (!nextCursor || loadingMore) return;
|
|
1689
|
+
const mine = ask.current;
|
|
1690
|
+
setLoadingMore(true);
|
|
1691
|
+
setMoreFailed(false);
|
|
1692
|
+
try {
|
|
1693
|
+
const page = await client.reviews.list(handle, { sort, ...rating ? { rating } : {}, limit: REVIEWS_PAGE_SIZE, cursor: nextCursor });
|
|
1694
|
+
if (mine !== ask.current || "redirectTo" in page) return;
|
|
1695
|
+
setMore((prev) => ({ reviews: [..._nullishCoalesce(_optionalChain([prev, 'optionalAccess', _75 => _75.reviews]), () => ( [])), ...page.reviews], nextCursor: page.nextCursor }));
|
|
1696
|
+
} catch (e2) {
|
|
1697
|
+
if (mine === ask.current) setMoreFailed(true);
|
|
1698
|
+
} finally {
|
|
1699
|
+
if (mine === ask.current) setLoadingMore(false);
|
|
1700
|
+
}
|
|
1701
|
+
};
|
|
1702
|
+
const main = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1703
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ReviewGate, { ...local, handle }),
|
|
1704
|
+
summary.count > 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...controls, children: [
|
|
1705
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1706
|
+
_ui.Select,
|
|
1707
|
+
{
|
|
1708
|
+
label: t("product.reviewList.sortLabel"),
|
|
1709
|
+
value: sort,
|
|
1710
|
+
options: SORTS.map((s) => ({ value: s, label: t(sortLabelKey[s]) })),
|
|
1711
|
+
onChange: (value) => change({ sort: value })
|
|
1712
|
+
}
|
|
1713
|
+
),
|
|
1714
|
+
rating !== null ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { ...clear, type: "button", onClick: () => change({ rating: null }), children: t("product.reviewList.clearFilter") }) : null
|
|
1715
|
+
] }) : null,
|
|
1716
|
+
reviews.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { ...list, "aria-busy": first.isValidating || void 0, children: reviews.map((review) => /* @__PURE__ */ _react3.createElement.call(void 0, ReviewItem, { ...local, key: review.id, review })) }) : summary.count > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...empty, children: t("product.reviewList.noneForRating") }) : null,
|
|
1717
|
+
moreFailed ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...failed, children: t("product.reviewList.loadFailed") }) : null,
|
|
1718
|
+
nextCursor ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { ...loadMore, type: "button", "aria-disabled": loadingMore || void 0, onClick: () => void loadNext(), children: loadingMore ? t("product.reviewList.loading") : t("product.reviewList.loadMore") }) : null
|
|
1719
|
+
] });
|
|
1720
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...root, "data-layout": arrangement, children: [
|
|
1721
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...summaryPart, "data-layout": arrangement, children: summary.count > 0 && summary.average !== null ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1722
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { ...average, children: [
|
|
1723
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "aria-hidden": "true", children: summary.average.toFixed(1) }),
|
|
1724
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHZ6VEN6Qcjs.StarRating, { ...local, value: summary.average, count: summary.count })
|
|
1725
|
+
] }),
|
|
1726
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { ...histogram, "aria-label": t("product.reviewList.ratingsByStars"), children: STARS.map((stars) => {
|
|
1727
|
+
const n = summary.histogram[String(stars)];
|
|
1728
|
+
const pressed = rating === stars;
|
|
1729
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1730
|
+
"button",
|
|
1731
|
+
{
|
|
1732
|
+
...row,
|
|
1733
|
+
type: "button",
|
|
1734
|
+
"data-rating": stars,
|
|
1735
|
+
"aria-pressed": pressed,
|
|
1736
|
+
"aria-label": t("product.reviewList.filterRating", { rating: stars, count: n }),
|
|
1737
|
+
onClick: () => change({ rating: pressed ? null : stars }),
|
|
1738
|
+
children: [
|
|
1739
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { "aria-hidden": "true", children: [
|
|
1740
|
+
stars,
|
|
1741
|
+
" ",
|
|
1742
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Icon, { name: "star", size: 12 })
|
|
1743
|
+
] }),
|
|
1744
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...bar, "aria-hidden": "true", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...fill, style: { inlineSize: `${summary.count ? n / summary.count * 100 : 0}%` } }) }),
|
|
1745
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...count, "aria-hidden": "true", children: n })
|
|
1746
|
+
]
|
|
1747
|
+
}
|
|
1748
|
+
) }, stars);
|
|
1749
|
+
}) })
|
|
1750
|
+
] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...empty, ...keyAttr("product.noReviews"), children: t("product.noReviews") }) }),
|
|
1751
|
+
arrangement === "columns" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...mainPart, children: main }) : main
|
|
1752
|
+
] });
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
// src/product/ShippingSection.tsx
|
|
1756
|
+
|
|
1757
|
+
|
|
1758
|
+
|
|
1759
|
+
function useShippingContent(pageHandle) {
|
|
1760
|
+
const { site, settings } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
1761
|
+
const builder = site.source === "builder";
|
|
1762
|
+
const pageOutlet = site.pageOutlet;
|
|
1763
|
+
const Outlet = _react3.useMemo.call(void 0,
|
|
1764
|
+
() => builder && pageHandle && pageOutlet ? pageOutlet(pageHandle) : null,
|
|
1765
|
+
[builder, pageHandle, pageOutlet]
|
|
1766
|
+
);
|
|
1767
|
+
const loaded = _optionalChain([_react3.useContext.call(void 0, ProductPageContext), 'optionalAccess', _76 => _76.shippingPage]);
|
|
1768
|
+
const configured = _nullishCoalesce(_optionalChain([settings, 'access', _77 => _77.product, 'access', _78 => _78.sections, 'access', _79 => _79.find, 'call', _80 => _80((s) => s.key === "shipping"), 'optionalAccess', _81 => _81.pageHandle]), () => ( null));
|
|
1769
|
+
const seeded = pageHandle !== null && pageHandle === configured ? loaded : void 0;
|
|
1770
|
+
const seed = _react3.useMemo.call(void 0,
|
|
1771
|
+
() => typeof seeded === "string" ? { handle: pageHandle, title: "", bodyHtml: seeded, seo: { title: "", description: "" } } : void 0,
|
|
1772
|
+
[seeded, pageHandle]
|
|
1773
|
+
);
|
|
1774
|
+
const page = _extras.usePage.call(void 0, !builder && pageHandle && seeded !== null ? pageHandle : null, seed ? { initialData: seed } : void 0);
|
|
1775
|
+
if (builder) return Outlet ? { kind: "outlet", Outlet } : { kind: "hidden" };
|
|
1776
|
+
const html = _optionalChain([page, 'access', _82 => _82.data, 'optionalAccess', _83 => _83.bodyHtml]);
|
|
1777
|
+
return html ? { kind: "page", html } : { kind: "hidden" };
|
|
1778
|
+
}
|
|
1779
|
+
function ShippingSection({ pageHandle, classNames, className, unstyled }) {
|
|
1780
|
+
const local = { classNames, unstyled };
|
|
1781
|
+
const content = useShippingContent(pageHandle);
|
|
1782
|
+
const part = _chunkVWXJO427cjs.usePart.call(void 0, "shipping-section", { ...local, className });
|
|
1783
|
+
if (content.kind === "hidden") return null;
|
|
1784
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...part, children: content.kind === "outlet" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, content.Outlet, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RichText, { ...local, html: content.html }) });
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
// src/product/TagList.tsx
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
function TagList({ classNames, className, unstyled }) {
|
|
1791
|
+
const local = { classNames, unstyled };
|
|
1792
|
+
const { product } = useProductPage();
|
|
1793
|
+
const { settings, Link: Anchor } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
1794
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "tag-list", { ...local, className });
|
|
1795
|
+
const item = _chunkVWXJO427cjs.usePart.call(void 0, "tag-list-item", local);
|
|
1796
|
+
const link = _chunkVWXJO427cjs.usePart.call(void 0, "tag-list-link", local);
|
|
1797
|
+
const tags = _nullishCoalesce(product.tags, () => ( []));
|
|
1798
|
+
if (tags.length === 0) return null;
|
|
1799
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { ...root, children: tags.map((tag) => /* @__PURE__ */ _react3.createElement.call(void 0, "li", { ...item, key: tag }, /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Anchor, { ...link, href: _chunkHZ6VEN6Qcjs.routeHref.call(void 0, settings, "tag", tag), children: tag }))) });
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
// src/product/ProductSections.tsx
|
|
1803
|
+
|
|
1804
|
+
|
|
1805
|
+
|
|
1806
|
+
// src/product/use-media-query.ts
|
|
1807
|
+
|
|
1808
|
+
function useMediaQuery(query) {
|
|
1809
|
+
return _react3.useSyncExternalStore.call(void 0,
|
|
1810
|
+
(onChange) => {
|
|
1811
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return () => {
|
|
1812
|
+
};
|
|
1813
|
+
const list = window.matchMedia(query);
|
|
1814
|
+
list.addEventListener("change", onChange);
|
|
1815
|
+
return () => list.removeEventListener("change", onChange);
|
|
1816
|
+
},
|
|
1817
|
+
() => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(query).matches,
|
|
1818
|
+
() => false
|
|
1819
|
+
);
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
// src/product/ProductSections.tsx
|
|
1823
|
+
|
|
1824
|
+
|
|
1825
|
+
var PHONE_QUERY = "(max-width: 767px)";
|
|
1826
|
+
function specRows(variants, yes, no) {
|
|
1827
|
+
const words = (v) => typeof v === "boolean" ? v ? yes : no : String(v);
|
|
1828
|
+
const rows = /* @__PURE__ */ new Map();
|
|
1829
|
+
for (const variant of variants) {
|
|
1830
|
+
for (const [key, value] of Object.entries(_nullishCoalesce(variant.attributes, () => ( {})))) {
|
|
1831
|
+
const row = _nullishCoalesce(rows.get(key), () => ( { key, label: _nullishCoalesce(_optionalChain([variant, 'access', _84 => _84.attributeLabels, 'optionalAccess', _85 => _85[key]]), () => ( key.replace(/_/g, " "))), values: [] }));
|
|
1832
|
+
if (!row.values.includes(words(value))) row.values.push(words(value));
|
|
1833
|
+
rows.set(key, row);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
return [...rows.values()];
|
|
1837
|
+
}
|
|
1838
|
+
function Specs({ rows, ...local }) {
|
|
1839
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "product-specs", local);
|
|
1840
|
+
const row = _chunkVWXJO427cjs.usePart.call(void 0, "product-specs-row", local);
|
|
1841
|
+
const label = _chunkVWXJO427cjs.usePart.call(void 0, "product-specs-label", local);
|
|
1842
|
+
const value = _chunkVWXJO427cjs.usePart.call(void 0, "product-specs-value", local);
|
|
1843
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "dl", { ...root, children: rows.map((r) => /* @__PURE__ */ _react3.createElement.call(void 0, "div", { ...row, key: r.key, "data-key": r.key }, /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "dt", { ...label, children: r.label }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "dd", { ...value, children: r.values.join(", ") }))) });
|
|
1844
|
+
}
|
|
1845
|
+
function ProductSections({ style, classNames, className, unstyled }) {
|
|
1846
|
+
const local = { classNames, unstyled };
|
|
1847
|
+
const page = useProductPage();
|
|
1848
|
+
const { product, revealSectionRef } = page;
|
|
1849
|
+
const { settings } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
1850
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
1851
|
+
const phone = useMediaQuery(PHONE_QUERY);
|
|
1852
|
+
const base = page.sectionsId;
|
|
1853
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "product-sections", { ...local, className });
|
|
1854
|
+
const sectionPart = _chunkVWXJO427cjs.usePart.call(void 0, "product-section", local);
|
|
1855
|
+
const titlePart = _chunkVWXJO427cjs.usePart.call(void 0, "product-section-title", local);
|
|
1856
|
+
const triggerPart = _chunkVWXJO427cjs.usePart.call(void 0, "product-section-trigger", local);
|
|
1857
|
+
const bodyPart = _chunkVWXJO427cjs.usePart.call(void 0, "product-section-body", local);
|
|
1858
|
+
const configured = settings.product.sections;
|
|
1859
|
+
const shipping = useShippingContent(_nullishCoalesce(_optionalChain([configured, 'access', _86 => _86.find, 'call', _87 => _87((s) => s.key === "shipping"), 'optionalAccess', _88 => _88.pageHandle]), () => ( null)));
|
|
1860
|
+
const requested = _nullishCoalesce(style, () => ( page.sectionsStyle));
|
|
1861
|
+
const resolved2 = requested === "auto" ? phone ? "accordion" : "tabs" : requested;
|
|
1862
|
+
const rows = specRows(product.variants, t("boolean.yes"), t("boolean.no"));
|
|
1863
|
+
const hasDescription = !!(_optionalChain([product, 'access', _89 => _89.descriptionHtml, 'optionalAccess', _90 => _90.trim, 'call', _91 => _91()]) || _optionalChain([product, 'access', _92 => _92.description, 'optionalAccess', _93 => _93.trim, 'call', _94 => _94()]));
|
|
1864
|
+
const present = {
|
|
1865
|
+
description: hasDescription,
|
|
1866
|
+
specs: rows.length > 0,
|
|
1867
|
+
shipping: shipping.kind !== "hidden",
|
|
1868
|
+
tags: (_nullishCoalesce(_optionalChain([product, 'access', _95 => _95.tags, 'optionalAccess', _96 => _96.length]), () => ( 0))) > 0,
|
|
1869
|
+
categories: (_nullishCoalesce(_optionalChain([product, 'access', _97 => _97.categories, 'optionalAccess', _98 => _98.length]), () => ( 0))) > 0,
|
|
1870
|
+
// Server data says; without it the request decides inside the section.
|
|
1871
|
+
related: page.related === void 0 || page.related.length > 0,
|
|
1872
|
+
// `null`: the server found the catalog has no reviews to show for this product.
|
|
1873
|
+
reviews: page.initialReviews !== null
|
|
1874
|
+
};
|
|
1875
|
+
const entries = configured.filter((s) => s.enabled && present[s.key]);
|
|
1876
|
+
const [active, setActive] = _react3.useState.call(void 0, null);
|
|
1877
|
+
const [open, setOpen] = _react3.useState.call(void 0, null);
|
|
1878
|
+
const firstKey = _optionalChain([entries, 'access', _99 => _99[0], 'optionalAccess', _100 => _100.key]);
|
|
1879
|
+
const current = active && entries.some((e) => e.key === active) ? active : _nullishCoalesce(firstKey, () => ( ""));
|
|
1880
|
+
const opened = _nullishCoalesce(open, () => ( (firstKey ? [firstKey] : [])));
|
|
1881
|
+
_react3.useEffect.call(void 0, () => {
|
|
1882
|
+
revealSectionRef.current = (key) => {
|
|
1883
|
+
if (!entries.some((e) => e.key === key)) return false;
|
|
1884
|
+
setActive(key);
|
|
1885
|
+
setOpen((prev) => [.../* @__PURE__ */ new Set([..._nullishCoalesce(prev, () => ( (firstKey ? [firstKey] : []))), key])]);
|
|
1886
|
+
return true;
|
|
1887
|
+
};
|
|
1888
|
+
return () => {
|
|
1889
|
+
revealSectionRef.current = null;
|
|
1890
|
+
};
|
|
1891
|
+
});
|
|
1892
|
+
if (entries.length === 0) return null;
|
|
1893
|
+
const isShown = (key) => resolved2 === "tabs" ? current === key : resolved2 === "accordion" ? opened.includes(key) : true;
|
|
1894
|
+
const titleOf = (s) => (s.key === "related" ? settings.product.relatedTitle.trim() : "") || s.title.trim() || t(`product.${s.key}`);
|
|
1895
|
+
const bodyOf = (s) => {
|
|
1896
|
+
switch (s.key) {
|
|
1897
|
+
case "description":
|
|
1898
|
+
return _optionalChain([product, 'access', _101 => _101.descriptionHtml, 'optionalAccess', _102 => _102.trim, 'call', _103 => _103()]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RichText, { ...local, html: product.descriptionHtml }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: product.description });
|
|
1899
|
+
case "specs":
|
|
1900
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Specs, { ...local, rows });
|
|
1901
|
+
case "shipping":
|
|
1902
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ShippingSection, { ...local, pageHandle: s.pageHandle });
|
|
1903
|
+
case "tags":
|
|
1904
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TagList, { ...local });
|
|
1905
|
+
case "categories":
|
|
1906
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CategoryList, { ...local });
|
|
1907
|
+
case "related":
|
|
1908
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RelatedProducts, { ...local, active: isShown("related") });
|
|
1909
|
+
case "reviews":
|
|
1910
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Reviews, { ...local, active: isShown("reviews"), initialData: _nullishCoalesce(page.initialReviews, () => ( void 0)) });
|
|
1911
|
+
}
|
|
1912
|
+
};
|
|
1913
|
+
const list = entries.map((s) => ({ key: s.key, title: titleOf(s), body: bodyOf(s) }));
|
|
1914
|
+
const toggle = (key) => setOpen(opened.includes(key) ? opened.filter((k) => k !== key) : [...opened, key]);
|
|
1915
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...root, "data-style": resolved2, children: [
|
|
1916
|
+
resolved2 === "tabs" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1917
|
+
_ui.Tabs,
|
|
1918
|
+
{
|
|
1919
|
+
tabs: list.map((e) => ({ id: e.key, label: e.title })),
|
|
1920
|
+
active: current,
|
|
1921
|
+
onChange: setActive,
|
|
1922
|
+
idBase: base
|
|
1923
|
+
}
|
|
1924
|
+
) : null,
|
|
1925
|
+
list.map((e) => {
|
|
1926
|
+
const shown = isShown(e.key);
|
|
1927
|
+
const region = `${base}-region-${e.key}`;
|
|
1928
|
+
if (resolved2 === "tabs") {
|
|
1929
|
+
return /* @__PURE__ */ _react3.createElement.call(void 0,
|
|
1930
|
+
"section",
|
|
1931
|
+
{
|
|
1932
|
+
...sectionPart,
|
|
1933
|
+
key: e.key,
|
|
1934
|
+
id: `${base}-panel-${e.key}`,
|
|
1935
|
+
role: "tabpanel",
|
|
1936
|
+
"aria-labelledby": `${base}-tab-${e.key}`,
|
|
1937
|
+
hidden: !shown,
|
|
1938
|
+
"data-section": e.key
|
|
1939
|
+
},
|
|
1940
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { ...titlePart, "data-section-title": "", "data-in-tabs": "", children: e.title }),
|
|
1941
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...bodyPart, children: e.body })
|
|
1942
|
+
);
|
|
1943
|
+
}
|
|
1944
|
+
if (resolved2 === "accordion") {
|
|
1945
|
+
return /* @__PURE__ */ _react3.createElement.call(void 0, "section", { ...sectionPart, key: e.key, id: `${base}-panel-${e.key}`, "data-section": e.key }, /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { ...titlePart, "data-section-title": "", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { ...triggerPart, type: "button", "aria-expanded": shown, "aria-controls": region, onClick: () => toggle(e.key), children: [
|
|
1946
|
+
e.title,
|
|
1947
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Icon, { name: shown ? "chevron-up" : "chevron-down", size: 16 })
|
|
1948
|
+
] }) }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...bodyPart, id: region, role: "region", hidden: !shown, children: e.body }));
|
|
1949
|
+
}
|
|
1950
|
+
return /* @__PURE__ */ _react3.createElement.call(void 0, "section", { ...sectionPart, key: e.key, id: `${base}-panel-${e.key}`, "data-section": e.key }, /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { ...titlePart, "data-section-title": "", children: e.title }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...bodyPart, children: e.body }));
|
|
1951
|
+
})
|
|
1952
|
+
] });
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
// src/product/StickyAddToCart.tsx
|
|
1956
|
+
|
|
1957
|
+
|
|
1958
|
+
function StickyAddToCart({ classNames, className, unstyled }) {
|
|
1959
|
+
const local = { classNames, unstyled };
|
|
1960
|
+
const { product, variant, priceContext, add, adding, stock, sku, addToCartRef } = useProductPage();
|
|
1961
|
+
const { currency } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
1962
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
1963
|
+
const [shown, setShown] = _react3.useState.call(void 0, false);
|
|
1964
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "sticky-add-to-cart", { ...local, className });
|
|
1965
|
+
const titlePart = _chunkVWXJO427cjs.usePart.call(void 0, "sticky-add-to-cart-title", local);
|
|
1966
|
+
const pricePart = _chunkVWXJO427cjs.usePart.call(void 0, "sticky-add-to-cart-price", local);
|
|
1967
|
+
const button = _chunkVWXJO427cjs.usePart.call(void 0, "sticky-add-to-cart-button", local);
|
|
1968
|
+
_react3.useEffect.call(void 0, () => {
|
|
1969
|
+
const target = addToCartRef.current;
|
|
1970
|
+
if (!target || typeof IntersectionObserver === "undefined") return;
|
|
1971
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
1972
|
+
setShown(!!entry && !entry.isIntersecting && entry.boundingClientRect.top < 0);
|
|
1973
|
+
});
|
|
1974
|
+
observer.observe(target);
|
|
1975
|
+
return () => observer.disconnect();
|
|
1976
|
+
}, [addToCartRef]);
|
|
1977
|
+
if (!shown) return null;
|
|
1978
|
+
const now = variant ? _nullishCoalesce(variant.salePriceMinor, () => ( variant.priceMinor)) : null;
|
|
1979
|
+
const priced = _nullishCoalesce(_optionalChain([variant, 'optionalAccess', _104 => _104.currency]), () => ( currency));
|
|
1980
|
+
const cannot = !sku || stock === "out" || stock === "no_currency";
|
|
1981
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...root, role: "region", "aria-label": t("product.sticky.label"), children: [
|
|
1982
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...titlePart, children: _nullishCoalesce(product.title, () => ( product.handle)) }),
|
|
1983
|
+
now !== null && priced ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ...pricePart, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHZ6VEN6Qcjs.Price, { ...local, minor: now, currency: priced, priceContext }) }) : null,
|
|
1984
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { ...button, type: "button", disabled: cannot, "aria-disabled": adding || void 0, onClick: () => !adding && void add(), children: adding ? t("product.cartAdd.adding") : t("product.addToCart") })
|
|
1985
|
+
] });
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
// src/product/ProductPage.tsx
|
|
1989
|
+
|
|
1990
|
+
|
|
1991
|
+
|
|
1992
|
+
|
|
1993
|
+
function handleFromPath(pattern, pathname) {
|
|
1994
|
+
const [head, tail = ""] = pattern.split("{handle}");
|
|
1995
|
+
if (!pathname.startsWith(head) || !pathname.endsWith(tail) || pathname.length <= head.length + tail.length) return null;
|
|
1996
|
+
const raw = pathname.slice(head.length, pathname.length - tail.length);
|
|
1997
|
+
if (raw.includes("/")) return null;
|
|
1998
|
+
try {
|
|
1999
|
+
return decodeURIComponent(raw);
|
|
2000
|
+
} catch (e3) {
|
|
2001
|
+
return null;
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
function Loaded(props) {
|
|
2005
|
+
const { product, priceContext, initialData, children, classNames, className, unstyled } = props;
|
|
2006
|
+
const { settings } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
2007
|
+
const value = useProductPageState({
|
|
2008
|
+
product,
|
|
2009
|
+
priceContext,
|
|
2010
|
+
initialSku: _nullishCoalesce(_optionalChain([initialData, 'optionalAccess', _105 => _105.variantSku]), () => ( null)),
|
|
2011
|
+
related: _optionalChain([initialData, 'optionalAccess', _106 => _106.related]),
|
|
2012
|
+
generatedAt: _optionalChain([initialData, 'optionalAccess', _107 => _107.generatedAt]),
|
|
2013
|
+
reviews: _optionalChain([initialData, 'optionalAccess', _108 => _108.reviews]),
|
|
2014
|
+
shippingPage: _optionalChain([initialData, 'optionalAccess', _109 => _109.shippingPage]),
|
|
2015
|
+
layout: _nullishCoalesce(props.layout, () => ( settings.product.layout)),
|
|
2016
|
+
sectionsStyle: _nullishCoalesce(props.sectionsStyle, () => ( settings.product.sectionsStyle)),
|
|
2017
|
+
reviewsLayout: props.reviewsLayout,
|
|
2018
|
+
baseUrl: (_nullishCoalesce(props.baseUrl, () => ( ""))).replace(/\/+$/u, "")
|
|
2019
|
+
});
|
|
2020
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "product-page", { classNames, className, unstyled });
|
|
2021
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductPageContext.Provider, { value, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...root, "data-layout": value.layout, "data-sections-style": value.sectionsStyle, "data-product-page": product.handle, children }) });
|
|
2022
|
+
}
|
|
2023
|
+
function Root(props) {
|
|
2024
|
+
const { settings, router } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
2025
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
2026
|
+
const { classNames, className, unstyled } = props;
|
|
2027
|
+
const handle = _nullishCoalesce(_nullishCoalesce(props.handle, () => ( _optionalChain([props, 'access', _110 => _110.initialData, 'optionalAccess', _111 => _111.product, 'access', _112 => _112.handle]))), () => ( handleFromPath(settings.routes.product, router.pathname)));
|
|
2028
|
+
const seeded = _react3.useMemo.call(void 0,
|
|
2029
|
+
() => props.initialData ? { product: props.initialData.product } : void 0,
|
|
2030
|
+
[props.initialData]
|
|
2031
|
+
);
|
|
2032
|
+
const query = _react.useProduct.call(void 0, handle, { initialData: seeded });
|
|
2033
|
+
const data = query.data;
|
|
2034
|
+
const redirectTo = data && "redirectTo" in data ? data.redirectTo : null;
|
|
2035
|
+
_react3.useEffect.call(void 0, () => {
|
|
2036
|
+
if (redirectTo) router.replace(_chunkHZ6VEN6Qcjs.routeHref.call(void 0, settings, "product", redirectTo));
|
|
2037
|
+
}, [redirectTo, router, settings]);
|
|
2038
|
+
const root = _chunkVWXJO427cjs.usePart.call(void 0, "product-page", { classNames, className, unstyled });
|
|
2039
|
+
if (data && "product" in data) {
|
|
2040
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Loaded, { ...props, product: data.product, priceContext: data.priceContext });
|
|
2041
|
+
}
|
|
2042
|
+
if (query.error || redirectTo) {
|
|
2043
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...root, "data-status": "empty", children: redirectTo ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.EmptyState, { title: t("error.notFound") }) });
|
|
2044
|
+
}
|
|
2045
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...root, "data-status": "loading", "aria-busy": "true", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Skeleton, { count: 4 }) });
|
|
2046
|
+
}
|
|
2047
|
+
function ProductJsonLd() {
|
|
2048
|
+
const { product, baseUrl } = useProductPage();
|
|
2049
|
+
const { settings, currency } = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
2050
|
+
const { t } = _chunkXQHGFWLGcjs.useStrings.call(void 0, );
|
|
2051
|
+
const url = `${baseUrl}${_chunkHZ6VEN6Qcjs.routeHref.call(void 0, settings, "product", product.handle)}`;
|
|
2052
|
+
const priced = _nullishCoalesce(_nullishCoalesce(currency, () => ( _optionalChain([product, 'access', _113 => _113.variants, 'access', _114 => _114.find, 'call', _115 => _115((v) => v.currency), 'optionalAccess', _116 => _116.currency]))), () => ( _optionalChain([product, 'access', _117 => _117.priceRange, 'optionalAccess', _118 => _118.currency])));
|
|
2053
|
+
const crumbs = productCrumbs(product, settings, t("product.crumbs.home")).map((c) => ({ name: c.name, url: `${baseUrl}${c.href}` }));
|
|
2054
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2055
|
+
priced ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, JsonLd, { data: productJsonLd(product, { url, settings, currency: priced }) }) : null,
|
|
2056
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, JsonLd, { data: breadcrumbJsonLd(crumbs) })
|
|
2057
|
+
] });
|
|
2058
|
+
}
|
|
2059
|
+
function SlotAbove() {
|
|
2060
|
+
const { product, sku } = useProductPage();
|
|
2061
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SlotOutlet, { name: "product.above", context: { kind: "product", product, variantSku: sku } });
|
|
2062
|
+
}
|
|
2063
|
+
function SlotBelow() {
|
|
2064
|
+
const { product, sku } = useProductPage();
|
|
2065
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SlotOutlet, { name: "product.below", context: { kind: "product", product, variantSku: sku } });
|
|
2066
|
+
}
|
|
2067
|
+
function Main({ classNames, unstyled }) {
|
|
2068
|
+
const main = _chunkVWXJO427cjs.usePart.call(void 0, "product-page-main", { classNames, unstyled });
|
|
2069
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...main, children: [
|
|
2070
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Gallery, { classNames, unstyled }),
|
|
2071
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BuyBox, { classNames, unstyled })
|
|
2072
|
+
] });
|
|
2073
|
+
}
|
|
2074
|
+
function ProductPageImpl(props) {
|
|
2075
|
+
const { children, classNames, unstyled } = props;
|
|
2076
|
+
const local = { classNames, unstyled };
|
|
2077
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ...props, children: _nullishCoalesce(children, () => ( /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2078
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductJsonLd, {}),
|
|
2079
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Breadcrumbs, { ...local }),
|
|
2080
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SlotAbove, {}),
|
|
2081
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Main, { ...local }),
|
|
2082
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SlotBelow, {}),
|
|
2083
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductSections, { ...local }),
|
|
2084
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, StickyAddToCart, { ...local })
|
|
2085
|
+
] }))) });
|
|
2086
|
+
}
|
|
2087
|
+
var ProductPage = Object.assign(ProductPageImpl, {
|
|
2088
|
+
Root,
|
|
2089
|
+
JsonLd: ProductJsonLd,
|
|
2090
|
+
Breadcrumbs,
|
|
2091
|
+
SlotAbove,
|
|
2092
|
+
Gallery,
|
|
2093
|
+
BuyBox,
|
|
2094
|
+
VariantPicker,
|
|
2095
|
+
Price: _chunkHZ6VEN6Qcjs.Price,
|
|
2096
|
+
StockStatus,
|
|
2097
|
+
QuantityInput,
|
|
2098
|
+
AddToCart,
|
|
2099
|
+
StickyAddToCart,
|
|
2100
|
+
ProductSections,
|
|
2101
|
+
ShippingSection,
|
|
2102
|
+
TagList,
|
|
2103
|
+
CategoryList,
|
|
2104
|
+
RelatedProducts,
|
|
2105
|
+
Reviews,
|
|
2106
|
+
ReviewForm,
|
|
2107
|
+
SlotBelow
|
|
2108
|
+
});
|
|
2109
|
+
|
|
2110
|
+
// src/shopper/quiet-router.tsx
|
|
2111
|
+
|
|
2112
|
+
|
|
2113
|
+
var NOOP = () => {
|
|
2114
|
+
};
|
|
2115
|
+
function QuietRouter({ pathname, children }) {
|
|
2116
|
+
const outer = _chunkVWXJO427cjs.useStorefront.call(void 0, );
|
|
2117
|
+
const value = _react3.useMemo.call(void 0,
|
|
2118
|
+
() => ({ ...outer, router: { pathname, searchParams: new URLSearchParams(), push: NOOP, replace: NOOP } }),
|
|
2119
|
+
[outer, pathname]
|
|
2120
|
+
);
|
|
2121
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVWXJO427cjs.StorefrontContext.Provider, { value, children });
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
|
|
2129
|
+
|
|
2130
|
+
|
|
2131
|
+
|
|
2132
|
+
|
|
2133
|
+
|
|
2134
|
+
|
|
2135
|
+
|
|
2136
|
+
|
|
2137
|
+
|
|
2138
|
+
|
|
2139
|
+
|
|
2140
|
+
|
|
2141
|
+
|
|
2142
|
+
|
|
2143
|
+
|
|
2144
|
+
|
|
2145
|
+
|
|
2146
|
+
|
|
2147
|
+
|
|
2148
|
+
|
|
2149
|
+
|
|
2150
|
+
|
|
2151
|
+
|
|
2152
|
+
|
|
2153
|
+
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
|
|
2158
|
+
|
|
2159
|
+
|
|
2160
|
+
|
|
2161
|
+
|
|
2162
|
+
|
|
2163
|
+
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
|
|
2167
|
+
|
|
2168
|
+
|
|
2169
|
+
|
|
2170
|
+
|
|
2171
|
+
|
|
2172
|
+
|
|
2173
|
+
|
|
2174
|
+
|
|
2175
|
+
exports.SlotOutlet = SlotOutlet; exports.parseShopQuery = parseShopQuery; exports.shopQueryToSearch = shopQueryToSearch; exports.pageWindow = pageWindow; exports.variantFromSearch = variantFromSearch; exports.robotsForShopQuery = robotsForShopQuery; exports.canonicalForShopQuery = canonicalForShopQuery; exports.JsonLd = JsonLd; exports.productJsonLd = productJsonLd; exports.breadcrumbJsonLd = breadcrumbJsonLd; exports.itemListJsonLd = itemListJsonLd; exports.shopAllMetadata = shopAllMetadata; exports.searchMetadata = searchMetadata; exports.productMetadata = productMetadata; exports.Badge = Badge; exports.cardBadges = cardBadges; exports.WishlistButton = WishlistButton; exports.BackInStock = BackInStock; exports.FrequentlyBoughtTogether = FrequentlyBoughtTogether; exports.ReviewPhotos = ReviewPhotos; exports.ReviewVotes = ReviewVotes; exports.QuestionsAndAnswers = QuestionsAndAnswers; exports.Swatch = Swatch; exports.pickerKind = pickerKind; exports.selectOption = selectOption; exports.useProductPage = useProductPage; exports.AddToCart = AddToCart; exports.productCrumbs = productCrumbs; exports.Breadcrumbs = Breadcrumbs; exports.QuantityInput = QuantityInput; exports.stockWord = stockWord; exports.StockStatus = StockStatus; exports.VariantPicker = VariantPicker; exports.BuyBox = BuyBox; exports.CategoryList = CategoryList; exports.Gallery = Gallery; exports.sanitizeHtml = sanitizeHtml; exports.RichText = RichText; exports.useRelatedProducts = useRelatedProducts; exports.RelatedProducts = RelatedProducts; exports.ReviewForm = ReviewForm; exports.Reviews = Reviews; exports.useShippingContent = useShippingContent; exports.ShippingSection = ShippingSection; exports.TagList = TagList; exports.ProductSections = ProductSections; exports.StickyAddToCart = StickyAddToCart; exports.ProductPage = ProductPage; exports.QuietRouter = QuietRouter; exports.ProductCard = ProductCard;
|
|
2176
|
+
//# sourceMappingURL=chunk-NDUEJJLP.cjs.map
|