@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.d.ts
ADDED
|
@@ -0,0 +1,4607 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentType, ReactNode, ReactElement, RefObject, HTMLAttributes, FocusEvent } from 'react';
|
|
3
|
+
import { PageLoader, EcommerceStorefrontRegistries, EcommerceStorefrontSharedProps, StorefrontCartDrawer, StorefrontTemplate, StorefrontToast, StorefrontHeaderAction, StorefrontHeaderSearchResults, StorefrontAddressForm, StorefrontAddressValues, StorefrontAddressFieldName, StorefrontCategoryGrid, StorefrontChoiceCardOption, StorefrontCurrencySwitcher, StorefrontEmptyStateProps, StorefrontFieldProps, StorefrontGalleryItem, StorefrontMoney, StorefrontPrice, StorefrontPriceRange, StorefrontProductCard, StorefrontQuantityProps, StorefrontRatingInputProps, StorefrontRatingSummary, StorefrontSearchBoxProps, StorefrontStockStatus, StorefrontSwatchOption, StorefrontFilterGroup, StorefrontListingState, StorefrontPriceFilterGroup, StorefrontCatalogListing, StorefrontSearchEmptyState, StorefrontProductGrid, StorefrontBreadcrumb, StorefrontPurchaseFormBase, StorefrontProductSection, StorefrontBundledFormProps, StorefrontDigitalFormProps, StorefrontGroupedFormProps, StorefrontGroupedRow, StorefrontOptionsFormProps, StorefrontSimpleFormProps, StorefrontVariableFormProps, StorefrontProductReviews, StorefrontRelatedProducts, StorefrontRecentlyViewed, CartIndexProps, StorefrontCartTotals, StorefrontOrderTotals, StorefrontCartEstimate, StorefrontSelectOption, StorefrontCartFeedback, PaymentDriverContext, PaymentDriverResult, PaymentDriver, CheckoutIndexProps, StorefrontCheckoutUrls, StorefrontCheckoutStep, StorefrontCartSummary, StorefrontCheckoutPlacement, StorefrontPaymentSetup, RedirectPaymentDriverProps, StripePaymentElementDriverProps, OrderConfirmationProps, StorefrontOrderDetails, StorefrontOrderStatus, OrderLookupProps, AccountOrderShowProps, StorefrontAccountShell, AccountDashboardProps, AccountOrdersProps, AccountAddressesProps, AccountDownloadsProps, AccountProfileProps, AccountClaimProps, StorefrontBlockName, StorefrontBlockPresentation, StorefrontProductCatalogBlockProps, StorefrontAddToCartBlockProps, StorefrontGallery, StorefrontProductPriceBlockProps, StorefrontProductReviewsBlockProps, ProductShowProps, StorefrontCartContentsBlockProps, StorefrontCartPreviewLine, StorefrontCheckoutStepsBlockProps, StorefrontTemplateBlock } from '@artisanpack-ui/ecommerce-storefront-core';
|
|
4
|
+
import { createToaster } from '@artisanpack-ui/react';
|
|
5
|
+
import { StripeElementLocale, Stripe, Appearance } from '@stripe/stripe-js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a storefront page for Inertia.
|
|
9
|
+
*
|
|
10
|
+
* The wrapper makes sure the client registries exist (firing
|
|
11
|
+
* `ap.ecommerceStorefront.register` once) and passes the page's props
|
|
12
|
+
* through the `ap.ecommerceStorefront.pageProps` filter before the page
|
|
13
|
+
* renders. A page rendered through a visual-editor template draws the
|
|
14
|
+
* template's block tree in place of its own content, once a template
|
|
15
|
+
* renderer is set (`setStorefrontTemplateRenderer()`).
|
|
16
|
+
*
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A page component, with Inertia's optional persistent `layout`: a
|
|
22
|
+
* function that wraps the page element (`storefrontLayout`,
|
|
23
|
+
* `checkoutLayout`). Typed so a resolver returning these pages is accepted
|
|
24
|
+
* by `createInertiaApp({ resolve })` in Inertia 2 and 3.
|
|
25
|
+
*
|
|
26
|
+
* @since 1.0.0
|
|
27
|
+
*/
|
|
28
|
+
type StorefrontPageComponent<TProps = any> = ComponentType<TProps> & {
|
|
29
|
+
layout?: (page: ReactNode) => ReactNode;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Applies the `pageProps` filter to a page's props.
|
|
33
|
+
*
|
|
34
|
+
* A filter that returns something other than an object is ignored, so a
|
|
35
|
+
* broken callback can't blank the page.
|
|
36
|
+
*
|
|
37
|
+
* @since 1.0.0
|
|
38
|
+
*
|
|
39
|
+
* @param props - The page's props.
|
|
40
|
+
* @param pageName - The page name, such as `EcommerceStorefront/Product/Show`.
|
|
41
|
+
* @returns The filtered props.
|
|
42
|
+
*/
|
|
43
|
+
declare function filterPageProps<TProps extends object>(props: TProps, pageName: string): TProps;
|
|
44
|
+
/**
|
|
45
|
+
* Wraps a page so it registers the client components and filters its props.
|
|
46
|
+
*
|
|
47
|
+
* The wrapper keeps the page's `layout`, so a persistent layout still works.
|
|
48
|
+
*
|
|
49
|
+
* @since 1.0.0
|
|
50
|
+
*
|
|
51
|
+
* @param pageName - The page name the wrapper serves.
|
|
52
|
+
* @param Page - The page component.
|
|
53
|
+
* @returns The wrapped page.
|
|
54
|
+
*/
|
|
55
|
+
declare function withStorefrontPage<TProps extends object>(pageName: string, Page: StorefrontPageComponent<TProps>): StorefrontPageComponent<TProps>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The storefront's Inertia page resolver.
|
|
59
|
+
*
|
|
60
|
+
* @since 1.0.0
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Options for {@link createEcommerceStorefrontResolver}.
|
|
65
|
+
*
|
|
66
|
+
* @since 1.0.0
|
|
67
|
+
*/
|
|
68
|
+
interface EcommerceStorefrontResolverOptions {
|
|
69
|
+
/**
|
|
70
|
+
* Draws a storefront page name this package has no page for, instead of
|
|
71
|
+
* rejecting. Useful while a host replaces or adds storefront pages.
|
|
72
|
+
*/
|
|
73
|
+
fallback?: (name: string) => StorefrontPageComponent | Promise<StorefrontPageComponent>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Builds a page resolver.
|
|
77
|
+
*
|
|
78
|
+
* @since 1.0.0
|
|
79
|
+
*
|
|
80
|
+
* @param options - The resolver options.
|
|
81
|
+
* @returns `(name) => Promise<page>`, rejecting with `EcommerceStorefrontPageNotFoundError` for an unknown name when there is no fallback.
|
|
82
|
+
*/
|
|
83
|
+
declare function createEcommerceStorefrontResolver(options?: EcommerceStorefrontResolverOptions): (name: string) => Promise<StorefrontPageComponent>;
|
|
84
|
+
/**
|
|
85
|
+
* Resolves an `EcommerceStorefront/…` page name to its page component.
|
|
86
|
+
*
|
|
87
|
+
* Hand it to `createInertiaApp({ resolve })`. Unknown names reject with
|
|
88
|
+
* `EcommerceStorefrontPageNotFoundError`.
|
|
89
|
+
*
|
|
90
|
+
* @since 1.0.0
|
|
91
|
+
*/
|
|
92
|
+
declare const resolveEcommerceStorefrontPage: (name: string) => Promise<StorefrontPageComponent>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The storefront's pages, by page path.
|
|
96
|
+
*
|
|
97
|
+
* Each key is a page name without the `EcommerceStorefront/` prefix, and
|
|
98
|
+
* each page module default-exports its component. Pages load on demand,
|
|
99
|
+
* so a host only downloads the screens a shopper visits.
|
|
100
|
+
*
|
|
101
|
+
* @since 1.0.0
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Every page this package draws.
|
|
106
|
+
*
|
|
107
|
+
* @since 1.0.0
|
|
108
|
+
*/
|
|
109
|
+
declare const PAGES: Record<string, PageLoader<StorefrontPageComponent>>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The storefront's client registries.
|
|
113
|
+
*
|
|
114
|
+
* One set per page load: the first storefront page to render creates them
|
|
115
|
+
* and fires `ap.ecommerceStorefront.register` with them, so satellites and
|
|
116
|
+
* hosts register their components before anything draws.
|
|
117
|
+
*
|
|
118
|
+
* @since 1.0.0
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Any React component a registry holds. Each registry documents the props
|
|
123
|
+
* its components receive.
|
|
124
|
+
*
|
|
125
|
+
* @since 1.0.0
|
|
126
|
+
*/
|
|
127
|
+
type RegisteredComponent = ComponentType<any>;
|
|
128
|
+
/**
|
|
129
|
+
* The registries with React components.
|
|
130
|
+
*
|
|
131
|
+
* @since 1.0.0
|
|
132
|
+
*/
|
|
133
|
+
type ReactStorefrontRegistries = EcommerceStorefrontRegistries<RegisteredComponent>;
|
|
134
|
+
/**
|
|
135
|
+
* Adds a built-in registration. The storefront's own modules call this
|
|
136
|
+
* when they load. Added after the registries exist, it fills only the keys
|
|
137
|
+
* nothing has taken, so it never replaces a satellite's component.
|
|
138
|
+
*
|
|
139
|
+
* @since 1.0.0
|
|
140
|
+
*
|
|
141
|
+
* @param register - Registers the built-in components.
|
|
142
|
+
*/
|
|
143
|
+
declare function addBuiltInRegistration(register: (registries: ReactStorefrontRegistries) => void): void;
|
|
144
|
+
/**
|
|
145
|
+
* The registries, created and handed to `ap.ecommerceStorefront.register`
|
|
146
|
+
* on the first call.
|
|
147
|
+
*
|
|
148
|
+
* @since 1.0.0
|
|
149
|
+
*
|
|
150
|
+
* @returns The registries.
|
|
151
|
+
*/
|
|
152
|
+
declare function getRegistries(): ReactStorefrontRegistries;
|
|
153
|
+
/**
|
|
154
|
+
* Forgets the registries, so the next {@link getRegistries} call builds and
|
|
155
|
+
* registers them again. For tests.
|
|
156
|
+
*
|
|
157
|
+
* @since 1.0.0
|
|
158
|
+
*/
|
|
159
|
+
declare function resetRegistries(): void;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* An Inertia page a storefront component reads in place of the real one.
|
|
163
|
+
*
|
|
164
|
+
* Commerce blocks draw the same components as the storefront's pages, and
|
|
165
|
+
* those read the page through {@link useStorefrontPage}. A block hydrated as
|
|
166
|
+
* an island runs in a React root of its own, outside Inertia's `<App>`, and
|
|
167
|
+
* a block whose props aren't the page's (a Single Product block on a landing
|
|
168
|
+
* page) needs its components to see its own props. Both provide this context;
|
|
169
|
+
* without it the hook reads Inertia's page.
|
|
170
|
+
*
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
/**
|
|
174
|
+
* The parts of an Inertia page the storefront components read.
|
|
175
|
+
*
|
|
176
|
+
* @since 1.0.0
|
|
177
|
+
*/
|
|
178
|
+
interface StorefrontPageSnapshot {
|
|
179
|
+
/** The page component's name. */
|
|
180
|
+
component: string;
|
|
181
|
+
/** The page's props. */
|
|
182
|
+
props: Record<string, unknown>;
|
|
183
|
+
/** The page's URL. */
|
|
184
|
+
url: string;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Reads the storefront's shared props from the current Inertia page.
|
|
189
|
+
*
|
|
190
|
+
* @since 1.0.0
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The current page: a commerce block's own page when one is in effect (an
|
|
195
|
+
* island, or a block whose props aren't the page's), else Inertia's.
|
|
196
|
+
*
|
|
197
|
+
* Storefront components read the page through this hook rather than
|
|
198
|
+
* `usePage()`, so they also work inside a block.
|
|
199
|
+
*
|
|
200
|
+
* @since 1.0.0
|
|
201
|
+
*
|
|
202
|
+
* @returns The page's component name, props and URL.
|
|
203
|
+
*/
|
|
204
|
+
declare function useStorefrontPage(): StorefrontPageSnapshot;
|
|
205
|
+
/**
|
|
206
|
+
* The `ecommerceStorefront` shared prop every storefront page receives.
|
|
207
|
+
*
|
|
208
|
+
* @since 1.0.0
|
|
209
|
+
*
|
|
210
|
+
* @returns The shared props.
|
|
211
|
+
*/
|
|
212
|
+
declare function useStorefront(): EcommerceStorefrontSharedProps;
|
|
213
|
+
/**
|
|
214
|
+
* The page's validation errors (Inertia's `errors` prop), keyed by field.
|
|
215
|
+
*
|
|
216
|
+
* @since 1.0.0
|
|
217
|
+
*
|
|
218
|
+
* @returns The errors.
|
|
219
|
+
*/
|
|
220
|
+
declare function usePageErrors(): Record<string, string>;
|
|
221
|
+
/**
|
|
222
|
+
* The optional `ecommerceStorefrontCart` shared prop (the cart drawer's
|
|
223
|
+
* contents), or null until the drawer asks for it.
|
|
224
|
+
*
|
|
225
|
+
* @since 1.0.0
|
|
226
|
+
*
|
|
227
|
+
* @returns The drawer's cart, or null.
|
|
228
|
+
*/
|
|
229
|
+
declare function useStorefrontCart(): StorefrontCartDrawer | null;
|
|
230
|
+
/**
|
|
231
|
+
* The `ecommerceStorefrontTemplate` shared prop, or null.
|
|
232
|
+
*
|
|
233
|
+
* @since 1.0.0
|
|
234
|
+
*
|
|
235
|
+
* @returns The visual-editor template the page renders through, or null.
|
|
236
|
+
*/
|
|
237
|
+
declare function useStorefrontTemplate(): StorefrontTemplate | null;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* The storefront's toaster and the helper that shows a server toast on it.
|
|
241
|
+
*
|
|
242
|
+
* Toasts arrive in `ecommerceStorefront.toasts` (the layout shows each
|
|
243
|
+
* once) or in a throttled JSON answer's `toasts` key (the page that called
|
|
244
|
+
* the route shows them). Either way they go through {@link showStorefrontToast},
|
|
245
|
+
* which applies the `ap.ecommerceStorefront.toast` filter first.
|
|
246
|
+
*
|
|
247
|
+
* @since 1.0.0
|
|
248
|
+
*/
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* The design-system toaster the storefront shows its toasts on.
|
|
252
|
+
*
|
|
253
|
+
* @since 1.0.0
|
|
254
|
+
*/
|
|
255
|
+
type StorefrontToaster = ReturnType<typeof createToaster>;
|
|
256
|
+
/**
|
|
257
|
+
* The storefront's toaster, created on first use.
|
|
258
|
+
*
|
|
259
|
+
* @since 1.0.0
|
|
260
|
+
*
|
|
261
|
+
* @returns The toaster.
|
|
262
|
+
*/
|
|
263
|
+
declare function getStorefrontToaster(): StorefrontToaster;
|
|
264
|
+
/**
|
|
265
|
+
* Runs a toast's action: a `post` action sends an Inertia POST visit to a
|
|
266
|
+
* root-relative URL on this site; any other opens an http(s) or
|
|
267
|
+
* root-relative URL.
|
|
268
|
+
*
|
|
269
|
+
* A URL with a backslash or a control character is refused: browsers read
|
|
270
|
+
* `/\evil.test` as `//evil.test`, another site.
|
|
271
|
+
*
|
|
272
|
+
* @since 1.0.0
|
|
273
|
+
*
|
|
274
|
+
* @param action - The toast's action.
|
|
275
|
+
*/
|
|
276
|
+
declare function runToastAction(action: NonNullable<StorefrontToast['action']>): void;
|
|
277
|
+
/**
|
|
278
|
+
* Shows a storefront toast, after the `ap.ecommerceStorefront.toast` filter.
|
|
279
|
+
*
|
|
280
|
+
* A toast with an action stays until the shopper dismisses it; a toast with
|
|
281
|
+
* the id of one still showing replaces it.
|
|
282
|
+
*
|
|
283
|
+
* @since 1.0.0
|
|
284
|
+
*
|
|
285
|
+
* @param toast - The toast.
|
|
286
|
+
* @returns The toast's id, or null when the filter dropped it.
|
|
287
|
+
*/
|
|
288
|
+
declare function showStorefrontToast(toast: StorefrontToast): string | null;
|
|
289
|
+
/**
|
|
290
|
+
* Shows the toasts a JSON answer carried (a throttled `429`'s `toasts` key).
|
|
291
|
+
*
|
|
292
|
+
* @since 1.0.0
|
|
293
|
+
*
|
|
294
|
+
* @param body - The parsed JSON body.
|
|
295
|
+
*/
|
|
296
|
+
declare function showResponseToasts(body: unknown): void;
|
|
297
|
+
/**
|
|
298
|
+
* Forgets the toaster. For tests.
|
|
299
|
+
*
|
|
300
|
+
* @since 1.0.0
|
|
301
|
+
*/
|
|
302
|
+
declare function resetStorefrontToaster(): void;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The Lucide icons the storefront uses that the design system's icon
|
|
306
|
+
* registry doesn't ship, as ecommerce-storefront-livewire registers them
|
|
307
|
+
* (`EcommerceStorefrontLivewireServiceProvider::ICONS`).
|
|
308
|
+
*
|
|
309
|
+
* @since 1.0.0
|
|
310
|
+
*/
|
|
311
|
+
/**
|
|
312
|
+
* Icon name to inner SVG markup.
|
|
313
|
+
*
|
|
314
|
+
* @since 1.0.0
|
|
315
|
+
*/
|
|
316
|
+
declare const STOREFRONT_ICONS: Readonly<Record<string, string>>;
|
|
317
|
+
/**
|
|
318
|
+
* Registers the storefront's icons. A name the host already registered
|
|
319
|
+
* keeps the host's icon. Safe to call more than once.
|
|
320
|
+
*
|
|
321
|
+
* @since 1.0.0
|
|
322
|
+
*/
|
|
323
|
+
declare function registerStorefrontIcons(): void;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* The storefront layout: every storefront page renders inside it.
|
|
327
|
+
*
|
|
328
|
+
* Mirrors ecommerce-storefront-livewire's `layouts/app` and
|
|
329
|
+
* `partials/global`: "Skip to content", the sticky header (the store's mark
|
|
330
|
+
* and name, the store navigation, the header search and the header
|
|
331
|
+
* actions; below 768px a menu button opens the navigation in a drawer),
|
|
332
|
+
* the page, the footer (link columns, copyright, currency switcher and
|
|
333
|
+
* theme toggle), then the toaster, the cart drawer and the cart merge
|
|
334
|
+
* prompt. The page's title and search-engine tags go to `<Head>`.
|
|
335
|
+
*
|
|
336
|
+
* Pages use it as Inertia's persistent layout (`Page.layout =
|
|
337
|
+
* storefrontLayout`), so the drawer and toaster outlive visits. The
|
|
338
|
+
* checkout uses `checkoutLayout`: the slim secure header and no footer.
|
|
339
|
+
*
|
|
340
|
+
* Header actions come from the `headerActions` client registry, keyed by
|
|
341
|
+
* the `component` of each `ecommerceStorefront.headerActions` entry; an
|
|
342
|
+
* entry with no registered component draws nothing.
|
|
343
|
+
*
|
|
344
|
+
* @since 1.0.0
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* The chrome around the page.
|
|
349
|
+
*
|
|
350
|
+
* @since 1.0.0
|
|
351
|
+
*/
|
|
352
|
+
type StorefrontChrome = 'default' | 'checkout';
|
|
353
|
+
/**
|
|
354
|
+
* Props for {@link StorefrontLayout}.
|
|
355
|
+
*
|
|
356
|
+
* @since 1.0.0
|
|
357
|
+
*/
|
|
358
|
+
interface StorefrontLayoutProps {
|
|
359
|
+
children?: ReactNode;
|
|
360
|
+
/** `checkout` draws the slim secure header and no navigation or footer. */
|
|
361
|
+
chrome?: StorefrontChrome;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* The storefront layout.
|
|
365
|
+
*
|
|
366
|
+
* @since 1.0.0
|
|
367
|
+
*
|
|
368
|
+
* @param props - The page and the chrome.
|
|
369
|
+
* @returns The layout.
|
|
370
|
+
*/
|
|
371
|
+
declare function StorefrontLayout({ children, chrome, }: StorefrontLayoutProps): ReactElement;
|
|
372
|
+
/**
|
|
373
|
+
* The persistent layout pages assign: `Page.layout = storefrontLayout`.
|
|
374
|
+
*
|
|
375
|
+
* An arrow function on purpose: Inertia 3 treats a layout with a
|
|
376
|
+
* `prototype` (any `function` declaration) as a layout component and
|
|
377
|
+
* passes it the page props, while a one-argument arrow function is called
|
|
378
|
+
* with the page element, as Inertia 2 always does.
|
|
379
|
+
*
|
|
380
|
+
* @since 1.0.0
|
|
381
|
+
*
|
|
382
|
+
* @param page - The page element.
|
|
383
|
+
* @returns The page in the storefront layout.
|
|
384
|
+
*/
|
|
385
|
+
declare const storefrontLayout: (page: ReactNode) => ReactElement;
|
|
386
|
+
/**
|
|
387
|
+
* The checkout's persistent layout: the slim secure header, no footer. An
|
|
388
|
+
* arrow function for the reason given on {@link storefrontLayout}.
|
|
389
|
+
*
|
|
390
|
+
* @since 1.0.0
|
|
391
|
+
*
|
|
392
|
+
* @param page - The page element.
|
|
393
|
+
* @returns The page in the checkout layout.
|
|
394
|
+
*/
|
|
395
|
+
declare const checkoutLayout: (page: ReactNode) => ReactElement;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* The header's built-in action slots, registered in the `headerActions`
|
|
399
|
+
* client registry under the keys the server names: `currency`, `account`
|
|
400
|
+
* and `cart`. A satellite registers its own (a wishlist) the same way, and
|
|
401
|
+
* replaces a built-in by registering under its key.
|
|
402
|
+
*
|
|
403
|
+
* Each action component gets `action`, the `{ key, component }` entry from
|
|
404
|
+
* `ecommerceStorefront.headerActions`.
|
|
405
|
+
*
|
|
406
|
+
* @since 1.0.0
|
|
407
|
+
*/
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* The props every header action receives.
|
|
411
|
+
*
|
|
412
|
+
* @since 1.0.0
|
|
413
|
+
*/
|
|
414
|
+
interface HeaderActionProps {
|
|
415
|
+
action: StorefrontHeaderAction;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* The account link for a signed-in shopper, else "Sign in"; nothing when
|
|
419
|
+
* neither route exists.
|
|
420
|
+
*
|
|
421
|
+
* @since 1.0.0
|
|
422
|
+
*
|
|
423
|
+
* @returns The link.
|
|
424
|
+
*/
|
|
425
|
+
declare function AccountAction(): ReactElement | null;
|
|
426
|
+
/**
|
|
427
|
+
* The header's currency switcher.
|
|
428
|
+
*
|
|
429
|
+
* @since 1.0.0
|
|
430
|
+
*
|
|
431
|
+
* @returns The switcher.
|
|
432
|
+
*/
|
|
433
|
+
declare function CurrencyAction(): ReactElement;
|
|
434
|
+
/**
|
|
435
|
+
* Registers the built-in header actions, through
|
|
436
|
+
* {@link registerHeaderActionBuiltIns}.
|
|
437
|
+
*
|
|
438
|
+
* @since 1.0.0
|
|
439
|
+
*
|
|
440
|
+
* @param registries - The registries.
|
|
441
|
+
*/
|
|
442
|
+
declare function registerHeaderActions(registries: ReactStorefrontRegistries): void;
|
|
443
|
+
/**
|
|
444
|
+
* Adds the built-in header actions once.
|
|
445
|
+
*
|
|
446
|
+
* @since 1.0.0
|
|
447
|
+
*/
|
|
448
|
+
declare function registerHeaderActionBuiltIns(): void;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Every built-in client registration, added before the first page renders.
|
|
452
|
+
*
|
|
453
|
+
* `ap.ecommerceStorefront.register` fires once, when the first storefront
|
|
454
|
+
* page renders, and satellites replace, wrap or remove built-ins there. Pages
|
|
455
|
+
* load on demand, so built-ins added by a page's own chunk would arrive after
|
|
456
|
+
* the hook when the shopper starts on another page: a satellite's
|
|
457
|
+
* `unregister('reviews')` would be undone and `get('simple')` would find
|
|
458
|
+
* nothing. So the page wrapper ({@link withStorefrontPage}) adds them all
|
|
459
|
+
* first, at the cost of a bigger main chunk. The modules that draw the
|
|
460
|
+
* registries still register themselves too (once), for stories, tests and
|
|
461
|
+
* blocks that render them outside a page.
|
|
462
|
+
*
|
|
463
|
+
* @since 1.0.0
|
|
464
|
+
*/
|
|
465
|
+
/**
|
|
466
|
+
* Adds every built-in registration (once each).
|
|
467
|
+
*
|
|
468
|
+
* @since 1.0.0
|
|
469
|
+
*/
|
|
470
|
+
declare function registerBuiltIns(): void;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* The cart's built-in section: the related-products row as the cart's
|
|
474
|
+
* cross-sells (`cartSections` `related-products`).
|
|
475
|
+
*
|
|
476
|
+
* The page wrapper adds it before the first page renders (see
|
|
477
|
+
* src/builtIns.ts); {@link Cart} also calls {@link registerCartBuiltIns} at
|
|
478
|
+
* load, for a cart drawn outside a page (the Cart Contents block).
|
|
479
|
+
*
|
|
480
|
+
* @since 1.0.0
|
|
481
|
+
*/
|
|
482
|
+
/**
|
|
483
|
+
* Adds the cart's built-in registrations once.
|
|
484
|
+
*
|
|
485
|
+
* @since 1.0.0
|
|
486
|
+
*/
|
|
487
|
+
declare function registerCartBuiltIns(): void;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* The cart drawer's open state, kept in the layout so it survives Inertia
|
|
491
|
+
* visits and any page's header button can open it.
|
|
492
|
+
*
|
|
493
|
+
* The layout provides it; `CartDrawer` registers itself with
|
|
494
|
+
* {@link useRegisterCartDrawer}, and `CartHeaderButton` opens the drawer
|
|
495
|
+
* when one is registered (else it follows its link to the cart page).
|
|
496
|
+
*
|
|
497
|
+
* @since 1.0.0
|
|
498
|
+
*/
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* The cart drawer's state.
|
|
502
|
+
*
|
|
503
|
+
* @since 1.0.0
|
|
504
|
+
*/
|
|
505
|
+
interface CartDrawerState {
|
|
506
|
+
/** Whether the drawer is open. */
|
|
507
|
+
open: boolean;
|
|
508
|
+
/** Opens or closes the drawer. */
|
|
509
|
+
setOpen: (open: boolean) => void;
|
|
510
|
+
/** Whether a drawer is on the page to open. */
|
|
511
|
+
available: boolean;
|
|
512
|
+
/** Marks a drawer as on the page, or gone. */
|
|
513
|
+
setAvailable: (available: boolean) => void;
|
|
514
|
+
/** The element that opened the drawer, for focus to go back to. */
|
|
515
|
+
opener: RefObject<HTMLElement | null>;
|
|
516
|
+
/** Opens the drawer, remembering the element that opened it. */
|
|
517
|
+
openFrom: (opener: HTMLElement | null) => void;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Provides the cart drawer's state.
|
|
521
|
+
*
|
|
522
|
+
* @since 1.0.0
|
|
523
|
+
*
|
|
524
|
+
* The layout opens the drawer itself for each fresh `cart.open`;
|
|
525
|
+
* `openRequested` is for a drawer drawn on its own (stories, tests, blocks):
|
|
526
|
+
* it starts the drawer open, and opens it again whenever it turns true.
|
|
527
|
+
*
|
|
528
|
+
* @param props - `openRequested` and the children.
|
|
529
|
+
* @returns The provider.
|
|
530
|
+
*/
|
|
531
|
+
declare function CartDrawerProvider({ openRequested, children, }: {
|
|
532
|
+
openRequested?: boolean;
|
|
533
|
+
children: ReactNode;
|
|
534
|
+
}): ReactElement;
|
|
535
|
+
/**
|
|
536
|
+
* The cart drawer's state.
|
|
537
|
+
*
|
|
538
|
+
* @since 1.0.0
|
|
539
|
+
*
|
|
540
|
+
* @returns The state.
|
|
541
|
+
*/
|
|
542
|
+
declare function useCartDrawer(): CartDrawerState;
|
|
543
|
+
/**
|
|
544
|
+
* Marks a cart drawer as on the page while the calling component is mounted.
|
|
545
|
+
*
|
|
546
|
+
* @since 1.0.0
|
|
547
|
+
*/
|
|
548
|
+
declare function useRegisterCartDrawer(): void;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* The slide-out cart drawer, rendered once by the layout.
|
|
552
|
+
*
|
|
553
|
+
* Mirrors ecommerce-storefront-livewire's `Cart/Drawer`: the design
|
|
554
|
+
* system's Drawer, a modal dialog on the end side, titled "Your cart" and
|
|
555
|
+
* described by the item count. The header cart button opens it, and so does
|
|
556
|
+
* the server right after an add (`ecommerceStorefront.cart.open`). Its
|
|
557
|
+
* lines come in the optional `ecommerceStorefrontCart` prop, asked for with
|
|
558
|
+
* a partial reload when it opens; every change made in it reloads the same
|
|
559
|
+
* props, so the redirect back brings it up to date.
|
|
560
|
+
*
|
|
561
|
+
* The body holds the free-shipping meter and the lines (a 64px thumbnail,
|
|
562
|
+
* the name, options, the stepper and "Remove", the line total); a free gift
|
|
563
|
+
* shows a "Free gift" badge and no stepper. The footer holds the subtotal,
|
|
564
|
+
* the note about shipping and tax, and "View cart" beside "Checkout".
|
|
565
|
+
*
|
|
566
|
+
* Focus moves back to the control that opened it on close or, when the
|
|
567
|
+
* drawer opened from the server, to the last control focused outside it.
|
|
568
|
+
*
|
|
569
|
+
* @since 1.0.0
|
|
570
|
+
*/
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* The drawer panel's id, which the header cart button controls.
|
|
574
|
+
*
|
|
575
|
+
* @since 1.0.0
|
|
576
|
+
*/
|
|
577
|
+
declare const CART_DRAWER_CONTENT_ID = "ecommerce-cart-drawer-content";
|
|
578
|
+
/**
|
|
579
|
+
* The cart drawer.
|
|
580
|
+
*
|
|
581
|
+
* @since 1.0.0
|
|
582
|
+
*
|
|
583
|
+
* @returns The drawer.
|
|
584
|
+
*/
|
|
585
|
+
declare function CartDrawer(): ReactElement;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* The header's cart button: a link to the cart with the item count, which
|
|
589
|
+
* opens the cart drawer instead when the page has one.
|
|
590
|
+
*
|
|
591
|
+
* Mirrors ecommerce-storefront-livewire's `Cart/HeaderButton`. Opening
|
|
592
|
+
* remembers the button, so the drawer hands focus back to it on close.
|
|
593
|
+
*
|
|
594
|
+
* @since 1.0.0
|
|
595
|
+
*/
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* The header cart button.
|
|
599
|
+
*
|
|
600
|
+
* @since 1.0.0
|
|
601
|
+
*
|
|
602
|
+
* @returns The button.
|
|
603
|
+
*/
|
|
604
|
+
declare function CartHeaderButton(): ReactElement;
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* The prompt that merges a guest cart into the shopper's account cart after
|
|
608
|
+
* sign-in, rendered once by the layout.
|
|
609
|
+
*
|
|
610
|
+
* Mirrors ecommerce-storefront-livewire's `Cart/MergePrompt`, from the
|
|
611
|
+
* shared `ecommerceStorefront.cartMerge`: the design system's Dialog as an
|
|
612
|
+
* alertdialog with its icon (the bag on a soft primary circle), title,
|
|
613
|
+
* description and footer. The shopper must choose, so the backdrop doesn't
|
|
614
|
+
* close it, there is no close button, and Escape is caught before the
|
|
615
|
+
* dialog sees it. Each choice posts its value as `resolution` to the
|
|
616
|
+
* prompt's `url`; once answered, `cartMerge` is null and the prompt closes.
|
|
617
|
+
* Focus starts on the primary (solid) choice.
|
|
618
|
+
*
|
|
619
|
+
* @since 1.0.0
|
|
620
|
+
*/
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* The primary choice's id, focused when the prompt opens.
|
|
624
|
+
*
|
|
625
|
+
* @since 1.0.0
|
|
626
|
+
*/
|
|
627
|
+
declare const MERGE_PRIMARY_ID = "ecommerce-cart-merge-primary";
|
|
628
|
+
/**
|
|
629
|
+
* The cart merge prompt.
|
|
630
|
+
*
|
|
631
|
+
* @since 1.0.0
|
|
632
|
+
*
|
|
633
|
+
* @returns The prompt, inside its wrapper.
|
|
634
|
+
*/
|
|
635
|
+
declare function MergePrompt(): ReactElement;
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* The header search box.
|
|
639
|
+
*
|
|
640
|
+
* Mirrors ecommerce-storefront-livewire's `Search/HeaderSearch`: an ARIA 1.2
|
|
641
|
+
* combobox whose input owns a listbox of products, categories and "See all
|
|
642
|
+
* N results". As the shopper types (300ms after the last key, from two
|
|
643
|
+
* characters) it asks the `search.suggest` JSON route for suggestions. The
|
|
644
|
+
* arrow keys move the highlight (`aria-activedescendant`, `aria-selected`
|
|
645
|
+
* on the active option), Enter opens the highlighted option or submits the
|
|
646
|
+
* form to the search page, Escape closes the popover, and a polite status
|
|
647
|
+
* announces the suggestion count, or that searching is throttled or
|
|
648
|
+
* unavailable. Pressing "/" outside a text field or widget focuses the box,
|
|
649
|
+
* unless a modal is open; `search.shortcut` (the `search.keyboard_shortcut`
|
|
650
|
+
* config key) turns the shortcut, its hint and `aria-keyshortcuts` off.
|
|
651
|
+
*
|
|
652
|
+
* @since 1.0.0
|
|
653
|
+
*/
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Props for {@link HeaderSearch}.
|
|
657
|
+
*
|
|
658
|
+
* @since 1.0.0
|
|
659
|
+
*/
|
|
660
|
+
interface HeaderSearchProps {
|
|
661
|
+
/** The input's id. Default `ecommerce-header-search`. */
|
|
662
|
+
inputId?: string;
|
|
663
|
+
/** How long typing waits before asking for suggestions, in ms. Default 300. */
|
|
664
|
+
debounce?: number;
|
|
665
|
+
/** The term to start with (stories, gates). */
|
|
666
|
+
defaultQuery?: string;
|
|
667
|
+
/** Suggestions to start with, as the JSON route answers (stories, gates). */
|
|
668
|
+
defaultResults?: StorefrontHeaderSearchResults;
|
|
669
|
+
/** Starts with the popover open (stories, gates). */
|
|
670
|
+
defaultOpen?: boolean;
|
|
671
|
+
/** Starts in the loading state (stories, gates). */
|
|
672
|
+
defaultLoading?: boolean;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* The suggestions route: the search page's URL plus `/suggest`
|
|
676
|
+
* (`search.suggest` sits beside `search` in the storefront's routes).
|
|
677
|
+
*
|
|
678
|
+
* @since 1.0.0
|
|
679
|
+
*
|
|
680
|
+
* @param searchUrl - The search page's URL.
|
|
681
|
+
* @returns The suggestions URL.
|
|
682
|
+
*/
|
|
683
|
+
declare function suggestionsUrl(searchUrl: string): string;
|
|
684
|
+
/**
|
|
685
|
+
* The header search box.
|
|
686
|
+
*
|
|
687
|
+
* @since 1.0.0
|
|
688
|
+
*
|
|
689
|
+
* @param props - The input id.
|
|
690
|
+
* @returns The search box.
|
|
691
|
+
*/
|
|
692
|
+
declare function HeaderSearch({ inputId, debounce, defaultQuery, defaultResults, defaultOpen, defaultLoading, }: HeaderSearchProps): ReactElement;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* `ec-address`: a postal address, on its own or in a titled card with an
|
|
696
|
+
* "Edit" link.
|
|
697
|
+
*
|
|
698
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-address>`. The
|
|
699
|
+
* presenter sends the address already formatted into lines.
|
|
700
|
+
*
|
|
701
|
+
* @since 1.0.0
|
|
702
|
+
*/
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Props for {@link Address}.
|
|
706
|
+
*
|
|
707
|
+
* @since 1.0.0
|
|
708
|
+
*/
|
|
709
|
+
interface AddressProps {
|
|
710
|
+
/** The formatted lines; none draws "No address". */
|
|
711
|
+
lines: string[];
|
|
712
|
+
/** The phone number, or null. */
|
|
713
|
+
phone?: string | null;
|
|
714
|
+
/** A card title, such as "Shipping address". Without one, no card. */
|
|
715
|
+
title?: string | null;
|
|
716
|
+
/** The card's "Edit" link. */
|
|
717
|
+
editHref?: string | null;
|
|
718
|
+
className?: string;
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* An address.
|
|
722
|
+
*
|
|
723
|
+
* @since 1.0.0
|
|
724
|
+
*
|
|
725
|
+
* @param props - The lines, phone and card options.
|
|
726
|
+
* @returns The address.
|
|
727
|
+
*/
|
|
728
|
+
declare function Address({ lines, phone, title, editHref, className, }: AddressProps): ReactElement;
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* `ec-address-form`: an address fieldset that follows the country's format.
|
|
732
|
+
*
|
|
733
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-address-form>`:
|
|
734
|
+
* the country first, then the name and street fields, then the region (a
|
|
735
|
+
* select when the country has regions, else optional text), the postal code
|
|
736
|
+
* with the country's label and hint, and the phone last. When the country
|
|
737
|
+
* changes, the form asks `formatUrl` (the `address-format` JSON route) for
|
|
738
|
+
* the new country's regions and postal code rules.
|
|
739
|
+
*
|
|
740
|
+
* @since 1.0.0
|
|
741
|
+
*/
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Props for {@link AddressForm}.
|
|
745
|
+
*
|
|
746
|
+
* @since 1.0.0
|
|
747
|
+
*/
|
|
748
|
+
interface AddressFormProps {
|
|
749
|
+
/** The fields' name prefix, such as `shipping`: ids and error keys are `shipping.city`. */
|
|
750
|
+
name: string;
|
|
751
|
+
/** The countries, fields and the current country's format. */
|
|
752
|
+
form: StorefrontAddressForm;
|
|
753
|
+
/** The address so far. */
|
|
754
|
+
values: StorefrontAddressValues;
|
|
755
|
+
/** Called with a field and its new value. */
|
|
756
|
+
onChange: (field: StorefrontAddressFieldName, value: string) => void;
|
|
757
|
+
/** Called when a field loses focus, for forms that check as the shopper goes. */
|
|
758
|
+
onBlur?: (field: StorefrontAddressFieldName) => void;
|
|
759
|
+
/** The page's errors, keyed `{name}.{field}`. */
|
|
760
|
+
errors?: Record<string, string>;
|
|
761
|
+
/** The fieldset's legend. */
|
|
762
|
+
legend?: string | null;
|
|
763
|
+
/** An autocomplete section, such as `shipping`: tokens become `shipping postal-code`. */
|
|
764
|
+
section?: string | null;
|
|
765
|
+
/** The `address-format` JSON route; without it the format stays as given. */
|
|
766
|
+
formatUrl?: string | null;
|
|
767
|
+
className?: string;
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* An address form.
|
|
771
|
+
*
|
|
772
|
+
* @since 1.0.0
|
|
773
|
+
*
|
|
774
|
+
* @param props - The form, values and handlers.
|
|
775
|
+
* @returns The fieldset.
|
|
776
|
+
*/
|
|
777
|
+
declare function AddressForm({ name, form, values, onChange, onBlur, errors, legend, section, formatUrl, className, }: AddressFormProps): ReactElement;
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* `ec-category-grid`: category tiles with images and product counts.
|
|
781
|
+
*
|
|
782
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-category-grid>`.
|
|
783
|
+
* Draws nothing without tiles.
|
|
784
|
+
*
|
|
785
|
+
* @since 1.0.0
|
|
786
|
+
*/
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Props for {@link CategoryGrid}.
|
|
790
|
+
*
|
|
791
|
+
* @since 1.0.0
|
|
792
|
+
*/
|
|
793
|
+
interface CategoryGridProps {
|
|
794
|
+
/** The grid, as the presenter sends it. */
|
|
795
|
+
grid: StorefrontCategoryGrid;
|
|
796
|
+
className?: string;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* A grid of category tiles.
|
|
800
|
+
*
|
|
801
|
+
* @since 1.0.0
|
|
802
|
+
*
|
|
803
|
+
* @param props - The grid.
|
|
804
|
+
* @returns The grid, or nothing without tiles.
|
|
805
|
+
*/
|
|
806
|
+
declare function CategoryGrid({ grid, className }: CategoryGridProps): ReactElement | null;
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* `ec-choice-cards`: a fieldset of radio cards, each with a label, a hint
|
|
810
|
+
* or reason, an optional image and a price or other note.
|
|
811
|
+
*
|
|
812
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-choice-cards>`
|
|
813
|
+
* (shipping methods, bundle choices). The options say which is selected;
|
|
814
|
+
* the parent updates them through `onValueChange`.
|
|
815
|
+
*
|
|
816
|
+
* @since 1.0.0
|
|
817
|
+
*/
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Props for {@link ChoiceCards}.
|
|
821
|
+
*
|
|
822
|
+
* @since 1.0.0
|
|
823
|
+
*/
|
|
824
|
+
interface ChoiceCardsProps {
|
|
825
|
+
/** The radios' name. */
|
|
826
|
+
name: string;
|
|
827
|
+
/** The fieldset's legend. */
|
|
828
|
+
legend: string;
|
|
829
|
+
options: StorefrontChoiceCardOption[];
|
|
830
|
+
/** The inputs' id prefix. Defaults to `ec-choice-{name}`. */
|
|
831
|
+
idPrefix?: string;
|
|
832
|
+
required?: boolean;
|
|
833
|
+
hint?: string | null;
|
|
834
|
+
error?: string | null;
|
|
835
|
+
/** Extra ids describing the fieldset. */
|
|
836
|
+
describedBy?: string;
|
|
837
|
+
/** Called with the chosen option's value. */
|
|
838
|
+
onValueChange?: (value: string) => void;
|
|
839
|
+
className?: string;
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Choice cards.
|
|
843
|
+
*
|
|
844
|
+
* @since 1.0.0
|
|
845
|
+
*
|
|
846
|
+
* @param props - The options and fieldset settings.
|
|
847
|
+
* @returns The fieldset.
|
|
848
|
+
*/
|
|
849
|
+
declare function ChoiceCards({ name, legend, options, idPrefix, required, hint, error, describedBy, onValueChange, className, }: ChoiceCardsProps): ReactElement;
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* `ec-currency`: the currency switcher, in the header or the footer.
|
|
853
|
+
*
|
|
854
|
+
* Mirrors ecommerce-storefront-livewire's `Currency/Switcher`: a design-system
|
|
855
|
+
* DropdownMenu of radio items, shown only when the store sells in more than
|
|
856
|
+
* one currency. Choosing a currency posts it to the switcher's `url`; the
|
|
857
|
+
* redirect back reprices the page. A refused choice comes back as the
|
|
858
|
+
* page's `currency` error.
|
|
859
|
+
*
|
|
860
|
+
* @since 1.0.0
|
|
861
|
+
*/
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Props for {@link CurrencySwitcher}.
|
|
865
|
+
*
|
|
866
|
+
* @since 1.0.0
|
|
867
|
+
*/
|
|
868
|
+
interface CurrencySwitcherProps {
|
|
869
|
+
/** The switcher; defaults to the shared `ecommerceStorefront.currency`. */
|
|
870
|
+
switcher?: StorefrontCurrencySwitcher;
|
|
871
|
+
/** Where it sits, as `data-currency-placement`. Default `header`. */
|
|
872
|
+
placement?: string;
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* The currency switcher.
|
|
876
|
+
*
|
|
877
|
+
* @since 1.0.0
|
|
878
|
+
*
|
|
879
|
+
* @param props - The switcher and its placement.
|
|
880
|
+
* @returns The switcher.
|
|
881
|
+
*/
|
|
882
|
+
declare function CurrencySwitcher({ switcher, placement, }: CurrencySwitcherProps): ReactElement;
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* `ec-empty-state`: the design-system EmptyState with the storefront's
|
|
886
|
+
* defaults, optionally in a card and optionally a live status.
|
|
887
|
+
*
|
|
888
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-empty-state>`.
|
|
889
|
+
*
|
|
890
|
+
* @since 1.0.0
|
|
891
|
+
*/
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* Props for {@link EmptyState}.
|
|
895
|
+
*
|
|
896
|
+
* @since 1.0.0
|
|
897
|
+
*/
|
|
898
|
+
interface EmptyStateProps extends StorefrontEmptyStateProps, Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'children'> {
|
|
899
|
+
/** Actions under the description, such as a "Continue shopping" button. */
|
|
900
|
+
children?: ReactNode;
|
|
901
|
+
className?: string;
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* An empty state.
|
|
905
|
+
*
|
|
906
|
+
* @since 1.0.0
|
|
907
|
+
*
|
|
908
|
+
* @param props - The title, description, icon and options.
|
|
909
|
+
* @returns The empty state.
|
|
910
|
+
*/
|
|
911
|
+
declare function EmptyState({ title, description, icon, size, headingLevel, card, live, children, className, ...rest }: EmptyStateProps): ReactElement;
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* `ec-field`: one form control with its label, hint and error, wrapped so
|
|
915
|
+
* a form can find it by field key (the error summary's links focus it).
|
|
916
|
+
*
|
|
917
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-field>`: an
|
|
918
|
+
* Input, Select, Textarea, Password or Checkbox from the design system. An
|
|
919
|
+
* optional field's label says "(optional)"; a required checkbox gets the
|
|
920
|
+
* required star.
|
|
921
|
+
*
|
|
922
|
+
* @since 1.0.0
|
|
923
|
+
*/
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Props for {@link Field}.
|
|
927
|
+
*
|
|
928
|
+
* @since 1.0.0
|
|
929
|
+
*/
|
|
930
|
+
interface FieldProps extends StorefrontFieldProps {
|
|
931
|
+
/** The field's key in the page's `errors`, for `data-field-key`. Defaults to `name`. */
|
|
932
|
+
errorKey?: string | null;
|
|
933
|
+
name?: string;
|
|
934
|
+
value?: string;
|
|
935
|
+
checked?: boolean;
|
|
936
|
+
required?: boolean;
|
|
937
|
+
disabled?: boolean;
|
|
938
|
+
type?: string;
|
|
939
|
+
autoComplete?: string;
|
|
940
|
+
inputMode?: 'text' | 'numeric' | 'decimal' | 'tel' | 'email' | 'url' | 'search' | 'none';
|
|
941
|
+
/** Called with the new value of an input, select, textarea or password. */
|
|
942
|
+
onValueChange?: (value: string) => void;
|
|
943
|
+
/** Called with a checkbox's new state. */
|
|
944
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
945
|
+
onBlur?: (event: FocusEvent<HTMLElement>) => void;
|
|
946
|
+
/** Any other attributes for the control, such as `data-*`. */
|
|
947
|
+
attributes?: Record<string, unknown>;
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* A form field.
|
|
951
|
+
*
|
|
952
|
+
* @since 1.0.0
|
|
953
|
+
*
|
|
954
|
+
* @param props - The control, label, hint, error and value.
|
|
955
|
+
* @returns The field.
|
|
956
|
+
*/
|
|
957
|
+
declare function Field({ id, control, label, hint, error, options, placeholder, optional, maxLength, leadingIcon, errorKey, name, value, checked, required, disabled, type, autoComplete, inputMode, onValueChange, onCheckedChange, onBlur, attributes, }: FieldProps): ReactElement;
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* `ec-gallery`: a product's images, with thumbnails, a counter and a zoom
|
|
961
|
+
* lightbox.
|
|
962
|
+
*
|
|
963
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-gallery>`. The
|
|
964
|
+
* stage shows one image; a thumbnail shows another and a polite live region
|
|
965
|
+
* announces it. The lightbox is the behavior engine's (`useLightbox`), so
|
|
966
|
+
* its focus trap, keys and parts match the design system's ImageGallery.
|
|
967
|
+
*
|
|
968
|
+
* A variant change can bring up its image with a window event, as in
|
|
969
|
+
* Livewire: `ecommerce-gallery-show` with `{ url, scope }`.
|
|
970
|
+
*
|
|
971
|
+
* @since 1.0.0
|
|
972
|
+
*/
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* Props for {@link Gallery}.
|
|
976
|
+
*
|
|
977
|
+
* @since 1.0.0
|
|
978
|
+
*/
|
|
979
|
+
interface GalleryProps {
|
|
980
|
+
/** The images. */
|
|
981
|
+
items: StorefrontGalleryItem[];
|
|
982
|
+
/** The product's name, for the region's label and the lightbox title. */
|
|
983
|
+
name: string;
|
|
984
|
+
/** The image shown first, 0-based. */
|
|
985
|
+
active?: number;
|
|
986
|
+
/** Where the thumbnails go. Default `bottom`. */
|
|
987
|
+
thumbnails?: 'bottom' | 'start' | 'end' | 'none';
|
|
988
|
+
/** Offers the zoom lightbox. Default true. */
|
|
989
|
+
zoom?: boolean;
|
|
990
|
+
/** Only `ecommerce-gallery-show` events with this scope change the image. */
|
|
991
|
+
scope?: string | null;
|
|
992
|
+
/** The root id; the lightbox parts' ids start with it. */
|
|
993
|
+
id?: string;
|
|
994
|
+
className?: string;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* The event that brings up an image by URL.
|
|
998
|
+
*
|
|
999
|
+
* @since 1.0.0
|
|
1000
|
+
*/
|
|
1001
|
+
declare const GALLERY_SHOW_EVENT = "ecommerce-gallery-show";
|
|
1002
|
+
/**
|
|
1003
|
+
* A product image gallery.
|
|
1004
|
+
*
|
|
1005
|
+
* @since 1.0.0
|
|
1006
|
+
*
|
|
1007
|
+
* @param props - The images and options.
|
|
1008
|
+
* @returns The gallery.
|
|
1009
|
+
*/
|
|
1010
|
+
declare function Gallery({ items, name, active: initial, thumbnails, zoom, scope, id, className, }: GalleryProps): ReactElement;
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* `ec-money`: an amount the server already formatted, or a dash for none.
|
|
1014
|
+
*
|
|
1015
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-money>`. The
|
|
1016
|
+
* amount is set left to right (`<bdi dir="ltr">`) in any layout, a negative
|
|
1017
|
+
* amount reads "Minus", and a converted amount shows its equivalent in the
|
|
1018
|
+
* base currency.
|
|
1019
|
+
*
|
|
1020
|
+
* @since 1.0.0
|
|
1021
|
+
*/
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Props for {@link Money}.
|
|
1025
|
+
*
|
|
1026
|
+
* @since 1.0.0
|
|
1027
|
+
*/
|
|
1028
|
+
interface MoneyProps extends HTMLAttributes<HTMLSpanElement> {
|
|
1029
|
+
/** The amount, as the presenter sends it; null draws "No amount". */
|
|
1030
|
+
money: StorefrontMoney | null;
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* An amount.
|
|
1034
|
+
*
|
|
1035
|
+
* @since 1.0.0
|
|
1036
|
+
*
|
|
1037
|
+
* @param props - The amount and extra attributes.
|
|
1038
|
+
* @returns The amount.
|
|
1039
|
+
*/
|
|
1040
|
+
declare function Money({ money, className, ...rest }: MoneyProps): ReactElement;
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* `ec-price`: a product's price, sale, range, free or unavailable.
|
|
1044
|
+
*
|
|
1045
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-price>`. The
|
|
1046
|
+
* presenter sends the amounts already formatted (`StorefrontPrice`).
|
|
1047
|
+
*
|
|
1048
|
+
* @since 1.0.0
|
|
1049
|
+
*/
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* Props for {@link Price}.
|
|
1053
|
+
*
|
|
1054
|
+
* @since 1.0.0
|
|
1055
|
+
*/
|
|
1056
|
+
interface PriceProps extends HTMLAttributes<HTMLSpanElement> {
|
|
1057
|
+
/** The price; null or `unavailable` draws "Price unavailable". */
|
|
1058
|
+
price: StorefrontPrice | null;
|
|
1059
|
+
/** `sm`, `md` or `lg`. Default `md`. */
|
|
1060
|
+
size?: 'sm' | 'md' | 'lg';
|
|
1061
|
+
/** Shows the "25% off" badge on a sale price. Default true. */
|
|
1062
|
+
saleBadge?: boolean;
|
|
1063
|
+
/** Draws a range as "From $24.00" instead of "$24.00 – $32.00". */
|
|
1064
|
+
from?: boolean;
|
|
1065
|
+
/** Shows the tax note. Default true. */
|
|
1066
|
+
showTax?: boolean;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* A price.
|
|
1070
|
+
*
|
|
1071
|
+
* @since 1.0.0
|
|
1072
|
+
*
|
|
1073
|
+
* @param props - The price and options.
|
|
1074
|
+
* @returns The price.
|
|
1075
|
+
*/
|
|
1076
|
+
declare function Price({ price, size, saleBadge, from, showTax, className, ...rest }: PriceProps): ReactElement;
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* `ec-price-range`: the catalog's price filter, a two-thumb slider with a
|
|
1080
|
+
* lowest and highest amount input.
|
|
1081
|
+
*
|
|
1082
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-price-range>`.
|
|
1083
|
+
* Amounts are in minor units; the inputs show major units. A thumb or input
|
|
1084
|
+
* at its bound clears that end (null). Typing settles on blur or Enter and
|
|
1085
|
+
* snaps to the step; changes reach `onValueChange` 400ms after the last one,
|
|
1086
|
+
* as the Livewire filter refreshes.
|
|
1087
|
+
*
|
|
1088
|
+
* @since 1.0.0
|
|
1089
|
+
*/
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* The chosen bounds, in minor units; null leaves that end open.
|
|
1093
|
+
*
|
|
1094
|
+
* @since 1.0.0
|
|
1095
|
+
*/
|
|
1096
|
+
interface PriceRangeValue {
|
|
1097
|
+
from: number | null;
|
|
1098
|
+
to: number | null;
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Props for {@link PriceRange}.
|
|
1102
|
+
*
|
|
1103
|
+
* @since 1.0.0
|
|
1104
|
+
*/
|
|
1105
|
+
interface PriceRangeProps {
|
|
1106
|
+
range: StorefrontPriceRange;
|
|
1107
|
+
/** The legend, or null for none. */
|
|
1108
|
+
label?: string | null;
|
|
1109
|
+
/** The parts' id prefix. Default `ec-price-range`. */
|
|
1110
|
+
idPrefix?: string;
|
|
1111
|
+
/** Called with the new bounds, 400ms after the last change. */
|
|
1112
|
+
onValueChange?: (value: PriceRangeValue) => void;
|
|
1113
|
+
/** The delay before `onValueChange`, in ms. Default 400. */
|
|
1114
|
+
debounce?: number;
|
|
1115
|
+
className?: string;
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* A price range filter.
|
|
1119
|
+
*
|
|
1120
|
+
* @since 1.0.0
|
|
1121
|
+
*
|
|
1122
|
+
* @param props - The range and handlers.
|
|
1123
|
+
* @returns The fieldset.
|
|
1124
|
+
*/
|
|
1125
|
+
declare function PriceRange({ range, label, idPrefix, onValueChange, debounce, className, }: PriceRangeProps): ReactElement;
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* `ec-product-card`: a product in a grid.
|
|
1129
|
+
*
|
|
1130
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-product-card>`:
|
|
1131
|
+
* the image (or a placeholder) with sale and custom badges and any card
|
|
1132
|
+
* actions, the category, the name linking to the product, the price, the
|
|
1133
|
+
* rating and stock, and the call to action: "Add to cart" (quick add),
|
|
1134
|
+
* "Choose options" (drawn, not a control: the name's link carries it) or
|
|
1135
|
+
* a disabled "Sold out".
|
|
1136
|
+
*
|
|
1137
|
+
* Card actions come from the `productCardActions` client registry, keyed by
|
|
1138
|
+
* the card's `actions`; each gets the card as `card`.
|
|
1139
|
+
*
|
|
1140
|
+
* @since 1.0.0
|
|
1141
|
+
*/
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Props for {@link ProductCard}.
|
|
1145
|
+
*
|
|
1146
|
+
* @since 1.0.0
|
|
1147
|
+
*/
|
|
1148
|
+
interface ProductCardProps extends HTMLAttributes<HTMLElement> {
|
|
1149
|
+
/** The card, as the presenter sends it. */
|
|
1150
|
+
card: StorefrontProductCard;
|
|
1151
|
+
/** Shows the price. Default true. */
|
|
1152
|
+
showPrice?: boolean;
|
|
1153
|
+
/** Shows the rating. Default true. */
|
|
1154
|
+
showRating?: boolean;
|
|
1155
|
+
/** Quick add: called with the card when "Add to cart" is pressed. */
|
|
1156
|
+
onQuickAdd?: (card: StorefrontProductCard) => void;
|
|
1157
|
+
/** Disables "Add to cart" while the quick add is on its way. */
|
|
1158
|
+
quickAddPending?: boolean;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* A product card.
|
|
1162
|
+
*
|
|
1163
|
+
* @since 1.0.0
|
|
1164
|
+
*
|
|
1165
|
+
* @param props - The card and options.
|
|
1166
|
+
* @returns The card.
|
|
1167
|
+
*/
|
|
1168
|
+
declare function ProductCard({ card, showPrice, showRating, onQuickAdd, quickAddPending, className, ...rest }: ProductCardProps): ReactElement;
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* `ec-quantity`: a number input with decrease and increase buttons.
|
|
1172
|
+
*
|
|
1173
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-quantity>`.
|
|
1174
|
+
* The buttons step the value within `min` and `max`; at a bound the button
|
|
1175
|
+
* says so with `aria-disabled` and does nothing, so keyboard focus stays on
|
|
1176
|
+
* it. Without a visible label the input is still named ("Quantity, Linen
|
|
1177
|
+
* shirt").
|
|
1178
|
+
*
|
|
1179
|
+
* @since 1.0.0
|
|
1180
|
+
*/
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* Props for {@link Quantity}.
|
|
1184
|
+
*
|
|
1185
|
+
* @since 1.0.0
|
|
1186
|
+
*/
|
|
1187
|
+
interface QuantityProps extends StorefrontQuantityProps {
|
|
1188
|
+
/** The quantity, or null while the field is empty. */
|
|
1189
|
+
value: number | null;
|
|
1190
|
+
/** Called with the new quantity (null when the field is cleared). */
|
|
1191
|
+
onValueChange: (value: number | null) => void;
|
|
1192
|
+
name?: string;
|
|
1193
|
+
disabled?: boolean;
|
|
1194
|
+
required?: boolean;
|
|
1195
|
+
placeholder?: string;
|
|
1196
|
+
className?: string;
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* A quantity stepper.
|
|
1200
|
+
*
|
|
1201
|
+
* @since 1.0.0
|
|
1202
|
+
*
|
|
1203
|
+
* @param props - The value, bounds and labels.
|
|
1204
|
+
* @returns The stepper.
|
|
1205
|
+
*/
|
|
1206
|
+
declare function Quantity({ id, label, min, max, error, itemName, size, value, onValueChange, name, disabled, required, placeholder, className, }: QuantityProps): ReactElement;
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* `ec-rating-input`: five star radios for a review's rating.
|
|
1210
|
+
*
|
|
1211
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-rating-input>`:
|
|
1212
|
+
* a radiogroup fieldset whose stars light up on hover, with ":rating of 5"
|
|
1213
|
+
* beside them and the error under them.
|
|
1214
|
+
*
|
|
1215
|
+
* @since 1.0.0
|
|
1216
|
+
*/
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* Props for {@link RatingInput}.
|
|
1220
|
+
*
|
|
1221
|
+
* @since 1.0.0
|
|
1222
|
+
*/
|
|
1223
|
+
interface RatingInputProps extends StorefrontRatingInputProps {
|
|
1224
|
+
/** The chosen rating, 1–5, or 0 for none. */
|
|
1225
|
+
value: number;
|
|
1226
|
+
/** Called with the chosen rating. */
|
|
1227
|
+
onValueChange: (value: number) => void;
|
|
1228
|
+
className?: string;
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* A star rating input.
|
|
1232
|
+
*
|
|
1233
|
+
* @since 1.0.0
|
|
1234
|
+
*
|
|
1235
|
+
* @param props - The value, label and error.
|
|
1236
|
+
* @returns The fieldset.
|
|
1237
|
+
*/
|
|
1238
|
+
declare function RatingInput({ id, label, error, required, value, onValueChange, className, }: RatingInputProps): ReactElement;
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* `ec-rating`: a product's average rating and review count.
|
|
1242
|
+
*
|
|
1243
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-rating-summary>`.
|
|
1244
|
+
* With a link it reads as one spoken label ("Rated 4.5 out of 5, 12
|
|
1245
|
+
* reviews"); without one, the label is screen-reader text.
|
|
1246
|
+
*
|
|
1247
|
+
* @since 1.0.0
|
|
1248
|
+
*/
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* Props for {@link RatingSummary}.
|
|
1252
|
+
*
|
|
1253
|
+
* @since 1.0.0
|
|
1254
|
+
*/
|
|
1255
|
+
interface RatingSummaryProps {
|
|
1256
|
+
/** The rating, as the presenter sends it. */
|
|
1257
|
+
rating: StorefrontRatingSummary;
|
|
1258
|
+
/** Draws nothing instead of "No reviews yet" when there are none. */
|
|
1259
|
+
hideEmpty?: boolean;
|
|
1260
|
+
/** One star, the average and "(12)", for product cards. */
|
|
1261
|
+
compact?: boolean;
|
|
1262
|
+
/** Links to this URL instead of the rating's `href`; null for no link. */
|
|
1263
|
+
href?: string | null;
|
|
1264
|
+
className?: string;
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* A rating summary.
|
|
1268
|
+
*
|
|
1269
|
+
* @since 1.0.0
|
|
1270
|
+
*
|
|
1271
|
+
* @param props - The rating.
|
|
1272
|
+
* @returns The summary, or nothing.
|
|
1273
|
+
*/
|
|
1274
|
+
declare function RatingSummary({ rating, hideEmpty, compact, href, className, }: RatingSummaryProps): ReactElement | null;
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* `ec-search-box`: the header search, in its wrapper.
|
|
1278
|
+
*
|
|
1279
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-search-box>`,
|
|
1280
|
+
* which wraps the `Search/HeaderSearch` component.
|
|
1281
|
+
*
|
|
1282
|
+
* @since 1.0.0
|
|
1283
|
+
*/
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* Props for {@link SearchBox}.
|
|
1287
|
+
*
|
|
1288
|
+
* @since 1.0.0
|
|
1289
|
+
*/
|
|
1290
|
+
interface SearchBoxProps extends StorefrontSearchBoxProps {
|
|
1291
|
+
className?: string;
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* The search box.
|
|
1295
|
+
*
|
|
1296
|
+
* @since 1.0.0
|
|
1297
|
+
*
|
|
1298
|
+
* @param props - The input id.
|
|
1299
|
+
* @returns The search box.
|
|
1300
|
+
*/
|
|
1301
|
+
declare function SearchBox({ inputId, className, }: SearchBoxProps): ReactElement;
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
* `ec-skeleton`: a loading placeholder with a polite "Loading…" status.
|
|
1305
|
+
*
|
|
1306
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-skeleton>`:
|
|
1307
|
+
* text lines, product-card shapes or one image.
|
|
1308
|
+
*
|
|
1309
|
+
* @since 1.0.0
|
|
1310
|
+
*/
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* Props for {@link Skeleton}.
|
|
1314
|
+
*
|
|
1315
|
+
* @since 1.0.0
|
|
1316
|
+
*/
|
|
1317
|
+
interface SkeletonProps extends HTMLAttributes<HTMLDivElement> {
|
|
1318
|
+
/** `text`, `card` or `image`. Default `text`. */
|
|
1319
|
+
variant?: 'text' | 'card' | 'image';
|
|
1320
|
+
/** How many lines or cards, 1–24. Default 3. */
|
|
1321
|
+
count?: number;
|
|
1322
|
+
/** The status text. Default "Loading…". */
|
|
1323
|
+
label?: string;
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* A loading placeholder.
|
|
1327
|
+
*
|
|
1328
|
+
* @since 1.0.0
|
|
1329
|
+
*
|
|
1330
|
+
* @param props - The variant, count and label.
|
|
1331
|
+
* @returns The placeholder.
|
|
1332
|
+
*/
|
|
1333
|
+
declare function Skeleton({ variant, count, label, className, ...rest }: SkeletonProps): ReactElement;
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
* `ec-stock`: a product's stock status badge.
|
|
1337
|
+
*
|
|
1338
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-stock-status>`:
|
|
1339
|
+
* a soft badge with the status icon, or (compact, on product cards) a ghost
|
|
1340
|
+
* badge with a dot that only shows when the product isn't simply in stock.
|
|
1341
|
+
*
|
|
1342
|
+
* @since 1.0.0
|
|
1343
|
+
*/
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* Props for {@link StockStatus}.
|
|
1347
|
+
*
|
|
1348
|
+
* @since 1.0.0
|
|
1349
|
+
*/
|
|
1350
|
+
interface StockStatusProps extends HTMLAttributes<HTMLSpanElement> {
|
|
1351
|
+
/** The stock status, with its label, icon and color. */
|
|
1352
|
+
stock: StorefrontStockStatus;
|
|
1353
|
+
/** The product card's dot badge, hidden while in stock. */
|
|
1354
|
+
compact?: boolean;
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* A stock status.
|
|
1358
|
+
*
|
|
1359
|
+
* @since 1.0.0
|
|
1360
|
+
*
|
|
1361
|
+
* @param props - The status.
|
|
1362
|
+
* @returns The badge, or nothing when compact and in stock.
|
|
1363
|
+
*/
|
|
1364
|
+
declare function StockStatus({ stock, compact, className, ...rest }: StockStatusProps): ReactElement | null;
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* `ec-swatches`: a fieldset of option chips, with a color dot or image
|
|
1368
|
+
* where the option has one.
|
|
1369
|
+
*
|
|
1370
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-swatches>`:
|
|
1371
|
+
* radios (or checkboxes with `multiple`), the chosen label beside the
|
|
1372
|
+
* legend, counts and price differences, and a reason ("Sold out") for an
|
|
1373
|
+
* option that can't be chosen. The options say which are selected; the
|
|
1374
|
+
* parent updates them through `onValueChange`.
|
|
1375
|
+
*
|
|
1376
|
+
* @since 1.0.0
|
|
1377
|
+
*/
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* Props for {@link Swatches}.
|
|
1381
|
+
*
|
|
1382
|
+
* @since 1.0.0
|
|
1383
|
+
*/
|
|
1384
|
+
interface SwatchesProps {
|
|
1385
|
+
/** The input name. */
|
|
1386
|
+
name: string;
|
|
1387
|
+
/** The fieldset's legend. */
|
|
1388
|
+
legend: string;
|
|
1389
|
+
options: StorefrontSwatchOption[];
|
|
1390
|
+
/** Checkboxes instead of radios. */
|
|
1391
|
+
multiple?: boolean;
|
|
1392
|
+
/** The inputs' id prefix. Defaults to `ec-swatch-{name}`. */
|
|
1393
|
+
idPrefix?: string;
|
|
1394
|
+
required?: boolean;
|
|
1395
|
+
error?: string | null;
|
|
1396
|
+
/** Extra ids describing the fieldset. */
|
|
1397
|
+
describedBy?: string;
|
|
1398
|
+
/** Called when an option is chosen (or, with `multiple`, checked or unchecked). */
|
|
1399
|
+
onValueChange?: (value: string, checked: boolean) => void;
|
|
1400
|
+
className?: string;
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* Option swatches.
|
|
1404
|
+
*
|
|
1405
|
+
* @since 1.0.0
|
|
1406
|
+
*
|
|
1407
|
+
* @param props - The options and fieldset settings.
|
|
1408
|
+
* @returns The fieldset.
|
|
1409
|
+
*/
|
|
1410
|
+
declare function Swatches({ name, legend, options, multiple, idPrefix, required, error, describedBy, onValueChange, className, }: SwatchesProps): ReactElement;
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* `ec-toaster`: the storefront's toast region.
|
|
1414
|
+
*
|
|
1415
|
+
* Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-toaster>`: the
|
|
1416
|
+
* design-system Toaster at the top end from 768px, along the bottom on a
|
|
1417
|
+
* phone (`TOASTER_PLACEMENTS`), at most five toasts. The layout renders it
|
|
1418
|
+
* once; show toasts with `showStorefrontToast()`.
|
|
1419
|
+
*
|
|
1420
|
+
* @since 1.0.0
|
|
1421
|
+
*/
|
|
1422
|
+
|
|
1423
|
+
/**
|
|
1424
|
+
* The toast region.
|
|
1425
|
+
*
|
|
1426
|
+
* @since 1.0.0
|
|
1427
|
+
*
|
|
1428
|
+
* @returns The region.
|
|
1429
|
+
*/
|
|
1430
|
+
declare function Toaster(): ReactElement;
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* The catalog filter groups.
|
|
1434
|
+
*
|
|
1435
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/catalog/partials/filters`,
|
|
1436
|
+
* drawn in the desktop sidebar and again in the mobile drawer (`idPrefix`
|
|
1437
|
+
* keeps their ids apart). The groups stack between dividers:
|
|
1438
|
+
*
|
|
1439
|
+
* - Category, tag and rating: the design-system RadioGroup markup, written
|
|
1440
|
+
* out so each option carries its depth and count. "All" first; options
|
|
1441
|
+
* with no products are disabled.
|
|
1442
|
+
* - Price: the price range (two thumbs and two amount fields).
|
|
1443
|
+
* - Attributes and custom option groups: the swatches.
|
|
1444
|
+
* - In stock, on sale and custom toggles: a design-system Toggle, the label
|
|
1445
|
+
* followed by the count.
|
|
1446
|
+
*
|
|
1447
|
+
* The groups draw the state they're given; changes go to the handlers.
|
|
1448
|
+
*
|
|
1449
|
+
* @since 1.0.0
|
|
1450
|
+
*/
|
|
1451
|
+
|
|
1452
|
+
/**
|
|
1453
|
+
* Props for {@link CatalogFilters}.
|
|
1454
|
+
*
|
|
1455
|
+
* @since 1.0.0
|
|
1456
|
+
*/
|
|
1457
|
+
interface CatalogFiltersProps {
|
|
1458
|
+
groups: StorefrontFilterGroup[];
|
|
1459
|
+
/** The state the controls show (the shopper's latest choices). */
|
|
1460
|
+
state: StorefrontListingState;
|
|
1461
|
+
/** Keeps the sidebar's and the drawer's ids apart. */
|
|
1462
|
+
idPrefix: string;
|
|
1463
|
+
/** A category, tag or rating was chosen. */
|
|
1464
|
+
onChoice: (group: StorefrontFilterGroup, value: string) => void;
|
|
1465
|
+
/** An attribute or custom option was turned on or off. */
|
|
1466
|
+
onOption: (group: StorefrontFilterGroup, value: string, checked: boolean) => void;
|
|
1467
|
+
/** A toggle was turned on or off. */
|
|
1468
|
+
onToggle: (group: StorefrontFilterGroup, on: boolean) => void;
|
|
1469
|
+
/** The price bounds changed. */
|
|
1470
|
+
onPrice: (group: StorefrontPriceFilterGroup, value: PriceRangeValue) => void;
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* A price group as the price range component takes it.
|
|
1474
|
+
*
|
|
1475
|
+
* @since 1.0.0
|
|
1476
|
+
*
|
|
1477
|
+
* @param group - The price group.
|
|
1478
|
+
* @param locale - The storefront locale, for the currency symbol.
|
|
1479
|
+
* @returns The range.
|
|
1480
|
+
*/
|
|
1481
|
+
declare function priceRangeFor(group: StorefrontPriceFilterGroup, locale?: string): StorefrontPriceRange;
|
|
1482
|
+
/**
|
|
1483
|
+
* The filter groups.
|
|
1484
|
+
*
|
|
1485
|
+
* @since 1.0.0
|
|
1486
|
+
*
|
|
1487
|
+
* @param props - The groups, the state and the handlers.
|
|
1488
|
+
* @returns The groups.
|
|
1489
|
+
*/
|
|
1490
|
+
declare function CatalogFilters({ groups, state, idPrefix, onChoice, onOption, onToggle, onPrice, }: CatalogFiltersProps): ReactElement;
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* `ec-catalog`: a product listing with filters, sorting and paging.
|
|
1494
|
+
*
|
|
1495
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/catalog/index`. From
|
|
1496
|
+
* 1024px the filters sit in a sidebar beside the results; below that a
|
|
1497
|
+
* "Filters (2)" button opens them in a start-side drawer. The results: the
|
|
1498
|
+
* toolbar (the live results count, "Sort by" and "Per page"), the active
|
|
1499
|
+
* filter chips with "Clear all", the product cards and the pagination.
|
|
1500
|
+
* While a filter, sort or page loads, skeleton cards stand in for the cards
|
|
1501
|
+
* and the results are `aria-busy`. With no products: the search's own
|
|
1502
|
+
* empty state, the no-match card ("Clear filters") or the empty catalog.
|
|
1503
|
+
*
|
|
1504
|
+
* Every change is an Inertia visit to the listing URL the server's state
|
|
1505
|
+
* gives, back on page 1. Filters wait 300ms for more changes, as Livewire's
|
|
1506
|
+
* `wire:model.live.debounce.300ms` does; the controls show the shopper's
|
|
1507
|
+
* choices meanwhile. Removing a chip or using "Clear all" takes the control
|
|
1508
|
+
* out of the page, so focus moves on to the chip now in its place (else the
|
|
1509
|
+
* one before it), to "Show N products" in the drawer, or to the results
|
|
1510
|
+
* count, but only when it fell to the page.
|
|
1511
|
+
*
|
|
1512
|
+
* The search page reuses it with `resultsLabel`, `emptyState` and
|
|
1513
|
+
* `browseUrl`.
|
|
1514
|
+
*
|
|
1515
|
+
* @since 1.0.0
|
|
1516
|
+
*/
|
|
1517
|
+
|
|
1518
|
+
/**
|
|
1519
|
+
* Props for {@link CatalogListing}.
|
|
1520
|
+
*
|
|
1521
|
+
* @since 1.0.0
|
|
1522
|
+
*/
|
|
1523
|
+
interface CatalogListingProps {
|
|
1524
|
+
listing: StorefrontCatalogListing;
|
|
1525
|
+
/** The live results count; the product count by default. */
|
|
1526
|
+
resultsLabel?: string;
|
|
1527
|
+
/** The search's empty state, in place of the catalog's own. */
|
|
1528
|
+
emptyState?: StorefrontSearchEmptyState | null;
|
|
1529
|
+
/** "Browse all products", for the search's empty states. */
|
|
1530
|
+
browseUrl?: string | null;
|
|
1531
|
+
/** How long filters wait for more changes, in ms. Default 300. */
|
|
1532
|
+
debounce?: number;
|
|
1533
|
+
/** Shows the loading state (skeleton cards, `aria-busy`) regardless of visits. */
|
|
1534
|
+
loading?: boolean;
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* A product listing.
|
|
1538
|
+
*
|
|
1539
|
+
* @since 1.0.0
|
|
1540
|
+
*
|
|
1541
|
+
* @param props - The listing and the search's overrides.
|
|
1542
|
+
* @returns The section.
|
|
1543
|
+
*/
|
|
1544
|
+
declare function CatalogListing({ listing, resultsLabel, emptyState, browseUrl, debounce, loading, }: CatalogListingProps): ReactElement;
|
|
1545
|
+
|
|
1546
|
+
/**
|
|
1547
|
+
* `ec-product-grid`: a fixed grid of products, without filters or paging.
|
|
1548
|
+
*
|
|
1549
|
+
* Mirrors ecommerce-storefront-livewire's `Catalog/ProductGrid` (the product
|
|
1550
|
+
* grid block): the optional heading, then the product cards laid out by
|
|
1551
|
+
* `data-columns`. With no products it draws only its wrapper.
|
|
1552
|
+
*
|
|
1553
|
+
* @since 1.0.0
|
|
1554
|
+
*/
|
|
1555
|
+
|
|
1556
|
+
/**
|
|
1557
|
+
* Props for {@link ProductGrid}.
|
|
1558
|
+
*
|
|
1559
|
+
* @since 1.0.0
|
|
1560
|
+
*/
|
|
1561
|
+
interface ProductGridProps {
|
|
1562
|
+
grid: StorefrontProductGrid;
|
|
1563
|
+
/** What the grid shows (`featured`, `category`, …), for `data-product-grid`. */
|
|
1564
|
+
source?: string;
|
|
1565
|
+
/** The heading's id. Generated when omitted. */
|
|
1566
|
+
headingId?: string;
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* A product grid.
|
|
1570
|
+
*
|
|
1571
|
+
* @since 1.0.0
|
|
1572
|
+
*
|
|
1573
|
+
* @param props - The grid.
|
|
1574
|
+
* @returns The grid.
|
|
1575
|
+
*/
|
|
1576
|
+
declare function ProductGrid({ grid, source, headingId }: ProductGridProps): ReactElement;
|
|
1577
|
+
|
|
1578
|
+
/**
|
|
1579
|
+
* The storefront's breadcrumbs: the design-system Breadcrumbs with plain
|
|
1580
|
+
* links, as Livewire's `navigate="false"`.
|
|
1581
|
+
*
|
|
1582
|
+
* @since 1.0.0
|
|
1583
|
+
*/
|
|
1584
|
+
|
|
1585
|
+
/**
|
|
1586
|
+
* Props for {@link StorefrontBreadcrumbs}.
|
|
1587
|
+
*
|
|
1588
|
+
* @since 1.0.0
|
|
1589
|
+
*/
|
|
1590
|
+
interface StorefrontBreadcrumbsProps {
|
|
1591
|
+
/** The trail; the current page's has no URL. */
|
|
1592
|
+
items: StorefrontBreadcrumb[];
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Breadcrumbs.
|
|
1596
|
+
*
|
|
1597
|
+
* @since 1.0.0
|
|
1598
|
+
*
|
|
1599
|
+
* @param props - The trail.
|
|
1600
|
+
* @returns The breadcrumbs.
|
|
1601
|
+
*/
|
|
1602
|
+
declare function StorefrontBreadcrumbs({ items }: StorefrontBreadcrumbsProps): ReactElement;
|
|
1603
|
+
|
|
1604
|
+
/**
|
|
1605
|
+
* Listing URLs and filter state.
|
|
1606
|
+
*
|
|
1607
|
+
* The server sends a listing's normalised query-string `state` (defaults
|
|
1608
|
+
* left out) and its `urls.base`. Changing the sort, the page size or a
|
|
1609
|
+
* filter starts over at page 1, so these helpers build the next URL from
|
|
1610
|
+
* the state without `page`, as ecommerce-storefront-inertia's
|
|
1611
|
+
* `CatalogListing::url()` does (PHP's `http_build_query()`).
|
|
1612
|
+
*
|
|
1613
|
+
* @since 1.0.0
|
|
1614
|
+
*/
|
|
1615
|
+
|
|
1616
|
+
/**
|
|
1617
|
+
* A listing's state, plus the page.
|
|
1618
|
+
*
|
|
1619
|
+
* @since 1.0.0
|
|
1620
|
+
*/
|
|
1621
|
+
type ListingQuery = StorefrontListingState & {
|
|
1622
|
+
page?: number;
|
|
1623
|
+
};
|
|
1624
|
+
/**
|
|
1625
|
+
* The query string for a state.
|
|
1626
|
+
*
|
|
1627
|
+
* @since 1.0.0
|
|
1628
|
+
*
|
|
1629
|
+
* @param query - The state.
|
|
1630
|
+
* @returns The query string, without `?`.
|
|
1631
|
+
*/
|
|
1632
|
+
declare function buildQuery(query: ListingQuery): string;
|
|
1633
|
+
/**
|
|
1634
|
+
* A listing URL.
|
|
1635
|
+
*
|
|
1636
|
+
* @since 1.0.0
|
|
1637
|
+
*
|
|
1638
|
+
* @param base - The page's URL without a query string.
|
|
1639
|
+
* @param query - The state.
|
|
1640
|
+
* @returns The URL.
|
|
1641
|
+
*/
|
|
1642
|
+
declare function listingUrl(base: string, query: ListingQuery): string;
|
|
1643
|
+
/**
|
|
1644
|
+
* The value a single-choice filter group has in the state.
|
|
1645
|
+
*
|
|
1646
|
+
* @since 1.0.0
|
|
1647
|
+
*
|
|
1648
|
+
* @param state - The state.
|
|
1649
|
+
* @param group - The group.
|
|
1650
|
+
* @returns The chosen value; `''` (or `'0'` for the rating) for "All".
|
|
1651
|
+
*/
|
|
1652
|
+
declare function choiceValue(state: StorefrontListingState, group: StorefrontFilterGroup): string;
|
|
1653
|
+
/**
|
|
1654
|
+
* The values a multi-choice filter group has in the state.
|
|
1655
|
+
*
|
|
1656
|
+
* @since 1.0.0
|
|
1657
|
+
*
|
|
1658
|
+
* @param state - The state.
|
|
1659
|
+
* @param group - The group.
|
|
1660
|
+
* @returns The chosen values.
|
|
1661
|
+
*/
|
|
1662
|
+
declare function optionValues(state: StorefrontListingState, group: StorefrontFilterGroup): string[];
|
|
1663
|
+
/**
|
|
1664
|
+
* Whether a toggle filter group is on in the state.
|
|
1665
|
+
*
|
|
1666
|
+
* @since 1.0.0
|
|
1667
|
+
*
|
|
1668
|
+
* @param state - The state.
|
|
1669
|
+
* @param group - The group.
|
|
1670
|
+
* @returns True when on.
|
|
1671
|
+
*/
|
|
1672
|
+
declare function toggleValue(state: StorefrontListingState, group: StorefrontFilterGroup): boolean;
|
|
1673
|
+
/**
|
|
1674
|
+
* The state with a single-choice group set (`''` or `'0'` clears it).
|
|
1675
|
+
*
|
|
1676
|
+
* @since 1.0.0
|
|
1677
|
+
*
|
|
1678
|
+
* @param state - The state.
|
|
1679
|
+
* @param group - The group.
|
|
1680
|
+
* @param value - The chosen value.
|
|
1681
|
+
* @returns The new state.
|
|
1682
|
+
*/
|
|
1683
|
+
declare function withChoice(state: StorefrontListingState, group: StorefrontFilterGroup, value: string): StorefrontListingState;
|
|
1684
|
+
/**
|
|
1685
|
+
* The state with one option of a multi-choice group turned on or off.
|
|
1686
|
+
*
|
|
1687
|
+
* @since 1.0.0
|
|
1688
|
+
*
|
|
1689
|
+
* @param state - The state.
|
|
1690
|
+
* @param group - The group.
|
|
1691
|
+
* @param value - The option.
|
|
1692
|
+
* @param checked - Whether it is now on.
|
|
1693
|
+
* @returns The new state.
|
|
1694
|
+
*/
|
|
1695
|
+
declare function withOption(state: StorefrontListingState, group: StorefrontFilterGroup, value: string, checked: boolean): StorefrontListingState;
|
|
1696
|
+
/**
|
|
1697
|
+
* The state with a toggle group turned on or off.
|
|
1698
|
+
*
|
|
1699
|
+
* @since 1.0.0
|
|
1700
|
+
*
|
|
1701
|
+
* @param state - The state.
|
|
1702
|
+
* @param group - The group.
|
|
1703
|
+
* @param on - Whether it is now on.
|
|
1704
|
+
* @returns The new state.
|
|
1705
|
+
*/
|
|
1706
|
+
declare function withToggle(state: StorefrontListingState, group: StorefrontFilterGroup, on: boolean): StorefrontListingState;
|
|
1707
|
+
/**
|
|
1708
|
+
* The state with the price bounds set (minor units; null leaves an end open).
|
|
1709
|
+
*
|
|
1710
|
+
* @since 1.0.0
|
|
1711
|
+
*
|
|
1712
|
+
* @param state - The state.
|
|
1713
|
+
* @param from - The lowest price, or null.
|
|
1714
|
+
* @param to - The highest price, or null.
|
|
1715
|
+
* @param currency - The listing's currency.
|
|
1716
|
+
* @returns The new state.
|
|
1717
|
+
*/
|
|
1718
|
+
declare function withPrice(state: StorefrontListingState, from: number | null, to: number | null, currency: string): StorefrontListingState;
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
* A product card's quick add, as Livewire's `AddsToCart::quickAdd()`.
|
|
1722
|
+
*
|
|
1723
|
+
* Posts the product to the listing's `addToCartUrl`. The server answers
|
|
1724
|
+
* with a redirect back, a toast, the new cart count, and `cart.open` when
|
|
1725
|
+
* `cart.after_add` opens the drawer. The card's button is disabled while
|
|
1726
|
+
* its add is on its way.
|
|
1727
|
+
*
|
|
1728
|
+
* @since 1.0.0
|
|
1729
|
+
*/
|
|
1730
|
+
|
|
1731
|
+
/**
|
|
1732
|
+
* The quick add state.
|
|
1733
|
+
*
|
|
1734
|
+
* @since 1.0.0
|
|
1735
|
+
*/
|
|
1736
|
+
interface QuickAdd {
|
|
1737
|
+
/** The id of the product being added, or null. */
|
|
1738
|
+
pending: number | null;
|
|
1739
|
+
/** Adds a card's product to the cart. */
|
|
1740
|
+
add: (card: StorefrontProductCard) => void;
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Quick add for a listing.
|
|
1744
|
+
*
|
|
1745
|
+
* @since 1.0.0
|
|
1746
|
+
*
|
|
1747
|
+
* @param url - Where the add posts, or null when adding isn't available.
|
|
1748
|
+
* @returns The quick add state.
|
|
1749
|
+
*/
|
|
1750
|
+
declare function useQuickAdd(url: string | null): QuickAdd;
|
|
1751
|
+
|
|
1752
|
+
/**
|
|
1753
|
+
* The add-to-cart row every purchase form ends with.
|
|
1754
|
+
*
|
|
1755
|
+
* Mirrors ecommerce-storefront-livewire's
|
|
1756
|
+
* `livewire/product/forms/partials/add-to-cart`: the quantity stepper and
|
|
1757
|
+
* the "Add to cart" button (with the line price), the buttons satellites add
|
|
1758
|
+
* beside it (`addToCartActions`), why the button is disabled, and the live
|
|
1759
|
+
* regions that say what the last add did. On a sold-out product whose form
|
|
1760
|
+
* offers it (`backInStock`), the "Notify me" signup replaces the row.
|
|
1761
|
+
*
|
|
1762
|
+
* @since 1.0.0
|
|
1763
|
+
*/
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* Props for {@link AddToCart}.
|
|
1767
|
+
*
|
|
1768
|
+
* @since 1.0.0
|
|
1769
|
+
*/
|
|
1770
|
+
interface AddToCartProps {
|
|
1771
|
+
/** The form's props. */
|
|
1772
|
+
form: StorefrontPurchaseFormBase;
|
|
1773
|
+
/** The form's id prefix, `ec-product-{id}`. */
|
|
1774
|
+
formId: string;
|
|
1775
|
+
/** The chosen quantity. */
|
|
1776
|
+
quantity: number | null;
|
|
1777
|
+
/** Called with a new quantity. */
|
|
1778
|
+
onQuantityChange: (quantity: number | null) => void;
|
|
1779
|
+
/** Adds to the cart. */
|
|
1780
|
+
onAdd: () => void;
|
|
1781
|
+
/** An add is running. */
|
|
1782
|
+
processing: boolean;
|
|
1783
|
+
/** Shows the quantity stepper (and `form.showQuantity` must allow it). */
|
|
1784
|
+
showQuantity?: boolean;
|
|
1785
|
+
/** The button's text; "Add to cart" by default. */
|
|
1786
|
+
buttonLabel?: string;
|
|
1787
|
+
/** Adds the line price to the button. */
|
|
1788
|
+
priceOnButton?: boolean;
|
|
1789
|
+
/** Replaces `form.blockedReason`. */
|
|
1790
|
+
blockedReason?: string | null;
|
|
1791
|
+
/** Extra fields the "Notify me" signup posts (the variable form's `selected`). */
|
|
1792
|
+
notifyData?: Record<string, unknown>;
|
|
1793
|
+
}
|
|
1794
|
+
/**
|
|
1795
|
+
* The add-to-cart row.
|
|
1796
|
+
*
|
|
1797
|
+
* @since 1.0.0
|
|
1798
|
+
*
|
|
1799
|
+
* @param props - The row's props.
|
|
1800
|
+
* @returns The row.
|
|
1801
|
+
*/
|
|
1802
|
+
declare function AddToCart({ form, formId, quantity, onQuantityChange, onAdd, processing, showQuantity, buttonLabel, priceOnButton, blockedReason, notifyData, }: AddToCartProps): ReactElement;
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* What a purchase form needs from the page around it.
|
|
1806
|
+
*
|
|
1807
|
+
* Registered forms receive only their own props (`form.props`), as third-party
|
|
1808
|
+
* forms do. The product page adds the rest here: the previous request's
|
|
1809
|
+
* feedback (the "Added to your cart" announcement, a finished "Notify me"
|
|
1810
|
+
* signup) and the product's URL and variant, so the variable form can follow
|
|
1811
|
+
* the shopper's choice with `?variant=`. Outside a product page (a block, a
|
|
1812
|
+
* story) the defaults apply.
|
|
1813
|
+
*
|
|
1814
|
+
* @since 1.0.0
|
|
1815
|
+
*/
|
|
1816
|
+
/**
|
|
1817
|
+
* The purchase form's page context.
|
|
1818
|
+
*
|
|
1819
|
+
* @since 1.0.0
|
|
1820
|
+
*/
|
|
1821
|
+
interface PurchaseFormContextValue {
|
|
1822
|
+
/** The product's name, for the steppers' labels. */
|
|
1823
|
+
productName: string | null;
|
|
1824
|
+
/** The product page's URL, without a query string. */
|
|
1825
|
+
productUrl: string | null;
|
|
1826
|
+
/** The variant in the page's `?variant=`. */
|
|
1827
|
+
variantId: number | null;
|
|
1828
|
+
/** "Added to your cart.", for the form's live region. */
|
|
1829
|
+
announcement: string | null;
|
|
1830
|
+
/** The "Notify me" signup just succeeded. */
|
|
1831
|
+
notifySubscribed: boolean;
|
|
1832
|
+
/**
|
|
1833
|
+
* The Add-to-Cart block's button text, replacing "Add to cart" (and the
|
|
1834
|
+
* grouped and bundled forms' own labels); null for the default.
|
|
1835
|
+
*/
|
|
1836
|
+
buttonText?: string | null;
|
|
1837
|
+
}
|
|
1838
|
+
/**
|
|
1839
|
+
* The purchase form's page context.
|
|
1840
|
+
*
|
|
1841
|
+
* @since 1.0.0
|
|
1842
|
+
*/
|
|
1843
|
+
declare const PurchaseFormContext: react.Context<PurchaseFormContextValue>;
|
|
1844
|
+
/**
|
|
1845
|
+
* Reads the purchase form's page context.
|
|
1846
|
+
*
|
|
1847
|
+
* @since 1.0.0
|
|
1848
|
+
*
|
|
1849
|
+
* @returns The context.
|
|
1850
|
+
*/
|
|
1851
|
+
declare function usePurchaseFormContext(): PurchaseFormContextValue;
|
|
1852
|
+
|
|
1853
|
+
/**
|
|
1854
|
+
* The requests storefront components send, wherever they are drawn.
|
|
1855
|
+
*
|
|
1856
|
+
* On a storefront page these are Inertia's `router` visits. A commerce
|
|
1857
|
+
* block on a page the storefront didn't render can't reload the storefront
|
|
1858
|
+
* page's props: on a CMS page Inertia draws, its writes are Inertia visits
|
|
1859
|
+
* without `only` (the server redirects back to the CMS page), and outside
|
|
1860
|
+
* Inertia they are JSON requests. Either way the block then fetches its
|
|
1861
|
+
* own props again, and a GET (a filter, a review page) only refetches the
|
|
1862
|
+
* block with the new query.
|
|
1863
|
+
*
|
|
1864
|
+
* @internal
|
|
1865
|
+
*/
|
|
1866
|
+
/**
|
|
1867
|
+
* The visit options storefront components use.
|
|
1868
|
+
*
|
|
1869
|
+
* @internal
|
|
1870
|
+
*/
|
|
1871
|
+
interface StorefrontVisitOptions {
|
|
1872
|
+
data?: Record<string, unknown>;
|
|
1873
|
+
only?: string[];
|
|
1874
|
+
except?: string[];
|
|
1875
|
+
errorBag?: string;
|
|
1876
|
+
preserveScroll?: boolean;
|
|
1877
|
+
preserveState?: boolean | 'errors';
|
|
1878
|
+
replace?: boolean;
|
|
1879
|
+
onStart?: () => void;
|
|
1880
|
+
onFinish?: () => void;
|
|
1881
|
+
onSuccess?: () => void;
|
|
1882
|
+
onError?: (errors: Record<string, string>) => void;
|
|
1883
|
+
}
|
|
1884
|
+
/**
|
|
1885
|
+
* The visits storefront components send.
|
|
1886
|
+
*
|
|
1887
|
+
* @internal
|
|
1888
|
+
*/
|
|
1889
|
+
interface StorefrontRouter {
|
|
1890
|
+
get: (url: string, data?: Record<string, unknown>, options?: StorefrontVisitOptions) => void;
|
|
1891
|
+
post: (url: string, data?: Record<string, unknown>, options?: StorefrontVisitOptions) => void;
|
|
1892
|
+
patch: (url: string, data?: Record<string, unknown>, options?: StorefrontVisitOptions) => void;
|
|
1893
|
+
delete: (url: string, options?: StorefrontVisitOptions) => void;
|
|
1894
|
+
reload: (options?: StorefrontVisitOptions) => void;
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
/**
|
|
1898
|
+
* Shared plumbing for the product page, its purchase forms and sections:
|
|
1899
|
+
* the JSON calls (purchase form redraws, recently viewed), the Inertia
|
|
1900
|
+
* error bags that keep the form's and the review form's errors apart, and
|
|
1901
|
+
* the posts that add to the cart.
|
|
1902
|
+
*
|
|
1903
|
+
* @since 1.0.0
|
|
1904
|
+
*/
|
|
1905
|
+
|
|
1906
|
+
/**
|
|
1907
|
+
* The error bag the purchase form and the "Notify me" signup post with.
|
|
1908
|
+
*
|
|
1909
|
+
* Livewire scoped each component's errors to it; Inertia shares one
|
|
1910
|
+
* `errors` prop per page, so the product page's forms each post with an
|
|
1911
|
+
* error bag (`X-Inertia-Error-Bag`) and read only their own.
|
|
1912
|
+
*
|
|
1913
|
+
* @since 1.0.0
|
|
1914
|
+
*/
|
|
1915
|
+
declare const PURCHASE_ERROR_BAG = "purchase";
|
|
1916
|
+
/**
|
|
1917
|
+
* The error bag the review form posts with.
|
|
1918
|
+
*
|
|
1919
|
+
* @since 1.0.0
|
|
1920
|
+
*/
|
|
1921
|
+
declare const REVIEW_ERROR_BAG = "review";
|
|
1922
|
+
/**
|
|
1923
|
+
* The props a write on the product page reloads: the shared props (the
|
|
1924
|
+
* header count, toasts and `cart.open`), the cart drawer, and the page's
|
|
1925
|
+
* own props the write can change.
|
|
1926
|
+
*
|
|
1927
|
+
* Not the purchase form (`form`): a write that fails validation redirects
|
|
1928
|
+
* back with these props, and a freshly presented form would replace what
|
|
1929
|
+
* the shopper chose and typed. {@link PURCHASE_SUCCESS_RELOAD} reloads it
|
|
1930
|
+
* after a write that worked.
|
|
1931
|
+
*
|
|
1932
|
+
* @since 1.0.0
|
|
1933
|
+
*/
|
|
1934
|
+
declare const PURCHASE_RELOAD: string[];
|
|
1935
|
+
/**
|
|
1936
|
+
* The props reloaded after a product page write that worked: the purchase
|
|
1937
|
+
* form, presented again for the stock and cart the add left.
|
|
1938
|
+
*
|
|
1939
|
+
* @since 1.0.0
|
|
1940
|
+
*/
|
|
1941
|
+
declare const PURCHASE_SUCCESS_RELOAD: string[];
|
|
1942
|
+
/**
|
|
1943
|
+
* The errors in one error bag of the page's `errors` prop.
|
|
1944
|
+
*
|
|
1945
|
+
* @since 1.0.0
|
|
1946
|
+
*
|
|
1947
|
+
* @param bag - The bag's name.
|
|
1948
|
+
* @returns The bag's errors, keyed by field.
|
|
1949
|
+
*/
|
|
1950
|
+
declare function useErrorBag(bag: string): Record<string, string>;
|
|
1951
|
+
/**
|
|
1952
|
+
* Sends a JSON request to one of the storefront's JSON routes.
|
|
1953
|
+
*
|
|
1954
|
+
* A throttled answer (429) shows the toasts it carries and resolves null,
|
|
1955
|
+
* as does any other failure.
|
|
1956
|
+
*
|
|
1957
|
+
* @since 1.0.0
|
|
1958
|
+
*
|
|
1959
|
+
* @param url - The route's URL.
|
|
1960
|
+
* @param body - The JSON body for a POST, or undefined for a GET.
|
|
1961
|
+
* @param signal - Aborts the request.
|
|
1962
|
+
* @returns The decoded JSON, or null.
|
|
1963
|
+
*/
|
|
1964
|
+
declare function requestJson<T>(url: string, body?: unknown, signal?: AbortSignal): Promise<T | null>;
|
|
1965
|
+
/**
|
|
1966
|
+
* A unit price times a quantity, formatted in the shopper's locale.
|
|
1967
|
+
*
|
|
1968
|
+
* @since 1.0.0
|
|
1969
|
+
*
|
|
1970
|
+
* @param unit - One unit's price.
|
|
1971
|
+
* @param quantity - How many.
|
|
1972
|
+
* @param locale - The locale.
|
|
1973
|
+
* @returns The line price, or null without a price or a quantity.
|
|
1974
|
+
*/
|
|
1975
|
+
declare function linePrice(unit: StorefrontMoney | null, quantity: number | null, locale: string): string | null;
|
|
1976
|
+
/**
|
|
1977
|
+
* Posts a write from the product page with Inertia, in an error bag,
|
|
1978
|
+
* keeping the page's state and scroll.
|
|
1979
|
+
*
|
|
1980
|
+
* @since 1.0.0
|
|
1981
|
+
*
|
|
1982
|
+
* @param bag - The error bag.
|
|
1983
|
+
* @returns `post(url, data, only?, onSuccess?)` and whether a post is running.
|
|
1984
|
+
*/
|
|
1985
|
+
declare function useStorefrontPost(bag: string): {
|
|
1986
|
+
post: (url: string, data: Record<string, unknown>, only?: string[], onSuccess?: () => void) => void;
|
|
1987
|
+
processing: boolean;
|
|
1988
|
+
};
|
|
1989
|
+
/**
|
|
1990
|
+
* Visits the current page again with changed query parameters, reloading
|
|
1991
|
+
* only some props (the reviews filter and page).
|
|
1992
|
+
*
|
|
1993
|
+
* @since 1.0.0
|
|
1994
|
+
*
|
|
1995
|
+
* @param currentUrl - The page's URL, as Inertia has it.
|
|
1996
|
+
* @param query - Parameters to set; null removes one.
|
|
1997
|
+
* @param only - The props to reload.
|
|
1998
|
+
* @param visits - The router to visit with (a block's, from `useStorefrontRouter()`); Inertia's by default.
|
|
1999
|
+
*/
|
|
2000
|
+
declare function visitWithQuery(currentUrl: string, query: Record<string, string | number | null>, only: string[], visits?: StorefrontRouter): void;
|
|
2001
|
+
|
|
2002
|
+
/**
|
|
2003
|
+
* Registers the product page's built-in client components: the core
|
|
2004
|
+
* purchase forms (`productForms`) and the built-in sections and sold-out
|
|
2005
|
+
* notice (`productSections`). The cart's cross-sells are in cart/builtIns.ts.
|
|
2006
|
+
*
|
|
2007
|
+
* The page wrapper adds them before the first page renders (see
|
|
2008
|
+
* src/builtIns.ts); the modules that draw these registries also call
|
|
2009
|
+
* {@link registerProductBuiltIns} at load (the product page,
|
|
2010
|
+
* {@link StorefrontSections}), for use outside a page.
|
|
2011
|
+
*
|
|
2012
|
+
* @since 1.0.0
|
|
2013
|
+
*/
|
|
2014
|
+
/**
|
|
2015
|
+
* Adds the built-in registrations once.
|
|
2016
|
+
*
|
|
2017
|
+
* @since 1.0.0
|
|
2018
|
+
*/
|
|
2019
|
+
declare function registerProductBuiltIns(): void;
|
|
2020
|
+
|
|
2021
|
+
/**
|
|
2022
|
+
* Draws a page's sections from a client registry: the product page's
|
|
2023
|
+
* sections (`productSections`) and the cart's (`cartSections`).
|
|
2024
|
+
*
|
|
2025
|
+
* Each section is `{ key, component, props }`; the component registered
|
|
2026
|
+
* under `component` gets the section's props and `sectionKey`, plus any
|
|
2027
|
+
* `extra` props the page adds. A section whose component isn't registered
|
|
2028
|
+
* draws nothing.
|
|
2029
|
+
*
|
|
2030
|
+
* @since 1.0.0
|
|
2031
|
+
*/
|
|
2032
|
+
|
|
2033
|
+
/**
|
|
2034
|
+
* Props for {@link StorefrontSections}.
|
|
2035
|
+
*
|
|
2036
|
+
* @since 1.0.0
|
|
2037
|
+
*/
|
|
2038
|
+
interface StorefrontSectionsProps {
|
|
2039
|
+
/** The sections, in order. */
|
|
2040
|
+
sections: StorefrontProductSection[];
|
|
2041
|
+
/** Which registry draws them. */
|
|
2042
|
+
registry: keyof Pick<ReactStorefrontRegistries, 'productSections' | 'cartSections'>;
|
|
2043
|
+
/** The wrapper's class (`ec-product__section`) and data attribute name. */
|
|
2044
|
+
className?: string;
|
|
2045
|
+
/** The data attribute naming each wrapper's key, such as `data-product-section`. */
|
|
2046
|
+
keyAttribute?: string;
|
|
2047
|
+
/** Props every section gets as well. */
|
|
2048
|
+
extra?: Record<string, unknown>;
|
|
2049
|
+
}
|
|
2050
|
+
/**
|
|
2051
|
+
* The sections.
|
|
2052
|
+
*
|
|
2053
|
+
* @since 1.0.0
|
|
2054
|
+
*
|
|
2055
|
+
* @param props - The sections and their registry.
|
|
2056
|
+
* @returns One wrapper per drawn section.
|
|
2057
|
+
*/
|
|
2058
|
+
declare function StorefrontSections({ sections, registry, className, keyAttribute, extra, }: StorefrontSectionsProps): ReactElement;
|
|
2059
|
+
|
|
2060
|
+
/**
|
|
2061
|
+
* The `bundled` purchase form: the set's contents, its total and saving.
|
|
2062
|
+
*
|
|
2063
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/product/forms/bundled`.
|
|
2064
|
+
*
|
|
2065
|
+
* @since 1.0.0
|
|
2066
|
+
*/
|
|
2067
|
+
|
|
2068
|
+
/**
|
|
2069
|
+
* The bundled purchase form.
|
|
2070
|
+
*
|
|
2071
|
+
* @since 1.0.0
|
|
2072
|
+
*
|
|
2073
|
+
* @param props - The form's props.
|
|
2074
|
+
* @returns The form.
|
|
2075
|
+
*/
|
|
2076
|
+
declare function BundledForm(props: StorefrontBundledFormProps): ReactElement;
|
|
2077
|
+
|
|
2078
|
+
/**
|
|
2079
|
+
* The `digital` purchase form: the license choice and the download notes.
|
|
2080
|
+
*
|
|
2081
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/product/forms/digital`.
|
|
2082
|
+
*
|
|
2083
|
+
* @since 1.0.0
|
|
2084
|
+
*/
|
|
2085
|
+
|
|
2086
|
+
/**
|
|
2087
|
+
* The digital purchase form.
|
|
2088
|
+
*
|
|
2089
|
+
* @since 1.0.0
|
|
2090
|
+
*
|
|
2091
|
+
* @param props - The form's props.
|
|
2092
|
+
* @returns The form.
|
|
2093
|
+
*/
|
|
2094
|
+
declare function DigitalForm(props: StorefrontDigitalFormProps): ReactElement;
|
|
2095
|
+
|
|
2096
|
+
/**
|
|
2097
|
+
* The `grouped` purchase form: a quantity per child product.
|
|
2098
|
+
*
|
|
2099
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/product/forms/grouped`:
|
|
2100
|
+
* a table of the group's products with a quantity box per buyable row, the
|
|
2101
|
+
* running item count and total, and "Add selected to cart".
|
|
2102
|
+
*
|
|
2103
|
+
* @since 1.0.0
|
|
2104
|
+
*/
|
|
2105
|
+
|
|
2106
|
+
/**
|
|
2107
|
+
* The item count and total of the chosen quantities.
|
|
2108
|
+
*
|
|
2109
|
+
* @since 1.0.0
|
|
2110
|
+
*
|
|
2111
|
+
* @param rows - The form's rows.
|
|
2112
|
+
* @param quantities - Row id to quantity.
|
|
2113
|
+
* @param locale - The shopper's locale.
|
|
2114
|
+
* @returns The count, and the total (null when a chosen row has no unit price).
|
|
2115
|
+
*/
|
|
2116
|
+
declare function groupedSummary(rows: StorefrontGroupedRow[], quantities: Record<string, number | null>, locale: string): {
|
|
2117
|
+
count: number;
|
|
2118
|
+
total: string | null;
|
|
2119
|
+
};
|
|
2120
|
+
/**
|
|
2121
|
+
* The grouped purchase form.
|
|
2122
|
+
*
|
|
2123
|
+
* @since 1.0.0
|
|
2124
|
+
*
|
|
2125
|
+
* @param props - The form's props.
|
|
2126
|
+
* @returns The form.
|
|
2127
|
+
*/
|
|
2128
|
+
declare function GroupedForm(props: StorefrontGroupedFormProps): ReactElement;
|
|
2129
|
+
|
|
2130
|
+
/**
|
|
2131
|
+
* The `options` purchase form: a product type's storefront options.
|
|
2132
|
+
*
|
|
2133
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/product/forms/options`:
|
|
2134
|
+
* one field per visible option (text, textarea, number, quantity, select,
|
|
2135
|
+
* radio or choice cards, swatches, checkbox, or an info row), a character
|
|
2136
|
+
* count for limited text, and the engine's quote when the form shows one.
|
|
2137
|
+
* A reactive form posts its options to `optionsUrl` on each change and
|
|
2138
|
+
* redraws from the answer (which fields show, what's disabled, the quote).
|
|
2139
|
+
*
|
|
2140
|
+
* @since 1.0.0
|
|
2141
|
+
*/
|
|
2142
|
+
|
|
2143
|
+
/**
|
|
2144
|
+
* Reads a value by its dot-notation field name, from flat or nested values.
|
|
2145
|
+
*
|
|
2146
|
+
* @since 1.0.0
|
|
2147
|
+
*
|
|
2148
|
+
* @param values - The values.
|
|
2149
|
+
* @param name - The field name, such as `engraving.text`.
|
|
2150
|
+
* @returns The value, or undefined.
|
|
2151
|
+
*/
|
|
2152
|
+
declare function optionValue(values: Record<string, unknown>, name: string): unknown;
|
|
2153
|
+
/**
|
|
2154
|
+
* Sets a value by its dot-notation field name, nesting as Laravel reads
|
|
2155
|
+
* `options.{name}`.
|
|
2156
|
+
*
|
|
2157
|
+
* @since 1.0.0
|
|
2158
|
+
*
|
|
2159
|
+
* @param values - The nested values.
|
|
2160
|
+
* @param name - The field name.
|
|
2161
|
+
* @param value - The value.
|
|
2162
|
+
* @returns A copy with the value set.
|
|
2163
|
+
*/
|
|
2164
|
+
declare function withOptionValue(values: Record<string, unknown>, name: string, value: unknown): Record<string, unknown>;
|
|
2165
|
+
/**
|
|
2166
|
+
* The options purchase form.
|
|
2167
|
+
*
|
|
2168
|
+
* @since 1.0.0
|
|
2169
|
+
*
|
|
2170
|
+
* @param props - The form's props.
|
|
2171
|
+
* @returns The form.
|
|
2172
|
+
*/
|
|
2173
|
+
declare function OptionsForm(props: StorefrontOptionsFormProps): ReactElement;
|
|
2174
|
+
|
|
2175
|
+
/**
|
|
2176
|
+
* The `simple` purchase form: a quantity and "Add to cart".
|
|
2177
|
+
*
|
|
2178
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/product/forms/simple`.
|
|
2179
|
+
*
|
|
2180
|
+
* @since 1.0.0
|
|
2181
|
+
*/
|
|
2182
|
+
|
|
2183
|
+
/**
|
|
2184
|
+
* The simple purchase form.
|
|
2185
|
+
*
|
|
2186
|
+
* @since 1.0.0
|
|
2187
|
+
*
|
|
2188
|
+
* @param props - The form's props.
|
|
2189
|
+
* @returns The form.
|
|
2190
|
+
*/
|
|
2191
|
+
declare function SimpleForm(props: StorefrontSimpleFormProps): ReactElement;
|
|
2192
|
+
|
|
2193
|
+
/**
|
|
2194
|
+
* The `variable` purchase form: a swatch group or a select per attribute.
|
|
2195
|
+
*
|
|
2196
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/product/forms/variable`.
|
|
2197
|
+
* A choice posts the selection to the form's `optionsUrl`, which answers
|
|
2198
|
+
* the redrawn form (availability, a cleared choice and its notice, the
|
|
2199
|
+
* matching variant); a new variant then reloads the page's price, stock and
|
|
2200
|
+
* gallery with `?variant=`, as the Livewire page follows the choice.
|
|
2201
|
+
*
|
|
2202
|
+
* @since 1.0.0
|
|
2203
|
+
*/
|
|
2204
|
+
|
|
2205
|
+
/**
|
|
2206
|
+
* The page props a variant change reloads.
|
|
2207
|
+
*
|
|
2208
|
+
* Not the form itself: the redraw already holds it, and the page presents
|
|
2209
|
+
* the form from the URL's `?variant=` alone, so a choice that leaves no
|
|
2210
|
+
* full variant would come back as an empty selection and lose the choice
|
|
2211
|
+
* and its notice.
|
|
2212
|
+
*
|
|
2213
|
+
* @since 1.0.0
|
|
2214
|
+
*/
|
|
2215
|
+
declare const VARIANT_RELOAD: string[];
|
|
2216
|
+
/**
|
|
2217
|
+
* The variable purchase form.
|
|
2218
|
+
*
|
|
2219
|
+
* @since 1.0.0
|
|
2220
|
+
*
|
|
2221
|
+
* @param props - The form's props.
|
|
2222
|
+
* @returns The form.
|
|
2223
|
+
*/
|
|
2224
|
+
declare function VariableForm(props: StorefrontVariableFormProps): ReactElement;
|
|
2225
|
+
|
|
2226
|
+
/**
|
|
2227
|
+
* The core purchase forms, registered in the `productForms` registry under
|
|
2228
|
+
* the product type keys the server's `ProductFormRegistry` uses.
|
|
2229
|
+
*
|
|
2230
|
+
* @since 1.0.0
|
|
2231
|
+
*/
|
|
2232
|
+
|
|
2233
|
+
/**
|
|
2234
|
+
* The core forms by key.
|
|
2235
|
+
*
|
|
2236
|
+
* @since 1.0.0
|
|
2237
|
+
*/
|
|
2238
|
+
declare const CORE_PRODUCT_FORMS: {
|
|
2239
|
+
readonly simple: typeof SimpleForm;
|
|
2240
|
+
readonly variable: typeof VariableForm;
|
|
2241
|
+
readonly grouped: typeof GroupedForm;
|
|
2242
|
+
readonly bundled: typeof BundledForm;
|
|
2243
|
+
readonly digital: typeof DigitalForm;
|
|
2244
|
+
readonly options: typeof OptionsForm;
|
|
2245
|
+
};
|
|
2246
|
+
/**
|
|
2247
|
+
* Registers the core purchase forms (positions 10, 20, …).
|
|
2248
|
+
*
|
|
2249
|
+
* @since 1.0.0
|
|
2250
|
+
*
|
|
2251
|
+
* @param registries - The client registries.
|
|
2252
|
+
*/
|
|
2253
|
+
declare function registerProductForms(registries: ReactStorefrontRegistries): void;
|
|
2254
|
+
|
|
2255
|
+
/**
|
|
2256
|
+
* The `reviews` product section.
|
|
2257
|
+
*
|
|
2258
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/product/reviews`: the
|
|
2259
|
+
* average and a rating breakdown that filters the list, the review form
|
|
2260
|
+
* (with its error summary and the guest name and email), the thank-you
|
|
2261
|
+
* notice that takes focus after a submit, and the paged list.
|
|
2262
|
+
*
|
|
2263
|
+
* Filtering and paging reload the page's `sections` with `?review-rating=`
|
|
2264
|
+
* and `?reviews-page=`; the form posts to `submitUrl` in its own error bag.
|
|
2265
|
+
*
|
|
2266
|
+
* @since 1.0.0
|
|
2267
|
+
*/
|
|
2268
|
+
|
|
2269
|
+
/**
|
|
2270
|
+
* The query parameter the rating filter uses.
|
|
2271
|
+
*
|
|
2272
|
+
* @since 1.0.0
|
|
2273
|
+
*/
|
|
2274
|
+
declare const REVIEW_RATING_QUERY = "review-rating";
|
|
2275
|
+
/**
|
|
2276
|
+
* Props for {@link Reviews}.
|
|
2277
|
+
*
|
|
2278
|
+
* @since 1.0.0
|
|
2279
|
+
*/
|
|
2280
|
+
interface ReviewsProps extends StorefrontProductReviews {
|
|
2281
|
+
/** The product's id, for the element ids. */
|
|
2282
|
+
productId?: number;
|
|
2283
|
+
/** A review was just submitted (the page's `feedback.reviewSubmitted`). */
|
|
2284
|
+
reviewSubmitted?: {
|
|
2285
|
+
published: boolean;
|
|
2286
|
+
} | null;
|
|
2287
|
+
/**
|
|
2288
|
+
* Whether the section offers the review form (the Reviews block's
|
|
2289
|
+
* `showForm`). Off, it drops the button, the thank-you notice and the
|
|
2290
|
+
* eligibility line.
|
|
2291
|
+
*/
|
|
2292
|
+
allowForm?: boolean;
|
|
2293
|
+
}
|
|
2294
|
+
/**
|
|
2295
|
+
* The reviews section.
|
|
2296
|
+
*
|
|
2297
|
+
* @since 1.0.0
|
|
2298
|
+
*
|
|
2299
|
+
* @param props - The reviews.
|
|
2300
|
+
* @returns The section.
|
|
2301
|
+
*/
|
|
2302
|
+
declare function Reviews({ productId, reviewSubmitted, allowForm, histogram, total, average, ratingFilter, reviews, pagination, canReview, reason, loginUrl, guest, honeypotName, submitUrl, }: ReviewsProps): ReactElement;
|
|
2303
|
+
|
|
2304
|
+
/**
|
|
2305
|
+
* The `related-products` section: upsells and related products on the
|
|
2306
|
+
* product page, the cart's cross-sells below the cart.
|
|
2307
|
+
*
|
|
2308
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/product/related-products`
|
|
2309
|
+
* (a scrolling row of product cards with previous and next buttons) and its
|
|
2310
|
+
* lazy placeholder. The suggestions arrive in the page's deferred
|
|
2311
|
+
* `relatedProducts` prop (group `related`), keyed by the section's key, so
|
|
2312
|
+
* the placeholder shows until Inertia has fetched them.
|
|
2313
|
+
*
|
|
2314
|
+
* @since 1.0.0
|
|
2315
|
+
*/
|
|
2316
|
+
|
|
2317
|
+
/**
|
|
2318
|
+
* Props for {@link RelatedProducts}.
|
|
2319
|
+
*
|
|
2320
|
+
* @since 1.0.0
|
|
2321
|
+
*/
|
|
2322
|
+
interface RelatedProductsProps {
|
|
2323
|
+
/** The section's key: its suggestions are `relatedProducts[sectionKey]`. */
|
|
2324
|
+
sectionKey: string;
|
|
2325
|
+
/** `related`, `upsell` or `cross_sell`. */
|
|
2326
|
+
type?: string;
|
|
2327
|
+
/** A heading in place of the type's. */
|
|
2328
|
+
heading?: string | null;
|
|
2329
|
+
/** Placeholder cards while loading (1–4). */
|
|
2330
|
+
limit?: number | null;
|
|
2331
|
+
/**
|
|
2332
|
+
* Columns from the section's params. The server applies them to the
|
|
2333
|
+
* suggestions (`related.columns`), which the row reads, so the section
|
|
2334
|
+
* itself doesn't need them.
|
|
2335
|
+
*/
|
|
2336
|
+
columns?: number | null;
|
|
2337
|
+
/** Where a card's "Add to cart" posts; defaults to the storefront's `cart/add`. */
|
|
2338
|
+
addToCartUrl?: string | null;
|
|
2339
|
+
}
|
|
2340
|
+
/**
|
|
2341
|
+
* The heading a related-products section shows before its suggestions load.
|
|
2342
|
+
*
|
|
2343
|
+
* @since 1.0.0
|
|
2344
|
+
*
|
|
2345
|
+
* @param type - The suggestion type.
|
|
2346
|
+
* @param onCart - Whether the section is below the cart.
|
|
2347
|
+
* @returns The heading.
|
|
2348
|
+
*/
|
|
2349
|
+
declare function relatedHeading(type: string | undefined, onCart: boolean): string;
|
|
2350
|
+
/**
|
|
2351
|
+
* The related-products section.
|
|
2352
|
+
*
|
|
2353
|
+
* @since 1.0.0
|
|
2354
|
+
*
|
|
2355
|
+
* @param props - The section's key and params.
|
|
2356
|
+
* @returns The section.
|
|
2357
|
+
*/
|
|
2358
|
+
declare function RelatedProducts({ sectionKey, type, heading, limit, addToCartUrl, }: RelatedProductsProps): ReactElement;
|
|
2359
|
+
/**
|
|
2360
|
+
* Props for {@link RelatedProductsRow}.
|
|
2361
|
+
*
|
|
2362
|
+
* @since 1.0.0
|
|
2363
|
+
*/
|
|
2364
|
+
interface RelatedProductsRowProps {
|
|
2365
|
+
/** The suggestions. */
|
|
2366
|
+
related: StorefrontRelatedProducts;
|
|
2367
|
+
/** Where a card's "Add to cart" posts. */
|
|
2368
|
+
addToCartUrl?: string | null;
|
|
2369
|
+
}
|
|
2370
|
+
/**
|
|
2371
|
+
* A row of suggestions (also the Related Products block).
|
|
2372
|
+
*
|
|
2373
|
+
* @since 1.0.0
|
|
2374
|
+
*
|
|
2375
|
+
* @param props - The suggestions.
|
|
2376
|
+
* @returns The row.
|
|
2377
|
+
*/
|
|
2378
|
+
declare function RelatedProductsRow({ related, addToCartUrl, }: RelatedProductsRowProps): ReactElement;
|
|
2379
|
+
/**
|
|
2380
|
+
* Props for {@link RelatedProductsPlaceholder}.
|
|
2381
|
+
*
|
|
2382
|
+
* @since 1.0.0
|
|
2383
|
+
*/
|
|
2384
|
+
interface RelatedProductsPlaceholderProps {
|
|
2385
|
+
/** The section's heading. */
|
|
2386
|
+
title: string;
|
|
2387
|
+
/** Skeleton cards (1–4). */
|
|
2388
|
+
count?: number;
|
|
2389
|
+
}
|
|
2390
|
+
/**
|
|
2391
|
+
* The skeleton row shown while the suggestions load.
|
|
2392
|
+
*
|
|
2393
|
+
* @since 1.0.0
|
|
2394
|
+
*
|
|
2395
|
+
* @param props - The heading and the number of cards.
|
|
2396
|
+
* @returns The placeholder.
|
|
2397
|
+
*/
|
|
2398
|
+
declare function RelatedProductsPlaceholder({ title, count, }: RelatedProductsPlaceholderProps): ReactElement;
|
|
2399
|
+
|
|
2400
|
+
/**
|
|
2401
|
+
* The recently viewed row.
|
|
2402
|
+
*
|
|
2403
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/product/recently-viewed`
|
|
2404
|
+
* and its placeholder: small cards (a thumbnail, the name and the price) for
|
|
2405
|
+
* the products the shopper looked at last, filled by the recently-viewed
|
|
2406
|
+
* satellite through the JSON `recently-viewed` route.
|
|
2407
|
+
*
|
|
2408
|
+
* Give it the row (`data`, as the Recently Viewed block's props carry it),
|
|
2409
|
+
* or the route to load it from; the placeholder shows while it loads.
|
|
2410
|
+
*
|
|
2411
|
+
* @since 1.0.0
|
|
2412
|
+
*/
|
|
2413
|
+
|
|
2414
|
+
/**
|
|
2415
|
+
* Props for {@link RecentlyViewed}.
|
|
2416
|
+
*
|
|
2417
|
+
* @since 1.0.0
|
|
2418
|
+
*/
|
|
2419
|
+
interface RecentlyViewedProps {
|
|
2420
|
+
/** The row, already loaded. */
|
|
2421
|
+
data?: StorefrontRecentlyViewed | null;
|
|
2422
|
+
/** The `recently-viewed` route; defaults to the storefront's. */
|
|
2423
|
+
url?: string | null;
|
|
2424
|
+
/** The product being viewed, left out of the row. */
|
|
2425
|
+
productId?: number | null;
|
|
2426
|
+
/** How many products (and placeholder cards). */
|
|
2427
|
+
limit?: number | null;
|
|
2428
|
+
/** Columns. */
|
|
2429
|
+
columns?: number | null;
|
|
2430
|
+
/** A heading in place of "Recently viewed". */
|
|
2431
|
+
heading?: string | null;
|
|
2432
|
+
/**
|
|
2433
|
+
* With `data`, load the row again from the route and show it in place of
|
|
2434
|
+
* `data` (the Recently Viewed block: its props were built when the page
|
|
2435
|
+
* was, and a page restored from history would show a stale row).
|
|
2436
|
+
*/
|
|
2437
|
+
refresh?: boolean;
|
|
2438
|
+
}
|
|
2439
|
+
/**
|
|
2440
|
+
* The recently viewed row.
|
|
2441
|
+
*
|
|
2442
|
+
* @since 1.0.0
|
|
2443
|
+
*
|
|
2444
|
+
* @param props - The row, or where to load it.
|
|
2445
|
+
* @returns The row, its placeholder, or its empty root.
|
|
2446
|
+
*/
|
|
2447
|
+
declare function RecentlyViewed({ data, url, productId, limit, columns, heading, refresh, }: RecentlyViewedProps): ReactElement;
|
|
2448
|
+
/**
|
|
2449
|
+
* Props for {@link RecentlyViewedPlaceholder}.
|
|
2450
|
+
*
|
|
2451
|
+
* @since 1.0.0
|
|
2452
|
+
*/
|
|
2453
|
+
interface RecentlyViewedPlaceholderProps {
|
|
2454
|
+
title: string;
|
|
2455
|
+
/** Skeleton cards (1–12). */
|
|
2456
|
+
count?: number;
|
|
2457
|
+
/** Columns (1–6). */
|
|
2458
|
+
columns?: number;
|
|
2459
|
+
}
|
|
2460
|
+
/**
|
|
2461
|
+
* The skeleton row shown while the products load.
|
|
2462
|
+
*
|
|
2463
|
+
* @since 1.0.0
|
|
2464
|
+
*
|
|
2465
|
+
* @param props - The heading, cards and columns.
|
|
2466
|
+
* @returns The placeholder.
|
|
2467
|
+
*/
|
|
2468
|
+
declare function RecentlyViewedPlaceholder({ title, count, columns, }: RecentlyViewedPlaceholderProps): ReactElement;
|
|
2469
|
+
|
|
2470
|
+
/**
|
|
2471
|
+
* The `sold-out` notice a sold-out product shows under its purchase form.
|
|
2472
|
+
*
|
|
2473
|
+
* Mirrors ecommerce-storefront-livewire's `livewire/product/partials/sold-out`.
|
|
2474
|
+
*
|
|
2475
|
+
* @since 1.0.0
|
|
2476
|
+
*/
|
|
2477
|
+
|
|
2478
|
+
/**
|
|
2479
|
+
* Props every `productSections` component drawing a sold-out notice gets.
|
|
2480
|
+
*
|
|
2481
|
+
* @since 1.0.0
|
|
2482
|
+
*/
|
|
2483
|
+
interface SoldOutNoticeProps {
|
|
2484
|
+
/**
|
|
2485
|
+
* The sold-out product's id. The built-in notice doesn't need it; a
|
|
2486
|
+
* notice of your own (a pre-order prompt, say) can use it.
|
|
2487
|
+
*/
|
|
2488
|
+
productId: number;
|
|
2489
|
+
}
|
|
2490
|
+
/**
|
|
2491
|
+
* The sold-out notice.
|
|
2492
|
+
*
|
|
2493
|
+
* @since 1.0.0
|
|
2494
|
+
*
|
|
2495
|
+
* @param _props - The product's id, which the built-in notice doesn't use.
|
|
2496
|
+
* @returns The notice.
|
|
2497
|
+
*/
|
|
2498
|
+
declare function SoldOutNotice(_props?: Partial<SoldOutNoticeProps>): ReactElement;
|
|
2499
|
+
|
|
2500
|
+
/**
|
|
2501
|
+
* The built-in product sections and notices (`productSections`). The cart's
|
|
2502
|
+
* cross-sells (`cartSections` `related-products`) register from
|
|
2503
|
+
* `cart/builtIns.ts`, so they exist when the cart is the first page.
|
|
2504
|
+
*
|
|
2505
|
+
* @since 1.0.0
|
|
2506
|
+
*/
|
|
2507
|
+
|
|
2508
|
+
/**
|
|
2509
|
+
* Registers `reviews`, `related-products`, `recently-viewed` and `sold-out`
|
|
2510
|
+
* in `productSections`.
|
|
2511
|
+
*
|
|
2512
|
+
* @since 1.0.0
|
|
2513
|
+
*
|
|
2514
|
+
* @param registries - The client registries.
|
|
2515
|
+
*/
|
|
2516
|
+
declare function registerProductSections(registries: ReactStorefrontRegistries): void;
|
|
2517
|
+
|
|
2518
|
+
/**
|
|
2519
|
+
* The cart: the cart page's body, and the Cart Contents block's.
|
|
2520
|
+
*
|
|
2521
|
+
* Mirrors ecommerce-storefront-livewire's `Cart/Index`. With `showTitle`
|
|
2522
|
+
* (the cart page), "Your cart" and the item count come first; after a
|
|
2523
|
+
* removal, a bar says what went with "Undo". Then the lines in a
|
|
2524
|
+
* design-system Card (thumbnail, name, options, the price each, any notice,
|
|
2525
|
+
* the quantity stepper and an icon-only remove, the line total at the end)
|
|
2526
|
+
* and "Continue shopping", beside the sticky order summary: the coupon
|
|
2527
|
+
* input group and the applied coupon as a chip, "Estimate shipping", the
|
|
2528
|
+
* totals and "Checkout", the page's one solid primary button. An empty cart
|
|
2529
|
+
* is an empty-state Card with "Continue shopping". The sections the server
|
|
2530
|
+
* lists (cross-sells by default) follow, each drawn by the component the
|
|
2531
|
+
* `cartSections` registry holds for it.
|
|
2532
|
+
*
|
|
2533
|
+
* Every change is a form post that redirects back with the new props and a
|
|
2534
|
+
* `feedback` prop: its announcement goes to the polite live region, and
|
|
2535
|
+
* focus moves to the restored line or to "Undo" when the control that had
|
|
2536
|
+
* it is gone.
|
|
2537
|
+
*
|
|
2538
|
+
* @since 1.0.0
|
|
2539
|
+
*/
|
|
2540
|
+
|
|
2541
|
+
/**
|
|
2542
|
+
* Props for {@link Cart}.
|
|
2543
|
+
*
|
|
2544
|
+
* @since 1.0.0
|
|
2545
|
+
*/
|
|
2546
|
+
type CartProps = CartIndexProps;
|
|
2547
|
+
/**
|
|
2548
|
+
* The cart.
|
|
2549
|
+
*
|
|
2550
|
+
* @since 1.0.0
|
|
2551
|
+
*
|
|
2552
|
+
* @param props - The cart page's props.
|
|
2553
|
+
* @returns The cart.
|
|
2554
|
+
*/
|
|
2555
|
+
declare function Cart({ cart, showTitle, showCoupon, estimate, countries, urls, sections, feedback, }: CartProps): ReactElement;
|
|
2556
|
+
|
|
2557
|
+
/**
|
|
2558
|
+
* The cart's write routes and its one JSON request.
|
|
2559
|
+
*
|
|
2560
|
+
* The cart props carry the cart page's URL but not the URLs of the changes
|
|
2561
|
+
* made from it, which sit under it on the server (`cart/lines/{line}`,
|
|
2562
|
+
* `cart/undo`, `cart/coupon`, `cart/shipping-rates`, `cart/shipping`, see
|
|
2563
|
+
* ecommerce-storefront-inertia's routes/storefront.php), so they are built
|
|
2564
|
+
* from the cart page's URL here.
|
|
2565
|
+
*
|
|
2566
|
+
* @since 1.0.0
|
|
2567
|
+
*/
|
|
2568
|
+
/**
|
|
2569
|
+
* The props a drawer change reloads: the header count, the toasts and the
|
|
2570
|
+
* drawer's own contents.
|
|
2571
|
+
*
|
|
2572
|
+
* @since 1.0.0
|
|
2573
|
+
*/
|
|
2574
|
+
declare const CART_DRAWER_ONLY: string[];
|
|
2575
|
+
/**
|
|
2576
|
+
* A cart write route's URL, root-relative so it stays on this site.
|
|
2577
|
+
*
|
|
2578
|
+
* @since 1.0.0
|
|
2579
|
+
*
|
|
2580
|
+
* @param cartUrl - The cart page's URL (`ecommerceStorefront.cart.url`).
|
|
2581
|
+
* @param path - The route under it, such as `lines/4` or `undo`.
|
|
2582
|
+
* @returns The URL.
|
|
2583
|
+
*/
|
|
2584
|
+
declare function cartActionUrl(cartUrl: string, path: string): string;
|
|
2585
|
+
/**
|
|
2586
|
+
* A JSON answer: its status and body (null when it wasn't JSON or the
|
|
2587
|
+
* request failed).
|
|
2588
|
+
*
|
|
2589
|
+
* @since 1.0.0
|
|
2590
|
+
*/
|
|
2591
|
+
interface JsonAnswer<TBody> {
|
|
2592
|
+
status: number;
|
|
2593
|
+
body: TBody | null;
|
|
2594
|
+
}
|
|
2595
|
+
/**
|
|
2596
|
+
* Posts JSON and reads the JSON answer, for routes that change nothing and
|
|
2597
|
+
* answer JSON instead of redirecting (the shipping quote).
|
|
2598
|
+
*
|
|
2599
|
+
* @since 1.0.0
|
|
2600
|
+
*
|
|
2601
|
+
* @param url - The route.
|
|
2602
|
+
* @param data - The body.
|
|
2603
|
+
* @returns The status (0 when the request failed) and body.
|
|
2604
|
+
*/
|
|
2605
|
+
declare function postJson<TBody>(url: string, data: Record<string, unknown>): Promise<JsonAnswer<TBody>>;
|
|
2606
|
+
|
|
2607
|
+
/**
|
|
2608
|
+
* A cart line's controls (`ec-cart-line__controls`): the quantity stepper,
|
|
2609
|
+
* which sends the new quantity once the shopper settles on it, and what
|
|
2610
|
+
* follows it (the line's "Remove").
|
|
2611
|
+
*
|
|
2612
|
+
* Livewire binds the stepper with `wire:model.live.change`: a step sends at
|
|
2613
|
+
* once, typing sends on change. Here a step or a typed value is sent after
|
|
2614
|
+
* a short pause, and straight away when focus leaves the stepper, so typing
|
|
2615
|
+
* "12" doesn't send "1" first.
|
|
2616
|
+
*
|
|
2617
|
+
* @since 1.0.0
|
|
2618
|
+
*/
|
|
2619
|
+
|
|
2620
|
+
/**
|
|
2621
|
+
* How long a changed quantity waits before it is sent, in milliseconds.
|
|
2622
|
+
*
|
|
2623
|
+
* @since 1.0.0
|
|
2624
|
+
*/
|
|
2625
|
+
declare const QUANTITY_COMMIT_DELAY = 500;
|
|
2626
|
+
/**
|
|
2627
|
+
* Props for {@link LineControls}.
|
|
2628
|
+
*
|
|
2629
|
+
* @since 1.0.0
|
|
2630
|
+
*/
|
|
2631
|
+
interface LineControlsProps {
|
|
2632
|
+
id: string;
|
|
2633
|
+
itemName: string;
|
|
2634
|
+
size: 'xs' | 'sm';
|
|
2635
|
+
quantity: number;
|
|
2636
|
+
max: number;
|
|
2637
|
+
error: string | null;
|
|
2638
|
+
disabled?: boolean;
|
|
2639
|
+
/** Sends the new quantity. */
|
|
2640
|
+
onCommit: (quantity: number) => void;
|
|
2641
|
+
/** Drawn after the stepper, inside the controls. */
|
|
2642
|
+
children?: ReactNode;
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* A cart line's controls.
|
|
2646
|
+
*
|
|
2647
|
+
* @since 1.0.0
|
|
2648
|
+
*
|
|
2649
|
+
* @param props - The line's quantity, bounds and the commit callback.
|
|
2650
|
+
* @returns The controls.
|
|
2651
|
+
*/
|
|
2652
|
+
declare function LineControls({ id, itemName, size, quantity, max, error, disabled, onCommit, children, }: LineControlsProps): ReactElement;
|
|
2653
|
+
|
|
2654
|
+
/**
|
|
2655
|
+
* An order summary's totals: subtotal, each discount, shipping, tax, then a
|
|
2656
|
+
* divider and the total.
|
|
2657
|
+
*
|
|
2658
|
+
* Mirrors ecommerce-storefront-livewire's `partials/order-totals`. Labels
|
|
2659
|
+
* are muted and values sit at the end; a discount reads after a true minus
|
|
2660
|
+
* (announced as "Minus"). A `<dl>` can't hold an `<hr>`, so the rows and the
|
|
2661
|
+
* total are two lists either side of the divider. The cart page, the
|
|
2662
|
+
* checkout summary and a placed order's summary share it; a placed order's
|
|
2663
|
+
* refunds follow the total.
|
|
2664
|
+
*
|
|
2665
|
+
* @since 1.0.0
|
|
2666
|
+
*/
|
|
2667
|
+
|
|
2668
|
+
/**
|
|
2669
|
+
* Props for {@link OrderTotals}.
|
|
2670
|
+
*
|
|
2671
|
+
* @since 1.0.0
|
|
2672
|
+
*/
|
|
2673
|
+
interface OrderTotalsProps {
|
|
2674
|
+
/** A cart's totals, or a placed order's (which may carry `refunded`). */
|
|
2675
|
+
totals: StorefrontCartTotals | StorefrontOrderTotals;
|
|
2676
|
+
/** Replaces "Calculated at checkout" for a shipping cost that isn't known yet. */
|
|
2677
|
+
shippingPending?: string | null;
|
|
2678
|
+
/** Replaces "Calculated at checkout" for tax that isn't known yet. */
|
|
2679
|
+
taxPending?: string | null;
|
|
2680
|
+
}
|
|
2681
|
+
/**
|
|
2682
|
+
* The totals.
|
|
2683
|
+
*
|
|
2684
|
+
* @since 1.0.0
|
|
2685
|
+
*
|
|
2686
|
+
* @param props - The totals and the pending texts.
|
|
2687
|
+
* @returns The totals.
|
|
2688
|
+
*/
|
|
2689
|
+
declare function OrderTotals({ totals, shippingPending, taxPending, }: OrderTotalsProps): ReactElement;
|
|
2690
|
+
|
|
2691
|
+
/**
|
|
2692
|
+
* The cart page's "Estimate shipping" disclosure.
|
|
2693
|
+
*
|
|
2694
|
+
* Mirrors the estimate in ecommerce-storefront-livewire's `Cart/Index`: a
|
|
2695
|
+
* native `<details>` holding the country, region and postcode, "Get
|
|
2696
|
+
* shipping rates", and the quoted rates as radio cards. The quote is a JSON
|
|
2697
|
+
* route (POST `cart.shipping-rates`): bad input comes back as a 422 with
|
|
2698
|
+
* field errors, and over the rate limit as a 429 whose toasts are shown
|
|
2699
|
+
* here. Choosing a rate posts it with the destination (POST `cart.shipping`),
|
|
2700
|
+
* so the totals pick it up and it carries into checkout.
|
|
2701
|
+
*
|
|
2702
|
+
* @since 1.0.0
|
|
2703
|
+
*/
|
|
2704
|
+
|
|
2705
|
+
/**
|
|
2706
|
+
* Props for {@link ShippingEstimate}.
|
|
2707
|
+
*
|
|
2708
|
+
* @since 1.0.0
|
|
2709
|
+
*/
|
|
2710
|
+
interface ShippingEstimateProps {
|
|
2711
|
+
estimate: StorefrontCartEstimate;
|
|
2712
|
+
countries: StorefrontSelectOption[];
|
|
2713
|
+
/** The cart page's URL; the quote and choice routes sit under it. */
|
|
2714
|
+
cartUrl: string;
|
|
2715
|
+
/** The `address-format` JSON route, for a country's regions; null keeps the format given. */
|
|
2716
|
+
formatUrl: string | null;
|
|
2717
|
+
/** The page's errors (`rate` from choosing a rate). */
|
|
2718
|
+
errors: Record<string, string>;
|
|
2719
|
+
/** Called with the quote's live-region message. */
|
|
2720
|
+
onAnnounce: (message: string) => void;
|
|
2721
|
+
}
|
|
2722
|
+
/**
|
|
2723
|
+
* The shipping estimate.
|
|
2724
|
+
*
|
|
2725
|
+
* @since 1.0.0
|
|
2726
|
+
*
|
|
2727
|
+
* @param props - The saved estimate, the countries and the routes.
|
|
2728
|
+
* @returns The disclosure.
|
|
2729
|
+
*/
|
|
2730
|
+
declare function ShippingEstimate({ estimate, countries, cartUrl, formatUrl, errors, onAnnounce, }: ShippingEstimateProps): ReactElement;
|
|
2731
|
+
|
|
2732
|
+
/**
|
|
2733
|
+
* Moves focus after a cart line is removed or put back, when the control
|
|
2734
|
+
* that had it is gone.
|
|
2735
|
+
*
|
|
2736
|
+
* Mirrors ecommerce-storefront-livewire's `cart/partials/focus-after-change`:
|
|
2737
|
+
* to the restored line's "Remove", else to "Undo", else to `fallback`. It
|
|
2738
|
+
* runs once per change (each redirect back brings a new `feedback`), and
|
|
2739
|
+
* only when focus was lost, never taking it from a control the shopper has
|
|
2740
|
+
* since moved to.
|
|
2741
|
+
*
|
|
2742
|
+
* @since 1.0.0
|
|
2743
|
+
*/
|
|
2744
|
+
|
|
2745
|
+
/**
|
|
2746
|
+
* Moves focus after a line change.
|
|
2747
|
+
*
|
|
2748
|
+
* @since 1.0.0
|
|
2749
|
+
*
|
|
2750
|
+
* @param root - The cart's container.
|
|
2751
|
+
* @param feedback - What the last change did.
|
|
2752
|
+
* @param fallback - A selector for the last resort, searched in the root then the document.
|
|
2753
|
+
*/
|
|
2754
|
+
declare function useFocusAfterChange(root: RefObject<HTMLElement | null>, feedback: StorefrontCartFeedback | null, fallback: string): void;
|
|
2755
|
+
|
|
2756
|
+
/**
|
|
2757
|
+
* The React side of the payment-driver contract.
|
|
2758
|
+
*
|
|
2759
|
+
* A gateway's client half is a `PaymentDriver` from `-core` (`mount`,
|
|
2760
|
+
* `confirm`, `error`, `unmount`). The component registered under its key
|
|
2761
|
+
* in the `paymentDrivers` registry draws the driver's UI and wraps the
|
|
2762
|
+
* driver with {@link usePaymentDriver}, which mounts it once its element
|
|
2763
|
+
* is in the page, confirms it when the shopper pays, hands the result to
|
|
2764
|
+
* the checkout and shows the failures the checkout learns of.
|
|
2765
|
+
*
|
|
2766
|
+
* @since 1.0.0
|
|
2767
|
+
*/
|
|
2768
|
+
|
|
2769
|
+
/**
|
|
2770
|
+
* A payment failure the checkout knows of. The id changes with every
|
|
2771
|
+
* failure, so the same message is shown again.
|
|
2772
|
+
*
|
|
2773
|
+
* @since 1.0.0
|
|
2774
|
+
*/
|
|
2775
|
+
interface PaymentDriverFailure {
|
|
2776
|
+
id: number;
|
|
2777
|
+
message: string;
|
|
2778
|
+
/**
|
|
2779
|
+
* `server`: the server refused a confirmed payment (the default).
|
|
2780
|
+
* `driver`: the driver's own failure, which it already showed; it comes
|
|
2781
|
+
* back only so a remounted driver shows it again.
|
|
2782
|
+
*/
|
|
2783
|
+
source?: 'driver' | 'server';
|
|
2784
|
+
}
|
|
2785
|
+
/**
|
|
2786
|
+
* Where a reported result left the shopper: on their way elsewhere, or
|
|
2787
|
+
* still on the checkout.
|
|
2788
|
+
*
|
|
2789
|
+
* @since 1.0.0
|
|
2790
|
+
*/
|
|
2791
|
+
type PaymentReportOutcome = 'left' | 'stayed';
|
|
2792
|
+
/**
|
|
2793
|
+
* What the checkout gives the component registered for a payment driver.
|
|
2794
|
+
*
|
|
2795
|
+
* @since 1.0.0
|
|
2796
|
+
*/
|
|
2797
|
+
interface PaymentDriverComponentProps<TProps extends object = Record<string, unknown>> {
|
|
2798
|
+
/** The session to pay, the driver's props, the return URL and the payable check. */
|
|
2799
|
+
context: PaymentDriverContext<TProps>;
|
|
2800
|
+
/**
|
|
2801
|
+
* Hands the driver's result to the checkout: `confirmed` places the
|
|
2802
|
+
* order, `redirect` leaves for the provider, `failed` is reported to the
|
|
2803
|
+
* server. Resolves once the checkout has acted on it: `left` when the
|
|
2804
|
+
* shopper is on their way elsewhere (the confirmation page, the
|
|
2805
|
+
* provider), `stayed` when they are still on the checkout and the driver
|
|
2806
|
+
* should give "Pay" back.
|
|
2807
|
+
*/
|
|
2808
|
+
report: (result: PaymentDriverResult) => Promise<PaymentReportOutcome | void>;
|
|
2809
|
+
/**
|
|
2810
|
+
* The latest failure the checkout knows of, or null. A driver that mounts
|
|
2811
|
+
* with one shows its message.
|
|
2812
|
+
*/
|
|
2813
|
+
failure: PaymentDriverFailure | null;
|
|
2814
|
+
}
|
|
2815
|
+
/**
|
|
2816
|
+
* Where a driver is: ready, taking the payment, or done (the checkout is
|
|
2817
|
+
* placing the order, or the browser is leaving for the provider).
|
|
2818
|
+
*
|
|
2819
|
+
* @since 1.0.0
|
|
2820
|
+
*/
|
|
2821
|
+
type PaymentDriverStatus = 'idle' | 'paying' | 'placing';
|
|
2822
|
+
/**
|
|
2823
|
+
* What {@link usePaymentDriver} returns.
|
|
2824
|
+
*
|
|
2825
|
+
* @since 1.0.0
|
|
2826
|
+
*/
|
|
2827
|
+
interface UsePaymentDriver {
|
|
2828
|
+
/** The element the driver mounts its UI in. */
|
|
2829
|
+
elementRef: RefObject<HTMLDivElement | null>;
|
|
2830
|
+
/** Takes the payment. Ignored while a payment is under way. */
|
|
2831
|
+
pay: () => Promise<void>;
|
|
2832
|
+
status: PaymentDriverStatus;
|
|
2833
|
+
/** The failure to show, as plain text, or null. */
|
|
2834
|
+
error: string | null;
|
|
2835
|
+
/** Bumped with every error, so a live region can announce the same message again. */
|
|
2836
|
+
errorId: number;
|
|
2837
|
+
}
|
|
2838
|
+
/**
|
|
2839
|
+
* Wraps a `PaymentDriver` for a React component.
|
|
2840
|
+
*
|
|
2841
|
+
* A driver may add `report: false` to a failed result for a failure the
|
|
2842
|
+
* shopper fixes in its own form (a validation error): it is shown, but not
|
|
2843
|
+
* reported to the server.
|
|
2844
|
+
*
|
|
2845
|
+
* Only a failure gives the shopper "Pay" back: after a confirmed payment
|
|
2846
|
+
* the checkout is placing the order, and a second press would confirm a
|
|
2847
|
+
* payment that has already gone through.
|
|
2848
|
+
*
|
|
2849
|
+
* @since 1.0.0
|
|
2850
|
+
*
|
|
2851
|
+
* @param driver - The driver; keep the same object for the component's life.
|
|
2852
|
+
* @param props - The props the checkout gave the component.
|
|
2853
|
+
* @returns The element ref, `pay()`, the status and the error.
|
|
2854
|
+
*/
|
|
2855
|
+
declare function usePaymentDriver<TProps extends object>(driver: PaymentDriver<TProps>, { context, report, failure }: PaymentDriverComponentProps<TProps>): UsePaymentDriver;
|
|
2856
|
+
|
|
2857
|
+
/**
|
|
2858
|
+
* The checkout's own props: the page's, plus whether it prints the
|
|
2859
|
+
* "Checkout" title (the page does; the Checkout Steps block may not).
|
|
2860
|
+
*
|
|
2861
|
+
* @since 1.0.0
|
|
2862
|
+
*/
|
|
2863
|
+
type CheckoutProps = Omit<CheckoutIndexProps, 'ecommerceStorefront' | 'errors'> & {
|
|
2864
|
+
/** Print the "Checkout" title (the page's h1). Defaults to true. */
|
|
2865
|
+
showTitle?: boolean;
|
|
2866
|
+
};
|
|
2867
|
+
/**
|
|
2868
|
+
* How a step's request keeps the page.
|
|
2869
|
+
*
|
|
2870
|
+
* - `step`: a submit that moves on; a fresh page when it works, the input
|
|
2871
|
+
* kept when it fails.
|
|
2872
|
+
* - `keep`: a choice applied straight away (a shipping rate, a gateway);
|
|
2873
|
+
* the page keeps its state, so focus stays on the control.
|
|
2874
|
+
*
|
|
2875
|
+
* @since 1.0.0
|
|
2876
|
+
*/
|
|
2877
|
+
type CheckoutPostMode = 'step' | 'keep';
|
|
2878
|
+
/**
|
|
2879
|
+
* What the checkout context holds.
|
|
2880
|
+
*
|
|
2881
|
+
* @since 1.0.0
|
|
2882
|
+
*/
|
|
2883
|
+
interface CheckoutContextValue {
|
|
2884
|
+
props: CheckoutProps;
|
|
2885
|
+
/** The page's errors and the open step's setup problems, keyed alike. */
|
|
2886
|
+
errors: Record<string, string>;
|
|
2887
|
+
/** Posts to a checkout route; ignored when the route isn't registered. */
|
|
2888
|
+
post: (url: string | null, data: Record<string, unknown>, mode?: CheckoutPostMode, callbacks?: CheckoutPostCallbacks) => void;
|
|
2889
|
+
/** Opens a step (`?step=`), as "Edit" and "Change address" do. */
|
|
2890
|
+
goTo: (step: string) => void;
|
|
2891
|
+
/** The URL being posted to, while a request runs. */
|
|
2892
|
+
processing: string | null;
|
|
2893
|
+
/** Bumped by every failed submit, so the error summary is announced again. */
|
|
2894
|
+
errorRound: number;
|
|
2895
|
+
/**
|
|
2896
|
+
* The last payment failure, kept here rather than in the driver so it
|
|
2897
|
+
* survives the driver remounting (a new payment session after a failed
|
|
2898
|
+
* payment re-keys it). Cleared by a new attempt or another gateway.
|
|
2899
|
+
*/
|
|
2900
|
+
paymentFailure: PaymentDriverFailure | null;
|
|
2901
|
+
/** Records a payment failure: the driver's own, or the server's refusal. */
|
|
2902
|
+
reportPaymentFailure: (message: string, source: 'driver' | 'server') => void;
|
|
2903
|
+
/** Forgets the last payment failure. */
|
|
2904
|
+
clearPaymentFailure: () => void;
|
|
2905
|
+
}
|
|
2906
|
+
/**
|
|
2907
|
+
* Called when a checkout request finishes.
|
|
2908
|
+
*
|
|
2909
|
+
* @since 1.0.0
|
|
2910
|
+
*/
|
|
2911
|
+
interface CheckoutPostCallbacks {
|
|
2912
|
+
onSuccess?: () => void;
|
|
2913
|
+
onError?: (errors: Record<string, string>) => void;
|
|
2914
|
+
onFinish?: () => void;
|
|
2915
|
+
}
|
|
2916
|
+
/**
|
|
2917
|
+
* Asks the next checkout render to move focus to the open step's title.
|
|
2918
|
+
*
|
|
2919
|
+
* @since 1.0.0
|
|
2920
|
+
*/
|
|
2921
|
+
declare function requestStepFocus(): void;
|
|
2922
|
+
/**
|
|
2923
|
+
* The checkout URL with `?step=`.
|
|
2924
|
+
*
|
|
2925
|
+
* @since 1.0.0
|
|
2926
|
+
*
|
|
2927
|
+
* @param urls - The checkout's URLs.
|
|
2928
|
+
* @param step - The step key.
|
|
2929
|
+
* @returns The URL, or null without a checkout route.
|
|
2930
|
+
*/
|
|
2931
|
+
declare function stepUrl(urls: StorefrontCheckoutUrls, step: string): string | null;
|
|
2932
|
+
/**
|
|
2933
|
+
* The checkout context, inside a checkout.
|
|
2934
|
+
*
|
|
2935
|
+
* @since 1.0.0
|
|
2936
|
+
*
|
|
2937
|
+
* @returns The context value.
|
|
2938
|
+
*/
|
|
2939
|
+
declare function useCheckout(): CheckoutContextValue;
|
|
2940
|
+
|
|
2941
|
+
/**
|
|
2942
|
+
* The checkout.
|
|
2943
|
+
*
|
|
2944
|
+
* @since 1.0.0
|
|
2945
|
+
*/
|
|
2946
|
+
|
|
2947
|
+
/**
|
|
2948
|
+
* Props a satellite's checkout step component gets (`checkoutSteps`
|
|
2949
|
+
* registry).
|
|
2950
|
+
*
|
|
2951
|
+
* @since 1.0.0
|
|
2952
|
+
*/
|
|
2953
|
+
interface CheckoutStepComponentProps {
|
|
2954
|
+
/** The step, with its `completeUrl`. */
|
|
2955
|
+
step: StorefrontCheckoutStep;
|
|
2956
|
+
/** Posts to the step's `completeUrl`, moving the checkout on. */
|
|
2957
|
+
complete: (data?: Record<string, unknown>) => void;
|
|
2958
|
+
}
|
|
2959
|
+
/**
|
|
2960
|
+
* The checkout: the steps beside a sticky order summary (from 1024px;
|
|
2961
|
+
* below that the summary is a "Show order summary" bar above the title),
|
|
2962
|
+
* with the "Checkout" title first when `showTitle`.
|
|
2963
|
+
*
|
|
2964
|
+
* Multi-step: the design-system Steps from 768px (below that, "Step 2 of
|
|
2965
|
+
* 5 · Address"), then every step as a card: finished steps collapse to
|
|
2966
|
+
* what they chose with "Edit", the open step shows its form, and the
|
|
2967
|
+
* steps still to come are muted. Single page: every step, with the ones
|
|
2968
|
+
* after an unfinished step disabled and saying why. A satellite's step is
|
|
2969
|
+
* the component it registered in the `checkoutSteps` registry.
|
|
2970
|
+
*
|
|
2971
|
+
* After an order is placed but its payment isn't finished, the payment for
|
|
2972
|
+
* that order is shown instead, with "Finish paying for order …" as the
|
|
2973
|
+
* title.
|
|
2974
|
+
*
|
|
2975
|
+
* @since 1.0.0
|
|
2976
|
+
*
|
|
2977
|
+
* @param props - The checkout page's props.
|
|
2978
|
+
* @returns The checkout.
|
|
2979
|
+
*/
|
|
2980
|
+
declare function Checkout(props: CheckoutProps): ReactElement;
|
|
2981
|
+
|
|
2982
|
+
/**
|
|
2983
|
+
* The checkout's error summary.
|
|
2984
|
+
*
|
|
2985
|
+
* @since 1.0.0
|
|
2986
|
+
*/
|
|
2987
|
+
|
|
2988
|
+
/**
|
|
2989
|
+
* Every problem on the step, each prefixed with its field's label
|
|
2990
|
+
* (`errorLabels`) and linked to the field. It is re-created after each
|
|
2991
|
+
* failed submit, so it is announced and focused again.
|
|
2992
|
+
*
|
|
2993
|
+
* @since 1.0.0
|
|
2994
|
+
*
|
|
2995
|
+
* @returns The summary, or null without errors.
|
|
2996
|
+
*/
|
|
2997
|
+
declare function CheckoutErrorSummary(): ReactElement | null;
|
|
2998
|
+
|
|
2999
|
+
/**
|
|
3000
|
+
* The checkout's order summary.
|
|
3001
|
+
*
|
|
3002
|
+
* @since 1.0.0
|
|
3003
|
+
*/
|
|
3004
|
+
|
|
3005
|
+
/**
|
|
3006
|
+
* Props of {@link CheckoutOrderSummary}.
|
|
3007
|
+
*
|
|
3008
|
+
* @since 1.0.0
|
|
3009
|
+
*/
|
|
3010
|
+
interface CheckoutOrderSummaryProps {
|
|
3011
|
+
summary: StorefrontCartSummary | null;
|
|
3012
|
+
/** "Edit cart" links here; null hides it. */
|
|
3013
|
+
cartUrl: string | null;
|
|
3014
|
+
}
|
|
3015
|
+
/**
|
|
3016
|
+
* A Card with the lines (a thumbnail carrying the quantity, the name, the
|
|
3017
|
+
* options or "Free gift", the line total) and the totals, which follow the
|
|
3018
|
+
* shipping rate and tax as the shopper chooses them. Sticky beside the
|
|
3019
|
+
* steps from 1024px; below that, a "Show order summary" bar with the total
|
|
3020
|
+
* opens it.
|
|
3021
|
+
*
|
|
3022
|
+
* @since 1.0.0
|
|
3023
|
+
*
|
|
3024
|
+
* @param props - The cart summary and the cart URL.
|
|
3025
|
+
* @returns The summary.
|
|
3026
|
+
*/
|
|
3027
|
+
declare function CheckoutOrderSummary({ summary, cartUrl, }: CheckoutOrderSummaryProps): ReactElement;
|
|
3028
|
+
|
|
3029
|
+
/**
|
|
3030
|
+
* What a finished checkout step chose.
|
|
3031
|
+
*
|
|
3032
|
+
* @since 1.0.0
|
|
3033
|
+
*/
|
|
3034
|
+
|
|
3035
|
+
/**
|
|
3036
|
+
* Props of {@link CheckoutStepSummary}.
|
|
3037
|
+
*
|
|
3038
|
+
* @since 1.0.0
|
|
3039
|
+
*/
|
|
3040
|
+
interface CheckoutStepSummaryProps {
|
|
3041
|
+
/** The step's key. */
|
|
3042
|
+
step: string;
|
|
3043
|
+
}
|
|
3044
|
+
/**
|
|
3045
|
+
* Under a finished step's title: the email, the ship-to and bill-to
|
|
3046
|
+
* addresses side by side (from 640px), the shipping option and its price,
|
|
3047
|
+
* what the review settled (terms accepted, an account to create, a note),
|
|
3048
|
+
* or the payment.
|
|
3049
|
+
*
|
|
3050
|
+
* @since 1.0.0
|
|
3051
|
+
*
|
|
3052
|
+
* @param props - The step.
|
|
3053
|
+
* @returns The summary.
|
|
3054
|
+
*/
|
|
3055
|
+
declare function CheckoutStepSummary({ step }: CheckoutStepSummaryProps): ReactElement | null;
|
|
3056
|
+
|
|
3057
|
+
/**
|
|
3058
|
+
* An order that is placed but not paid yet.
|
|
3059
|
+
*
|
|
3060
|
+
* @since 1.0.0
|
|
3061
|
+
*/
|
|
3062
|
+
|
|
3063
|
+
/**
|
|
3064
|
+
* Props of {@link Placement}.
|
|
3065
|
+
*
|
|
3066
|
+
* @since 1.0.0
|
|
3067
|
+
*/
|
|
3068
|
+
interface PlacementProps {
|
|
3069
|
+
placement: StorefrontCheckoutPlacement;
|
|
3070
|
+
}
|
|
3071
|
+
/**
|
|
3072
|
+
* One centered Card: a warning clock icon tile, "Finish paying for order
|
|
3073
|
+
* {number}" (the page's h1 when the checkout shows its title, else an h2),
|
|
3074
|
+
* a line saying the order is saved, an error Alert with what happened, the
|
|
3075
|
+
* order's items, shipping and total, then the payment driver for the
|
|
3076
|
+
* order's own payment. Confirming it finishes the order.
|
|
3077
|
+
*
|
|
3078
|
+
* @since 1.0.0
|
|
3079
|
+
*
|
|
3080
|
+
* @param props - The placed order.
|
|
3081
|
+
* @returns The placement.
|
|
3082
|
+
*/
|
|
3083
|
+
declare function Placement({ placement }: PlacementProps): ReactElement;
|
|
3084
|
+
|
|
3085
|
+
/**
|
|
3086
|
+
* Display lines for an address the checkout only has as form values.
|
|
3087
|
+
*
|
|
3088
|
+
* @since 1.0.0
|
|
3089
|
+
*/
|
|
3090
|
+
|
|
3091
|
+
/**
|
|
3092
|
+
* The address as display lines, matching the server's `AddressPresenter`:
|
|
3093
|
+
* the name, the company, the street lines, "City, Region Postcode" and the
|
|
3094
|
+
* country's name. The checkout's props carry the cart's addresses as form
|
|
3095
|
+
* values only, so the finished address step draws them from those, naming
|
|
3096
|
+
* the country and region from the address form's options.
|
|
3097
|
+
*
|
|
3098
|
+
* @since 1.0.0
|
|
3099
|
+
*
|
|
3100
|
+
* @param values - The address's fields.
|
|
3101
|
+
* @param form - The address form, for the country and region names.
|
|
3102
|
+
* @returns The lines, without empty ones.
|
|
3103
|
+
*/
|
|
3104
|
+
declare function addressLines(values: StorefrontAddressValues, form?: StorefrontAddressForm | null): string[];
|
|
3105
|
+
/**
|
|
3106
|
+
* The address on one line, as the shipping step's "Shipping to …" shows
|
|
3107
|
+
* it: the street, the city, then the region and postcode.
|
|
3108
|
+
*
|
|
3109
|
+
* @since 1.0.0
|
|
3110
|
+
*
|
|
3111
|
+
* @param values - The address's fields.
|
|
3112
|
+
* @returns The line, or '' when there is nothing to show.
|
|
3113
|
+
*/
|
|
3114
|
+
declare function shipToLine(values: StorefrontAddressValues): string;
|
|
3115
|
+
|
|
3116
|
+
/**
|
|
3117
|
+
* Checkout step: address.
|
|
3118
|
+
*
|
|
3119
|
+
* @since 1.0.0
|
|
3120
|
+
*/
|
|
3121
|
+
|
|
3122
|
+
/**
|
|
3123
|
+
* "Ship to" and the address form, then "Billing address is the same as
|
|
3124
|
+
* shipping" (checked); unchecked, "Bill to" and a second form. A cart that
|
|
3125
|
+
* doesn't ship asks for the billing address only, and says why. A
|
|
3126
|
+
* signed-in shopper with saved addresses picks one from radio cards (or
|
|
3127
|
+
* "Use a new address", which opens the form), and can save a new one to
|
|
3128
|
+
* their address book. Then "Continue".
|
|
3129
|
+
*
|
|
3130
|
+
* @since 1.0.0
|
|
3131
|
+
*
|
|
3132
|
+
* @returns The step's form.
|
|
3133
|
+
*/
|
|
3134
|
+
declare function AddressStep(): ReactElement;
|
|
3135
|
+
|
|
3136
|
+
/**
|
|
3137
|
+
* Checkout step: contact.
|
|
3138
|
+
*
|
|
3139
|
+
* @since 1.0.0
|
|
3140
|
+
*/
|
|
3141
|
+
|
|
3142
|
+
/**
|
|
3143
|
+
* For a guest, the sign-in prompt (a person icon, "Have an account? Sign
|
|
3144
|
+
* in for faster checkout." and an outline "Sign in"), or, when the store
|
|
3145
|
+
* needs an account to pay, an info Alert with "Sign in" and "Create an
|
|
3146
|
+
* account". Then the email (a mail icon, and a hint saying what it's used
|
|
3147
|
+
* for), "Email me news and offers" and "Continue". Posts `{ email,
|
|
3148
|
+
* marketing_consent }` to `urls.contact`.
|
|
3149
|
+
*
|
|
3150
|
+
* @since 1.0.0
|
|
3151
|
+
*
|
|
3152
|
+
* @returns The step's form.
|
|
3153
|
+
*/
|
|
3154
|
+
declare function ContactStep(): ReactElement;
|
|
3155
|
+
|
|
3156
|
+
/**
|
|
3157
|
+
* Checkout step: payment, the last step.
|
|
3158
|
+
*
|
|
3159
|
+
* @since 1.0.0
|
|
3160
|
+
*/
|
|
3161
|
+
|
|
3162
|
+
/**
|
|
3163
|
+
* "Payment method": the gateways as radio cards, each with its name, an
|
|
3164
|
+
* optional description and icon. Choosing one posts `{ gateway }` to
|
|
3165
|
+
* `urls.gateway`, and the chosen card opens to hold the gateway's payment
|
|
3166
|
+
* driver; confirming the payment places the order, as the line under the
|
|
3167
|
+
* cards says. With one gateway it is chosen for the shopper, and its card
|
|
3168
|
+
* has no radio.
|
|
3169
|
+
*
|
|
3170
|
+
* The cards follow the design-system RadioGroup's markup contract
|
|
3171
|
+
* (`fieldset.apui-radio-group[data-variant="cards"]` and its parts) rather
|
|
3172
|
+
* than the component, because a card holds the driver's own form, which
|
|
3173
|
+
* can't sit inside the radio's label.
|
|
3174
|
+
*
|
|
3175
|
+
* While a payment is stranded, no payment method is offered. A free order
|
|
3176
|
+
* is placed with "Place order", and one whose payment is already confirmed
|
|
3177
|
+
* with "Place order · {total}" (POST `urls.place` with the token). A guest
|
|
3178
|
+
* who needs an account is asked to sign in or register; with no gateway, a
|
|
3179
|
+
* warning says to contact the store.
|
|
3180
|
+
*
|
|
3181
|
+
* @since 1.0.0
|
|
3182
|
+
*
|
|
3183
|
+
* @returns The step.
|
|
3184
|
+
*/
|
|
3185
|
+
declare function PaymentStep(): ReactElement;
|
|
3186
|
+
|
|
3187
|
+
/**
|
|
3188
|
+
* Checkout step: review.
|
|
3189
|
+
*
|
|
3190
|
+
* @since 1.0.0
|
|
3191
|
+
*/
|
|
3192
|
+
|
|
3193
|
+
/**
|
|
3194
|
+
* Before payment, what's left to settle: the optional order note (with a
|
|
3195
|
+
* character count), "Create an account with this email" for guests when
|
|
3196
|
+
* the store offers it (the password under it once checked), the terms
|
|
3197
|
+
* checkbox with its link (when a terms page is set), and "Continue to
|
|
3198
|
+
* payment". Posts `{ note, accept_terms, create_account, password }` to
|
|
3199
|
+
* `urls.review`; the password is never sent back.
|
|
3200
|
+
*
|
|
3201
|
+
* @since 1.0.0
|
|
3202
|
+
*
|
|
3203
|
+
* @returns The step's form.
|
|
3204
|
+
*/
|
|
3205
|
+
declare function ReviewStep(): ReactElement;
|
|
3206
|
+
|
|
3207
|
+
/**
|
|
3208
|
+
* Checkout step: shipping.
|
|
3209
|
+
*
|
|
3210
|
+
* @since 1.0.0
|
|
3211
|
+
*/
|
|
3212
|
+
|
|
3213
|
+
/**
|
|
3214
|
+
* "Shipping to" the cart's address on one line, with "Change address"
|
|
3215
|
+
* (back to the address step). Then the rates quoted for it as radio cards,
|
|
3216
|
+
* one per row: the name and its delivery estimate, with the price (or
|
|
3217
|
+
* "Free") at the end. The chosen one is applied straight away (POST
|
|
3218
|
+
* `urls.shippingRate`), so the order summary's totals follow it. Then
|
|
3219
|
+
* "Continue" (POST `urls.shipping`). With no rates for the address, a
|
|
3220
|
+
* warning Alert offers "Change address" instead.
|
|
3221
|
+
*
|
|
3222
|
+
* @since 1.0.0
|
|
3223
|
+
*
|
|
3224
|
+
* @returns The step's form.
|
|
3225
|
+
*/
|
|
3226
|
+
declare function ShippingStep(): ReactElement;
|
|
3227
|
+
|
|
3228
|
+
/**
|
|
3229
|
+
* Renders the payment driver for a payment session.
|
|
3230
|
+
*
|
|
3231
|
+
* @since 1.0.0
|
|
3232
|
+
*/
|
|
3233
|
+
|
|
3234
|
+
/**
|
|
3235
|
+
* Props of {@link PaymentDriverHost}.
|
|
3236
|
+
*
|
|
3237
|
+
* @since 1.0.0
|
|
3238
|
+
*/
|
|
3239
|
+
interface PaymentDriverHostProps {
|
|
3240
|
+
/** The payment session and its driver. */
|
|
3241
|
+
setup: StorefrontPaymentSetup;
|
|
3242
|
+
/** The one-time token placing the order carries; null for a placed order's payment. */
|
|
3243
|
+
token: string | null;
|
|
3244
|
+
}
|
|
3245
|
+
/**
|
|
3246
|
+
* Looks the session's `component` up in the `paymentDrivers` registry and
|
|
3247
|
+
* renders it with the driver context. It acts on what the driver reports:
|
|
3248
|
+
* a confirmed payment is posted with the token to
|
|
3249
|
+
* `urls.paymentConfirmed` (the server checks it with the gateway and
|
|
3250
|
+
* places the order), a redirect leaves for the provider, and a failure is
|
|
3251
|
+
* posted to `urls.paymentFailed`. A refusal from the server goes back to
|
|
3252
|
+
* the driver as its `failure`.
|
|
3253
|
+
*
|
|
3254
|
+
* @since 1.0.0
|
|
3255
|
+
*
|
|
3256
|
+
* @param props - The session and the token.
|
|
3257
|
+
* @returns The driver, or null when no component is registered for it.
|
|
3258
|
+
*/
|
|
3259
|
+
declare function PaymentDriverHost({ setup, token }: PaymentDriverHostProps): ReactElement | null;
|
|
3260
|
+
|
|
3261
|
+
/**
|
|
3262
|
+
* The core `redirect` payment driver.
|
|
3263
|
+
*
|
|
3264
|
+
* @since 1.0.0
|
|
3265
|
+
*/
|
|
3266
|
+
|
|
3267
|
+
/**
|
|
3268
|
+
* A Card: an external-link icon tile beside "Pay with {gateway}" and one
|
|
3269
|
+
* line saying the shopper finishes paying on the gateway's site and comes
|
|
3270
|
+
* back, then a full-width neutral "Continue to {gateway}" with a trailing
|
|
3271
|
+
* arrow (mirrored in right-to-left layouts). Without a usable redirect
|
|
3272
|
+
* URL, a warning Alert says the method isn't available.
|
|
3273
|
+
*
|
|
3274
|
+
* @since 1.0.0
|
|
3275
|
+
*
|
|
3276
|
+
* @param props - What the checkout gives a payment driver.
|
|
3277
|
+
* @returns The driver's UI.
|
|
3278
|
+
*/
|
|
3279
|
+
declare function RedirectPayment(props: PaymentDriverComponentProps<RedirectPaymentDriverProps>): ReactElement;
|
|
3280
|
+
|
|
3281
|
+
/**
|
|
3282
|
+
* The core `stripe-payment-element` payment driver's behavior.
|
|
3283
|
+
*
|
|
3284
|
+
* @since 1.0.0
|
|
3285
|
+
*/
|
|
3286
|
+
|
|
3287
|
+
/**
|
|
3288
|
+
* What the driver tells its component.
|
|
3289
|
+
*
|
|
3290
|
+
* @since 1.0.0
|
|
3291
|
+
*/
|
|
3292
|
+
interface StripeDriverCallbacks {
|
|
3293
|
+
/** Stripe's form is ready to take a payment. */
|
|
3294
|
+
onReady: () => void;
|
|
3295
|
+
/** Stripe.js or the form couldn't load. */
|
|
3296
|
+
onLoadError: (message: string) => void;
|
|
3297
|
+
}
|
|
3298
|
+
/**
|
|
3299
|
+
* Loads Stripe.js. `@stripe/stripe-js` is an optional peer, imported only
|
|
3300
|
+
* when a Stripe payment form mounts, so a store without Stripe never needs
|
|
3301
|
+
* it.
|
|
3302
|
+
*
|
|
3303
|
+
* @since 1.0.0
|
|
3304
|
+
*/
|
|
3305
|
+
type StripeLoader = (publishableKey: string, options: {
|
|
3306
|
+
locale: StripeElementLocale;
|
|
3307
|
+
}) => Promise<Stripe | null>;
|
|
3308
|
+
/**
|
|
3309
|
+
* Stripe's appearance from the `--apui-*` tokens, so its fields match the
|
|
3310
|
+
* Input: the field radius, border, text, placeholder and error colors, and
|
|
3311
|
+
* the focus ring. The gateway's `appearance` goes on top.
|
|
3312
|
+
*
|
|
3313
|
+
* @since 1.0.0
|
|
3314
|
+
*
|
|
3315
|
+
* @param root - An element inside the storefront, to read the tokens from.
|
|
3316
|
+
* @param custom - The gateway's appearance.
|
|
3317
|
+
* @returns Stripe's appearance.
|
|
3318
|
+
*/
|
|
3319
|
+
declare function stripeAppearance(root: HTMLElement, custom: Record<string, unknown>): Appearance;
|
|
3320
|
+
/**
|
|
3321
|
+
* Creates the Stripe Payment Element driver: it mounts Stripe's form in
|
|
3322
|
+
* the component's element, keeps its look in step with light, dark and
|
|
3323
|
+
* theme switches, and confirms with `redirect: 'if_required'`, so 3-D
|
|
3324
|
+
* Secure runs in the page and methods that must redirect come back through
|
|
3325
|
+
* the return route. No card data passes through the storefront.
|
|
3326
|
+
*
|
|
3327
|
+
* @since 1.0.0
|
|
3328
|
+
*
|
|
3329
|
+
* @param callbacks - Ready and load-failure callbacks.
|
|
3330
|
+
* @param loader - Loads Stripe.js; `@stripe/stripe-js`'s `loadStripe()` by default.
|
|
3331
|
+
* @returns The driver.
|
|
3332
|
+
*/
|
|
3333
|
+
declare function createStripePaymentElementDriver(callbacks: StripeDriverCallbacks, loader?: StripeLoader): PaymentDriver<StripePaymentElementDriverProps>;
|
|
3334
|
+
|
|
3335
|
+
/**
|
|
3336
|
+
* The core `stripe-payment-element` payment driver.
|
|
3337
|
+
*
|
|
3338
|
+
* @since 1.0.0
|
|
3339
|
+
*/
|
|
3340
|
+
|
|
3341
|
+
/**
|
|
3342
|
+
* Props of {@link StripePayment}.
|
|
3343
|
+
*
|
|
3344
|
+
* @since 1.0.0
|
|
3345
|
+
*/
|
|
3346
|
+
interface StripePaymentProps extends PaymentDriverComponentProps<StripePaymentElementDriverProps> {
|
|
3347
|
+
/** Loads Stripe.js; `@stripe/stripe-js`'s `loadStripe()` by default. */
|
|
3348
|
+
loader?: StripeLoader;
|
|
3349
|
+
}
|
|
3350
|
+
/**
|
|
3351
|
+
* A Card holding Stripe's form, then the reassurance line (a shield icon
|
|
3352
|
+
* and "Your card details go straight to Stripe…") and a full-width "Pay
|
|
3353
|
+
* now". While Stripe loads, field skeletons sit under the glass Loading
|
|
3354
|
+
* overlay with "Loading the payment form…". A Stripe error shows under the
|
|
3355
|
+
* form in an assertive live region. Without a publishable key and client
|
|
3356
|
+
* secret, a warning Alert says the method isn't available.
|
|
3357
|
+
*
|
|
3358
|
+
* After Stripe confirms, "Pay now" stays disabled and says "Placing your
|
|
3359
|
+
* order…" until the checkout moves on; only a failure gives it back.
|
|
3360
|
+
* React never renders inside Stripe's element, so its iframe survives
|
|
3361
|
+
* every re-render.
|
|
3362
|
+
*
|
|
3363
|
+
* @since 1.0.0
|
|
3364
|
+
*
|
|
3365
|
+
* @param props - What the checkout gives a payment driver.
|
|
3366
|
+
* @returns The driver's UI.
|
|
3367
|
+
*/
|
|
3368
|
+
declare function StripePayment({ loader, ...props }: StripePaymentProps): ReactElement;
|
|
3369
|
+
|
|
3370
|
+
/**
|
|
3371
|
+
* The core payment drivers' registration.
|
|
3372
|
+
*
|
|
3373
|
+
* @since 1.0.0
|
|
3374
|
+
*/
|
|
3375
|
+
|
|
3376
|
+
/**
|
|
3377
|
+
* The core drivers, by `paymentDrivers` registry key.
|
|
3378
|
+
*
|
|
3379
|
+
* @since 1.0.0
|
|
3380
|
+
*/
|
|
3381
|
+
declare const CORE_PAYMENT_DRIVERS: {
|
|
3382
|
+
readonly 'stripe-payment-element': typeof StripePayment;
|
|
3383
|
+
readonly redirect: typeof RedirectPayment;
|
|
3384
|
+
};
|
|
3385
|
+
/**
|
|
3386
|
+
* Adds the core payment drivers (`stripe-payment-element` and `redirect`)
|
|
3387
|
+
* to the `paymentDrivers` registry. A satellite that registered its own
|
|
3388
|
+
* component under one of these keys first keeps it.
|
|
3389
|
+
*
|
|
3390
|
+
* @since 1.0.0
|
|
3391
|
+
*/
|
|
3392
|
+
declare function registerPaymentDrivers(): void;
|
|
3393
|
+
|
|
3394
|
+
/**
|
|
3395
|
+
* An order's confirmation.
|
|
3396
|
+
*
|
|
3397
|
+
* Mirrors ecommerce-storefront-livewire's `order/confirmation`: a success
|
|
3398
|
+
* check icon tile, "Thank you for your order" (the page's h1, else an h2)
|
|
3399
|
+
* and the confirmation email line, then a Card meta strip (order number,
|
|
3400
|
+
* placed date, status Badge). Guests then see two Alerts: "Create an
|
|
3401
|
+
* account to track orders" and "Look up this order later". Then the order
|
|
3402
|
+
* details, then "View in your account" (the owner) and "Continue shopping".
|
|
3403
|
+
*
|
|
3404
|
+
* @since 1.0.0
|
|
3405
|
+
*/
|
|
3406
|
+
|
|
3407
|
+
/**
|
|
3408
|
+
* Props for {@link OrderConfirmation}.
|
|
3409
|
+
*
|
|
3410
|
+
* `owner` comes with the page's props, but the view, like the Livewire one,
|
|
3411
|
+
* decides on the guest hints from `registerUrl` and `lookupUrl`, which the
|
|
3412
|
+
* server leaves null for the order's owner.
|
|
3413
|
+
*
|
|
3414
|
+
* @since 1.0.0
|
|
3415
|
+
*/
|
|
3416
|
+
interface OrderConfirmationViewProps extends OrderConfirmationProps {
|
|
3417
|
+
/** Make the heading the page's h1; else it is an h2. */
|
|
3418
|
+
showTitle?: boolean;
|
|
3419
|
+
}
|
|
3420
|
+
/**
|
|
3421
|
+
* The confirmation.
|
|
3422
|
+
*
|
|
3423
|
+
* @since 1.0.0
|
|
3424
|
+
*
|
|
3425
|
+
* @param props - The order and its links.
|
|
3426
|
+
* @returns The confirmation.
|
|
3427
|
+
*/
|
|
3428
|
+
declare function OrderConfirmation({ order, accountUrl, downloadsUrl, registerUrl, lookupUrl, catalogUrl, showTitle, }: OrderConfirmationViewProps): ReactElement;
|
|
3429
|
+
|
|
3430
|
+
/**
|
|
3431
|
+
* A placed order's details, shared by the confirmation page, the account
|
|
3432
|
+
* order page and the guest order view.
|
|
3433
|
+
*
|
|
3434
|
+
* Mirrors ecommerce-storefront-livewire's `partials/order-details`: an
|
|
3435
|
+
* Items card (list rows with a 64px thumbnail, the name, the options, the
|
|
3436
|
+
* SKU with "2 × $28.00", and the line total), then any downloads, then two
|
|
3437
|
+
* cards side by side that stack below 768px: Addresses and payment (a
|
|
3438
|
+
* `<dl>` with the shipping and billing addresses, the payment method and
|
|
3439
|
+
* email, and the shopper's note) and the Order summary.
|
|
3440
|
+
*
|
|
3441
|
+
* Each card's heading is an `<h2>` of its own (the design-system Card's
|
|
3442
|
+
* title is an `<h3>`), so the details keep their place in the page's
|
|
3443
|
+
* outline.
|
|
3444
|
+
*
|
|
3445
|
+
* @since 1.0.0
|
|
3446
|
+
*/
|
|
3447
|
+
|
|
3448
|
+
/**
|
|
3449
|
+
* Props for {@link OrderDetails}.
|
|
3450
|
+
*
|
|
3451
|
+
* @since 1.0.0
|
|
3452
|
+
*/
|
|
3453
|
+
interface OrderDetailsProps {
|
|
3454
|
+
order: StorefrontOrderDetails;
|
|
3455
|
+
/** Links the downloads to the shopper's account; without it guests are told the links are in their email. */
|
|
3456
|
+
downloadsUrl?: string | null;
|
|
3457
|
+
}
|
|
3458
|
+
/**
|
|
3459
|
+
* An order's status as a soft Badge with its icon, so the status doesn't
|
|
3460
|
+
* rest on color.
|
|
3461
|
+
*
|
|
3462
|
+
* @since 1.0.0
|
|
3463
|
+
*
|
|
3464
|
+
* @param props - The status.
|
|
3465
|
+
* @returns The badge.
|
|
3466
|
+
*/
|
|
3467
|
+
declare function OrderStatusBadge({ status }: {
|
|
3468
|
+
status: StorefrontOrderStatus;
|
|
3469
|
+
}): ReactElement;
|
|
3470
|
+
/**
|
|
3471
|
+
* The order's details.
|
|
3472
|
+
*
|
|
3473
|
+
* @since 1.0.0
|
|
3474
|
+
*
|
|
3475
|
+
* @param props - The order and the downloads link.
|
|
3476
|
+
* @returns The details.
|
|
3477
|
+
*/
|
|
3478
|
+
declare function OrderDetails({ order, downloadsUrl }: OrderDetailsProps): ReactElement;
|
|
3479
|
+
|
|
3480
|
+
/**
|
|
3481
|
+
* The guest order lookup.
|
|
3482
|
+
*
|
|
3483
|
+
* Mirrors ecommerce-storefront-livewire's `order/lookup`: a centered 480px
|
|
3484
|
+
* column with "Find your order" (the page's h1) and where to find both
|
|
3485
|
+
* details. A failure is an error Alert above the form in an assertive live
|
|
3486
|
+
* region; when no order matched, the order number field is marked invalid.
|
|
3487
|
+
* The form sits in a Card: email (with a mail icon) and order number, then
|
|
3488
|
+
* a full-width "Find my order". "Have an account? Sign in to see all your
|
|
3489
|
+
* orders" sits under the Card.
|
|
3490
|
+
*
|
|
3491
|
+
* The form posts `email` and `order_number` to `findUrl`; a match
|
|
3492
|
+
* redirects to the order's signed page.
|
|
3493
|
+
*
|
|
3494
|
+
* @since 1.0.0
|
|
3495
|
+
*/
|
|
3496
|
+
|
|
3497
|
+
/**
|
|
3498
|
+
* Props for {@link OrderLookup}.
|
|
3499
|
+
*
|
|
3500
|
+
* @since 1.0.0
|
|
3501
|
+
*/
|
|
3502
|
+
interface OrderLookupViewProps extends OrderLookupProps {
|
|
3503
|
+
/** Draw "Find your order" as the page's h1. */
|
|
3504
|
+
showTitle?: boolean;
|
|
3505
|
+
}
|
|
3506
|
+
/**
|
|
3507
|
+
* The lookup.
|
|
3508
|
+
*
|
|
3509
|
+
* @since 1.0.0
|
|
3510
|
+
*
|
|
3511
|
+
* @param props - Where to post, the sign-in link and the last failure.
|
|
3512
|
+
* @returns The lookup.
|
|
3513
|
+
*/
|
|
3514
|
+
declare function OrderLookup({ findUrl, loginUrl, failure, showTitle, }: OrderLookupViewProps): ReactElement;
|
|
3515
|
+
|
|
3516
|
+
/**
|
|
3517
|
+
* "Ordered as a guest? Find your order", for the host's sign-in screen,
|
|
3518
|
+
* which the storefront doesn't own.
|
|
3519
|
+
*
|
|
3520
|
+
* Mirrors ecommerce-storefront-livewire's `partials/order-lookup-link`:
|
|
3521
|
+
* muted body-small text with the design-system Link in its muted tone, a
|
|
3522
|
+
* full page load (the lookup page uses the storefront layout, not the
|
|
3523
|
+
* host's).
|
|
3524
|
+
*
|
|
3525
|
+
* @since 1.0.0
|
|
3526
|
+
*/
|
|
3527
|
+
|
|
3528
|
+
/**
|
|
3529
|
+
* Props for {@link OrderLookupLink}.
|
|
3530
|
+
*
|
|
3531
|
+
* @since 1.0.0
|
|
3532
|
+
*/
|
|
3533
|
+
interface OrderLookupLinkProps {
|
|
3534
|
+
/** The lookup page's URL; null draws nothing. */
|
|
3535
|
+
href: string | null;
|
|
3536
|
+
}
|
|
3537
|
+
/**
|
|
3538
|
+
* The link.
|
|
3539
|
+
*
|
|
3540
|
+
* @since 1.0.0
|
|
3541
|
+
*
|
|
3542
|
+
* @param props - The lookup page's URL.
|
|
3543
|
+
* @returns The link, or nothing without a URL.
|
|
3544
|
+
*/
|
|
3545
|
+
declare function OrderLookupLink({ href }: OrderLookupLinkProps): ReactElement | null;
|
|
3546
|
+
|
|
3547
|
+
/**
|
|
3548
|
+
* One order: the account's order page, and the read-only guest order view
|
|
3549
|
+
* a signed link opens.
|
|
3550
|
+
*
|
|
3551
|
+
* Mirrors ecommerce-storefront-livewire's `account/order-show`. The header:
|
|
3552
|
+
* "All orders" (the account) or an "Order lookup" breadcrumb (a guest),
|
|
3553
|
+
* then "Order {number}" (the page's h1, else an h2) over "Placed {date} ·
|
|
3554
|
+
* {n} items · {total}", with the status Badge and an outline "Buy again"
|
|
3555
|
+
* at the end. Then a Shipment Card per shipment (the design-system Steps,
|
|
3556
|
+
* and the carrier, tracking number and "Track package" on a sunken panel),
|
|
3557
|
+
* the store's messages as a Timeline in a Card, the order details, and any
|
|
3558
|
+
* refunds.
|
|
3559
|
+
*
|
|
3560
|
+
* @since 1.0.0
|
|
3561
|
+
*/
|
|
3562
|
+
|
|
3563
|
+
/**
|
|
3564
|
+
* Props for {@link OrderShow}.
|
|
3565
|
+
*
|
|
3566
|
+
* @since 1.0.0
|
|
3567
|
+
*/
|
|
3568
|
+
interface OrderShowProps extends AccountOrderShowProps {
|
|
3569
|
+
/** Make "Order {number}" the page's h1; else it is an h2. */
|
|
3570
|
+
showTitle?: boolean;
|
|
3571
|
+
}
|
|
3572
|
+
/**
|
|
3573
|
+
* The order.
|
|
3574
|
+
*
|
|
3575
|
+
* @since 1.0.0
|
|
3576
|
+
*
|
|
3577
|
+
* @param props - The order and its links.
|
|
3578
|
+
* @returns The order page's body.
|
|
3579
|
+
*/
|
|
3580
|
+
declare function OrderShow({ order, readOnly, canBuyAgain, buyAgainUrl, downloadsUrl, ordersUrl, lookupUrl, storeName, showTitle, }: OrderShowProps): ReactElement;
|
|
3581
|
+
|
|
3582
|
+
/**
|
|
3583
|
+
* The frame around every customer account page.
|
|
3584
|
+
*
|
|
3585
|
+
* Mirrors ecommerce-storefront-livewire's `components/account-shell`
|
|
3586
|
+
* (`ec-account`): from 1024px a sidebar (Avatar, name and email, the
|
|
3587
|
+
* account Menu, a Divider and a ghost "Sign out") beside the content; below
|
|
3588
|
+
* 1024px the sidebar hides, a bar says who is signed in with a small "Sign
|
|
3589
|
+
* out", and the same entries show as a row of tabs. Both navigations are
|
|
3590
|
+
* `<nav aria-label="Account">`; only one shows at a time. The current page
|
|
3591
|
+
* carries `aria-current="page"`. With a `title` the content starts with a
|
|
3592
|
+
* PageHeader holding the page's one h1; without one the content brings its
|
|
3593
|
+
* own.
|
|
3594
|
+
*
|
|
3595
|
+
* The entries are plain links (full page loads), as in Livewire. "Sign out"
|
|
3596
|
+
* is a real form post to the host's sign-out route with the root view's
|
|
3597
|
+
* CSRF token, since the host's response is usually not an Inertia page.
|
|
3598
|
+
*
|
|
3599
|
+
* @since 1.0.0
|
|
3600
|
+
*/
|
|
3601
|
+
|
|
3602
|
+
/**
|
|
3603
|
+
* Props for {@link AccountShell}.
|
|
3604
|
+
*
|
|
3605
|
+
* @since 1.0.0
|
|
3606
|
+
*/
|
|
3607
|
+
interface AccountShellProps {
|
|
3608
|
+
/** The `shell` prop every account page carries. */
|
|
3609
|
+
shell: StorefrontAccountShell;
|
|
3610
|
+
/** The page's h1, drawn in a PageHeader; leave it out when the content brings its own. */
|
|
3611
|
+
title?: string | null;
|
|
3612
|
+
children?: ReactNode;
|
|
3613
|
+
className?: string;
|
|
3614
|
+
}
|
|
3615
|
+
/**
|
|
3616
|
+
* The account frame.
|
|
3617
|
+
*
|
|
3618
|
+
* @since 1.0.0
|
|
3619
|
+
*
|
|
3620
|
+
* @param props - The shell, the optional title and the page's content.
|
|
3621
|
+
* @returns The frame.
|
|
3622
|
+
*/
|
|
3623
|
+
declare function AccountShell({ shell, title, children, className, }: AccountShellProps): ReactElement;
|
|
3624
|
+
|
|
3625
|
+
/**
|
|
3626
|
+
* The account dashboard.
|
|
3627
|
+
*
|
|
3628
|
+
* Mirrors ecommerce-storefront-livewire's `account/dashboard`: the greeting
|
|
3629
|
+
* (the page's h1, else a lead paragraph), then the Recent orders Card (a
|
|
3630
|
+
* divided List, or the EmptyState with "Start shopping"), then three Cards
|
|
3631
|
+
* that stack below 768px (the default shipping and billing addresses and
|
|
3632
|
+
* the downloads), then the claim prompt and ghost links to edit the profile
|
|
3633
|
+
* and change the password.
|
|
3634
|
+
*
|
|
3635
|
+
* @since 1.0.0
|
|
3636
|
+
*/
|
|
3637
|
+
|
|
3638
|
+
/**
|
|
3639
|
+
* Props for {@link AccountDashboard}.
|
|
3640
|
+
*
|
|
3641
|
+
* @since 1.0.0
|
|
3642
|
+
*/
|
|
3643
|
+
interface AccountDashboardViewProps extends Omit<AccountDashboardProps, 'shell'> {
|
|
3644
|
+
/** The greeting; defaults to "Welcome back, {name}." */
|
|
3645
|
+
greeting?: string | null;
|
|
3646
|
+
/** Draw the greeting as the page's h1; else a lead paragraph. */
|
|
3647
|
+
showTitle?: boolean;
|
|
3648
|
+
}
|
|
3649
|
+
/**
|
|
3650
|
+
* The dashboard.
|
|
3651
|
+
*
|
|
3652
|
+
* @since 1.0.0
|
|
3653
|
+
*
|
|
3654
|
+
* @param props - The dashboard's props.
|
|
3655
|
+
* @returns The dashboard.
|
|
3656
|
+
*/
|
|
3657
|
+
declare function AccountDashboard({ name, greeting, showTitle, orders, shippingAddress, billingAddress, billingSame, downloads, failed, claimable, claimUrl, ordersUrl, addressesUrl, downloadsUrl, catalogUrl, profileUrl, passwordUrl, }: AccountDashboardViewProps): ReactElement;
|
|
3658
|
+
|
|
3659
|
+
/**
|
|
3660
|
+
* The order history.
|
|
3661
|
+
*
|
|
3662
|
+
* Mirrors ecommerce-storefront-livewire's `account/orders`: "Orders" (the
|
|
3663
|
+
* page's h1) with the "Show" filter at the end. From 768px the orders are a
|
|
3664
|
+
* Table (order number linking to the order, placed date, status Badge, item
|
|
3665
|
+
* count, total and a "View" link) with the Pagination in its footer; below
|
|
3666
|
+
* 768px the same orders are a divided List in a Card, with the Pagination
|
|
3667
|
+
* under it. No orders is the EmptyState in a Card with "Start shopping"
|
|
3668
|
+
* (or "Show all orders" when the filter matched nothing); a failure is a
|
|
3669
|
+
* warning Alert with "Try again" above the heading.
|
|
3670
|
+
*
|
|
3671
|
+
* Filtering and paging visit the page again with `?status=` and `?page=`.
|
|
3672
|
+
*
|
|
3673
|
+
* @since 1.0.0
|
|
3674
|
+
*/
|
|
3675
|
+
|
|
3676
|
+
/**
|
|
3677
|
+
* Props for {@link AccountOrders}.
|
|
3678
|
+
*
|
|
3679
|
+
* @since 1.0.0
|
|
3680
|
+
*/
|
|
3681
|
+
interface AccountOrdersViewProps extends Omit<AccountOrdersProps, 'shell'> {
|
|
3682
|
+
/** Draw "Orders" as the page's h1. */
|
|
3683
|
+
showTitle?: boolean;
|
|
3684
|
+
}
|
|
3685
|
+
/**
|
|
3686
|
+
* The order history.
|
|
3687
|
+
*
|
|
3688
|
+
* @since 1.0.0
|
|
3689
|
+
*
|
|
3690
|
+
* @param props - The orders, their pagination and the filter.
|
|
3691
|
+
* @returns The order history.
|
|
3692
|
+
*/
|
|
3693
|
+
declare function AccountOrders({ orders, pagination, status, filters, failed, catalogUrl, showTitle, }: AccountOrdersViewProps): ReactElement;
|
|
3694
|
+
|
|
3695
|
+
/**
|
|
3696
|
+
* The address book.
|
|
3697
|
+
*
|
|
3698
|
+
* Mirrors ecommerce-storefront-livewire's `account/addresses`: "Saved
|
|
3699
|
+
* addresses" (the page's h1) with "Add an address" at the end. The
|
|
3700
|
+
* addresses are Cards, two across from 768px: the label with its "Default
|
|
3701
|
+
* shipping" and "Default billing" Badges, the address, then a footer with
|
|
3702
|
+
* "Edit", "Use for shipping" and "Use for billing" (each only while it
|
|
3703
|
+
* isn't already the default) and "Delete". No addresses is the EmptyState
|
|
3704
|
+
* in a Card. Adding and editing open the address form in a Dialog; deleting
|
|
3705
|
+
* asks first in an alert Dialog.
|
|
3706
|
+
*
|
|
3707
|
+
* A new address posts to `storeUrl`, an edit PATCHes the address's
|
|
3708
|
+
* `updateUrl`, "Delete" sends DELETE to its `deleteUrl` and "Use for …"
|
|
3709
|
+
* posts `{ type }` to its `defaultUrl`; each redirects back with a toast.
|
|
3710
|
+
* Errors come back keyed by field.
|
|
3711
|
+
*
|
|
3712
|
+
* @since 1.0.0
|
|
3713
|
+
*/
|
|
3714
|
+
|
|
3715
|
+
/**
|
|
3716
|
+
* Props for {@link AccountAddresses}.
|
|
3717
|
+
*
|
|
3718
|
+
* @since 1.0.0
|
|
3719
|
+
*/
|
|
3720
|
+
interface AccountAddressesViewProps extends Omit<AccountAddressesProps, 'shell'> {
|
|
3721
|
+
/** Draw "Saved addresses" as the page's h1. */
|
|
3722
|
+
showTitle?: boolean;
|
|
3723
|
+
}
|
|
3724
|
+
/**
|
|
3725
|
+
* The address book.
|
|
3726
|
+
*
|
|
3727
|
+
* @since 1.0.0
|
|
3728
|
+
*
|
|
3729
|
+
* @param props - The addresses, the blank form and where to save.
|
|
3730
|
+
* @returns The address book.
|
|
3731
|
+
*/
|
|
3732
|
+
declare function AccountAddresses({ addresses, failed, blankForm, form, labelMax, storeUrl, showTitle, }: AccountAddressesViewProps): ReactElement;
|
|
3733
|
+
|
|
3734
|
+
/**
|
|
3735
|
+
* Downloads and license keys.
|
|
3736
|
+
*
|
|
3737
|
+
* Mirrors ecommerce-storefront-livewire's `account/downloads`: the lead
|
|
3738
|
+
* line, then two Cards. Files: a divided List, each row a file (or play)
|
|
3739
|
+
* icon tile, the file's name, then its product, version, downloads left,
|
|
3740
|
+
* expiry and order (or why it can't be downloaded), with an outline
|
|
3741
|
+
* "Download" or "Play" (opens in a new tab) at the end, or an "Expired" /
|
|
3742
|
+
* "No downloads left" Badge. License keys: each key's product and tier with
|
|
3743
|
+
* a state Badge, then the key in the design-system Clipboard field, and the
|
|
3744
|
+
* activations. No files and no keys is the EmptyState in a Card.
|
|
3745
|
+
*
|
|
3746
|
+
* The file links are plain links to the signed `downloads.file` and
|
|
3747
|
+
* `downloads.stream` routes, never Inertia visits. "Download" posts to
|
|
3748
|
+
* `linkUrl` for a freshly signed link when clicked, so a page left open
|
|
3749
|
+
* past the link's lifetime still works; its href is the fallback.
|
|
3750
|
+
*
|
|
3751
|
+
* @since 1.0.0
|
|
3752
|
+
*/
|
|
3753
|
+
|
|
3754
|
+
/**
|
|
3755
|
+
* Props for {@link AccountDownloads}.
|
|
3756
|
+
*
|
|
3757
|
+
* @since 1.0.0
|
|
3758
|
+
*/
|
|
3759
|
+
type AccountDownloadsViewProps = Omit<AccountDownloadsProps, 'shell'>;
|
|
3760
|
+
/**
|
|
3761
|
+
* The downloads page's body.
|
|
3762
|
+
*
|
|
3763
|
+
* @since 1.0.0
|
|
3764
|
+
*
|
|
3765
|
+
* @param props - The files, the license keys and the catalog link.
|
|
3766
|
+
* @returns The downloads.
|
|
3767
|
+
*/
|
|
3768
|
+
declare function AccountDownloads({ downloads, licenses, failed, catalogUrl, }: AccountDownloadsViewProps): ReactElement;
|
|
3769
|
+
|
|
3770
|
+
/**
|
|
3771
|
+
* The profile and notification preferences.
|
|
3772
|
+
*
|
|
3773
|
+
* Mirrors ecommerce-storefront-livewire's `account/profile`: three Cards.
|
|
3774
|
+
* Your details: first and last name, the optional phone, the news-and-offers
|
|
3775
|
+
* consent, and "Save details" in the footer. Email and password: the
|
|
3776
|
+
* sign-in address and outline links to the host's screens. Notifications: a
|
|
3777
|
+
* Toggle per category for each channel (the always-sent one locked on, news
|
|
3778
|
+
* and offers off until the shopper agrees above), and "Save notification
|
|
3779
|
+
* preferences" in the footer.
|
|
3780
|
+
*
|
|
3781
|
+
* "Save details" PATCHes all four fields to `updateUrl`; the preferences
|
|
3782
|
+
* PATCH `{ preferences }` to `preferencesUrl`. Both redirect back with a
|
|
3783
|
+
* toast. The forms keep the shopper's input across a failed save; a save
|
|
3784
|
+
* that worked keeps what was saved, and takes the preferences the server
|
|
3785
|
+
* sends back (withdrawing consent switches news and offers off).
|
|
3786
|
+
*
|
|
3787
|
+
* @since 1.0.0
|
|
3788
|
+
*/
|
|
3789
|
+
|
|
3790
|
+
/**
|
|
3791
|
+
* Props for {@link AccountProfile}.
|
|
3792
|
+
*
|
|
3793
|
+
* @since 1.0.0
|
|
3794
|
+
*/
|
|
3795
|
+
type AccountProfileViewProps = Omit<AccountProfileProps, 'shell'>;
|
|
3796
|
+
/**
|
|
3797
|
+
* The profile page's body.
|
|
3798
|
+
*
|
|
3799
|
+
* @since 1.0.0
|
|
3800
|
+
*
|
|
3801
|
+
* @param props - The profile, the preferences and where they save.
|
|
3802
|
+
* @returns The profile.
|
|
3803
|
+
*/
|
|
3804
|
+
declare function AccountProfile({ profile, preferences, email, consented, channels, categories, profileUrl, passwordUrl, updateUrl, preferencesUrl, }: AccountProfileViewProps): ReactElement;
|
|
3805
|
+
|
|
3806
|
+
/**
|
|
3807
|
+
* Claiming guest orders.
|
|
3808
|
+
*
|
|
3809
|
+
* Mirrors ecommerce-storefront-livewire's `account/claim`: the lead line,
|
|
3810
|
+
* then a success Alert after a claim ("Order {number} is now in your
|
|
3811
|
+
* account", or how many joined, with an outline "View orders") in a polite
|
|
3812
|
+
* live region, or an error Alert in an assertive one. The form sits in a
|
|
3813
|
+
* Card: the order number and shipping postcode, then "Claim orders".
|
|
3814
|
+
*
|
|
3815
|
+
* The form posts `order_number` and `postal_code` to `claimUrl`, which
|
|
3816
|
+
* redirects back with `claimed` or `failure`.
|
|
3817
|
+
*
|
|
3818
|
+
* @since 1.0.0
|
|
3819
|
+
*/
|
|
3820
|
+
|
|
3821
|
+
/**
|
|
3822
|
+
* Props for {@link AccountClaim}.
|
|
3823
|
+
*
|
|
3824
|
+
* @since 1.0.0
|
|
3825
|
+
*/
|
|
3826
|
+
type AccountClaimViewProps = Omit<AccountClaimProps, 'shell'>;
|
|
3827
|
+
/**
|
|
3828
|
+
* The claim page's body.
|
|
3829
|
+
*
|
|
3830
|
+
* @since 1.0.0
|
|
3831
|
+
*
|
|
3832
|
+
* @param props - Where to post, the orders link and the last claim's result.
|
|
3833
|
+
* @returns The claim form.
|
|
3834
|
+
*/
|
|
3835
|
+
declare function AccountClaim({ claimUrl, ordersUrl, claimed, failure, }: AccountClaimViewProps): ReactElement;
|
|
3836
|
+
|
|
3837
|
+
/**
|
|
3838
|
+
* Types shared by the commerce block components.
|
|
3839
|
+
*
|
|
3840
|
+
* @since 1.0.0
|
|
3841
|
+
*/
|
|
3842
|
+
|
|
3843
|
+
/**
|
|
3844
|
+
* What a commerce block's component gets: the block's props (the
|
|
3845
|
+
* `-core` props type for its name) and its clamped attributes.
|
|
3846
|
+
*
|
|
3847
|
+
* @since 1.0.0
|
|
3848
|
+
*/
|
|
3849
|
+
interface StorefrontBlockComponentProps<TProps = unknown> {
|
|
3850
|
+
/** The block's props, as its presentation carries them. */
|
|
3851
|
+
props: TProps;
|
|
3852
|
+
/** The block's attributes, clamped to its schema. */
|
|
3853
|
+
attributes: Record<string, unknown>;
|
|
3854
|
+
}
|
|
3855
|
+
/**
|
|
3856
|
+
* A commerce block's component.
|
|
3857
|
+
*
|
|
3858
|
+
* @since 1.0.0
|
|
3859
|
+
*/
|
|
3860
|
+
type StorefrontBlockComponent = ComponentType<StorefrontBlockComponentProps<any>>;
|
|
3861
|
+
|
|
3862
|
+
/**
|
|
3863
|
+
* Draws a commerce block from its presentation, and keeps the component
|
|
3864
|
+
* each block name draws with.
|
|
3865
|
+
*
|
|
3866
|
+
* Mirrors ecommerce-storefront-livewire's `blocks/block` wrapper: a
|
|
3867
|
+
* `.ec-commerce-block` carrying `data-commerce-block`, with the dashed
|
|
3868
|
+
* "Sample product" notice above the block when an editor preview fell back
|
|
3869
|
+
* to the newest product.
|
|
3870
|
+
*
|
|
3871
|
+
* @since 1.0.0
|
|
3872
|
+
*/
|
|
3873
|
+
|
|
3874
|
+
/**
|
|
3875
|
+
* The prefix every commerce block name starts with.
|
|
3876
|
+
*
|
|
3877
|
+
* @since 1.0.0
|
|
3878
|
+
*/
|
|
3879
|
+
declare const STOREFRONT_BLOCK_PREFIX = "artisanpack-commerce/";
|
|
3880
|
+
/**
|
|
3881
|
+
* The storefront's own blocks, by name.
|
|
3882
|
+
*
|
|
3883
|
+
* @since 1.0.0
|
|
3884
|
+
*/
|
|
3885
|
+
declare const STOREFRONT_BLOCKS: Readonly<Record<StorefrontBlockName, StorefrontBlockComponent>>;
|
|
3886
|
+
/**
|
|
3887
|
+
* Draws a commerce block of your own (a `StorefrontBlock` subclass added
|
|
3888
|
+
* with the `ap.ecommerceStorefrontInertia.blocks` filter), or replaces a
|
|
3889
|
+
* built-in block's component.
|
|
3890
|
+
*
|
|
3891
|
+
* @since 1.0.0
|
|
3892
|
+
*
|
|
3893
|
+
* @param name - The block's full name (`artisanpack-commerce/{slug}`).
|
|
3894
|
+
* @param component - The component, which gets `{ props, attributes }`.
|
|
3895
|
+
*/
|
|
3896
|
+
declare function registerStorefrontBlock(name: string, component: StorefrontBlockComponent): void;
|
|
3897
|
+
/**
|
|
3898
|
+
* The component a block name draws with: one you registered, else the
|
|
3899
|
+
* built-in one.
|
|
3900
|
+
*
|
|
3901
|
+
* @since 1.0.0
|
|
3902
|
+
*
|
|
3903
|
+
* @param name - The block's full name.
|
|
3904
|
+
* @returns The component, or undefined for a name nothing draws.
|
|
3905
|
+
*/
|
|
3906
|
+
declare function getStorefrontBlock(name: string): StorefrontBlockComponent | undefined;
|
|
3907
|
+
/**
|
|
3908
|
+
* Every commerce block name a component is known for, built-in ones first.
|
|
3909
|
+
*
|
|
3910
|
+
* @since 1.0.0
|
|
3911
|
+
*
|
|
3912
|
+
* @returns The names.
|
|
3913
|
+
*/
|
|
3914
|
+
declare function storefrontBlockNames(): string[];
|
|
3915
|
+
/**
|
|
3916
|
+
* Forgets the blocks registered with {@link registerStorefrontBlock}
|
|
3917
|
+
* (tests).
|
|
3918
|
+
*
|
|
3919
|
+
* @since 1.0.0
|
|
3920
|
+
*/
|
|
3921
|
+
declare function resetStorefrontBlocks(): void;
|
|
3922
|
+
/**
|
|
3923
|
+
* A block name's slug: `artisanpack-commerce/product-grid` → `product-grid`.
|
|
3924
|
+
*
|
|
3925
|
+
* @since 1.0.0
|
|
3926
|
+
*
|
|
3927
|
+
* @param name - The block's full name.
|
|
3928
|
+
* @returns The slug.
|
|
3929
|
+
*/
|
|
3930
|
+
declare function storefrontBlockSlug(name: string): string;
|
|
3931
|
+
/**
|
|
3932
|
+
* The dashed notice over a block whose editor preview fell back to the
|
|
3933
|
+
* newest product.
|
|
3934
|
+
*
|
|
3935
|
+
* @since 1.0.0
|
|
3936
|
+
*
|
|
3937
|
+
* @returns The notice.
|
|
3938
|
+
*/
|
|
3939
|
+
declare function BlockSampleNotice(): ReactElement;
|
|
3940
|
+
/**
|
|
3941
|
+
* Props for {@link StorefrontBlockBody} and {@link StorefrontBlock}.
|
|
3942
|
+
*
|
|
3943
|
+
* @since 1.0.0
|
|
3944
|
+
*/
|
|
3945
|
+
interface StorefrontBlockProps {
|
|
3946
|
+
/** The block's presentation; null when it has nothing to show. */
|
|
3947
|
+
presentation: StorefrontBlockPresentation | null;
|
|
3948
|
+
/** Extra classes for the wrapper ({@link StorefrontBlock} only). */
|
|
3949
|
+
className?: string;
|
|
3950
|
+
}
|
|
3951
|
+
/**
|
|
3952
|
+
* A block's content without the wrapper: the sample notice, if any, then
|
|
3953
|
+
* the block's component. An island draws this inside its own
|
|
3954
|
+
* `[data-ec-block]` element, which is already the wrapper.
|
|
3955
|
+
*
|
|
3956
|
+
* @since 1.0.0
|
|
3957
|
+
*
|
|
3958
|
+
* @param props - The presentation.
|
|
3959
|
+
* @returns The content, or nothing for a block with nothing to show or no component.
|
|
3960
|
+
*/
|
|
3961
|
+
declare function StorefrontBlockBody({ presentation }: StorefrontBlockProps): ReactElement | null;
|
|
3962
|
+
/**
|
|
3963
|
+
* A commerce block in its `.ec-commerce-block` wrapper.
|
|
3964
|
+
*
|
|
3965
|
+
* @since 1.0.0
|
|
3966
|
+
*
|
|
3967
|
+
* @param props - The presentation and extra wrapper classes.
|
|
3968
|
+
* @returns The block, or nothing when it has nothing to show.
|
|
3969
|
+
*/
|
|
3970
|
+
declare function StorefrontBlock({ presentation, className, }: StorefrontBlockProps): ReactElement | null;
|
|
3971
|
+
|
|
3972
|
+
/**
|
|
3973
|
+
* Gives a commerce block's components a page whose props include the
|
|
3974
|
+
* block's own.
|
|
3975
|
+
*
|
|
3976
|
+
* @since 1.0.0
|
|
3977
|
+
*/
|
|
3978
|
+
|
|
3979
|
+
/**
|
|
3980
|
+
* Props for {@link BlockPage}.
|
|
3981
|
+
*
|
|
3982
|
+
* @since 1.0.0
|
|
3983
|
+
*/
|
|
3984
|
+
interface BlockPageProps {
|
|
3985
|
+
/** Props laid over the current page's (a Single Product block's product page props). */
|
|
3986
|
+
props: Record<string, unknown>;
|
|
3987
|
+
children: ReactNode;
|
|
3988
|
+
}
|
|
3989
|
+
/**
|
|
3990
|
+
* Lays `props` over the current page's props for the children, so the
|
|
3991
|
+
* product page's sections (reviews, related products) read a Single Product
|
|
3992
|
+
* block's props as they read the product page's.
|
|
3993
|
+
*
|
|
3994
|
+
* @since 1.0.0
|
|
3995
|
+
*
|
|
3996
|
+
* @param props - The props to lay over the page's, and the children.
|
|
3997
|
+
* @returns The children, inside the page.
|
|
3998
|
+
*/
|
|
3999
|
+
declare function BlockPage({ props, children }: BlockPageProps): ReactElement;
|
|
4000
|
+
|
|
4001
|
+
/**
|
|
4002
|
+
* The page commerce blocks read where no storefront page is in effect.
|
|
4003
|
+
*
|
|
4004
|
+
* Storefront pages share the `ecommerceStorefront` prop, which the block
|
|
4005
|
+
* components read (the locale, the storefront's routes, the cart's URL). A
|
|
4006
|
+
* block can also sit on a page the storefront didn't render: a CMS page
|
|
4007
|
+
* drawn by visual-editor's renderer, or an island hydrated in a Blade page,
|
|
4008
|
+
* outside Inertia. There the block gets stand-in shared props built from
|
|
4009
|
+
* {@link configureStorefrontBlocks} and the document.
|
|
4010
|
+
*
|
|
4011
|
+
* @since 1.0.0
|
|
4012
|
+
*/
|
|
4013
|
+
|
|
4014
|
+
/**
|
|
4015
|
+
* Settings for commerce blocks drawn outside the storefront's pages.
|
|
4016
|
+
*
|
|
4017
|
+
* @since 1.0.0
|
|
4018
|
+
*/
|
|
4019
|
+
interface StorefrontBlockSettings {
|
|
4020
|
+
/**
|
|
4021
|
+
* The storefront's home URL (the catalog, `/shop` by default), which the
|
|
4022
|
+
* blocks build the storefront's routes from: the `blocks.props` route, the
|
|
4023
|
+
* cart and quick add. Storefront pages send it themselves.
|
|
4024
|
+
*/
|
|
4025
|
+
storefrontUrl?: string | null;
|
|
4026
|
+
/** The `blocks.props` route's URL, when it isn't `{storefrontUrl}/blocks/props`. */
|
|
4027
|
+
propsUrl?: string | null;
|
|
4028
|
+
/** The locale, when the document's `lang` isn't it (`pt_BR`). */
|
|
4029
|
+
locale?: string;
|
|
4030
|
+
}
|
|
4031
|
+
/**
|
|
4032
|
+
* Sets how commerce blocks reach the storefront from pages it didn't render.
|
|
4033
|
+
*
|
|
4034
|
+
* @since 1.0.0
|
|
4035
|
+
*
|
|
4036
|
+
* @param next - The settings; omitted keys keep their values.
|
|
4037
|
+
*/
|
|
4038
|
+
declare function configureStorefrontBlocks(next: StorefrontBlockSettings): void;
|
|
4039
|
+
/**
|
|
4040
|
+
* The current block settings.
|
|
4041
|
+
*
|
|
4042
|
+
* @since 1.0.0
|
|
4043
|
+
*
|
|
4044
|
+
* @returns The settings.
|
|
4045
|
+
*/
|
|
4046
|
+
declare function storefrontBlockSettings(): StorefrontBlockSettings;
|
|
4047
|
+
/**
|
|
4048
|
+
* Forgets the block settings (tests).
|
|
4049
|
+
*
|
|
4050
|
+
* @since 1.0.0
|
|
4051
|
+
*/
|
|
4052
|
+
declare function resetStorefrontBlockSettings(): void;
|
|
4053
|
+
/**
|
|
4054
|
+
* Stand-in `ecommerceStorefront` props for a page the storefront didn't
|
|
4055
|
+
* render: the locale and direction from the document, and the storefront's
|
|
4056
|
+
* routes from {@link configureStorefrontBlocks}. Nothing in it is the
|
|
4057
|
+
* shopper's (an empty cart count, no account), so the blocks only read
|
|
4058
|
+
* their own props for that.
|
|
4059
|
+
*
|
|
4060
|
+
* @since 1.0.0
|
|
4061
|
+
*
|
|
4062
|
+
* @returns The shared props.
|
|
4063
|
+
*/
|
|
4064
|
+
declare function fallbackSharedProps(): EcommerceStorefrontSharedProps;
|
|
4065
|
+
/**
|
|
4066
|
+
* Props for {@link StorefrontBlockRoot}.
|
|
4067
|
+
*
|
|
4068
|
+
* @since 1.0.0
|
|
4069
|
+
*/
|
|
4070
|
+
interface StorefrontBlockRootProps {
|
|
4071
|
+
/**
|
|
4072
|
+
* The page the block sits on. Leave it out on a page Inertia renders
|
|
4073
|
+
* (the block reads Inertia's page); give it in a React root of its own.
|
|
4074
|
+
*/
|
|
4075
|
+
page?: StorefrontPageSnapshot | null;
|
|
4076
|
+
children: ReactNode;
|
|
4077
|
+
}
|
|
4078
|
+
/**
|
|
4079
|
+
* Gives a block the page it sits on, with stand-in shared props when that
|
|
4080
|
+
* page has no `ecommerceStorefront` prop.
|
|
4081
|
+
*
|
|
4082
|
+
* @since 1.0.0
|
|
4083
|
+
*
|
|
4084
|
+
* @param props - The page, and the block.
|
|
4085
|
+
* @returns The block, inside the page.
|
|
4086
|
+
*/
|
|
4087
|
+
declare function StorefrontBlockRoot({ page, children }: StorefrontBlockRootProps): ReactElement;
|
|
4088
|
+
|
|
4089
|
+
/**
|
|
4090
|
+
* The catalog commerce blocks: Product Grid, Category Grid and Product
|
|
4091
|
+
* Catalog.
|
|
4092
|
+
*
|
|
4093
|
+
* Each draws the component the matching storefront page draws, as the
|
|
4094
|
+
* Livewire blocks mount the same Livewire components.
|
|
4095
|
+
*
|
|
4096
|
+
* @since 1.0.0
|
|
4097
|
+
*/
|
|
4098
|
+
|
|
4099
|
+
/**
|
|
4100
|
+
* The Product Grid block: the catalog's product grid, with quick add.
|
|
4101
|
+
*
|
|
4102
|
+
* @since 1.0.0
|
|
4103
|
+
*
|
|
4104
|
+
* @param props - The block's props and attributes.
|
|
4105
|
+
* @returns The grid.
|
|
4106
|
+
*/
|
|
4107
|
+
declare function ProductGridBlock({ props, attributes, }: StorefrontBlockComponentProps<StorefrontProductGrid>): ReactElement;
|
|
4108
|
+
/**
|
|
4109
|
+
* The Category Grid block: category tiles.
|
|
4110
|
+
*
|
|
4111
|
+
* @since 1.0.0
|
|
4112
|
+
*
|
|
4113
|
+
* @param props - The block's props.
|
|
4114
|
+
* @returns The grid, or nothing without tiles.
|
|
4115
|
+
*/
|
|
4116
|
+
declare function CategoryGridBlock({ props, }: StorefrontBlockComponentProps<StorefrontCategoryGrid>): ReactElement | null;
|
|
4117
|
+
/**
|
|
4118
|
+
* The Product Catalog block: the listing of the page it's on.
|
|
4119
|
+
*
|
|
4120
|
+
* On the catalog, a category, a tag or the search page its `header` and
|
|
4121
|
+
* `listing` are null and it draws that page from the page's own props (a
|
|
4122
|
+
* category or tag hero drops to `<h2>` under a template's heading). Anywhere
|
|
4123
|
+
* else it carries the whole catalog and draws the catalog page.
|
|
4124
|
+
*
|
|
4125
|
+
* @since 1.0.0
|
|
4126
|
+
*
|
|
4127
|
+
* @param props - The block's props.
|
|
4128
|
+
* @returns The listing.
|
|
4129
|
+
*/
|
|
4130
|
+
declare function ProductCatalogBlock({ props, }: StorefrontBlockComponentProps<StorefrontProductCatalogBlockProps>): ReactElement | null;
|
|
4131
|
+
|
|
4132
|
+
/**
|
|
4133
|
+
* The product commerce blocks: Single Product, Product Gallery, Price,
|
|
4134
|
+
* Add-to-Cart Button, Reviews, Related Products and Recently Viewed.
|
|
4135
|
+
*
|
|
4136
|
+
* Each draws the product page's own component, as the Livewire blocks do.
|
|
4137
|
+
*
|
|
4138
|
+
* @since 1.0.0
|
|
4139
|
+
*/
|
|
4140
|
+
|
|
4141
|
+
/**
|
|
4142
|
+
* The Single Product block: the whole product page. Its sections read the
|
|
4143
|
+
* block's props as the page's, so the related products show at once.
|
|
4144
|
+
*
|
|
4145
|
+
* @since 1.0.0
|
|
4146
|
+
*
|
|
4147
|
+
* @param props - The product page's props.
|
|
4148
|
+
* @returns The product.
|
|
4149
|
+
*/
|
|
4150
|
+
declare function SingleProductBlock({ props, }: StorefrontBlockComponentProps<ProductShowProps>): ReactElement;
|
|
4151
|
+
/**
|
|
4152
|
+
* The Product Gallery block: the product's images.
|
|
4153
|
+
*
|
|
4154
|
+
* @since 1.0.0
|
|
4155
|
+
*
|
|
4156
|
+
* @param props - The gallery.
|
|
4157
|
+
* @returns The gallery.
|
|
4158
|
+
*/
|
|
4159
|
+
declare function ProductGalleryBlock({ props, }: StorefrontBlockComponentProps<StorefrontGallery>): ReactElement;
|
|
4160
|
+
/**
|
|
4161
|
+
* The Price block: the product's price at the product page's size.
|
|
4162
|
+
*
|
|
4163
|
+
* @since 1.0.0
|
|
4164
|
+
*
|
|
4165
|
+
* @param props - The price.
|
|
4166
|
+
* @returns The price.
|
|
4167
|
+
*/
|
|
4168
|
+
declare function ProductPriceBlock({ props, }: StorefrontBlockComponentProps<StorefrontProductPriceBlockProps>): ReactElement;
|
|
4169
|
+
/**
|
|
4170
|
+
* The Add-to-Cart Button block: the product's purchase form from the
|
|
4171
|
+
* `productForms` registry, or a neutral notice when its type has none. The
|
|
4172
|
+
* block's `showQuantity` can hide the form's stepper, never bring back one
|
|
4173
|
+
* the form leaves out.
|
|
4174
|
+
*
|
|
4175
|
+
* @since 1.0.0
|
|
4176
|
+
*
|
|
4177
|
+
* @param props - The form, the product and the button text.
|
|
4178
|
+
* @returns The form.
|
|
4179
|
+
*/
|
|
4180
|
+
declare function AddToCartBlock({ props, }: StorefrontBlockComponentProps<StorefrontAddToCartBlockProps>): ReactElement | null;
|
|
4181
|
+
/**
|
|
4182
|
+
* The Reviews block: the product's reviews, with or without the form.
|
|
4183
|
+
*
|
|
4184
|
+
* @since 1.0.0
|
|
4185
|
+
*
|
|
4186
|
+
* @param props - The product, its reviews and whether to offer the form.
|
|
4187
|
+
* @returns The reviews.
|
|
4188
|
+
*/
|
|
4189
|
+
declare function ProductReviewsBlock({ props, }: StorefrontBlockComponentProps<StorefrontProductReviewsBlockProps>): ReactElement;
|
|
4190
|
+
/**
|
|
4191
|
+
* The Related Products block: related products, upsells or cross-sells.
|
|
4192
|
+
*
|
|
4193
|
+
* @since 1.0.0
|
|
4194
|
+
*
|
|
4195
|
+
* @param props - The suggestions.
|
|
4196
|
+
* @returns The row.
|
|
4197
|
+
*/
|
|
4198
|
+
declare function RelatedProductsBlock({ props, }: StorefrontBlockComponentProps<StorefrontRelatedProducts>): ReactElement;
|
|
4199
|
+
/**
|
|
4200
|
+
* The Recently Viewed block: the shopper's recently viewed products. It
|
|
4201
|
+
* shows the row its props carry, then loads it again from the
|
|
4202
|
+
* `recently-viewed` route with the block's settings, as the product page's
|
|
4203
|
+
* section does, so a page restored from history (or a cached page) shows
|
|
4204
|
+
* the shopper's history as it is now.
|
|
4205
|
+
*
|
|
4206
|
+
* @since 1.0.0
|
|
4207
|
+
*
|
|
4208
|
+
* @param props - The row, and the block's limit, columns and heading.
|
|
4209
|
+
* @returns The row.
|
|
4210
|
+
*/
|
|
4211
|
+
declare function RecentlyViewedBlock({ props, attributes, }: StorefrontBlockComponentProps<StorefrontRecentlyViewed>): ReactElement;
|
|
4212
|
+
|
|
4213
|
+
/**
|
|
4214
|
+
* The cart and checkout commerce blocks: Cart Contents and Checkout Steps,
|
|
4215
|
+
* with the editor previews the Livewire blocks draw
|
|
4216
|
+
* (`blocks/cart-preview` and `blocks/checkout-preview`).
|
|
4217
|
+
*
|
|
4218
|
+
* @since 1.0.0
|
|
4219
|
+
*/
|
|
4220
|
+
|
|
4221
|
+
/**
|
|
4222
|
+
* The checkout page's name.
|
|
4223
|
+
*
|
|
4224
|
+
* @since 1.0.0
|
|
4225
|
+
*/
|
|
4226
|
+
declare const CHECKOUT_PAGE = "EcommerceStorefront/Checkout/Index";
|
|
4227
|
+
/**
|
|
4228
|
+
* Props for {@link CartPreview}.
|
|
4229
|
+
*
|
|
4230
|
+
* @since 1.0.0
|
|
4231
|
+
*/
|
|
4232
|
+
interface CartPreviewProps {
|
|
4233
|
+
lines: StorefrontCartPreviewLine[];
|
|
4234
|
+
subtotal: StorefrontMoney;
|
|
4235
|
+
showCrossSells: boolean;
|
|
4236
|
+
showCoupon: boolean;
|
|
4237
|
+
}
|
|
4238
|
+
/**
|
|
4239
|
+
* The Cart Contents block's editor preview: a sample cart, never saved.
|
|
4240
|
+
*
|
|
4241
|
+
* @since 1.0.0
|
|
4242
|
+
*
|
|
4243
|
+
* @param props - The sample lines, their subtotal and the block's options.
|
|
4244
|
+
* @returns The preview.
|
|
4245
|
+
*/
|
|
4246
|
+
declare function CartPreview({ lines, subtotal, showCrossSells, showCoupon, }: CartPreviewProps): ReactElement;
|
|
4247
|
+
/**
|
|
4248
|
+
* The Cart Contents block: the cart page's cart without its title, or the
|
|
4249
|
+
* sample cart in an editor preview.
|
|
4250
|
+
*
|
|
4251
|
+
* @since 1.0.0
|
|
4252
|
+
*
|
|
4253
|
+
* @param props - The cart page's props, or the preview.
|
|
4254
|
+
* @returns The cart.
|
|
4255
|
+
*/
|
|
4256
|
+
declare function CartContentsBlock({ props, }: StorefrontBlockComponentProps<StorefrontCartContentsBlockProps>): ReactElement;
|
|
4257
|
+
/**
|
|
4258
|
+
* Props for {@link CheckoutPreview}.
|
|
4259
|
+
*
|
|
4260
|
+
* @since 1.0.0
|
|
4261
|
+
*/
|
|
4262
|
+
interface CheckoutPreviewProps {
|
|
4263
|
+
layout: StorefrontCheckoutStepsBlockProps['layout'];
|
|
4264
|
+
steps: StorefrontCheckoutStepsBlockProps['steps'];
|
|
4265
|
+
}
|
|
4266
|
+
/**
|
|
4267
|
+
* The Checkout Steps block's preview: the steps in the chosen layout,
|
|
4268
|
+
* without a cart.
|
|
4269
|
+
*
|
|
4270
|
+
* @since 1.0.0
|
|
4271
|
+
*
|
|
4272
|
+
* @param props - The layout and the core steps.
|
|
4273
|
+
* @returns The preview.
|
|
4274
|
+
*/
|
|
4275
|
+
declare function CheckoutPreview({ layout, steps }: CheckoutPreviewProps): ReactElement;
|
|
4276
|
+
/**
|
|
4277
|
+
* The Checkout Steps block. On the checkout page it draws the checkout from
|
|
4278
|
+
* the page's props in the block's layout; elsewhere (an editor preview, a
|
|
4279
|
+
* page with no cart to check out) it draws the preview of the steps.
|
|
4280
|
+
*
|
|
4281
|
+
* @since 1.0.0
|
|
4282
|
+
*
|
|
4283
|
+
* @param props - The layout and the core steps.
|
|
4284
|
+
* @returns The checkout, or its preview.
|
|
4285
|
+
*/
|
|
4286
|
+
declare function CheckoutStepsBlock({ props, }: StorefrontBlockComponentProps<StorefrontCheckoutStepsBlockProps>): ReactElement;
|
|
4287
|
+
|
|
4288
|
+
/**
|
|
4289
|
+
* Commerce blocks inside a visual-editor block tree.
|
|
4290
|
+
*
|
|
4291
|
+
* visual-editor's React renderer (`@artisanpack-ui/visual-editor-renderer-react`)
|
|
4292
|
+
* draws a block tree by asking a registry for each block name's renderer, a
|
|
4293
|
+
* component that gets the block's `name` and `attributes`. Hand its
|
|
4294
|
+
* `registerBlockRenderer` to {@link registerStorefrontBlockRenderers} and
|
|
4295
|
+
* every commerce block in a tree draws with the storefront's components:
|
|
4296
|
+
*
|
|
4297
|
+
* ```tsx
|
|
4298
|
+
* import { registerBlockRenderer } from '@artisanpack-ui/visual-editor-renderer-react';
|
|
4299
|
+
* import { registerStorefrontBlockRenderers } from '@artisanpack-ui/ecommerce-storefront-react';
|
|
4300
|
+
*
|
|
4301
|
+
* registerStorefrontBlockRenderers(registerBlockRenderer);
|
|
4302
|
+
* ```
|
|
4303
|
+
*
|
|
4304
|
+
* A block finds its props in the templated page's `blockProps` (by the
|
|
4305
|
+
* `clientId` {@link storefrontTemplateTree} copied into its attributes), and
|
|
4306
|
+
* otherwise fetches them from the storefront's `blocks.props` route.
|
|
4307
|
+
*
|
|
4308
|
+
* @since 1.0.0
|
|
4309
|
+
*/
|
|
4310
|
+
|
|
4311
|
+
/**
|
|
4312
|
+
* The longest attributes JSON the `blocks.props` route reads, in bytes.
|
|
4313
|
+
*
|
|
4314
|
+
* @since 1.0.0
|
|
4315
|
+
*/
|
|
4316
|
+
declare const BLOCK_ATTRIBUTES_MAX_BYTES = 4096;
|
|
4317
|
+
/**
|
|
4318
|
+
* What a visual-editor block renderer gets (the parts the storefront reads).
|
|
4319
|
+
*
|
|
4320
|
+
* @since 1.0.0
|
|
4321
|
+
*/
|
|
4322
|
+
interface StorefrontBlockRendererProps {
|
|
4323
|
+
/** The block's name. */
|
|
4324
|
+
name: string;
|
|
4325
|
+
/** The block's saved attributes. */
|
|
4326
|
+
attributes: Record<string, unknown>;
|
|
4327
|
+
}
|
|
4328
|
+
/**
|
|
4329
|
+
* A block's saved attributes without the private keys renderers stamp on
|
|
4330
|
+
* them (`_ecClientId`, visual-editor's `_ve…`).
|
|
4331
|
+
*
|
|
4332
|
+
* @since 1.0.0
|
|
4333
|
+
*
|
|
4334
|
+
* @param attributes - The attributes.
|
|
4335
|
+
* @returns The block's own attributes.
|
|
4336
|
+
*/
|
|
4337
|
+
declare function publicBlockAttributes(attributes: Record<string, unknown>): Record<string, unknown>;
|
|
4338
|
+
/**
|
|
4339
|
+
* The `blocks.props` URL for a block, or null without a storefront URL or
|
|
4340
|
+
* when the attributes are too long for the route.
|
|
4341
|
+
*
|
|
4342
|
+
* @since 1.0.0
|
|
4343
|
+
*
|
|
4344
|
+
* @param endpoint - The route's URL (`{storefront}/blocks/props`).
|
|
4345
|
+
* @param name - The block's name.
|
|
4346
|
+
* @param attributes - The block's attributes.
|
|
4347
|
+
* @param productId - The page's product, for product blocks that follow the page.
|
|
4348
|
+
* @param query - More query parameters the block reads (a listing's filters, a review page).
|
|
4349
|
+
* @returns The URL.
|
|
4350
|
+
*/
|
|
4351
|
+
declare function blockPropsUrl(endpoint: string | null, name: string, attributes: Record<string, unknown>, productId?: number | null, query?: Record<string, string>): string | null;
|
|
4352
|
+
/**
|
|
4353
|
+
* The `blocks.props` route's URL for the current page: the configured one,
|
|
4354
|
+
* else the storefront's home URL followed by `/blocks/props`.
|
|
4355
|
+
*
|
|
4356
|
+
* @since 1.0.0
|
|
4357
|
+
*
|
|
4358
|
+
* @param storefrontBase - The storefront's home URL from the shared props.
|
|
4359
|
+
* @returns The URL, or null when it can't be built.
|
|
4360
|
+
*/
|
|
4361
|
+
declare function blockPropsEndpoint(storefrontBase: string | null | undefined): string | null;
|
|
4362
|
+
/**
|
|
4363
|
+
* A block's presentation, as it loads.
|
|
4364
|
+
*
|
|
4365
|
+
* @since 1.0.0
|
|
4366
|
+
*/
|
|
4367
|
+
type BlockPresentationState = {
|
|
4368
|
+
status: 'loading';
|
|
4369
|
+
} | {
|
|
4370
|
+
status: 'ready';
|
|
4371
|
+
presentation: StorefrontBlockPresentation | null;
|
|
4372
|
+
} | {
|
|
4373
|
+
status: 'error';
|
|
4374
|
+
};
|
|
4375
|
+
/**
|
|
4376
|
+
* Fetches a block's presentation from the `blocks.props` route.
|
|
4377
|
+
*
|
|
4378
|
+
* @since 1.0.0
|
|
4379
|
+
*
|
|
4380
|
+
* @param url - The route's URL for the block ({@link blockPropsUrl}).
|
|
4381
|
+
* @param signal - Aborts the request.
|
|
4382
|
+
* @returns The presentation, or null when the block has nothing to show.
|
|
4383
|
+
* @throws When the request fails or the answer isn't the route's.
|
|
4384
|
+
*/
|
|
4385
|
+
declare function fetchBlockPresentation(url: string, signal?: AbortSignal): Promise<StorefrontBlockPresentation | null>;
|
|
4386
|
+
/**
|
|
4387
|
+
* A block's presentation: from the templated page's `blockProps` when the
|
|
4388
|
+
* block is in the template, else fetched from the `blocks.props` route.
|
|
4389
|
+
*
|
|
4390
|
+
* @since 1.0.0
|
|
4391
|
+
*
|
|
4392
|
+
* @param name - The block's name.
|
|
4393
|
+
* @param attributes - The block's attributes, as the renderer gives them.
|
|
4394
|
+
* @returns The presentation's state.
|
|
4395
|
+
*/
|
|
4396
|
+
declare function useBlockPresentation(name: string, attributes: Record<string, unknown>): BlockPresentationState;
|
|
4397
|
+
/**
|
|
4398
|
+
* Draws a commerce block inside a visual-editor block tree. While its props
|
|
4399
|
+
* load it keeps an empty, busy wrapper; a block with nothing to show, or
|
|
4400
|
+
* whose props failed to load, draws nothing, as the server-rendered block
|
|
4401
|
+
* does on the site.
|
|
4402
|
+
*
|
|
4403
|
+
* @since 1.0.0
|
|
4404
|
+
*
|
|
4405
|
+
* @param props - The block's name and attributes.
|
|
4406
|
+
* @returns The block.
|
|
4407
|
+
*/
|
|
4408
|
+
declare function StorefrontBlockRenderer({ name, attributes, }: StorefrontBlockRendererProps): ReactElement | null;
|
|
4409
|
+
/**
|
|
4410
|
+
* Registers {@link StorefrontBlockRenderer} for every commerce block with a
|
|
4411
|
+
* renderer registry, such as visual-editor's `registerBlockRenderer`.
|
|
4412
|
+
*
|
|
4413
|
+
* @since 1.0.0
|
|
4414
|
+
*
|
|
4415
|
+
* @param register - The registry's register function.
|
|
4416
|
+
* @param names - The block names; every built-in and registered block by default.
|
|
4417
|
+
*/
|
|
4418
|
+
declare function registerStorefrontBlockRenderers(register: (name: string, renderer: ComponentType<StorefrontBlockRendererProps>) => void, names?: string[]): void;
|
|
4419
|
+
|
|
4420
|
+
/**
|
|
4421
|
+
* Hydrates the commerce block islands the server printed.
|
|
4422
|
+
*
|
|
4423
|
+
* When visual-editor renders a commerce block on the server (its block
|
|
4424
|
+
* preview, or a renderer's dynamic-block fallback), the block prints an
|
|
4425
|
+
* island: a `[data-ec-block]` element carrying its name, clamped attributes
|
|
4426
|
+
* and props as JSON around a plain-HTML fallback. {@link hydrateStorefrontBlocks}
|
|
4427
|
+
* finds the islands under a root, fetches each one's props from the
|
|
4428
|
+
* `blocks.props` route, and draws it with its block's component in a React
|
|
4429
|
+
* root of its own, replacing the fallback.
|
|
4430
|
+
*
|
|
4431
|
+
* @since 1.0.0
|
|
4432
|
+
*/
|
|
4433
|
+
|
|
4434
|
+
/**
|
|
4435
|
+
* The selector for an island.
|
|
4436
|
+
*
|
|
4437
|
+
* @since 1.0.0
|
|
4438
|
+
*/
|
|
4439
|
+
declare const BLOCK_ISLAND_SELECTOR = "[data-ec-block]";
|
|
4440
|
+
/**
|
|
4441
|
+
* The attribute a hydrated island carries, so it isn't hydrated twice.
|
|
4442
|
+
*
|
|
4443
|
+
* @since 1.0.0
|
|
4444
|
+
*/
|
|
4445
|
+
declare const BLOCK_ISLAND_HYDRATED = "data-ec-block-hydrated";
|
|
4446
|
+
/**
|
|
4447
|
+
* Options for {@link hydrateStorefrontBlocks}.
|
|
4448
|
+
*
|
|
4449
|
+
* @since 1.0.0
|
|
4450
|
+
*/
|
|
4451
|
+
interface HydrateStorefrontBlocksOptions {
|
|
4452
|
+
/**
|
|
4453
|
+
* The page the islands sit on: an Inertia page's component, props and URL
|
|
4454
|
+
* (pass `usePage()`'s, or the page object from `createInertiaApp()`), so
|
|
4455
|
+
* a block reads the page's `ecommerceStorefront` props. Leave it out on a
|
|
4456
|
+
* page Inertia didn't render: the blocks get stand-in shared props (see
|
|
4457
|
+
* `configureStorefrontBlocks()`).
|
|
4458
|
+
*/
|
|
4459
|
+
page?: StorefrontPageSnapshot | null;
|
|
4460
|
+
/** Hydrate only the islands marked `data-ec-block-interactive`. */
|
|
4461
|
+
interactiveOnly?: boolean;
|
|
4462
|
+
}
|
|
4463
|
+
/**
|
|
4464
|
+
* What an island's markup is trusted to say: which block it is, its
|
|
4465
|
+
* attributes and whether it takes input. Its props are not read from the
|
|
4466
|
+
* markup (see {@link hydrateStorefrontBlocks}).
|
|
4467
|
+
*
|
|
4468
|
+
* @since 1.0.0
|
|
4469
|
+
*/
|
|
4470
|
+
interface StorefrontBlockIsland {
|
|
4471
|
+
/** The block's name, one this package draws. */
|
|
4472
|
+
name: StorefrontBlockName;
|
|
4473
|
+
/** The block's attributes, which the `blocks.props` route clamps again. */
|
|
4474
|
+
attributes: Record<string, unknown>;
|
|
4475
|
+
/** Marked `data-ec-block-interactive`. */
|
|
4476
|
+
interactive: boolean;
|
|
4477
|
+
}
|
|
4478
|
+
/**
|
|
4479
|
+
* The name an island must carry: `artisanpack-commerce/` and a slug.
|
|
4480
|
+
*
|
|
4481
|
+
* @since 1.0.0
|
|
4482
|
+
*/
|
|
4483
|
+
declare const BLOCK_ISLAND_NAME: RegExp;
|
|
4484
|
+
/**
|
|
4485
|
+
* Reads an island's name, attributes and interactive flag from its data
|
|
4486
|
+
* attributes, or null when the element isn't a commerce block island this
|
|
4487
|
+
* package draws. `data-ec-block-props` is ignored.
|
|
4488
|
+
*
|
|
4489
|
+
* @since 1.0.0
|
|
4490
|
+
*
|
|
4491
|
+
* @param element - The `[data-ec-block]` element.
|
|
4492
|
+
* @returns The island.
|
|
4493
|
+
*/
|
|
4494
|
+
declare function readBlockIsland(element: HTMLElement): StorefrontBlockIsland | null;
|
|
4495
|
+
/**
|
|
4496
|
+
* Hydrates the commerce block islands under `root` that aren't hydrated
|
|
4497
|
+
* yet.
|
|
4498
|
+
*
|
|
4499
|
+
* Each island's props come from the `blocks.props` route, not from its
|
|
4500
|
+
* `data-ec-block-props`. Anything that can put markup on the page (a
|
|
4501
|
+
* content author's rich text, a sanitizer that keeps `data-*` attributes)
|
|
4502
|
+
* could print an island of its own, and the props of several blocks hold
|
|
4503
|
+
* HTML (product descriptions) and URLs the block posts to. From the markup
|
|
4504
|
+
* only the block's name, its attributes, which the server clamps to the
|
|
4505
|
+
* block's schema, and the interactive flag are read; the server answers
|
|
4506
|
+
* with the props for those, as it would for its own island. The fallback
|
|
4507
|
+
* stays until they arrive, and stays for good when the request fails, the
|
|
4508
|
+
* block has nothing to show, or the storefront's URL isn't known (call
|
|
4509
|
+
* `configureStorefrontBlocks()` on a page Inertia didn't render).
|
|
4510
|
+
*
|
|
4511
|
+
* @since 1.0.0
|
|
4512
|
+
*
|
|
4513
|
+
* @param root - Where to look; the document by default.
|
|
4514
|
+
* @param options - The page the islands sit on, and whether to skip display blocks.
|
|
4515
|
+
* @returns Stops pending requests and unmounts the islands this call hydrated (their elements are left empty).
|
|
4516
|
+
*/
|
|
4517
|
+
declare function hydrateStorefrontBlocks(root?: ParentNode, options?: HydrateStorefrontBlocksOptions): () => void;
|
|
4518
|
+
|
|
4519
|
+
/**
|
|
4520
|
+
* Storefront pages rendered through a visual-editor template.
|
|
4521
|
+
*
|
|
4522
|
+
* When a page renders through a saved template, its shared props carry the
|
|
4523
|
+
* template's block tree (`ecommerceStorefrontTemplate`), and the page draws
|
|
4524
|
+
* that tree with visual-editor's React renderer in place of its own
|
|
4525
|
+
* content. The renderer isn't a dependency of this package: the host hands
|
|
4526
|
+
* it over with {@link setStorefrontTemplateRenderer}, usually
|
|
4527
|
+
* `(tree) => <BlockTree tree={tree} />`. Without one, pages draw their own
|
|
4528
|
+
* content as they do without templates.
|
|
4529
|
+
*
|
|
4530
|
+
* This module stays small, since every page loads it.
|
|
4531
|
+
*
|
|
4532
|
+
* @since 1.0.0
|
|
4533
|
+
*/
|
|
4534
|
+
|
|
4535
|
+
/**
|
|
4536
|
+
* The attribute a commerce block in a template tree carries its `clientId`
|
|
4537
|
+
* in, since visual-editor's renderer hands a block renderer its attributes
|
|
4538
|
+
* but not its `clientId`.
|
|
4539
|
+
*
|
|
4540
|
+
* @since 1.0.0
|
|
4541
|
+
*/
|
|
4542
|
+
declare const BLOCK_CLIENT_ID_ATTRIBUTE = "_ecClientId";
|
|
4543
|
+
/**
|
|
4544
|
+
* Draws a template's block tree: visual-editor's renderer.
|
|
4545
|
+
*
|
|
4546
|
+
* @since 1.0.0
|
|
4547
|
+
*/
|
|
4548
|
+
type StorefrontTemplateRenderer = (tree: StorefrontTemplateBlock[], template: StorefrontTemplate) => ReactNode;
|
|
4549
|
+
/**
|
|
4550
|
+
* Sets what draws a templated page's block tree, or `null` to draw pages'
|
|
4551
|
+
* own content again.
|
|
4552
|
+
*
|
|
4553
|
+
* ```tsx
|
|
4554
|
+
* import { BlockTree, registerBlockRenderer } from '@artisanpack-ui/visual-editor-renderer-react';
|
|
4555
|
+
*
|
|
4556
|
+
* registerStorefrontBlockRenderers(registerBlockRenderer);
|
|
4557
|
+
* setStorefrontTemplateRenderer((tree) => <BlockTree tree={tree} />);
|
|
4558
|
+
* ```
|
|
4559
|
+
*
|
|
4560
|
+
* @since 1.0.0
|
|
4561
|
+
*
|
|
4562
|
+
* @param next - The renderer.
|
|
4563
|
+
*/
|
|
4564
|
+
declare function setStorefrontTemplateRenderer(next: StorefrontTemplateRenderer | null): void;
|
|
4565
|
+
/**
|
|
4566
|
+
* The template renderer, or null when none is set.
|
|
4567
|
+
*
|
|
4568
|
+
* @since 1.0.0
|
|
4569
|
+
*
|
|
4570
|
+
* @returns The renderer.
|
|
4571
|
+
*/
|
|
4572
|
+
declare function getStorefrontTemplateRenderer(): StorefrontTemplateRenderer | null;
|
|
4573
|
+
/**
|
|
4574
|
+
* A template's block tree with each commerce block's `clientId` copied
|
|
4575
|
+
* into its {@link BLOCK_CLIENT_ID_ATTRIBUTE} attribute, so its renderer can
|
|
4576
|
+
* find its props in the template's `blockProps`.
|
|
4577
|
+
*
|
|
4578
|
+
* @since 1.0.0
|
|
4579
|
+
*
|
|
4580
|
+
* @param blocks - The template's blocks.
|
|
4581
|
+
* @returns The stamped blocks.
|
|
4582
|
+
*/
|
|
4583
|
+
declare function storefrontTemplateTree(blocks: StorefrontTemplateBlock[]): StorefrontTemplateBlock[];
|
|
4584
|
+
/**
|
|
4585
|
+
* Props for {@link StorefrontTemplateContent}.
|
|
4586
|
+
*
|
|
4587
|
+
* @since 1.0.0
|
|
4588
|
+
*/
|
|
4589
|
+
interface StorefrontTemplateContentProps {
|
|
4590
|
+
/** The page's template. */
|
|
4591
|
+
template: StorefrontTemplate;
|
|
4592
|
+
/** What draws the tree. */
|
|
4593
|
+
render: StorefrontTemplateRenderer;
|
|
4594
|
+
}
|
|
4595
|
+
/**
|
|
4596
|
+
* A templated page's content: the template's block tree, drawn by the
|
|
4597
|
+
* template renderer. The template's own group block (`.ec-template`) lays
|
|
4598
|
+
* it out.
|
|
4599
|
+
*
|
|
4600
|
+
* @since 1.0.0
|
|
4601
|
+
*
|
|
4602
|
+
* @param props - The template and its renderer.
|
|
4603
|
+
* @returns The content.
|
|
4604
|
+
*/
|
|
4605
|
+
declare function StorefrontTemplateContent({ template, render, }: StorefrontTemplateContentProps): ReactElement;
|
|
4606
|
+
|
|
4607
|
+
export { AccountAction, AccountAddresses, type AccountAddressesViewProps, AccountClaim, type AccountClaimViewProps, AccountDashboard, type AccountDashboardViewProps, AccountDownloads, type AccountDownloadsViewProps, AccountOrders, type AccountOrdersViewProps, AccountProfile, type AccountProfileViewProps, AccountShell, type AccountShellProps, AddToCart, AddToCartBlock, type AddToCartProps, Address, AddressForm, type AddressFormProps, type AddressProps, AddressStep, BLOCK_ATTRIBUTES_MAX_BYTES, BLOCK_CLIENT_ID_ATTRIBUTE, BLOCK_ISLAND_HYDRATED, BLOCK_ISLAND_NAME, BLOCK_ISLAND_SELECTOR, BlockPage, type BlockPageProps, type BlockPresentationState, BlockSampleNotice, BundledForm, CART_DRAWER_CONTENT_ID, CART_DRAWER_ONLY, CHECKOUT_PAGE, CORE_PAYMENT_DRIVERS, CORE_PRODUCT_FORMS, Cart, CartContentsBlock, CartDrawer, CartDrawerProvider, type CartDrawerState, CartHeaderButton, CartPreview, type CartPreviewProps, type CartProps, CatalogFilters, type CatalogFiltersProps, CatalogListing, type CatalogListingProps, CategoryGrid, CategoryGridBlock, type CategoryGridProps, Checkout, type CheckoutContextValue, CheckoutErrorSummary, CheckoutOrderSummary, type CheckoutOrderSummaryProps, type CheckoutPostCallbacks, type CheckoutPostMode, CheckoutPreview, type CheckoutPreviewProps, type CheckoutProps, type CheckoutStepComponentProps, CheckoutStepSummary, type CheckoutStepSummaryProps, CheckoutStepsBlock, ChoiceCards, type ChoiceCardsProps, ContactStep, CurrencyAction, CurrencySwitcher, type CurrencySwitcherProps, DigitalForm, type EcommerceStorefrontResolverOptions, EmptyState, type EmptyStateProps, Field, type FieldProps, GALLERY_SHOW_EVENT, Gallery, type GalleryProps, GroupedForm, type HeaderActionProps, HeaderSearch, type HeaderSearchProps, type HydrateStorefrontBlocksOptions, type JsonAnswer, LineControls, type LineControlsProps, type ListingQuery, MERGE_PRIMARY_ID, MergePrompt, Money, type MoneyProps, OptionsForm, OrderConfirmation, type OrderConfirmationViewProps, OrderDetails, type OrderDetailsProps, OrderLookup, OrderLookupLink, type OrderLookupLinkProps, type OrderLookupViewProps, OrderShow, type OrderShowProps, OrderStatusBadge, OrderTotals, type OrderTotalsProps, PAGES, PURCHASE_ERROR_BAG, PURCHASE_RELOAD, PURCHASE_SUCCESS_RELOAD, type PaymentDriverComponentProps, type PaymentDriverFailure, PaymentDriverHost, type PaymentDriverHostProps, type PaymentDriverStatus, type PaymentReportOutcome, PaymentStep, Placement, type PlacementProps, Price, type PriceProps, PriceRange, type PriceRangeProps, type PriceRangeValue, ProductCard, type ProductCardProps, ProductCatalogBlock, ProductGalleryBlock, ProductGrid, ProductGridBlock, type ProductGridProps, ProductPriceBlock, ProductReviewsBlock, PurchaseFormContext, type PurchaseFormContextValue, QUANTITY_COMMIT_DELAY, Quantity, type QuantityProps, type QuickAdd, REVIEW_ERROR_BAG, REVIEW_RATING_QUERY, RatingInput, type RatingInputProps, RatingSummary, type RatingSummaryProps, type ReactStorefrontRegistries, RecentlyViewed, RecentlyViewedBlock, RecentlyViewedPlaceholder, type RecentlyViewedPlaceholderProps, type RecentlyViewedProps, RedirectPayment, type RegisteredComponent, RelatedProducts, RelatedProductsBlock, RelatedProductsPlaceholder, type RelatedProductsPlaceholderProps, type RelatedProductsProps, RelatedProductsRow, type RelatedProductsRowProps, ReviewStep, Reviews, type ReviewsProps, STOREFRONT_BLOCKS, STOREFRONT_BLOCK_PREFIX, STOREFRONT_ICONS, SearchBox, type SearchBoxProps, ShippingEstimate, type ShippingEstimateProps, ShippingStep, SimpleForm, SingleProductBlock, Skeleton, type SkeletonProps, SoldOutNotice, type SoldOutNoticeProps, StockStatus, type StockStatusProps, StorefrontBlock, StorefrontBlockBody, type StorefrontBlockComponent, type StorefrontBlockComponentProps, type StorefrontBlockIsland, type StorefrontBlockProps, StorefrontBlockRenderer, type StorefrontBlockRendererProps, StorefrontBlockRoot, type StorefrontBlockRootProps, type StorefrontBlockSettings, StorefrontBreadcrumbs, type StorefrontBreadcrumbsProps, type StorefrontChrome, StorefrontLayout, type StorefrontLayoutProps, type StorefrontPageComponent, type StorefrontPageSnapshot, StorefrontSections, type StorefrontSectionsProps, StorefrontTemplateContent, type StorefrontTemplateContentProps, type StorefrontTemplateRenderer, type StorefrontToaster, type StripeDriverCallbacks, type StripeLoader, StripePayment, type StripePaymentProps, Swatches, type SwatchesProps, Toaster, type UsePaymentDriver, VARIANT_RELOAD, VariableForm, addBuiltInRegistration, addressLines, blockPropsEndpoint, blockPropsUrl, buildQuery, cartActionUrl, checkoutLayout, choiceValue, configureStorefrontBlocks, createEcommerceStorefrontResolver, createStripePaymentElementDriver, fallbackSharedProps, fetchBlockPresentation, filterPageProps, getRegistries, getStorefrontBlock, getStorefrontTemplateRenderer, getStorefrontToaster, groupedSummary, hydrateStorefrontBlocks, linePrice, listingUrl, optionValue, optionValues, postJson, priceRangeFor, publicBlockAttributes, readBlockIsland, registerBuiltIns, registerCartBuiltIns, registerHeaderActionBuiltIns, registerHeaderActions, registerPaymentDrivers, registerProductBuiltIns, registerProductForms, registerProductSections, registerStorefrontBlock, registerStorefrontBlockRenderers, registerStorefrontIcons, relatedHeading, requestJson, requestStepFocus, resetRegistries, resetStorefrontBlockSettings, resetStorefrontBlocks, resetStorefrontToaster, resolveEcommerceStorefrontPage, runToastAction, setStorefrontTemplateRenderer, shipToLine, showResponseToasts, showStorefrontToast, stepUrl, storefrontBlockNames, storefrontBlockSettings, storefrontBlockSlug, storefrontLayout, storefrontTemplateTree, stripeAppearance, suggestionsUrl, toggleValue, useBlockPresentation, useCartDrawer, useCheckout, useErrorBag, useFocusAfterChange, usePageErrors, usePaymentDriver, usePurchaseFormContext, useQuickAdd, useRegisterCartDrawer, useStorefront, useStorefrontCart, useStorefrontPage, useStorefrontPost, useStorefrontTemplate, visitWithQuery, withChoice, withOption, withOptionValue, withPrice, withStorefrontPage, withToggle };
|