@artisanpack-ui/ecommerce-storefront-react 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +67 -2
- package/dist/Addresses-D3ESHG3L.mjs +27 -0
- package/dist/Addresses-D3ESHG3L.mjs.map +1 -0
- package/dist/CategoryShow-OAGROEMA.mjs +12 -0
- package/dist/CategoryShow-OAGROEMA.mjs.map +1 -0
- package/dist/Claim-CJ4UOAUD.mjs +22 -0
- package/dist/Claim-CJ4UOAUD.mjs.map +1 -0
- package/dist/Confirmation-TLMMBPWS.mjs +20 -0
- package/dist/Confirmation-TLMMBPWS.mjs.map +1 -0
- package/dist/Dashboard-ARXORMTL.mjs +24 -0
- package/dist/Dashboard-ARXORMTL.mjs.map +1 -0
- package/dist/Downloads-CEQBY7JO.mjs +25 -0
- package/dist/Downloads-CEQBY7JO.mjs.map +1 -0
- package/dist/Index-KRR3Q7EJ.mjs +12 -0
- package/dist/Index-KRR3Q7EJ.mjs.map +1 -0
- package/dist/Index-RLQFEBTX.mjs +22 -0
- package/dist/Index-RLQFEBTX.mjs.map +1 -0
- package/dist/Index-WDJYGR5Q.mjs +12 -0
- package/dist/Index-WDJYGR5Q.mjs.map +1 -0
- package/dist/Index-XYU5QLUT.mjs +23 -0
- package/dist/Index-XYU5QLUT.mjs.map +1 -0
- package/dist/Lookup-QNUQKUID.mjs +19 -0
- package/dist/Lookup-QNUQKUID.mjs.map +1 -0
- package/dist/OrderShow-RYTP62YA.mjs +27 -0
- package/dist/OrderShow-RYTP62YA.mjs.map +1 -0
- package/dist/Orders-LZW57GE6.mjs +25 -0
- package/dist/Orders-LZW57GE6.mjs.map +1 -0
- package/dist/Profile-ZAAWFCAL.mjs +25 -0
- package/dist/Profile-ZAAWFCAL.mjs.map +1 -0
- package/dist/Show-LFWUO3KR.mjs +14 -0
- package/dist/Show-LFWUO3KR.mjs.map +1 -0
- package/dist/TagShow-FXKXRGY2.mjs +12 -0
- package/dist/TagShow-FXKXRGY2.mjs.map +1 -0
- package/dist/chunk-5UUNH3EH.mjs +1888 -0
- package/dist/chunk-5UUNH3EH.mjs.map +1 -0
- package/dist/chunk-A3MMQ2RY.mjs +183 -0
- package/dist/chunk-A3MMQ2RY.mjs.map +1 -0
- package/dist/chunk-ABGPTZ3Q.mjs +198 -0
- package/dist/chunk-ABGPTZ3Q.mjs.map +1 -0
- package/dist/chunk-BJ3FJFZQ.mjs +32 -0
- package/dist/chunk-BJ3FJFZQ.mjs.map +1 -0
- package/dist/chunk-BSASRFQ7.mjs +89 -0
- package/dist/chunk-BSASRFQ7.mjs.map +1 -0
- package/dist/chunk-CGCW3555.mjs +148 -0
- package/dist/chunk-CGCW3555.mjs.map +1 -0
- package/dist/chunk-DWR23FJD.mjs +643 -0
- package/dist/chunk-DWR23FJD.mjs.map +1 -0
- package/dist/chunk-ENY3MH2W.mjs +148 -0
- package/dist/chunk-ENY3MH2W.mjs.map +1 -0
- package/dist/chunk-EWJLRWPO.mjs +280 -0
- package/dist/chunk-EWJLRWPO.mjs.map +1 -0
- package/dist/chunk-FL5XL3ET.mjs +212 -0
- package/dist/chunk-FL5XL3ET.mjs.map +1 -0
- package/dist/chunk-FOOP6UK3.mjs +218 -0
- package/dist/chunk-FOOP6UK3.mjs.map +1 -0
- package/dist/chunk-HCC7GTVO.mjs +115 -0
- package/dist/chunk-HCC7GTVO.mjs.map +1 -0
- package/dist/chunk-HXZMY3GE.mjs +2331 -0
- package/dist/chunk-HXZMY3GE.mjs.map +1 -0
- package/dist/chunk-IOL2YQ62.mjs +109 -0
- package/dist/chunk-IOL2YQ62.mjs.map +1 -0
- package/dist/chunk-JH7SFSZA.mjs +104 -0
- package/dist/chunk-JH7SFSZA.mjs.map +1 -0
- package/dist/chunk-JJOPX4PI.mjs +205 -0
- package/dist/chunk-JJOPX4PI.mjs.map +1 -0
- package/dist/chunk-LT3GG7YQ.mjs +32 -0
- package/dist/chunk-LT3GG7YQ.mjs.map +1 -0
- package/dist/chunk-MZFULGDI.mjs +267 -0
- package/dist/chunk-MZFULGDI.mjs.map +1 -0
- package/dist/chunk-O4WPMMSH.mjs +58 -0
- package/dist/chunk-O4WPMMSH.mjs.map +1 -0
- package/dist/chunk-OU3WYFIH.mjs +397 -0
- package/dist/chunk-OU3WYFIH.mjs.map +1 -0
- package/dist/chunk-P3NIV4YG.mjs +998 -0
- package/dist/chunk-P3NIV4YG.mjs.map +1 -0
- package/dist/chunk-PEBBSZ5R.mjs +201 -0
- package/dist/chunk-PEBBSZ5R.mjs.map +1 -0
- package/dist/chunk-T5OWL6EG.mjs +73 -0
- package/dist/chunk-T5OWL6EG.mjs.map +1 -0
- package/dist/chunk-THPUK35U.mjs +132 -0
- package/dist/chunk-THPUK35U.mjs.map +1 -0
- package/dist/chunk-TPOKMH5E.mjs +142 -0
- package/dist/chunk-TPOKMH5E.mjs.map +1 -0
- package/dist/chunk-VX5TEJNU.mjs +1898 -0
- package/dist/chunk-VX5TEJNU.mjs.map +1 -0
- package/dist/chunk-WUL34MB2.mjs +268 -0
- package/dist/chunk-WUL34MB2.mjs.map +1 -0
- package/dist/chunk-WYGOMIZK.mjs +140 -0
- package/dist/chunk-WYGOMIZK.mjs.map +1 -0
- package/dist/chunk-Y2IOBBN7.mjs +127 -0
- package/dist/chunk-Y2IOBBN7.mjs.map +1 -0
- package/dist/chunk-Y5BRPEHA.mjs +54 -0
- package/dist/chunk-Y5BRPEHA.mjs.map +1 -0
- package/dist/index.d.ts +4607 -0
- package/dist/index.mjs +1515 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +112 -4
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1515 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountClaim
|
|
3
|
+
} from "./chunk-CGCW3555.mjs";
|
|
4
|
+
import {
|
|
5
|
+
OrderConfirmation
|
|
6
|
+
} from "./chunk-BSASRFQ7.mjs";
|
|
7
|
+
import {
|
|
8
|
+
OrderLookup
|
|
9
|
+
} from "./chunk-THPUK35U.mjs";
|
|
10
|
+
import {
|
|
11
|
+
OrderShow
|
|
12
|
+
} from "./chunk-MZFULGDI.mjs";
|
|
13
|
+
import {
|
|
14
|
+
OrderDetails,
|
|
15
|
+
OrderStatusBadge
|
|
16
|
+
} from "./chunk-FL5XL3ET.mjs";
|
|
17
|
+
import {
|
|
18
|
+
AccountDashboard
|
|
19
|
+
} from "./chunk-JJOPX4PI.mjs";
|
|
20
|
+
import {
|
|
21
|
+
AccountOrders
|
|
22
|
+
} from "./chunk-FOOP6UK3.mjs";
|
|
23
|
+
import {
|
|
24
|
+
AccountAddresses
|
|
25
|
+
} from "./chunk-OU3WYFIH.mjs";
|
|
26
|
+
import {
|
|
27
|
+
AccountDownloads
|
|
28
|
+
} from "./chunk-WUL34MB2.mjs";
|
|
29
|
+
import {
|
|
30
|
+
AccountProfile
|
|
31
|
+
} from "./chunk-EWJLRWPO.mjs";
|
|
32
|
+
import "./chunk-Y5BRPEHA.mjs";
|
|
33
|
+
import {
|
|
34
|
+
AccountShell
|
|
35
|
+
} from "./chunk-HCC7GTVO.mjs";
|
|
36
|
+
import {
|
|
37
|
+
CatalogIndex
|
|
38
|
+
} from "./chunk-BJ3FJFZQ.mjs";
|
|
39
|
+
import {
|
|
40
|
+
CatalogCategoryShow
|
|
41
|
+
} from "./chunk-JH7SFSZA.mjs";
|
|
42
|
+
import {
|
|
43
|
+
CatalogTagShow
|
|
44
|
+
} from "./chunk-LT3GG7YQ.mjs";
|
|
45
|
+
import {
|
|
46
|
+
SearchIndex
|
|
47
|
+
} from "./chunk-ENY3MH2W.mjs";
|
|
48
|
+
import {
|
|
49
|
+
CatalogFilters,
|
|
50
|
+
CatalogListing,
|
|
51
|
+
PriceRange,
|
|
52
|
+
StorefrontBreadcrumbs,
|
|
53
|
+
buildQuery,
|
|
54
|
+
choiceValue,
|
|
55
|
+
listingUrl,
|
|
56
|
+
optionValues,
|
|
57
|
+
priceRangeFor,
|
|
58
|
+
toggleValue,
|
|
59
|
+
useQuickAdd,
|
|
60
|
+
withChoice,
|
|
61
|
+
withOption,
|
|
62
|
+
withPrice,
|
|
63
|
+
withToggle
|
|
64
|
+
} from "./chunk-P3NIV4YG.mjs";
|
|
65
|
+
import {
|
|
66
|
+
AddToCart,
|
|
67
|
+
BundledForm,
|
|
68
|
+
CORE_PRODUCT_FORMS,
|
|
69
|
+
ChoiceCards,
|
|
70
|
+
DigitalForm,
|
|
71
|
+
GALLERY_SHOW_EVENT,
|
|
72
|
+
Gallery,
|
|
73
|
+
GroupedForm,
|
|
74
|
+
OptionsForm,
|
|
75
|
+
ProductShow,
|
|
76
|
+
PurchaseFormContext,
|
|
77
|
+
REVIEW_RATING_QUERY,
|
|
78
|
+
RatingInput,
|
|
79
|
+
RecentlyViewed,
|
|
80
|
+
RecentlyViewedPlaceholder,
|
|
81
|
+
Reviews,
|
|
82
|
+
SimpleForm,
|
|
83
|
+
SoldOutNotice,
|
|
84
|
+
StorefrontSections,
|
|
85
|
+
VARIANT_RELOAD,
|
|
86
|
+
VariableForm,
|
|
87
|
+
groupedSummary,
|
|
88
|
+
optionValue,
|
|
89
|
+
registerProductBuiltIns,
|
|
90
|
+
registerProductForms,
|
|
91
|
+
registerProductSections,
|
|
92
|
+
usePurchaseFormContext,
|
|
93
|
+
withOptionValue
|
|
94
|
+
} from "./chunk-HXZMY3GE.mjs";
|
|
95
|
+
import {
|
|
96
|
+
PURCHASE_ERROR_BAG,
|
|
97
|
+
PURCHASE_RELOAD,
|
|
98
|
+
PURCHASE_SUCCESS_RELOAD,
|
|
99
|
+
REVIEW_ERROR_BAG,
|
|
100
|
+
linePrice,
|
|
101
|
+
requestJson,
|
|
102
|
+
useErrorBag,
|
|
103
|
+
useStorefrontPost,
|
|
104
|
+
visitWithQuery
|
|
105
|
+
} from "./chunk-Y2IOBBN7.mjs";
|
|
106
|
+
import {
|
|
107
|
+
Swatches
|
|
108
|
+
} from "./chunk-IOL2YQ62.mjs";
|
|
109
|
+
import {
|
|
110
|
+
Cart,
|
|
111
|
+
ShippingEstimate,
|
|
112
|
+
registerCartBuiltIns
|
|
113
|
+
} from "./chunk-DWR23FJD.mjs";
|
|
114
|
+
import {
|
|
115
|
+
RelatedProducts,
|
|
116
|
+
RelatedProductsPlaceholder,
|
|
117
|
+
RelatedProductsRow,
|
|
118
|
+
relatedHeading
|
|
119
|
+
} from "./chunk-PEBBSZ5R.mjs";
|
|
120
|
+
import {
|
|
121
|
+
ProductCard,
|
|
122
|
+
RatingSummary,
|
|
123
|
+
StockStatus
|
|
124
|
+
} from "./chunk-ABGPTZ3Q.mjs";
|
|
125
|
+
import "./chunk-TPOKMH5E.mjs";
|
|
126
|
+
import {
|
|
127
|
+
AddressStep,
|
|
128
|
+
CORE_PAYMENT_DRIVERS,
|
|
129
|
+
Checkout,
|
|
130
|
+
CheckoutErrorSummary,
|
|
131
|
+
CheckoutOrderSummary,
|
|
132
|
+
CheckoutStepSummary,
|
|
133
|
+
ContactStep,
|
|
134
|
+
PaymentDriverHost,
|
|
135
|
+
PaymentStep,
|
|
136
|
+
Placement,
|
|
137
|
+
RedirectPayment,
|
|
138
|
+
ReviewStep,
|
|
139
|
+
ShippingStep,
|
|
140
|
+
StripePayment,
|
|
141
|
+
addressLines,
|
|
142
|
+
createStripePaymentElementDriver,
|
|
143
|
+
registerPaymentDrivers,
|
|
144
|
+
requestStepFocus,
|
|
145
|
+
shipToLine,
|
|
146
|
+
stepUrl,
|
|
147
|
+
stripeAppearance,
|
|
148
|
+
useCheckout,
|
|
149
|
+
usePaymentDriver
|
|
150
|
+
} from "./chunk-5UUNH3EH.mjs";
|
|
151
|
+
import {
|
|
152
|
+
AddressForm
|
|
153
|
+
} from "./chunk-A3MMQ2RY.mjs";
|
|
154
|
+
import {
|
|
155
|
+
Address
|
|
156
|
+
} from "./chunk-O4WPMMSH.mjs";
|
|
157
|
+
import {
|
|
158
|
+
OrderTotals
|
|
159
|
+
} from "./chunk-T5OWL6EG.mjs";
|
|
160
|
+
import {
|
|
161
|
+
Field
|
|
162
|
+
} from "./chunk-WYGOMIZK.mjs";
|
|
163
|
+
import {
|
|
164
|
+
AccountAction,
|
|
165
|
+
CART_DRAWER_CONTENT_ID,
|
|
166
|
+
CART_DRAWER_ONLY,
|
|
167
|
+
CartDrawer,
|
|
168
|
+
CartDrawerProvider,
|
|
169
|
+
CartHeaderButton,
|
|
170
|
+
CurrencyAction,
|
|
171
|
+
CurrencySwitcher,
|
|
172
|
+
EmptyState,
|
|
173
|
+
HeaderSearch,
|
|
174
|
+
LineControls,
|
|
175
|
+
MERGE_PRIMARY_ID,
|
|
176
|
+
MergePrompt,
|
|
177
|
+
Money,
|
|
178
|
+
Price,
|
|
179
|
+
QUANTITY_COMMIT_DELAY,
|
|
180
|
+
Quantity,
|
|
181
|
+
STOREFRONT_ICONS,
|
|
182
|
+
SearchBox,
|
|
183
|
+
StorefrontBlockHostContext,
|
|
184
|
+
StorefrontLayout,
|
|
185
|
+
StorefrontPageContext,
|
|
186
|
+
Toaster,
|
|
187
|
+
addBuiltInRegistration,
|
|
188
|
+
cartActionUrl,
|
|
189
|
+
checkoutLayout,
|
|
190
|
+
cx,
|
|
191
|
+
getRegistries,
|
|
192
|
+
getStorefrontToaster,
|
|
193
|
+
isSameOrigin,
|
|
194
|
+
postJson,
|
|
195
|
+
registerHeaderActionBuiltIns,
|
|
196
|
+
registerHeaderActions,
|
|
197
|
+
registerStorefrontIcons,
|
|
198
|
+
resetRegistries,
|
|
199
|
+
resetStorefrontToaster,
|
|
200
|
+
runToastAction,
|
|
201
|
+
showResponseToasts,
|
|
202
|
+
showStorefrontToast,
|
|
203
|
+
storefrontLayout,
|
|
204
|
+
suggestionsUrl,
|
|
205
|
+
useCartDrawer,
|
|
206
|
+
useFocusAfterChange,
|
|
207
|
+
usePageErrors,
|
|
208
|
+
useRegisterCartDrawer,
|
|
209
|
+
useStorefront,
|
|
210
|
+
useStorefrontCart,
|
|
211
|
+
useStorefrontPage,
|
|
212
|
+
useStorefrontTemplate
|
|
213
|
+
} from "./chunk-VX5TEJNU.mjs";
|
|
214
|
+
|
|
215
|
+
// src/resolver.ts
|
|
216
|
+
import {
|
|
217
|
+
EcommerceStorefrontPageNotFoundError,
|
|
218
|
+
createPageResolver
|
|
219
|
+
} from "@artisanpack-ui/ecommerce-storefront-core";
|
|
220
|
+
|
|
221
|
+
// src/page.tsx
|
|
222
|
+
import { applyFilters } from "@artisanpack-ui/hooks-js";
|
|
223
|
+
import { HOOKS } from "@artisanpack-ui/ecommerce-storefront-core";
|
|
224
|
+
import { useMemo as useMemo2 } from "react";
|
|
225
|
+
|
|
226
|
+
// src/blocks/templates.tsx
|
|
227
|
+
import { useMemo } from "react";
|
|
228
|
+
import { jsx } from "react/jsx-runtime";
|
|
229
|
+
var BLOCK_CLIENT_ID_ATTRIBUTE = "_ecClientId";
|
|
230
|
+
var renderer = null;
|
|
231
|
+
function setStorefrontTemplateRenderer(next) {
|
|
232
|
+
renderer = next;
|
|
233
|
+
}
|
|
234
|
+
function getStorefrontTemplateRenderer() {
|
|
235
|
+
return renderer;
|
|
236
|
+
}
|
|
237
|
+
function storefrontTemplateTree(blocks) {
|
|
238
|
+
return blocks.map((block) => ({
|
|
239
|
+
...block,
|
|
240
|
+
..."string" === typeof block.clientId && "" !== block.clientId ? { attributes: { ...block.attributes ?? {}, [BLOCK_CLIENT_ID_ATTRIBUTE]: block.clientId } } : {},
|
|
241
|
+
...void 0 !== block.innerBlocks ? { innerBlocks: storefrontTemplateTree(block.innerBlocks) } : {}
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
function StorefrontTemplateContent({
|
|
245
|
+
template,
|
|
246
|
+
render
|
|
247
|
+
}) {
|
|
248
|
+
const tree = useMemo(() => storefrontTemplateTree(template.blocks), [template.blocks]);
|
|
249
|
+
return /* @__PURE__ */ jsx("div", { "data-storefront-template": template.slug, children: render(tree, template) });
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// src/builtIns.ts
|
|
253
|
+
function registerBuiltIns() {
|
|
254
|
+
registerHeaderActionBuiltIns();
|
|
255
|
+
registerProductBuiltIns();
|
|
256
|
+
registerCartBuiltIns();
|
|
257
|
+
registerPaymentDrivers();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// src/page.tsx
|
|
261
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
262
|
+
function filterPageProps(props, pageName) {
|
|
263
|
+
const filtered = applyFilters(HOOKS.pageProps, props, pageName);
|
|
264
|
+
return null !== filtered && "object" === typeof filtered && !Array.isArray(filtered) ? filtered : props;
|
|
265
|
+
}
|
|
266
|
+
function withStorefrontPage(pageName, Page) {
|
|
267
|
+
function StorefrontPage(props) {
|
|
268
|
+
registerBuiltIns();
|
|
269
|
+
getRegistries();
|
|
270
|
+
const filtered = useMemo2(() => filterPageProps(props, pageName), [props]);
|
|
271
|
+
const template = useStorefrontTemplate();
|
|
272
|
+
const renderTemplate = getStorefrontTemplateRenderer();
|
|
273
|
+
if (null !== template && null !== renderTemplate) {
|
|
274
|
+
return /* @__PURE__ */ jsx2(StorefrontTemplateContent, { template, render: renderTemplate });
|
|
275
|
+
}
|
|
276
|
+
return /* @__PURE__ */ jsx2(Page, { ...filtered });
|
|
277
|
+
}
|
|
278
|
+
StorefrontPage.displayName = `StorefrontPage(${pageName})`;
|
|
279
|
+
const wrapped = StorefrontPage;
|
|
280
|
+
if (void 0 !== Page.layout) {
|
|
281
|
+
wrapped.layout = Page.layout;
|
|
282
|
+
}
|
|
283
|
+
return wrapped;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// src/pages.ts
|
|
287
|
+
var PAGES = {
|
|
288
|
+
"Catalog/Index": () => import("./Index-WDJYGR5Q.mjs"),
|
|
289
|
+
"Catalog/CategoryShow": () => import("./CategoryShow-OAGROEMA.mjs"),
|
|
290
|
+
"Catalog/TagShow": () => import("./TagShow-FXKXRGY2.mjs"),
|
|
291
|
+
"Search/Index": () => import("./Index-KRR3Q7EJ.mjs"),
|
|
292
|
+
"Product/Show": () => import("./Show-LFWUO3KR.mjs"),
|
|
293
|
+
"Cart/Index": () => import("./Index-RLQFEBTX.mjs"),
|
|
294
|
+
// Checkout (#6)
|
|
295
|
+
"Checkout/Index": () => import("./Index-XYU5QLUT.mjs"),
|
|
296
|
+
// Orders and account (#7, #8)
|
|
297
|
+
"Order/Confirmation": () => import("./Confirmation-TLMMBPWS.mjs"),
|
|
298
|
+
"Order/Lookup": () => import("./Lookup-QNUQKUID.mjs"),
|
|
299
|
+
"Account/OrderShow": () => import("./OrderShow-RYTP62YA.mjs"),
|
|
300
|
+
"Account/Dashboard": () => import("./Dashboard-ARXORMTL.mjs"),
|
|
301
|
+
"Account/Orders": () => import("./Orders-LZW57GE6.mjs"),
|
|
302
|
+
"Account/Addresses": () => import("./Addresses-D3ESHG3L.mjs"),
|
|
303
|
+
"Account/Downloads": () => import("./Downloads-CEQBY7JO.mjs"),
|
|
304
|
+
"Account/Profile": () => import("./Profile-ZAAWFCAL.mjs"),
|
|
305
|
+
"Account/Claim": () => import("./Claim-CJ4UOAUD.mjs")
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
// src/resolver.ts
|
|
309
|
+
function createEcommerceStorefrontResolver(options = {}) {
|
|
310
|
+
const resolve = createPageResolver(PAGES);
|
|
311
|
+
const wrapped = /* @__PURE__ */ new Map();
|
|
312
|
+
return async (name) => {
|
|
313
|
+
const cached = wrapped.get(name);
|
|
314
|
+
if (void 0 !== cached) {
|
|
315
|
+
return cached;
|
|
316
|
+
}
|
|
317
|
+
let page;
|
|
318
|
+
try {
|
|
319
|
+
page = await resolve(name);
|
|
320
|
+
} catch (error) {
|
|
321
|
+
if (!(error instanceof EcommerceStorefrontPageNotFoundError) || void 0 === options.fallback) {
|
|
322
|
+
throw error;
|
|
323
|
+
}
|
|
324
|
+
page = await options.fallback(name);
|
|
325
|
+
}
|
|
326
|
+
const storefrontPage = withStorefrontPage(name, page);
|
|
327
|
+
wrapped.set(name, storefrontPage);
|
|
328
|
+
return storefrontPage;
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
var resolveEcommerceStorefrontPage = createEcommerceStorefrontResolver();
|
|
332
|
+
|
|
333
|
+
// src/components/CategoryGrid.tsx
|
|
334
|
+
import {
|
|
335
|
+
__,
|
|
336
|
+
trans_choice
|
|
337
|
+
} from "@artisanpack-ui/ecommerce-storefront-core";
|
|
338
|
+
import { Icon } from "@artisanpack-ui/react";
|
|
339
|
+
import { useId } from "react";
|
|
340
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
341
|
+
function CategoryGrid({ grid, className }) {
|
|
342
|
+
const headingId = `ec-category-grid-${useId().replace(/[^A-Za-z0-9_-]/g, "")}`;
|
|
343
|
+
if (0 === grid.tiles.length) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
const columns = Math.max(1, grid.columns);
|
|
347
|
+
return /* @__PURE__ */ jsxs(
|
|
348
|
+
"section",
|
|
349
|
+
{
|
|
350
|
+
className: cx("ec-category-grid", className),
|
|
351
|
+
"aria-labelledby": null !== grid.heading ? headingId : void 0,
|
|
352
|
+
"aria-label": null === grid.heading ? __("Categories") : void 0,
|
|
353
|
+
"data-category-grid": "",
|
|
354
|
+
children: [
|
|
355
|
+
null !== grid.heading ? /* @__PURE__ */ jsx3("h2", { id: headingId, className: "ec-category-grid__title", children: grid.heading }) : null,
|
|
356
|
+
/* @__PURE__ */ jsx3("ul", { role: "list", className: "ec-category-grid__list", "data-columns": columns, children: grid.tiles.map((tile) => /* @__PURE__ */ jsx3("li", { className: "ec-category-grid__item", "data-category-tile": tile.id, children: /* @__PURE__ */ jsxs(
|
|
357
|
+
"article",
|
|
358
|
+
{
|
|
359
|
+
className: "apui-card ec-category-tile",
|
|
360
|
+
"data-surface": "default",
|
|
361
|
+
"data-interactive": null !== tile.url ? "" : void 0,
|
|
362
|
+
children: [
|
|
363
|
+
grid.showImages ? /* @__PURE__ */ jsx3(
|
|
364
|
+
"div",
|
|
365
|
+
{
|
|
366
|
+
className: "ec-category-tile__media",
|
|
367
|
+
"data-scope": "card",
|
|
368
|
+
"data-part": "media",
|
|
369
|
+
"aria-hidden": "true",
|
|
370
|
+
children: null !== tile.image ? /* @__PURE__ */ jsx3(
|
|
371
|
+
"img",
|
|
372
|
+
{
|
|
373
|
+
src: tile.image.url,
|
|
374
|
+
srcSet: tile.image.srcset ?? void 0,
|
|
375
|
+
sizes: null !== tile.image.srcset ? `(min-width: 1024px) ${Math.ceil(100 / columns)}vw, (min-width: 640px) 33vw, 50vw` : void 0,
|
|
376
|
+
width: tile.image.width ?? 800,
|
|
377
|
+
height: tile.image.height ?? 600,
|
|
378
|
+
alt: "",
|
|
379
|
+
loading: "lazy",
|
|
380
|
+
decoding: "async"
|
|
381
|
+
}
|
|
382
|
+
) : /* @__PURE__ */ jsx3(Icon, { name: "layout-grid", className: "ec-category-tile__placeholder" })
|
|
383
|
+
}
|
|
384
|
+
) : null,
|
|
385
|
+
/* @__PURE__ */ jsxs("div", { className: "ec-category-tile__body", children: [
|
|
386
|
+
/* @__PURE__ */ jsxs("div", { className: "ec-category-tile__text", children: [
|
|
387
|
+
/* @__PURE__ */ jsx3("h3", { className: "ec-category-tile__name", children: null !== tile.url ? /* @__PURE__ */ jsx3("a", { href: tile.url, children: tile.name }) : tile.name }),
|
|
388
|
+
grid.showCounts ? /* @__PURE__ */ jsx3("p", { className: "ec-category-tile__count", "data-category-count": "", children: trans_choice(":count product|:count products", tile.count, {
|
|
389
|
+
count: tile.count
|
|
390
|
+
}) }) : null
|
|
391
|
+
] }),
|
|
392
|
+
null !== tile.url ? /* @__PURE__ */ jsx3(Icon, { name: "arrow-right", className: "ec-category-tile__arrow" }) : null
|
|
393
|
+
] })
|
|
394
|
+
]
|
|
395
|
+
}
|
|
396
|
+
) }, tile.id)) })
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// src/components/Skeleton.tsx
|
|
403
|
+
import { __ as __2 } from "@artisanpack-ui/ecommerce-storefront-core";
|
|
404
|
+
import { Card, Skeleton as ApuiSkeleton } from "@artisanpack-ui/react";
|
|
405
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
406
|
+
function Skeleton({
|
|
407
|
+
variant = "text",
|
|
408
|
+
count = 3,
|
|
409
|
+
label,
|
|
410
|
+
className,
|
|
411
|
+
...rest
|
|
412
|
+
}) {
|
|
413
|
+
const kind = ["text", "card", "image"].includes(variant) ? variant : "text";
|
|
414
|
+
const total = Math.max(1, Math.min(24, Math.trunc(count)));
|
|
415
|
+
const items = Array.from({ length: total }, (_, index) => index);
|
|
416
|
+
return /* @__PURE__ */ jsxs2("div", { ...rest, className: cx("ec-skeleton", className), "data-skeleton": kind, children: [
|
|
417
|
+
/* @__PURE__ */ jsx4("span", { className: "apui-sr-only", role: "status", children: label ?? __2("Loading\u2026") }),
|
|
418
|
+
/* @__PURE__ */ jsx4("div", { className: "ec-skeleton__shapes", "data-variant": kind, "aria-busy": "true", "aria-hidden": "true", children: "image" === kind ? /* @__PURE__ */ jsx4(ApuiSkeleton, { className: "ec-skeleton__image" }) : items.map(
|
|
419
|
+
(index) => "card" === kind ? /* @__PURE__ */ jsxs2(
|
|
420
|
+
Card,
|
|
421
|
+
{
|
|
422
|
+
className: "ec-skeleton-card",
|
|
423
|
+
media: /* @__PURE__ */ jsx4(ApuiSkeleton, { className: "ec-skeleton-card__media" }),
|
|
424
|
+
children: [
|
|
425
|
+
/* @__PURE__ */ jsx4(
|
|
426
|
+
ApuiSkeleton,
|
|
427
|
+
{
|
|
428
|
+
shape: "text",
|
|
429
|
+
className: "ec-skeleton-card__line",
|
|
430
|
+
"data-length": "medium"
|
|
431
|
+
}
|
|
432
|
+
),
|
|
433
|
+
/* @__PURE__ */ jsx4(ApuiSkeleton, { shape: "text", className: "ec-skeleton-card__line", "data-length": "long" }),
|
|
434
|
+
/* @__PURE__ */ jsx4(ApuiSkeleton, { shape: "text", className: "ec-skeleton-card__line", "data-length": "short" }),
|
|
435
|
+
/* @__PURE__ */ jsx4(ApuiSkeleton, { className: "ec-skeleton-card__button" })
|
|
436
|
+
]
|
|
437
|
+
},
|
|
438
|
+
index
|
|
439
|
+
) : /* @__PURE__ */ jsx4(
|
|
440
|
+
ApuiSkeleton,
|
|
441
|
+
{
|
|
442
|
+
shape: "text",
|
|
443
|
+
className: "ec-skeleton__line",
|
|
444
|
+
"data-last": index === total - 1 ? "" : void 0
|
|
445
|
+
},
|
|
446
|
+
index
|
|
447
|
+
)
|
|
448
|
+
) })
|
|
449
|
+
] });
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// src/catalog/ProductGrid.tsx
|
|
453
|
+
import { __ as __3 } from "@artisanpack-ui/ecommerce-storefront-core";
|
|
454
|
+
import { useId as useId2 } from "react";
|
|
455
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
456
|
+
function ProductGrid({ grid, source = "", headingId }) {
|
|
457
|
+
const generatedId = useId2();
|
|
458
|
+
const titleId = headingId ?? `ecommerce-product-grid-${generatedId.replace(/[^A-Za-z0-9_-]/g, "")}`;
|
|
459
|
+
const quickAdd = useQuickAdd(grid.showAddToCart ? grid.addToCartUrl : null);
|
|
460
|
+
const headingLevel = null !== grid.heading ? 3 : 2;
|
|
461
|
+
return /* @__PURE__ */ jsx5("div", { "data-product-grid": source, children: grid.products.length > 0 ? /* @__PURE__ */ jsxs3(
|
|
462
|
+
"section",
|
|
463
|
+
{
|
|
464
|
+
className: "ec-product-grid",
|
|
465
|
+
"aria-labelledby": null !== grid.heading ? titleId : void 0,
|
|
466
|
+
"aria-label": null === grid.heading ? __3("Products") : void 0,
|
|
467
|
+
children: [
|
|
468
|
+
null !== grid.heading ? /* @__PURE__ */ jsx5("h2", { id: titleId, className: "ec-product-grid__title", children: grid.heading }) : null,
|
|
469
|
+
/* @__PURE__ */ jsx5(
|
|
470
|
+
"ul",
|
|
471
|
+
{
|
|
472
|
+
role: "list",
|
|
473
|
+
className: "ec-product-grid__list",
|
|
474
|
+
"data-columns": grid.columns,
|
|
475
|
+
"data-product-grid-list": "",
|
|
476
|
+
children: grid.products.map((product) => /* @__PURE__ */ jsx5("li", { className: "ec-product-grid__item", children: /* @__PURE__ */ jsx5(
|
|
477
|
+
ProductCard,
|
|
478
|
+
{
|
|
479
|
+
card: { ...product, headingLevel },
|
|
480
|
+
showPrice: grid.showPrice,
|
|
481
|
+
showRating: grid.showRating,
|
|
482
|
+
onQuickAdd: quickAdd.add,
|
|
483
|
+
quickAddPending: quickAdd.pending === product.id
|
|
484
|
+
}
|
|
485
|
+
) }, product.id))
|
|
486
|
+
}
|
|
487
|
+
)
|
|
488
|
+
]
|
|
489
|
+
}
|
|
490
|
+
) : null });
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// src/order/OrderLookupLink.tsx
|
|
494
|
+
import { __ as __4 } from "@artisanpack-ui/ecommerce-storefront-core";
|
|
495
|
+
import { Link } from "@artisanpack-ui/react";
|
|
496
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
497
|
+
function OrderLookupLink({ href }) {
|
|
498
|
+
if (null === href || "" === href) {
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
return /* @__PURE__ */ jsxs4("p", { className: "ec-order-lookup-link", "data-order-lookup-link": "", children: [
|
|
502
|
+
__4("Ordered as a guest?"),
|
|
503
|
+
" ",
|
|
504
|
+
/* @__PURE__ */ jsx6(Link, { href, tone: "muted", children: __4("Find your order") })
|
|
505
|
+
] });
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// src/blocks/StorefrontBlock.tsx
|
|
509
|
+
import {
|
|
510
|
+
__ as __7
|
|
511
|
+
} from "@artisanpack-ui/ecommerce-storefront-core";
|
|
512
|
+
import { Badge as Badge2 } from "@artisanpack-ui/react";
|
|
513
|
+
import { createElement } from "react";
|
|
514
|
+
|
|
515
|
+
// src/blocks/cartBlocks.tsx
|
|
516
|
+
import {
|
|
517
|
+
__ as __5
|
|
518
|
+
} from "@artisanpack-ui/ecommerce-storefront-core";
|
|
519
|
+
import { Badge, Button, Card as Card2, Icon as Icon2, Input, Skeleton as Skeleton2, Step, Steps } from "@artisanpack-ui/react";
|
|
520
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
521
|
+
registerPaymentDrivers();
|
|
522
|
+
var CHECKOUT_PAGE = "EcommerceStorefront/Checkout/Index";
|
|
523
|
+
function CartPreview({
|
|
524
|
+
lines,
|
|
525
|
+
subtotal,
|
|
526
|
+
showCrossSells,
|
|
527
|
+
showCoupon
|
|
528
|
+
}) {
|
|
529
|
+
return /* @__PURE__ */ jsxs5("div", { className: "ec-cart-preview", "data-cart-preview": "", children: [
|
|
530
|
+
/* @__PURE__ */ jsxs5("div", { className: "ec-block-notice ec-block-notice--sample", "data-commerce-sample": "", children: [
|
|
531
|
+
/* @__PURE__ */ jsx7(Badge, { color: "info", leadingIcon: "info", children: __5("Sample cart") }),
|
|
532
|
+
/* @__PURE__ */ jsx7("p", { className: "ec-block-notice__message", children: __5(
|
|
533
|
+
"Shoppers see their own cart here. This preview uses your newest products and isn't saved."
|
|
534
|
+
) })
|
|
535
|
+
] }),
|
|
536
|
+
/* @__PURE__ */ jsxs5("div", { className: "ec-cart-preview__layout", children: [
|
|
537
|
+
/* @__PURE__ */ jsx7(Card2, { className: "ec-cart-preview__lines", children: /* @__PURE__ */ jsx7("ul", { role: "list", className: "ec-cart-preview__list", "aria-label": __5("Items in your cart"), children: lines.map((line, index) => /* @__PURE__ */ jsxs5("li", { className: "ec-cart-preview__line", "data-cart-preview-line": "", children: [
|
|
538
|
+
/* @__PURE__ */ jsx7("div", { className: "ec-cart-preview__media", "aria-hidden": "true", children: null !== line.image ? /* @__PURE__ */ jsx7(
|
|
539
|
+
"img",
|
|
540
|
+
{
|
|
541
|
+
src: line.image.url,
|
|
542
|
+
srcSet: line.image.srcset ?? void 0,
|
|
543
|
+
sizes: null !== line.image.srcset ? "96px" : void 0,
|
|
544
|
+
width: 96,
|
|
545
|
+
height: 96,
|
|
546
|
+
alt: "",
|
|
547
|
+
loading: "lazy",
|
|
548
|
+
decoding: "async"
|
|
549
|
+
}
|
|
550
|
+
) : /* @__PURE__ */ jsx7(Icon2, { name: "image" }) }),
|
|
551
|
+
/* @__PURE__ */ jsxs5("div", { className: "ec-cart-preview__details", children: [
|
|
552
|
+
/* @__PURE__ */ jsx7("p", { className: "ec-cart-preview__name", children: line.name }),
|
|
553
|
+
/* @__PURE__ */ jsx7("p", { className: "ec-cart-preview__quantity", children: __5("Quantity: :count", { count: 1 }) })
|
|
554
|
+
] }),
|
|
555
|
+
/* @__PURE__ */ jsx7("p", { className: "ec-cart-preview__amount", children: /* @__PURE__ */ jsx7(Money, { money: line.total }) })
|
|
556
|
+
] }, index)) }) }),
|
|
557
|
+
/* @__PURE__ */ jsxs5(Card2, { className: "ec-cart-preview__summary", title: __5("Order summary"), children: [
|
|
558
|
+
showCoupon ? /* @__PURE__ */ jsx7(
|
|
559
|
+
Input,
|
|
560
|
+
{
|
|
561
|
+
id: "ec-cart-preview-coupon",
|
|
562
|
+
label: __5("Coupon code"),
|
|
563
|
+
disabled: true,
|
|
564
|
+
"data-cart-preview-coupon": ""
|
|
565
|
+
}
|
|
566
|
+
) : null,
|
|
567
|
+
/* @__PURE__ */ jsxs5("dl", { className: "ec-cart-preview__totals", children: [
|
|
568
|
+
/* @__PURE__ */ jsxs5("div", { className: "ec-cart-preview__total", children: [
|
|
569
|
+
/* @__PURE__ */ jsx7("dt", { children: __5("Subtotal") }),
|
|
570
|
+
/* @__PURE__ */ jsx7("dd", { children: /* @__PURE__ */ jsx7(Money, { money: subtotal }) })
|
|
571
|
+
] }),
|
|
572
|
+
/* @__PURE__ */ jsxs5("div", { className: "ec-cart-preview__total", children: [
|
|
573
|
+
/* @__PURE__ */ jsx7("dt", { children: __5("Shipping") }),
|
|
574
|
+
/* @__PURE__ */ jsx7("dd", { children: __5("Calculated at checkout") })
|
|
575
|
+
] })
|
|
576
|
+
] }),
|
|
577
|
+
/* @__PURE__ */ jsx7(Button, { color: "primary", className: "ec-cart-preview__checkout", disabled: true, children: __5("Checkout") })
|
|
578
|
+
] })
|
|
579
|
+
] }),
|
|
580
|
+
showCrossSells ? /* @__PURE__ */ jsx7(
|
|
581
|
+
"p",
|
|
582
|
+
{
|
|
583
|
+
className: "ec-block-notice ec-block-notice__message ec-cart-preview__cross-sells",
|
|
584
|
+
"data-cart-preview-cross-sells": "",
|
|
585
|
+
children: __5("Cross-sells for the shopper's cart appear here.")
|
|
586
|
+
}
|
|
587
|
+
) : null
|
|
588
|
+
] });
|
|
589
|
+
}
|
|
590
|
+
function CartContentsBlock({
|
|
591
|
+
props
|
|
592
|
+
}) {
|
|
593
|
+
if (null !== props.preview) {
|
|
594
|
+
return /* @__PURE__ */ jsx7(
|
|
595
|
+
CartPreview,
|
|
596
|
+
{
|
|
597
|
+
lines: props.preview.lines,
|
|
598
|
+
subtotal: props.preview.subtotal,
|
|
599
|
+
showCrossSells: props.preview.showCrossSells,
|
|
600
|
+
showCoupon: props.showCoupon
|
|
601
|
+
}
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
const { preview: _preview, ...cart } = props;
|
|
605
|
+
return /* @__PURE__ */ jsx7(Cart, { ...cart });
|
|
606
|
+
}
|
|
607
|
+
function CheckoutPreview({ layout, steps }) {
|
|
608
|
+
const singlePage = "single_page" === layout;
|
|
609
|
+
const first = steps[0];
|
|
610
|
+
return /* @__PURE__ */ jsxs5("div", { className: "ec-checkout-preview", "data-checkout-preview": layout, children: [
|
|
611
|
+
/* @__PURE__ */ jsxs5("div", { className: "ec-block-notice ec-block-notice--sample", "data-commerce-sample": "", children: [
|
|
612
|
+
/* @__PURE__ */ jsx7(Badge, { color: "info", children: singlePage ? __5("Single page") : __5("Multi-step") }),
|
|
613
|
+
/* @__PURE__ */ jsx7("p", { className: "ec-block-notice__message", children: __5("Shoppers check out their own cart here.") })
|
|
614
|
+
] }),
|
|
615
|
+
singlePage ? /* @__PURE__ */ jsx7("ol", { role: "list", className: "ec-checkout-preview__sections", "aria-label": __5("Checkout steps"), children: steps.map((step, index) => /* @__PURE__ */ jsx7(
|
|
616
|
+
"li",
|
|
617
|
+
{
|
|
618
|
+
"data-checkout-preview-step": step.key,
|
|
619
|
+
"aria-current": 0 === index ? "step" : void 0,
|
|
620
|
+
children: /* @__PURE__ */ jsx7(
|
|
621
|
+
Card2,
|
|
622
|
+
{
|
|
623
|
+
surface: 0 === index ? "default" : "sunken",
|
|
624
|
+
className: "ec-checkout-preview__section",
|
|
625
|
+
"data-upcoming": 0 !== index ? "" : void 0,
|
|
626
|
+
children: /* @__PURE__ */ jsxs5("p", { className: "ec-checkout-preview__section-title", children: [
|
|
627
|
+
/* @__PURE__ */ jsx7("span", { className: "ec-checkout-preview__marker", "aria-hidden": "true", children: index + 1 }),
|
|
628
|
+
/* @__PURE__ */ jsx7("span", { children: step.label })
|
|
629
|
+
] })
|
|
630
|
+
}
|
|
631
|
+
)
|
|
632
|
+
},
|
|
633
|
+
step.key
|
|
634
|
+
)) }) : /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
635
|
+
/* @__PURE__ */ jsx7(Steps, { value: 1, label: __5("Checkout steps"), className: "ec-checkout-preview__steps", children: steps.map((step) => /* @__PURE__ */ jsx7(Step, { title: step.label, "data-checkout-preview-step": step.key }, step.key)) }),
|
|
636
|
+
void 0 !== first ? /* @__PURE__ */ jsx7(Card2, { className: "ec-checkout-preview__current", title: first.label, children: /* @__PURE__ */ jsxs5("div", { className: "ec-checkout-preview__placeholder", "aria-hidden": "true", children: [
|
|
637
|
+
/* @__PURE__ */ jsx7(Skeleton2, { className: "ec-checkout-preview__field" }),
|
|
638
|
+
/* @__PURE__ */ jsx7(Skeleton2, { className: "ec-checkout-preview__button" })
|
|
639
|
+
] }) }) : null
|
|
640
|
+
] })
|
|
641
|
+
] });
|
|
642
|
+
}
|
|
643
|
+
function CheckoutStepsBlock({
|
|
644
|
+
props
|
|
645
|
+
}) {
|
|
646
|
+
const page = useStorefrontPage();
|
|
647
|
+
if (CHECKOUT_PAGE === page.component && void 0 !== page.props.steps) {
|
|
648
|
+
const checkout = page.props;
|
|
649
|
+
return /* @__PURE__ */ jsx7(Checkout, { ...checkout, layout: props.layout });
|
|
650
|
+
}
|
|
651
|
+
return /* @__PURE__ */ jsx7(CheckoutPreview, { layout: props.layout, steps: props.steps });
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// src/blocks/catalogBlocks.tsx
|
|
655
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
656
|
+
var CatalogPage = CatalogIndex;
|
|
657
|
+
function ProductGridBlock({
|
|
658
|
+
props,
|
|
659
|
+
attributes
|
|
660
|
+
}) {
|
|
661
|
+
const source = "string" === typeof attributes.source ? attributes.source : "";
|
|
662
|
+
return /* @__PURE__ */ jsx8(ProductGrid, { grid: props, source });
|
|
663
|
+
}
|
|
664
|
+
function CategoryGridBlock({
|
|
665
|
+
props
|
|
666
|
+
}) {
|
|
667
|
+
return /* @__PURE__ */ jsx8(CategoryGrid, { grid: props });
|
|
668
|
+
}
|
|
669
|
+
function ProductCatalogBlock({
|
|
670
|
+
props
|
|
671
|
+
}) {
|
|
672
|
+
const page = useStorefrontPage().props;
|
|
673
|
+
if (null !== props.header && null !== props.listing) {
|
|
674
|
+
return /* @__PURE__ */ jsx8(CatalogPage, { header: props.header, listing: props.listing });
|
|
675
|
+
}
|
|
676
|
+
if ("category" === props.page && void 0 !== page.category) {
|
|
677
|
+
return /* @__PURE__ */ jsx8(
|
|
678
|
+
CatalogCategoryShow,
|
|
679
|
+
{
|
|
680
|
+
...page,
|
|
681
|
+
headingLevel: props.headingLevel
|
|
682
|
+
}
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
if ("tag" === props.page && void 0 !== page.tag) {
|
|
686
|
+
return /* @__PURE__ */ jsx8(
|
|
687
|
+
CatalogTagShow,
|
|
688
|
+
{
|
|
689
|
+
...page,
|
|
690
|
+
headingLevel: props.headingLevel
|
|
691
|
+
}
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
if ("search" === props.page && void 0 !== page.listing) {
|
|
695
|
+
return /* @__PURE__ */ jsx8(SearchIndex, { ...page });
|
|
696
|
+
}
|
|
697
|
+
if (void 0 !== page.header && void 0 !== page.listing) {
|
|
698
|
+
return /* @__PURE__ */ jsx8(
|
|
699
|
+
CatalogPage,
|
|
700
|
+
{
|
|
701
|
+
header: page.header,
|
|
702
|
+
listing: page.listing
|
|
703
|
+
}
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
return null;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// src/blocks/productBlocks.tsx
|
|
710
|
+
import {
|
|
711
|
+
__ as __6
|
|
712
|
+
} from "@artisanpack-ui/ecommerce-storefront-core";
|
|
713
|
+
import { Alert } from "@artisanpack-ui/react";
|
|
714
|
+
import { useMemo as useMemo4 } from "react";
|
|
715
|
+
|
|
716
|
+
// src/blocks/BlockPage.tsx
|
|
717
|
+
import { useMemo as useMemo3 } from "react";
|
|
718
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
719
|
+
function BlockPage({ props, children }) {
|
|
720
|
+
const page = useStorefrontPage();
|
|
721
|
+
const value = useMemo3(() => ({ ...page, props: { ...page.props, ...props } }), [page, props]);
|
|
722
|
+
return /* @__PURE__ */ jsx9(StorefrontPageContext.Provider, { value, children });
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// src/blocks/productBlocks.tsx
|
|
726
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
727
|
+
registerProductBuiltIns();
|
|
728
|
+
function SingleProductBlock({
|
|
729
|
+
props
|
|
730
|
+
}) {
|
|
731
|
+
return /* @__PURE__ */ jsx10(BlockPage, { props, children: /* @__PURE__ */ jsx10(ProductShow, { ...props }) });
|
|
732
|
+
}
|
|
733
|
+
function ProductGalleryBlock({
|
|
734
|
+
props
|
|
735
|
+
}) {
|
|
736
|
+
return /* @__PURE__ */ jsx10(
|
|
737
|
+
Gallery,
|
|
738
|
+
{
|
|
739
|
+
items: props.items,
|
|
740
|
+
name: props.name,
|
|
741
|
+
active: props.active,
|
|
742
|
+
thumbnails: props.thumbnails,
|
|
743
|
+
zoom: props.zoom
|
|
744
|
+
}
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
function ProductPriceBlock({
|
|
748
|
+
props
|
|
749
|
+
}) {
|
|
750
|
+
return /* @__PURE__ */ jsx10(Price, { price: props.price, size: props.size, "data-product-price": "" });
|
|
751
|
+
}
|
|
752
|
+
function AddToCartBlock({
|
|
753
|
+
props
|
|
754
|
+
}) {
|
|
755
|
+
const { product, form, showQuantity, buttonText, unavailable } = props;
|
|
756
|
+
const context = useMemo4(
|
|
757
|
+
() => ({
|
|
758
|
+
productName: product.name,
|
|
759
|
+
productUrl: product.url,
|
|
760
|
+
variantId: null,
|
|
761
|
+
announcement: null,
|
|
762
|
+
notifySubscribed: false,
|
|
763
|
+
buttonText
|
|
764
|
+
}),
|
|
765
|
+
[product.name, product.url, buttonText]
|
|
766
|
+
);
|
|
767
|
+
if (null === form) {
|
|
768
|
+
return /* @__PURE__ */ jsx10(
|
|
769
|
+
Alert,
|
|
770
|
+
{
|
|
771
|
+
color: "neutral",
|
|
772
|
+
icon: "info",
|
|
773
|
+
title: unavailable ?? __6("This product can't be purchased online"),
|
|
774
|
+
"data-product-unavailable": ""
|
|
775
|
+
}
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
const Form = getRegistries().productForms.get(form.component)?.component;
|
|
779
|
+
return void 0 === Form ? null : /* @__PURE__ */ jsx10(PurchaseFormContext.Provider, { value: context, children: /* @__PURE__ */ jsx10(
|
|
780
|
+
Form,
|
|
781
|
+
{
|
|
782
|
+
...form.props,
|
|
783
|
+
showQuantity: showQuantity && false !== form.props.showQuantity
|
|
784
|
+
},
|
|
785
|
+
`${form.component}-${product.id}`
|
|
786
|
+
) });
|
|
787
|
+
}
|
|
788
|
+
function ProductReviewsBlock({
|
|
789
|
+
props
|
|
790
|
+
}) {
|
|
791
|
+
return /* @__PURE__ */ jsx10(Reviews, { ...props.reviews, productId: props.product.id, allowForm: props.showForm });
|
|
792
|
+
}
|
|
793
|
+
function RelatedProductsBlock({
|
|
794
|
+
props
|
|
795
|
+
}) {
|
|
796
|
+
return /* @__PURE__ */ jsx10(RelatedProductsRow, { related: props });
|
|
797
|
+
}
|
|
798
|
+
function numberAttribute(value) {
|
|
799
|
+
return "number" === typeof value && Number.isInteger(value) && value > 0 ? value : null;
|
|
800
|
+
}
|
|
801
|
+
function RecentlyViewedBlock({
|
|
802
|
+
props,
|
|
803
|
+
attributes
|
|
804
|
+
}) {
|
|
805
|
+
const product = useStorefrontPage().props.product;
|
|
806
|
+
const heading = attributes.heading;
|
|
807
|
+
return /* @__PURE__ */ jsx10(
|
|
808
|
+
RecentlyViewed,
|
|
809
|
+
{
|
|
810
|
+
data: props,
|
|
811
|
+
refresh: true,
|
|
812
|
+
productId: "number" === typeof product?.id ? product.id : null,
|
|
813
|
+
limit: numberAttribute(attributes.limit),
|
|
814
|
+
columns: numberAttribute(attributes.columns),
|
|
815
|
+
heading: "string" === typeof heading && "" !== heading.trim() ? heading : null
|
|
816
|
+
}
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// src/blocks/StorefrontBlock.tsx
|
|
821
|
+
import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
822
|
+
var STOREFRONT_BLOCK_PREFIX = "artisanpack-commerce/";
|
|
823
|
+
var STOREFRONT_BLOCKS = {
|
|
824
|
+
"artisanpack-commerce/product-grid": ProductGridBlock,
|
|
825
|
+
"artisanpack-commerce/category-grid": CategoryGridBlock,
|
|
826
|
+
"artisanpack-commerce/related-products": RelatedProductsBlock,
|
|
827
|
+
"artisanpack-commerce/recently-viewed": RecentlyViewedBlock,
|
|
828
|
+
"artisanpack-commerce/single-product": SingleProductBlock,
|
|
829
|
+
"artisanpack-commerce/product-gallery": ProductGalleryBlock,
|
|
830
|
+
"artisanpack-commerce/product-price": ProductPriceBlock,
|
|
831
|
+
"artisanpack-commerce/add-to-cart": AddToCartBlock,
|
|
832
|
+
"artisanpack-commerce/product-reviews": ProductReviewsBlock,
|
|
833
|
+
"artisanpack-commerce/product-catalog": ProductCatalogBlock,
|
|
834
|
+
"artisanpack-commerce/cart-contents": CartContentsBlock,
|
|
835
|
+
"artisanpack-commerce/checkout-steps": CheckoutStepsBlock
|
|
836
|
+
};
|
|
837
|
+
var added = /* @__PURE__ */ new Map();
|
|
838
|
+
function registerStorefrontBlock(name, component) {
|
|
839
|
+
added.set(name.trim(), component);
|
|
840
|
+
}
|
|
841
|
+
function getStorefrontBlock(name) {
|
|
842
|
+
const key = name.trim();
|
|
843
|
+
return added.get(key) ?? STOREFRONT_BLOCKS[key];
|
|
844
|
+
}
|
|
845
|
+
function storefrontBlockNames() {
|
|
846
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(STOREFRONT_BLOCKS), ...added.keys()])];
|
|
847
|
+
}
|
|
848
|
+
function resetStorefrontBlocks() {
|
|
849
|
+
added.clear();
|
|
850
|
+
}
|
|
851
|
+
function storefrontBlockSlug(name) {
|
|
852
|
+
return name.startsWith(STOREFRONT_BLOCK_PREFIX) ? name.slice(STOREFRONT_BLOCK_PREFIX.length) : name;
|
|
853
|
+
}
|
|
854
|
+
function BlockSampleNotice() {
|
|
855
|
+
return /* @__PURE__ */ jsxs6("div", { className: "ec-block-notice ec-block-notice--sample", "data-commerce-sample": "", children: [
|
|
856
|
+
/* @__PURE__ */ jsx11(Badge2, { color: "info", leadingIcon: "info", children: __7("Sample product") }),
|
|
857
|
+
/* @__PURE__ */ jsx11("p", { className: "ec-block-notice__message", children: __7(
|
|
858
|
+
"Showing the newest product as a sample. On a product page this block shows that page's product; set a product ID in the block settings to always show one product."
|
|
859
|
+
) })
|
|
860
|
+
] });
|
|
861
|
+
}
|
|
862
|
+
function StorefrontBlockBody({ presentation }) {
|
|
863
|
+
registerBuiltIns();
|
|
864
|
+
if (null === presentation) {
|
|
865
|
+
return null;
|
|
866
|
+
}
|
|
867
|
+
const Component = getStorefrontBlock(presentation.name);
|
|
868
|
+
if (void 0 === Component) {
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
return /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
872
|
+
presentation.sample ? /* @__PURE__ */ jsx11(BlockSampleNotice, {}) : null,
|
|
873
|
+
createElement(Component, {
|
|
874
|
+
props: presentation.props,
|
|
875
|
+
attributes: presentation.attributes
|
|
876
|
+
})
|
|
877
|
+
] });
|
|
878
|
+
}
|
|
879
|
+
function StorefrontBlock({
|
|
880
|
+
presentation,
|
|
881
|
+
className
|
|
882
|
+
}) {
|
|
883
|
+
if (null === presentation || void 0 === getStorefrontBlock(presentation.name)) {
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
return /* @__PURE__ */ jsx11(
|
|
887
|
+
"div",
|
|
888
|
+
{
|
|
889
|
+
className: cx("ec-commerce-block", className),
|
|
890
|
+
"data-commerce-block": storefrontBlockSlug(presentation.name),
|
|
891
|
+
children: /* @__PURE__ */ jsx11(StorefrontBlockBody, { presentation })
|
|
892
|
+
}
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
// src/blocks/blockRoot.tsx
|
|
897
|
+
import { useMemo as useMemo5 } from "react";
|
|
898
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
899
|
+
var settings = {};
|
|
900
|
+
function configureStorefrontBlocks(next) {
|
|
901
|
+
settings = { ...settings, ...next };
|
|
902
|
+
}
|
|
903
|
+
function storefrontBlockSettings() {
|
|
904
|
+
return settings;
|
|
905
|
+
}
|
|
906
|
+
function resetStorefrontBlockSettings() {
|
|
907
|
+
settings = {};
|
|
908
|
+
}
|
|
909
|
+
function fallbackSharedProps() {
|
|
910
|
+
const element = "undefined" === typeof document ? null : document.documentElement;
|
|
911
|
+
const base = settings.storefrontUrl?.replace(/\/$/, "") ?? null;
|
|
912
|
+
const name = "undefined" === typeof document ? "" : document.title;
|
|
913
|
+
return {
|
|
914
|
+
locale: settings.locale ?? (element?.lang || "en").replace("-", "_"),
|
|
915
|
+
direction: "rtl" === element?.dir ? "rtl" : "ltr",
|
|
916
|
+
routes: {
|
|
917
|
+
storefront: { namePrefix: "artisanpack.ecommerce.storefront.", base },
|
|
918
|
+
account: { namePrefix: "artisanpack.ecommerce.account.", base: null }
|
|
919
|
+
},
|
|
920
|
+
toasts: [],
|
|
921
|
+
seo: {
|
|
922
|
+
title: null,
|
|
923
|
+
description: null,
|
|
924
|
+
canonical: null,
|
|
925
|
+
robots: null,
|
|
926
|
+
image: null,
|
|
927
|
+
type: "website",
|
|
928
|
+
siteName: name,
|
|
929
|
+
openGraph: false,
|
|
930
|
+
schemas: []
|
|
931
|
+
},
|
|
932
|
+
store: { name, mark: "", url: base ?? "/", tagline: null },
|
|
933
|
+
navigation: [],
|
|
934
|
+
footer: [],
|
|
935
|
+
headerActions: [],
|
|
936
|
+
account: null,
|
|
937
|
+
auth: { login: null, register: null, logout: null, profile: null, password: null },
|
|
938
|
+
search: { url: null === base ? null : `${base}/search`, shortcut: false },
|
|
939
|
+
cart: { url: null === base ? null : `${base}/cart`, count: 0 }
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
function StorefrontBlockRoot({ page, children }) {
|
|
943
|
+
const value = useMemo5(() => {
|
|
944
|
+
const current = page ?? {
|
|
945
|
+
component: "",
|
|
946
|
+
props: {},
|
|
947
|
+
url: "undefined" === typeof window ? "/" : window.location.href
|
|
948
|
+
};
|
|
949
|
+
return {
|
|
950
|
+
...current,
|
|
951
|
+
props: {
|
|
952
|
+
errors: {},
|
|
953
|
+
...current.props,
|
|
954
|
+
ecommerceStorefront: current.props.ecommerceStorefront ?? fallbackSharedProps()
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
}, [page]);
|
|
958
|
+
return /* @__PURE__ */ jsx12(StorefrontPageContext.Provider, { value, children });
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// src/blocks/renderers.tsx
|
|
962
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
963
|
+
|
|
964
|
+
// src/blocks/blockHost.tsx
|
|
965
|
+
import {
|
|
966
|
+
useCallback,
|
|
967
|
+
useEffect,
|
|
968
|
+
useMemo as useMemo6,
|
|
969
|
+
useRef,
|
|
970
|
+
useState
|
|
971
|
+
} from "react";
|
|
972
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
973
|
+
var BLOCK_PROPS_QUERY_KEYS = ["name", "attributes", "product"];
|
|
974
|
+
function blockQuery(url) {
|
|
975
|
+
const base = "undefined" !== typeof window ? window.location.href : "http://localhost";
|
|
976
|
+
const query = {};
|
|
977
|
+
new URL(url, base).searchParams.forEach((value, key) => {
|
|
978
|
+
if (!BLOCK_PROPS_QUERY_KEYS.includes(key)) {
|
|
979
|
+
query[key] = value;
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
return query;
|
|
983
|
+
}
|
|
984
|
+
function StorefrontBlockHost({
|
|
985
|
+
name,
|
|
986
|
+
attributes,
|
|
987
|
+
productId = null,
|
|
988
|
+
inertia,
|
|
989
|
+
onPresentation,
|
|
990
|
+
children
|
|
991
|
+
}) {
|
|
992
|
+
const page = useStorefrontPage();
|
|
993
|
+
const base = useStorefront().routes?.storefront?.base ?? null;
|
|
994
|
+
const [url, setUrl] = useState(null);
|
|
995
|
+
const [plainErrors, setPlainErrors] = useState({});
|
|
996
|
+
const [bagged, setBagged] = useState({});
|
|
997
|
+
const latest = useRef({ name, attributes, productId, base, url, onPresentation });
|
|
998
|
+
useEffect(() => {
|
|
999
|
+
latest.current = { name, attributes, productId, base, url, onPresentation };
|
|
1000
|
+
});
|
|
1001
|
+
const pending = useRef(null);
|
|
1002
|
+
useEffect(() => () => pending.current?.abort(), []);
|
|
1003
|
+
const refresh = useCallback(async (next) => {
|
|
1004
|
+
const current = latest.current;
|
|
1005
|
+
const target = next ?? current.url;
|
|
1006
|
+
const propsUrl = blockPropsUrl(
|
|
1007
|
+
blockPropsEndpoint(current.base),
|
|
1008
|
+
current.name,
|
|
1009
|
+
current.attributes,
|
|
1010
|
+
current.productId,
|
|
1011
|
+
null === target ? {} : blockQuery(target)
|
|
1012
|
+
);
|
|
1013
|
+
if (null === propsUrl) {
|
|
1014
|
+
return true;
|
|
1015
|
+
}
|
|
1016
|
+
if (null !== target) {
|
|
1017
|
+
setUrl(target);
|
|
1018
|
+
}
|
|
1019
|
+
pending.current?.abort();
|
|
1020
|
+
const controller = new AbortController();
|
|
1021
|
+
pending.current = controller;
|
|
1022
|
+
let presentation;
|
|
1023
|
+
try {
|
|
1024
|
+
presentation = await fetchBlockPresentation(propsUrl, controller.signal);
|
|
1025
|
+
} catch (error) {
|
|
1026
|
+
if (controller.signal.aborted) {
|
|
1027
|
+
return false;
|
|
1028
|
+
}
|
|
1029
|
+
throw error;
|
|
1030
|
+
}
|
|
1031
|
+
if (controller.signal.aborted) {
|
|
1032
|
+
return false;
|
|
1033
|
+
}
|
|
1034
|
+
current.onPresentation(presentation);
|
|
1035
|
+
return true;
|
|
1036
|
+
}, []);
|
|
1037
|
+
const setErrors = useCallback((bag, errors) => {
|
|
1038
|
+
if (null === bag) {
|
|
1039
|
+
setPlainErrors(errors);
|
|
1040
|
+
} else {
|
|
1041
|
+
setBagged((previous) => ({ ...previous, [bag]: errors }));
|
|
1042
|
+
}
|
|
1043
|
+
}, []);
|
|
1044
|
+
const host = useMemo6(
|
|
1045
|
+
() => ({ inertia, refresh, setErrors }),
|
|
1046
|
+
[inertia, refresh, setErrors]
|
|
1047
|
+
);
|
|
1048
|
+
const snapshot = useMemo6(() => {
|
|
1049
|
+
const errors = page.props.errors;
|
|
1050
|
+
return {
|
|
1051
|
+
...page,
|
|
1052
|
+
url: url ?? page.url,
|
|
1053
|
+
props: {
|
|
1054
|
+
...page.props,
|
|
1055
|
+
errors: {
|
|
1056
|
+
...null !== errors && "object" === typeof errors ? errors : {},
|
|
1057
|
+
...plainErrors,
|
|
1058
|
+
...bagged
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
}, [page, url, plainErrors, bagged]);
|
|
1063
|
+
return /* @__PURE__ */ jsx13(StorefrontBlockHostContext.Provider, { value: host, children: /* @__PURE__ */ jsx13(StorefrontPageContext.Provider, { value: snapshot, children }) });
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
// src/blocks/renderers.tsx
|
|
1067
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1068
|
+
var BLOCK_ATTRIBUTES_MAX_BYTES = 4096;
|
|
1069
|
+
function publicBlockAttributes(attributes) {
|
|
1070
|
+
return Object.fromEntries(Object.entries(attributes).filter(([key]) => !key.startsWith("_")));
|
|
1071
|
+
}
|
|
1072
|
+
function blockPropsUrl(endpoint, name, attributes, productId = null, query = {}) {
|
|
1073
|
+
if (null === endpoint) {
|
|
1074
|
+
return null;
|
|
1075
|
+
}
|
|
1076
|
+
const json = JSON.stringify(publicBlockAttributes(attributes));
|
|
1077
|
+
if (new TextEncoder().encode(json).length > BLOCK_ATTRIBUTES_MAX_BYTES) {
|
|
1078
|
+
return null;
|
|
1079
|
+
}
|
|
1080
|
+
const params = new URLSearchParams({ ...query, name, attributes: json });
|
|
1081
|
+
if (null !== productId && productId > 0) {
|
|
1082
|
+
params.set("product", String(productId));
|
|
1083
|
+
}
|
|
1084
|
+
return `${endpoint}${endpoint.includes("?") ? "&" : "?"}${params.toString()}`;
|
|
1085
|
+
}
|
|
1086
|
+
function blockPropsEndpoint(storefrontBase) {
|
|
1087
|
+
const settings2 = storefrontBlockSettings();
|
|
1088
|
+
if (void 0 !== settings2.propsUrl && null !== settings2.propsUrl) {
|
|
1089
|
+
return settings2.propsUrl;
|
|
1090
|
+
}
|
|
1091
|
+
const base = storefrontBase ?? settings2.storefrontUrl ?? null;
|
|
1092
|
+
return null === base ? null : `${base.replace(/\/$/, "")}/blocks/props`;
|
|
1093
|
+
}
|
|
1094
|
+
async function fetchBlockPresentation(url, signal) {
|
|
1095
|
+
if (!isSameOrigin(url)) {
|
|
1096
|
+
throw new Error("The blocks.props route must be on the same origin.");
|
|
1097
|
+
}
|
|
1098
|
+
const response = await fetch(url, {
|
|
1099
|
+
credentials: "same-origin",
|
|
1100
|
+
headers: { Accept: "application/json", "X-Requested-With": "XMLHttpRequest" },
|
|
1101
|
+
signal
|
|
1102
|
+
});
|
|
1103
|
+
if (!response.ok) {
|
|
1104
|
+
throw new Error(`blocks.props answered ${response.status}.`);
|
|
1105
|
+
}
|
|
1106
|
+
const body = await response.json();
|
|
1107
|
+
if (null === body || "object" !== typeof body || !("block" in body)) {
|
|
1108
|
+
throw new Error("blocks.props answered something else.");
|
|
1109
|
+
}
|
|
1110
|
+
return body.block ?? null;
|
|
1111
|
+
}
|
|
1112
|
+
function useBlockPresentation(name, attributes) {
|
|
1113
|
+
const page = useStorefrontPage();
|
|
1114
|
+
const template = useStorefrontTemplate();
|
|
1115
|
+
const clientId = attributes[BLOCK_CLIENT_ID_ATTRIBUTE];
|
|
1116
|
+
const fromTemplate = null !== template && "string" === typeof clientId && Object.prototype.hasOwnProperty.call(template.blockProps, clientId) ? template.blockProps[clientId] ?? null : void 0;
|
|
1117
|
+
const shared = page.props.ecommerceStorefront;
|
|
1118
|
+
const product = page.props.product;
|
|
1119
|
+
const productId = "number" === typeof product?.id ? product.id : null;
|
|
1120
|
+
const url = blockPropsUrl(
|
|
1121
|
+
blockPropsEndpoint(shared?.routes?.storefront?.base),
|
|
1122
|
+
name,
|
|
1123
|
+
attributes,
|
|
1124
|
+
productId
|
|
1125
|
+
);
|
|
1126
|
+
const [fetched, setFetched] = useState2(
|
|
1127
|
+
null
|
|
1128
|
+
);
|
|
1129
|
+
useEffect2(() => {
|
|
1130
|
+
if (void 0 !== fromTemplate || null === url) {
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
const controller = new AbortController();
|
|
1134
|
+
fetchBlockPresentation(url, controller.signal).then(
|
|
1135
|
+
(presentation) => setFetched({ url, state: { status: "ready", presentation } }),
|
|
1136
|
+
() => {
|
|
1137
|
+
if (!controller.signal.aborted) {
|
|
1138
|
+
setFetched({ url, state: { status: "error" } });
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
);
|
|
1142
|
+
return () => controller.abort();
|
|
1143
|
+
}, [fromTemplate, url]);
|
|
1144
|
+
if (void 0 !== fromTemplate) {
|
|
1145
|
+
return { status: "ready", presentation: fromTemplate };
|
|
1146
|
+
}
|
|
1147
|
+
if (null === url) {
|
|
1148
|
+
return { status: "error" };
|
|
1149
|
+
}
|
|
1150
|
+
return null !== fetched && fetched.url === url ? fetched.state : { status: "loading" };
|
|
1151
|
+
}
|
|
1152
|
+
function StorefrontBlockRenderer({
|
|
1153
|
+
name,
|
|
1154
|
+
attributes
|
|
1155
|
+
}) {
|
|
1156
|
+
const page = useStorefrontPage();
|
|
1157
|
+
return void 0 === page.props.ecommerceStorefront ? /* @__PURE__ */ jsx14(StorefrontBlockRoot, { page, children: /* @__PURE__ */ jsx14(RenderedBlock, { name, attributes, hosted: true }) }) : /* @__PURE__ */ jsx14(RenderedBlock, { name, attributes });
|
|
1158
|
+
}
|
|
1159
|
+
function RenderedBlock({
|
|
1160
|
+
name,
|
|
1161
|
+
attributes,
|
|
1162
|
+
hosted = false
|
|
1163
|
+
}) {
|
|
1164
|
+
const state = useBlockPresentation(name, attributes);
|
|
1165
|
+
const [refreshed, setRefreshed] = useState2(
|
|
1166
|
+
void 0
|
|
1167
|
+
);
|
|
1168
|
+
if ("loading" === state.status && void 0 === refreshed) {
|
|
1169
|
+
return /* @__PURE__ */ jsx14(
|
|
1170
|
+
"div",
|
|
1171
|
+
{
|
|
1172
|
+
className: "ec-commerce-block",
|
|
1173
|
+
"data-commerce-block": storefrontBlockSlug(name),
|
|
1174
|
+
"aria-busy": "true"
|
|
1175
|
+
}
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1178
|
+
const presentation = void 0 !== refreshed ? refreshed : "ready" === state.status ? state.presentation : null;
|
|
1179
|
+
if (!hosted) {
|
|
1180
|
+
return "error" === state.status ? null : /* @__PURE__ */ jsx14(StorefrontBlock, { presentation });
|
|
1181
|
+
}
|
|
1182
|
+
return /* @__PURE__ */ jsx14(StorefrontBlockHost, { name, attributes, inertia: true, onPresentation: setRefreshed, children: /* @__PURE__ */ jsx14(StorefrontBlock, { presentation }) });
|
|
1183
|
+
}
|
|
1184
|
+
function registerStorefrontBlockRenderers(register, names = storefrontBlockNames()) {
|
|
1185
|
+
for (const name of names) {
|
|
1186
|
+
register(name, StorefrontBlockRenderer);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
// src/blocks/islands.tsx
|
|
1191
|
+
import { createRoot } from "react-dom/client";
|
|
1192
|
+
import { useState as useState3 } from "react";
|
|
1193
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1194
|
+
var BLOCK_ISLAND_SELECTOR = "[data-ec-block]";
|
|
1195
|
+
var BLOCK_ISLAND_HYDRATED = "data-ec-block-hydrated";
|
|
1196
|
+
var BLOCK_ISLAND_NAME = /^artisanpack-commerce\/[a-z0-9-]{1,64}$/;
|
|
1197
|
+
function readBlockIsland(element) {
|
|
1198
|
+
const name = element.dataset.ecBlock ?? "";
|
|
1199
|
+
if (!BLOCK_ISLAND_NAME.test(name) || void 0 === getStorefrontBlock(name)) {
|
|
1200
|
+
return null;
|
|
1201
|
+
}
|
|
1202
|
+
let attributes = {};
|
|
1203
|
+
try {
|
|
1204
|
+
const parsed = JSON.parse(element.dataset.ecBlockAttributes ?? "{}");
|
|
1205
|
+
if (null !== parsed && "object" === typeof parsed && !Array.isArray(parsed)) {
|
|
1206
|
+
attributes = parsed;
|
|
1207
|
+
}
|
|
1208
|
+
} catch {
|
|
1209
|
+
attributes = {};
|
|
1210
|
+
}
|
|
1211
|
+
return {
|
|
1212
|
+
name,
|
|
1213
|
+
attributes,
|
|
1214
|
+
interactive: void 0 !== element.dataset.ecBlockInteractive
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
function IslandBlock({
|
|
1218
|
+
presentation: initial,
|
|
1219
|
+
hosted,
|
|
1220
|
+
inertia
|
|
1221
|
+
}) {
|
|
1222
|
+
const [presentation, setPresentation] = useState3(initial);
|
|
1223
|
+
if (!hosted) {
|
|
1224
|
+
return /* @__PURE__ */ jsx15(StorefrontBlockBody, { presentation });
|
|
1225
|
+
}
|
|
1226
|
+
return /* @__PURE__ */ jsx15(
|
|
1227
|
+
StorefrontBlockHost,
|
|
1228
|
+
{
|
|
1229
|
+
name: initial.name,
|
|
1230
|
+
attributes: initial.attributes,
|
|
1231
|
+
inertia,
|
|
1232
|
+
onPresentation: setPresentation,
|
|
1233
|
+
children: /* @__PURE__ */ jsx15(StorefrontBlockBody, { presentation })
|
|
1234
|
+
}
|
|
1235
|
+
);
|
|
1236
|
+
}
|
|
1237
|
+
function islandPropsUrl(island, page) {
|
|
1238
|
+
const shared = page?.props.ecommerceStorefront;
|
|
1239
|
+
const product = page?.props.product;
|
|
1240
|
+
return blockPropsUrl(
|
|
1241
|
+
blockPropsEndpoint(shared?.routes?.storefront?.base),
|
|
1242
|
+
island.name,
|
|
1243
|
+
island.attributes,
|
|
1244
|
+
"number" === typeof product?.id ? product.id : null
|
|
1245
|
+
);
|
|
1246
|
+
}
|
|
1247
|
+
function hydrateStorefrontBlocks(root = document, options = {}) {
|
|
1248
|
+
const page = options.page ?? null;
|
|
1249
|
+
const roots = [];
|
|
1250
|
+
const pending = [];
|
|
1251
|
+
let disposed = false;
|
|
1252
|
+
const mount = (element, presentation) => {
|
|
1253
|
+
element.replaceChildren();
|
|
1254
|
+
const island = createRoot(element);
|
|
1255
|
+
island.render(
|
|
1256
|
+
/* @__PURE__ */ jsx15(StorefrontBlockRoot, { page, children: /* @__PURE__ */ jsx15(
|
|
1257
|
+
IslandBlock,
|
|
1258
|
+
{
|
|
1259
|
+
presentation,
|
|
1260
|
+
hosted: void 0 === page?.props.ecommerceStorefront,
|
|
1261
|
+
inertia: null !== page
|
|
1262
|
+
}
|
|
1263
|
+
) })
|
|
1264
|
+
);
|
|
1265
|
+
roots.push({ element, root: island });
|
|
1266
|
+
};
|
|
1267
|
+
for (const element of Array.from(root.querySelectorAll(BLOCK_ISLAND_SELECTOR))) {
|
|
1268
|
+
if (element.hasAttribute(BLOCK_ISLAND_HYDRATED)) {
|
|
1269
|
+
continue;
|
|
1270
|
+
}
|
|
1271
|
+
const island = readBlockIsland(element);
|
|
1272
|
+
if (null === island || options.interactiveOnly && !island.interactive) {
|
|
1273
|
+
continue;
|
|
1274
|
+
}
|
|
1275
|
+
const url = islandPropsUrl(island, page);
|
|
1276
|
+
if (null === url) {
|
|
1277
|
+
continue;
|
|
1278
|
+
}
|
|
1279
|
+
const controller = new AbortController();
|
|
1280
|
+
element.setAttribute(BLOCK_ISLAND_HYDRATED, "");
|
|
1281
|
+
pending.push({ element, controller });
|
|
1282
|
+
fetchBlockPresentation(url, controller.signal).then(
|
|
1283
|
+
(presentation) => {
|
|
1284
|
+
if (disposed) {
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
if (null === presentation || presentation.name !== island.name) {
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
mount(element, presentation);
|
|
1291
|
+
},
|
|
1292
|
+
() => void 0
|
|
1293
|
+
);
|
|
1294
|
+
}
|
|
1295
|
+
return () => {
|
|
1296
|
+
disposed = true;
|
|
1297
|
+
for (const { controller } of pending) {
|
|
1298
|
+
controller.abort();
|
|
1299
|
+
}
|
|
1300
|
+
for (const { element } of pending) {
|
|
1301
|
+
element.removeAttribute(BLOCK_ISLAND_HYDRATED);
|
|
1302
|
+
}
|
|
1303
|
+
for (const { root: island } of roots) {
|
|
1304
|
+
island.unmount();
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
export {
|
|
1309
|
+
AccountAction,
|
|
1310
|
+
AccountAddresses,
|
|
1311
|
+
AccountClaim,
|
|
1312
|
+
AccountDashboard,
|
|
1313
|
+
AccountDownloads,
|
|
1314
|
+
AccountOrders,
|
|
1315
|
+
AccountProfile,
|
|
1316
|
+
AccountShell,
|
|
1317
|
+
AddToCart,
|
|
1318
|
+
AddToCartBlock,
|
|
1319
|
+
Address,
|
|
1320
|
+
AddressForm,
|
|
1321
|
+
AddressStep,
|
|
1322
|
+
BLOCK_ATTRIBUTES_MAX_BYTES,
|
|
1323
|
+
BLOCK_CLIENT_ID_ATTRIBUTE,
|
|
1324
|
+
BLOCK_ISLAND_HYDRATED,
|
|
1325
|
+
BLOCK_ISLAND_NAME,
|
|
1326
|
+
BLOCK_ISLAND_SELECTOR,
|
|
1327
|
+
BlockPage,
|
|
1328
|
+
BlockSampleNotice,
|
|
1329
|
+
BundledForm,
|
|
1330
|
+
CART_DRAWER_CONTENT_ID,
|
|
1331
|
+
CART_DRAWER_ONLY,
|
|
1332
|
+
CHECKOUT_PAGE,
|
|
1333
|
+
CORE_PAYMENT_DRIVERS,
|
|
1334
|
+
CORE_PRODUCT_FORMS,
|
|
1335
|
+
Cart,
|
|
1336
|
+
CartContentsBlock,
|
|
1337
|
+
CartDrawer,
|
|
1338
|
+
CartDrawerProvider,
|
|
1339
|
+
CartHeaderButton,
|
|
1340
|
+
CartPreview,
|
|
1341
|
+
CatalogFilters,
|
|
1342
|
+
CatalogListing,
|
|
1343
|
+
CategoryGrid,
|
|
1344
|
+
CategoryGridBlock,
|
|
1345
|
+
Checkout,
|
|
1346
|
+
CheckoutErrorSummary,
|
|
1347
|
+
CheckoutOrderSummary,
|
|
1348
|
+
CheckoutPreview,
|
|
1349
|
+
CheckoutStepSummary,
|
|
1350
|
+
CheckoutStepsBlock,
|
|
1351
|
+
ChoiceCards,
|
|
1352
|
+
ContactStep,
|
|
1353
|
+
CurrencyAction,
|
|
1354
|
+
CurrencySwitcher,
|
|
1355
|
+
DigitalForm,
|
|
1356
|
+
EmptyState,
|
|
1357
|
+
Field,
|
|
1358
|
+
GALLERY_SHOW_EVENT,
|
|
1359
|
+
Gallery,
|
|
1360
|
+
GroupedForm,
|
|
1361
|
+
HeaderSearch,
|
|
1362
|
+
LineControls,
|
|
1363
|
+
MERGE_PRIMARY_ID,
|
|
1364
|
+
MergePrompt,
|
|
1365
|
+
Money,
|
|
1366
|
+
OptionsForm,
|
|
1367
|
+
OrderConfirmation,
|
|
1368
|
+
OrderDetails,
|
|
1369
|
+
OrderLookup,
|
|
1370
|
+
OrderLookupLink,
|
|
1371
|
+
OrderShow,
|
|
1372
|
+
OrderStatusBadge,
|
|
1373
|
+
OrderTotals,
|
|
1374
|
+
PAGES,
|
|
1375
|
+
PURCHASE_ERROR_BAG,
|
|
1376
|
+
PURCHASE_RELOAD,
|
|
1377
|
+
PURCHASE_SUCCESS_RELOAD,
|
|
1378
|
+
PaymentDriverHost,
|
|
1379
|
+
PaymentStep,
|
|
1380
|
+
Placement,
|
|
1381
|
+
Price,
|
|
1382
|
+
PriceRange,
|
|
1383
|
+
ProductCard,
|
|
1384
|
+
ProductCatalogBlock,
|
|
1385
|
+
ProductGalleryBlock,
|
|
1386
|
+
ProductGrid,
|
|
1387
|
+
ProductGridBlock,
|
|
1388
|
+
ProductPriceBlock,
|
|
1389
|
+
ProductReviewsBlock,
|
|
1390
|
+
PurchaseFormContext,
|
|
1391
|
+
QUANTITY_COMMIT_DELAY,
|
|
1392
|
+
Quantity,
|
|
1393
|
+
REVIEW_ERROR_BAG,
|
|
1394
|
+
REVIEW_RATING_QUERY,
|
|
1395
|
+
RatingInput,
|
|
1396
|
+
RatingSummary,
|
|
1397
|
+
RecentlyViewed,
|
|
1398
|
+
RecentlyViewedBlock,
|
|
1399
|
+
RecentlyViewedPlaceholder,
|
|
1400
|
+
RedirectPayment,
|
|
1401
|
+
RelatedProducts,
|
|
1402
|
+
RelatedProductsBlock,
|
|
1403
|
+
RelatedProductsPlaceholder,
|
|
1404
|
+
RelatedProductsRow,
|
|
1405
|
+
ReviewStep,
|
|
1406
|
+
Reviews,
|
|
1407
|
+
STOREFRONT_BLOCKS,
|
|
1408
|
+
STOREFRONT_BLOCK_PREFIX,
|
|
1409
|
+
STOREFRONT_ICONS,
|
|
1410
|
+
SearchBox,
|
|
1411
|
+
ShippingEstimate,
|
|
1412
|
+
ShippingStep,
|
|
1413
|
+
SimpleForm,
|
|
1414
|
+
SingleProductBlock,
|
|
1415
|
+
Skeleton,
|
|
1416
|
+
SoldOutNotice,
|
|
1417
|
+
StockStatus,
|
|
1418
|
+
StorefrontBlock,
|
|
1419
|
+
StorefrontBlockBody,
|
|
1420
|
+
StorefrontBlockRenderer,
|
|
1421
|
+
StorefrontBlockRoot,
|
|
1422
|
+
StorefrontBreadcrumbs,
|
|
1423
|
+
StorefrontLayout,
|
|
1424
|
+
StorefrontSections,
|
|
1425
|
+
StorefrontTemplateContent,
|
|
1426
|
+
StripePayment,
|
|
1427
|
+
Swatches,
|
|
1428
|
+
Toaster,
|
|
1429
|
+
VARIANT_RELOAD,
|
|
1430
|
+
VariableForm,
|
|
1431
|
+
addBuiltInRegistration,
|
|
1432
|
+
addressLines,
|
|
1433
|
+
blockPropsEndpoint,
|
|
1434
|
+
blockPropsUrl,
|
|
1435
|
+
buildQuery,
|
|
1436
|
+
cartActionUrl,
|
|
1437
|
+
checkoutLayout,
|
|
1438
|
+
choiceValue,
|
|
1439
|
+
configureStorefrontBlocks,
|
|
1440
|
+
createEcommerceStorefrontResolver,
|
|
1441
|
+
createStripePaymentElementDriver,
|
|
1442
|
+
fallbackSharedProps,
|
|
1443
|
+
fetchBlockPresentation,
|
|
1444
|
+
filterPageProps,
|
|
1445
|
+
getRegistries,
|
|
1446
|
+
getStorefrontBlock,
|
|
1447
|
+
getStorefrontTemplateRenderer,
|
|
1448
|
+
getStorefrontToaster,
|
|
1449
|
+
groupedSummary,
|
|
1450
|
+
hydrateStorefrontBlocks,
|
|
1451
|
+
linePrice,
|
|
1452
|
+
listingUrl,
|
|
1453
|
+
optionValue,
|
|
1454
|
+
optionValues,
|
|
1455
|
+
postJson,
|
|
1456
|
+
priceRangeFor,
|
|
1457
|
+
publicBlockAttributes,
|
|
1458
|
+
readBlockIsland,
|
|
1459
|
+
registerBuiltIns,
|
|
1460
|
+
registerCartBuiltIns,
|
|
1461
|
+
registerHeaderActionBuiltIns,
|
|
1462
|
+
registerHeaderActions,
|
|
1463
|
+
registerPaymentDrivers,
|
|
1464
|
+
registerProductBuiltIns,
|
|
1465
|
+
registerProductForms,
|
|
1466
|
+
registerProductSections,
|
|
1467
|
+
registerStorefrontBlock,
|
|
1468
|
+
registerStorefrontBlockRenderers,
|
|
1469
|
+
registerStorefrontIcons,
|
|
1470
|
+
relatedHeading,
|
|
1471
|
+
requestJson,
|
|
1472
|
+
requestStepFocus,
|
|
1473
|
+
resetRegistries,
|
|
1474
|
+
resetStorefrontBlockSettings,
|
|
1475
|
+
resetStorefrontBlocks,
|
|
1476
|
+
resetStorefrontToaster,
|
|
1477
|
+
resolveEcommerceStorefrontPage,
|
|
1478
|
+
runToastAction,
|
|
1479
|
+
setStorefrontTemplateRenderer,
|
|
1480
|
+
shipToLine,
|
|
1481
|
+
showResponseToasts,
|
|
1482
|
+
showStorefrontToast,
|
|
1483
|
+
stepUrl,
|
|
1484
|
+
storefrontBlockNames,
|
|
1485
|
+
storefrontBlockSettings,
|
|
1486
|
+
storefrontBlockSlug,
|
|
1487
|
+
storefrontLayout,
|
|
1488
|
+
storefrontTemplateTree,
|
|
1489
|
+
stripeAppearance,
|
|
1490
|
+
suggestionsUrl,
|
|
1491
|
+
toggleValue,
|
|
1492
|
+
useBlockPresentation,
|
|
1493
|
+
useCartDrawer,
|
|
1494
|
+
useCheckout,
|
|
1495
|
+
useErrorBag,
|
|
1496
|
+
useFocusAfterChange,
|
|
1497
|
+
usePageErrors,
|
|
1498
|
+
usePaymentDriver,
|
|
1499
|
+
usePurchaseFormContext,
|
|
1500
|
+
useQuickAdd,
|
|
1501
|
+
useRegisterCartDrawer,
|
|
1502
|
+
useStorefront,
|
|
1503
|
+
useStorefrontCart,
|
|
1504
|
+
useStorefrontPage,
|
|
1505
|
+
useStorefrontPost,
|
|
1506
|
+
useStorefrontTemplate,
|
|
1507
|
+
visitWithQuery,
|
|
1508
|
+
withChoice,
|
|
1509
|
+
withOption,
|
|
1510
|
+
withOptionValue,
|
|
1511
|
+
withPrice,
|
|
1512
|
+
withStorefrontPage,
|
|
1513
|
+
withToggle
|
|
1514
|
+
};
|
|
1515
|
+
//# sourceMappingURL=index.mjs.map
|