@usethrottle/storefront-react 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +67 -0
- package/README.md +119 -2
- package/dist/StorefrontProvider-Br4wUHui.d.cts +559 -0
- package/dist/StorefrontProvider-DLEPEjg6.d.ts +559 -0
- package/dist/account/index.cjs +69 -0
- package/dist/account/index.cjs.map +1 -0
- package/dist/account/index.d.cts +23 -0
- package/dist/account/index.d.ts +23 -0
- package/dist/account/index.js +68 -0
- package/dist/account/index.js.map +1 -0
- package/dist/chunk-2LCPIY2P.cjs +16 -0
- package/dist/chunk-2LCPIY2P.cjs.map +1 -0
- package/dist/chunk-3A72UY6T.js +2126 -0
- package/dist/chunk-3A72UY6T.js.map +1 -0
- package/dist/chunk-3JMIVAHN.js +185 -0
- package/dist/chunk-3JMIVAHN.js.map +1 -0
- package/dist/chunk-4J6AGWNC.cjs +24 -0
- package/dist/chunk-4J6AGWNC.cjs.map +1 -0
- package/dist/chunk-4U6MYDZV.js +17 -0
- package/dist/chunk-4U6MYDZV.js.map +1 -0
- package/dist/chunk-66HDJVPS.js +22 -0
- package/dist/chunk-66HDJVPS.js.map +1 -0
- package/dist/chunk-6X2OZSNV.cjs +83 -0
- package/dist/chunk-6X2OZSNV.cjs.map +1 -0
- package/dist/chunk-6ZMMZ245.cjs +2127 -0
- package/dist/chunk-6ZMMZ245.cjs.map +1 -0
- package/dist/chunk-7R37CVAB.cjs +23 -0
- package/dist/chunk-7R37CVAB.cjs.map +1 -0
- package/dist/chunk-A3IFWQUV.js +368 -0
- package/dist/chunk-A3IFWQUV.js.map +1 -0
- package/dist/chunk-AYC2YK4E.cjs +95 -0
- package/dist/chunk-AYC2YK4E.cjs.map +1 -0
- package/dist/chunk-AZV5U7YB.cjs +18 -0
- package/dist/chunk-AZV5U7YB.cjs.map +1 -0
- package/dist/chunk-CE2SKNQP.cjs +71 -0
- package/dist/chunk-CE2SKNQP.cjs.map +1 -0
- package/dist/chunk-D76CRI4X.js +2175 -0
- package/dist/chunk-D76CRI4X.js.map +1 -0
- package/dist/chunk-DOAII637.cjs +186 -0
- package/dist/chunk-DOAII637.cjs.map +1 -0
- package/dist/chunk-DYHHAOMG.cjs +17 -0
- package/dist/chunk-DYHHAOMG.cjs.map +1 -0
- package/dist/chunk-EYSVU5SJ.js +196 -0
- package/dist/chunk-EYSVU5SJ.js.map +1 -0
- package/dist/chunk-HSUUDZWS.js +37 -0
- package/dist/chunk-HSUUDZWS.js.map +1 -0
- package/dist/chunk-HZ6VEN6Q.cjs +101 -0
- package/dist/chunk-HZ6VEN6Q.cjs.map +1 -0
- package/dist/chunk-IJOTLGPT.js +16 -0
- package/dist/chunk-IJOTLGPT.js.map +1 -0
- package/dist/chunk-ISDATHVC.js +219 -0
- package/dist/chunk-ISDATHVC.js.map +1 -0
- package/dist/chunk-LW2A6USV.js +100 -0
- package/dist/chunk-LW2A6USV.js.map +1 -0
- package/dist/chunk-M4YXSLRG.cjs +369 -0
- package/dist/chunk-M4YXSLRG.cjs.map +1 -0
- package/dist/chunk-NDUEJJLP.cjs +2176 -0
- package/dist/chunk-NDUEJJLP.cjs.map +1 -0
- package/dist/chunk-NNE4FYRT.js +820 -0
- package/dist/chunk-NNE4FYRT.js.map +1 -0
- package/dist/chunk-NW3EFHY2.js +15 -0
- package/dist/chunk-NW3EFHY2.js.map +1 -0
- package/dist/chunk-NZRUQUN5.js +167 -0
- package/dist/chunk-NZRUQUN5.js.map +1 -0
- package/dist/chunk-P6HHE57S.cjs +38 -0
- package/dist/chunk-P6HHE57S.cjs.map +1 -0
- package/dist/chunk-PHY7AY27.cjs +197 -0
- package/dist/chunk-PHY7AY27.cjs.map +1 -0
- package/dist/chunk-PNJOFFTL.cjs +128 -0
- package/dist/chunk-PNJOFFTL.cjs.map +1 -0
- package/dist/chunk-PXZQ4ONA.js +127 -0
- package/dist/chunk-PXZQ4ONA.js.map +1 -0
- package/dist/chunk-Q3VTUBPP.js +82 -0
- package/dist/chunk-Q3VTUBPP.js.map +1 -0
- package/dist/chunk-Q3XFD5UI.js +45 -0
- package/dist/chunk-Q3XFD5UI.js.map +1 -0
- package/dist/chunk-QM7KTT7F.js +94 -0
- package/dist/chunk-QM7KTT7F.js.map +1 -0
- package/dist/chunk-RLWZOLXL.js +70 -0
- package/dist/chunk-RLWZOLXL.js.map +1 -0
- package/dist/chunk-SV53BRP2.js +23 -0
- package/dist/chunk-SV53BRP2.js.map +1 -0
- package/dist/chunk-VWXJO427.cjs +821 -0
- package/dist/chunk-VWXJO427.cjs.map +1 -0
- package/dist/chunk-WIIOJDHR.cjs +220 -0
- package/dist/chunk-WIIOJDHR.cjs.map +1 -0
- package/dist/chunk-XQHGFWLG.cjs +46 -0
- package/dist/chunk-XQHGFWLG.cjs.map +1 -0
- package/dist/chunk-ZHCXI2ZZ.cjs +168 -0
- package/dist/chunk-ZHCXI2ZZ.cjs.map +1 -0
- package/dist/index-RSj2Rg62.d.cts +8 -0
- package/dist/index-RSj2Rg62.d.ts +8 -0
- package/dist/index.cjs +2829 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1718 -0
- package/dist/index.d.ts +1718 -0
- package/dist/index.js +2828 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata-QhKw-tvz.d.cts +188 -0
- package/dist/metadata-QhKw-tvz.d.ts +188 -0
- package/dist/next/client.cjs +84 -0
- package/dist/next/client.cjs.map +1 -0
- package/dist/next/client.d.cts +40 -0
- package/dist/next/client.d.ts +40 -0
- package/dist/next/client.js +83 -0
- package/dist/next/client.js.map +1 -0
- package/dist/next/index.cjs +1090 -0
- package/dist/next/index.cjs.map +1 -0
- package/dist/next/index.d.cts +218 -0
- package/dist/next/index.d.ts +218 -0
- package/dist/next/index.js +1049 -0
- package/dist/next/index.js.map +1 -0
- package/dist/server/index.cjs +994 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +229 -0
- package/dist/server/index.d.ts +229 -0
- package/dist/server/index.js +951 -0
- package/dist/server/index.js.map +1 -0
- package/dist/styles.css +2111 -0
- package/dist/use-part-DCfFk7kf.d.ts +24 -0
- package/dist/use-part-DgjPBL_O.d.cts +24 -0
- package/package.json +121 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1718 @@
|
|
|
1
|
+
import { f as SfStringKey, N as NormalizedSettings, h as StorefrontAnalytics, b as Ga4Item } from './StorefrontProvider-DLEPEjg6.js';
|
|
2
|
+
export { D as DefaultLink, G as GA4_EVENTS, a as Ga4EventName, c as Ga4Payload, L as LinkComponent, R as ResolveSiteDesignInput, d as ResolvedSiteDesign, S as SF_STRINGS_EN, e as SfLocalKey, g as SfStrings, i as StorefrontAppearance, j as StorefrontContextValue, k as StorefrontLocalization, l as StorefrontProvider, m as StorefrontProviderProps, n as StorefrontRouter, o as normalizeSettings, r as resolveSiteDesign, u as useHistoryRouter, p as useStorefront } from './StorefrontProvider-DLEPEjg6.js';
|
|
3
|
+
import { ThemeTokens, ThrottleVariables, SiteDesign, SiteMenuItem, SlotRenderer } from '@usethrottle/ui';
|
|
4
|
+
import { StorefrontSettings, ResolvedMenuTarget, StorefrontMenuItem, StorefrontProduct, ProductsQuery, ListProduct, StorefrontReviewsAnswer, StorefrontListAnswer, Filter, CategoryNode, ThrottleCart } from '@usethrottle/catalog';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
export { S as STOREFRONT_PART_KEYS, a as StorefrontPartKey } from './index-RSj2Rg62.js';
|
|
7
|
+
import * as react from 'react';
|
|
8
|
+
import { ReactNode, ComponentType, AnchorHTMLAttributes, RefObject, MutableRefObject } from 'react';
|
|
9
|
+
import { U as UsePartLocal } from './use-part-DCfFk7kf.js';
|
|
10
|
+
export { P as PartClassNames, u as usePart } from './use-part-DCfFk7kf.js';
|
|
11
|
+
import '@usethrottle/catalog/react';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Text lookup. A key resolves, first match wins, through:
|
|
15
|
+
* 1. the Builder's strings (`site.builderStrings[key]`); the catalog adapter's site strings are catalog text and rank with step 3;
|
|
16
|
+
* 2. the `localization` prop (a package key by `<area>.<name>`, a catalog key by
|
|
17
|
+
* its dotted path, such as `{ cart: { title: 'Basket' } }`): the developer's
|
|
18
|
+
* own text beats what the catalog sends;
|
|
19
|
+
* 3. for a catalog key, the catalog settings' `strings`;
|
|
20
|
+
* 4. the package's English (`SF_STRINGS_EN`), or for a catalog key the SDK's `DEFAULT_STRINGS`.
|
|
21
|
+
*
|
|
22
|
+
* `{name}` placeholders fill from `vars`; one with no value stays as written.
|
|
23
|
+
* `keyAttr(key)` is the `data-string-key` attribute the sync tests read.
|
|
24
|
+
*/
|
|
25
|
+
declare function useStrings(): {
|
|
26
|
+
t(key: SfStringKey, vars?: Record<string, string | number>): string;
|
|
27
|
+
keyAttr(key: SfStringKey): {
|
|
28
|
+
'data-string-key': string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The DOM attributes that are part of the storefront-react contract (R2): the
|
|
34
|
+
* Phase 1 `SEL` set a store's sync tests read. Components emit them natively,
|
|
35
|
+
* so any store built on them stays sync-testable. Home attributes
|
|
36
|
+
* (`hero-heading`, home shelves) belong to the store's own home.
|
|
37
|
+
*/
|
|
38
|
+
declare const SYNC_ATTRIBUTES: readonly ["data-throttle-setting", "data-theme-accent", "data-theme-radius", "data-menu", "data-listing", "data-listing-page-size", "data-sort-option", "data-product-card", "data-product-handle", "data-card-rating", "data-badge", "data-stock-words", "data-section", "data-section-title", "data-string-key", "data-filter-key", "data-filter-display", "data-filter-label", "data-locale-option", "data-currency-option", "data-collection-title", "data-category-handle", "data-category-parent", "data-review-id"];
|
|
39
|
+
/** The name of a `data-*` attribute components emit so an automated sync test can find them. */
|
|
40
|
+
type SyncAttribute = (typeof SYNC_ATTRIBUTES)[number];
|
|
41
|
+
|
|
42
|
+
type CartDrawerState = {
|
|
43
|
+
open: boolean;
|
|
44
|
+
setOpen(open: boolean): void;
|
|
45
|
+
};
|
|
46
|
+
/** Whether the cart drawer is open, and a way to change it. `StorefrontProvider` owns the state. */
|
|
47
|
+
declare function useCartDrawer(): CartDrawerState;
|
|
48
|
+
|
|
49
|
+
type Scheme = 'light' | 'dark';
|
|
50
|
+
/** The `--throttle-sf-*` custom properties the storefront stylesheet reads. */
|
|
51
|
+
type SfVariables = Record<`--throttle-sf-${string}`, string>;
|
|
52
|
+
/**
|
|
53
|
+
* The theme as the two variable layers the storefront renders from.
|
|
54
|
+
*
|
|
55
|
+
* - `variables` are `@usethrottle/ui`'s variables (the catalog SDK's own
|
|
56
|
+
* mapping, so storefront and auth components agree on every colour, the body
|
|
57
|
+
* font stack and the radius);
|
|
58
|
+
* - `sf` are the storefront-only properties: the accent colours that have no
|
|
59
|
+
* ui variable, the card radius and the grid gap.
|
|
60
|
+
*
|
|
61
|
+
* The derived accent shades use Meridian's formulas: `accent-hover` is the
|
|
62
|
+
* accent mixed toward black in the light scheme and brightened in the dark one,
|
|
63
|
+
* and `accent-subtle` is a wash of the brightened accent over the surface.
|
|
64
|
+
* Server-safe: no React, no DOM.
|
|
65
|
+
*/
|
|
66
|
+
declare function themeToVariables(theme: ThemeTokens, scheme: Scheme): {
|
|
67
|
+
variables: ThrottleVariables;
|
|
68
|
+
sf: SfVariables;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** The `id` of the `<style>` element that carries the storefront's CSS (`@layer throttle`). */
|
|
72
|
+
declare const STOREFRONT_STYLE_ID = "throttle-storefront-styles";
|
|
73
|
+
/** The `id` of the `<style>` element that declares the layer order first in `<head>`. */
|
|
74
|
+
declare const STOREFRONT_LAYER_ORDER_ID = "throttle-storefront-layer-order";
|
|
75
|
+
/**
|
|
76
|
+
* The whole storefront stylesheet: the primitives (class prefix `tsf-`, so
|
|
77
|
+
* auth's sheet never styles them), the base, each area's rules, then every
|
|
78
|
+
* preset's rules, all inside `@layer throttle` so an unlayered store rule or a
|
|
79
|
+
* Tailwind utility beats it. One source feeds the runtime injector and
|
|
80
|
+
* `dist/styles.css`.
|
|
81
|
+
*/
|
|
82
|
+
declare const STOREFRONT_STYLES: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The catalog settings read as a site design: what a store without a Builder
|
|
86
|
+
* shows for its theme, brand, menus, announcement, SEO defaults and site
|
|
87
|
+
* strings (each only when the settings carry a non-empty value).
|
|
88
|
+
*
|
|
89
|
+
* @deprecated A bridge for Phase 1 catalogs. It is removed when the Throttle
|
|
90
|
+
* Builder takes over site design (Builder M4); provide a site design instead.
|
|
91
|
+
*/
|
|
92
|
+
declare function catalogSiteDesign(settings: NormalizedSettings): SiteDesign;
|
|
93
|
+
|
|
94
|
+
type Routes = StorefrontSettings['routes'];
|
|
95
|
+
/**
|
|
96
|
+
* The URL a menu, announcement or hero target points to, from the store's route patterns. Null when the
|
|
97
|
+
* target has nothing to point at (no handle, or a link that is not http(s) or a site path).
|
|
98
|
+
* (Ported from Meridian `lib/menu.ts`.)
|
|
99
|
+
*/
|
|
100
|
+
declare function menuHref(settings: {
|
|
101
|
+
routes: Routes;
|
|
102
|
+
}, target: ResolvedMenuTarget): string | null;
|
|
103
|
+
/**
|
|
104
|
+
* The menu as site-design items: each item's target resolved by `menuHref`. An item that points nowhere
|
|
105
|
+
* (a deleted target) is left out, its children with it, so the nav never renders a dead entry. A renamed
|
|
106
|
+
* target already carries its current handle in the settings answer, so it resolves to the new URL.
|
|
107
|
+
*/
|
|
108
|
+
declare function menuItems(settings: {
|
|
109
|
+
routes: Routes;
|
|
110
|
+
}, items: readonly StorefrontMenuItem[]): SiteMenuItem[];
|
|
111
|
+
|
|
112
|
+
/** The places a host (the Throttle Builder) may add content: above and below a product page and a listing. */
|
|
113
|
+
type StorefrontSlotName = 'product.above' | 'product.below' | 'shop.above' | 'shop.below';
|
|
114
|
+
/** What a listing slot knows; matches the Builder's `context.listing` data source. */
|
|
115
|
+
type ListingContext = {
|
|
116
|
+
source: {
|
|
117
|
+
kind: 'all' | 'collection' | 'category' | 'tag' | 'search';
|
|
118
|
+
handle?: string;
|
|
119
|
+
q?: string;
|
|
120
|
+
};
|
|
121
|
+
total: number;
|
|
122
|
+
filters: Record<string, string[]>;
|
|
123
|
+
sort: string;
|
|
124
|
+
page: number;
|
|
125
|
+
};
|
|
126
|
+
/** What a slot knows; matches the Builder's `context.product` / `context.listing`. */
|
|
127
|
+
type SlotContext = {
|
|
128
|
+
kind: 'product';
|
|
129
|
+
product: StorefrontProduct;
|
|
130
|
+
variantSku: string | null;
|
|
131
|
+
} | {
|
|
132
|
+
kind: 'listing';
|
|
133
|
+
listing: ListingContext;
|
|
134
|
+
};
|
|
135
|
+
/** The props of `SlotOutlet`: which place this is and what it knows. */
|
|
136
|
+
type SlotOutletProps = {
|
|
137
|
+
/** Which place this is. A host registers a renderer for a name. */
|
|
138
|
+
name: StorefrontSlotName;
|
|
139
|
+
/** What the content may read: the product (and variant) or the listing. */
|
|
140
|
+
context: SlotContext;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* A place where a host (the Builder) may add content. Renders what
|
|
144
|
+
* `useSlotOutlet(name)` returns, with `{ context }`, inside a wrapper; with
|
|
145
|
+
* nothing to render (no host, or no renderer for the name) it renders nothing,
|
|
146
|
+
* not even the wrapper.
|
|
147
|
+
*/
|
|
148
|
+
declare function SlotOutlet({ name, context }: SlotOutletProps): react_jsx_runtime.JSX.Element | null;
|
|
149
|
+
|
|
150
|
+
/** True under `<Unstyled>` or a component's `unstyled` prop: parts drop their `tsf-<key>` base class. */
|
|
151
|
+
declare const UnstyledContext: react.Context<boolean>;
|
|
152
|
+
/** Whether the base `tsf-<part>` classes are dropped here (inside `<Unstyled>`). */
|
|
153
|
+
declare function useUnstyled(): boolean;
|
|
154
|
+
/** Renders its children with the package's base classes removed; `data-throttle-part` stays. */
|
|
155
|
+
declare function Unstyled(props: {
|
|
156
|
+
children?: ReactNode;
|
|
157
|
+
}): react_jsx_runtime.JSX.Element;
|
|
158
|
+
|
|
159
|
+
/** What `searchParams` is in a Next page: a plain record (a value may repeat). */
|
|
160
|
+
type SearchParamsInput = Record<string, string | string[] | undefined>;
|
|
161
|
+
/**
|
|
162
|
+
* The shop selection as URL state. Filters and ranges are `filter.<key>` URL
|
|
163
|
+
* parameters (the catalog SDK's wire form: a range is one `min..max` value).
|
|
164
|
+
* `sort` is always the effective sort: the URL's, or the store's default.
|
|
165
|
+
*/
|
|
166
|
+
type ShopQuery = {
|
|
167
|
+
filters: Record<string, string[]>;
|
|
168
|
+
ranges: Record<string, {
|
|
169
|
+
min?: number;
|
|
170
|
+
max?: number;
|
|
171
|
+
}>;
|
|
172
|
+
sort: string;
|
|
173
|
+
page: number;
|
|
174
|
+
q?: string;
|
|
175
|
+
};
|
|
176
|
+
/** What a listing shows: the whole shop, one collection, category or tag (by path), or a search. */
|
|
177
|
+
type ShopSource = {
|
|
178
|
+
kind: 'all';
|
|
179
|
+
} | {
|
|
180
|
+
kind: 'collection' | 'category' | 'tag';
|
|
181
|
+
handle: string;
|
|
182
|
+
} | {
|
|
183
|
+
kind: 'search';
|
|
184
|
+
q: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Reads the URL state. A sort the store has disabled (or does not know) falls
|
|
188
|
+
* back to `listing.defaultSort`; a page below 1 or not a number is 1.
|
|
189
|
+
* Parameters follow the catalog SDK's shop URL: `filter.<key>`, `sort`, `page`, `q`.
|
|
190
|
+
*
|
|
191
|
+
* `rangeKeys` names the range-type facets (`display: 'range'`). Only their
|
|
192
|
+
* `a..b` values become `ranges`; on any other key the text stays a filter
|
|
193
|
+
* value. Left out, every `a..b` value is read as a range.
|
|
194
|
+
*/
|
|
195
|
+
declare function parseShopQuery(params: URLSearchParams | SearchParamsInput, settings: NormalizedSettings, rangeKeys?: Iterable<string>): ShopQuery;
|
|
196
|
+
/** The canonical query string (no leading `?`): keys sorted, values sorted, defaults (the default sort, page 1) omitted. */
|
|
197
|
+
declare function shopQueryToSearch(q: ShopQuery, settings: NormalizedSettings): string;
|
|
198
|
+
/** The page numbers to show: the first, the last and the current one's neighbours, `null` for a gap. */
|
|
199
|
+
declare function pageWindow(current: number, count: number): Array<number | null>;
|
|
200
|
+
/** The variant a product URL names (`?variant=<sku>`), or null when it names none the product has. */
|
|
201
|
+
declare function variantFromSearch(params: URLSearchParams | SearchParamsInput, product: Pick<StorefrontProduct, 'variants'>): string | null;
|
|
202
|
+
/**
|
|
203
|
+
* R4: a shop URL is `noindex,follow` when it carries two or more filter
|
|
204
|
+
* values, a sort other than the store's default, or a search term (`q` on a
|
|
205
|
+
* listing; a search page is `noindex` on its own). Links are always followed.
|
|
206
|
+
*/
|
|
207
|
+
declare function robotsForShopQuery(q: ShopQuery, settings: NormalizedSettings): {
|
|
208
|
+
index: boolean;
|
|
209
|
+
follow: true;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* R4: the canonical URL keeps at most one filter value (the first by key, then
|
|
213
|
+
* value) and `page` above 1, and drops the sort. `q` stays only on a search
|
|
214
|
+
* page (`source.kind === 'search'`); on a listing it is dropped. Absolute:
|
|
215
|
+
* `baseUrl` + `pathname`.
|
|
216
|
+
*/
|
|
217
|
+
declare function canonicalForShopQuery(baseUrl: string, pathname: string, q: ShopQuery, settings: NormalizedSettings, source?: ShopSource): string;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The `fields` a product list asks for. A custom tag badge needs the product's
|
|
221
|
+
* tags, which the default (lite) answer leaves out. Undefined otherwise, so the
|
|
222
|
+
* request is the default one.
|
|
223
|
+
*/
|
|
224
|
+
declare function cardFields(settings: NormalizedSettings): readonly string[] | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* The `products.list` query for a listing. Pure, and the one place it is built:
|
|
227
|
+
* the server loader and a client island both call it, so the island's request
|
|
228
|
+
* matches the server's and starts on its answer (`initialData`).
|
|
229
|
+
*
|
|
230
|
+
* The page's path (`source`) names the collection, category or tag. A sort that
|
|
231
|
+
* is not the store's default counts as asked for (the URL omits the default):
|
|
232
|
+
* it is kept when it makes sense, `relevance` only with a search and `manual`
|
|
233
|
+
* only on a manual collection (`manualCollection`). With no sort asked for, the
|
|
234
|
+
* shop, a category or a tag takes `listing.defaultSort` (`featured` is the
|
|
235
|
+
* catalog's own default); a collection keeps its own order and a search keeps
|
|
236
|
+
* relevance. Pass `fields` from `cardFields(settings)`.
|
|
237
|
+
*/
|
|
238
|
+
declare function shopListQuery(query: ShopQuery, source: ShopSource, settings: NormalizedSettings, o?: {
|
|
239
|
+
fields?: readonly string[];
|
|
240
|
+
manualCollection?: boolean;
|
|
241
|
+
}): ProductsQuery;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* A JSON-LD `<script>`. Every `<` in the serialised JSON is written as the
|
|
245
|
+
* JSON escape `<`, so a value can never close the script element.
|
|
246
|
+
*/
|
|
247
|
+
declare function JsonLd({ data }: {
|
|
248
|
+
data: object;
|
|
249
|
+
}): react_jsx_runtime.JSX.Element;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* schema.org `Product` for a product page: its images, brand, SKU and one
|
|
253
|
+
* `Offer` at the lowest price a variant sells for (prices as decimal text).
|
|
254
|
+
* Available when any variant is in stock; with none, pre-order, back-order, else out of stock.
|
|
255
|
+
*/
|
|
256
|
+
declare function productJsonLd(product: StorefrontProduct, o: {
|
|
257
|
+
url: string;
|
|
258
|
+
settings: NormalizedSettings;
|
|
259
|
+
currency: string;
|
|
260
|
+
}): object;
|
|
261
|
+
/** schema.org `BreadcrumbList`. `url`s are absolute. */
|
|
262
|
+
declare function breadcrumbJsonLd(crumbs: {
|
|
263
|
+
name: string;
|
|
264
|
+
url: string;
|
|
265
|
+
}[]): object;
|
|
266
|
+
/** schema.org `ItemList` of a listing's products, each a link to its page. */
|
|
267
|
+
declare function itemListJsonLd(products: ListProduct[], o: {
|
|
268
|
+
baseUrl: string;
|
|
269
|
+
settings: NormalizedSettings;
|
|
270
|
+
}): object;
|
|
271
|
+
|
|
272
|
+
/** What every loader's answer carries. Plain JSON: safe to pass from a server component to a client one. */
|
|
273
|
+
type LoaderMeta = {
|
|
274
|
+
settings: NormalizedSettings;
|
|
275
|
+
/** Whether the catalog's lists carry ratings (`/config` `reviews`): hand it to `StorefrontProvider`'s `reviewsOnLists`. */
|
|
276
|
+
reviewsOnLists?: boolean;
|
|
277
|
+
/** When the server built this answer (ISO 8601). */
|
|
278
|
+
generatedAt: string;
|
|
279
|
+
};
|
|
280
|
+
/** One breadcrumb: a name and a site-relative link. */
|
|
281
|
+
type Crumb = {
|
|
282
|
+
name: string;
|
|
283
|
+
href: string;
|
|
284
|
+
};
|
|
285
|
+
/** What `loadShopAll` answers: the listing a `ShopAll` page needs, plain JSON. */
|
|
286
|
+
type ShopAllData = LoaderMeta & {
|
|
287
|
+
source: ShopSource;
|
|
288
|
+
query: ShopQuery;
|
|
289
|
+
/** The catalog's answer for the page `query` names. `list.sort` is the sort it applied (a collection keeps its own order unless the URL asks otherwise). */
|
|
290
|
+
list: StorefrontListAnswer;
|
|
291
|
+
/** The filters of `list`, for the filter pieces. */
|
|
292
|
+
facets: Filter[];
|
|
293
|
+
/** The page's heading: the shop's, the collection's, category's or tag's name, or the search's. */
|
|
294
|
+
title: string;
|
|
295
|
+
/** The merchant's SEO title for the entity, when it set one. */
|
|
296
|
+
seoTitle?: string;
|
|
297
|
+
description?: string;
|
|
298
|
+
/** A collection's kind: `shopListQuery`'s `manualCollection` is `collectionKind === 'manual'`. */
|
|
299
|
+
collectionKind?: 'manual' | 'rule';
|
|
300
|
+
/** Site-relative links, the store's name first when it has one. */
|
|
301
|
+
breadcrumbs: Crumb[];
|
|
302
|
+
};
|
|
303
|
+
/** What `loadProduct` answers: the product page's data, plain JSON. */
|
|
304
|
+
type ProductData = LoaderMeta & {
|
|
305
|
+
product: StorefrontProduct;
|
|
306
|
+
/** The variant `?variant=` names, or null. */
|
|
307
|
+
variantSku: string | null;
|
|
308
|
+
related: ListProduct[];
|
|
309
|
+
/**
|
|
310
|
+
* The first page of reviews (newest first), when the reviews section is on. `null`: there are no
|
|
311
|
+
* reviews to show (the catalog has reviews off, or answered 404 for this product), so the client
|
|
312
|
+
* asks for nothing. Absent: not asked (the section is off, or the read failed), so the client asks.
|
|
313
|
+
*/
|
|
314
|
+
reviews?: Exclude<StorefrontReviewsAnswer, {
|
|
315
|
+
redirectTo: string;
|
|
316
|
+
}> | null;
|
|
317
|
+
/**
|
|
318
|
+
* The body (HTML) of the catalog content page named by the `shipping` section's `pageHandle`.
|
|
319
|
+
* `null`: the page is missing, or the loader was told a Builder is in use (`builder: true`).
|
|
320
|
+
* Absent: not asked (no such section or no handle). Only a store with no Builder uses it (R14).
|
|
321
|
+
*/
|
|
322
|
+
shippingPage?: string | null;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
/** Page metadata, assignable to Next's `Metadata`. */
|
|
326
|
+
type StorefrontMetadata = {
|
|
327
|
+
title: string;
|
|
328
|
+
description?: string;
|
|
329
|
+
alternates: {
|
|
330
|
+
canonical: string;
|
|
331
|
+
};
|
|
332
|
+
robots?: {
|
|
333
|
+
index: boolean;
|
|
334
|
+
follow: boolean;
|
|
335
|
+
};
|
|
336
|
+
openGraph?: {
|
|
337
|
+
title: string;
|
|
338
|
+
description?: string;
|
|
339
|
+
images?: string[];
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
type MetadataOptions = {
|
|
343
|
+
baseUrl: string;
|
|
344
|
+
site?: SiteDesign | null;
|
|
345
|
+
};
|
|
346
|
+
/** A shop, collection, category or tag page: the entity's SEO title, the canonical and robots of R4. */
|
|
347
|
+
declare function shopAllMetadata(data: ShopAllData, o: MetadataOptions): StorefrontMetadata;
|
|
348
|
+
/** Search results: indexable search pages only add near-duplicates, so they are `noindex,follow`. */
|
|
349
|
+
declare function searchMetadata(data: ShopAllData, o: MetadataOptions): StorefrontMetadata;
|
|
350
|
+
/** A product page: the merchant's SEO title and description, the first image, a canonical without `?variant=`. */
|
|
351
|
+
declare function productMetadata(data: ProductData, o: MetadataOptions): StorefrontMetadata;
|
|
352
|
+
|
|
353
|
+
/** Reports nothing. The provider's default: there is no auto-detection of a tag on the page. */
|
|
354
|
+
declare const noopAnalytics: StorefrontAnalytics;
|
|
355
|
+
/**
|
|
356
|
+
* Reports to Google Analytics 4 on the page. `target: 'dataLayer'` (the default)
|
|
357
|
+
* pushes `{ ecommerce: null }` (so GA4 does not merge the last event's items into this one) and then `{ event, ecommerce }`, the shape Google Tag Manager reads; `'gtag'`
|
|
358
|
+
* calls `gtag('event', name, payload)`. It does nothing on the server, or when
|
|
359
|
+
* the page has no such global.
|
|
360
|
+
*/
|
|
361
|
+
declare function gaAnalytics(o?: {
|
|
362
|
+
target?: 'gtag' | 'dataLayer';
|
|
363
|
+
}): StorefrontAnalytics;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* A GA4 item for a product. The price is the chosen variant's (`variantSku`),
|
|
367
|
+
* else the product's lowest, as a decimal amount through `@usethrottle/money`.
|
|
368
|
+
*/
|
|
369
|
+
declare function toGa4Item(product: ListProduct | StorefrontProduct, o?: {
|
|
370
|
+
index?: number;
|
|
371
|
+
listName?: string;
|
|
372
|
+
variantSku?: string | null;
|
|
373
|
+
quantity?: number;
|
|
374
|
+
}): Ga4Item;
|
|
375
|
+
|
|
376
|
+
/** What `@usethrottle/scripts` exposes as `track` (a type-only dependency: nothing is imported). */
|
|
377
|
+
type ScriptsTrack = {
|
|
378
|
+
track(name: string, params?: Record<string, unknown>): void;
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* Reports through the Throttle scripts (`import * as scripts from '@usethrottle/scripts'`).
|
|
382
|
+
* Does nothing on the server. The GA4 payload is passed as the event's params; the scripts map them back to GA4.
|
|
383
|
+
*/
|
|
384
|
+
declare function throttleScriptsAnalytics(scripts: ScriptsTrack): StorefrontAnalytics;
|
|
385
|
+
|
|
386
|
+
/** Reports an event to the provider's `analytics` adapter (a no-op unless one was given). */
|
|
387
|
+
declare function useTrack(): StorefrontAnalytics['track'];
|
|
388
|
+
|
|
389
|
+
/** One badge on a card: its kind, its label and an optional colour. */
|
|
390
|
+
type CardBadge = {
|
|
391
|
+
kind: 'sale' | 'new' | 'lowStock' | 'custom';
|
|
392
|
+
label: string;
|
|
393
|
+
/** A hex colour the settings chose. Absent when it is the catalog's own default, so the theme's token shows. */
|
|
394
|
+
tone?: string;
|
|
395
|
+
};
|
|
396
|
+
/**
|
|
397
|
+
* The badges on a product card, in order: new, sale, low stock, then the custom
|
|
398
|
+
* tag badges. A port of Meridian `lib/badges.ts` (`cardFlags`); time-dependent
|
|
399
|
+
* output reads `generatedAt` (the server's clock, ISO), never `Date.now()`, so a
|
|
400
|
+
* server render and its hydration agree. Server-safe.
|
|
401
|
+
*/
|
|
402
|
+
declare function cardBadges(settings: NormalizedSettings, product: ListProduct, generatedAt: string): CardBadge[];
|
|
403
|
+
|
|
404
|
+
/** A picture that reserves its space: `aspectRatio` is required and becomes an inline `aspect-ratio`. */
|
|
405
|
+
type ImageProps = UsePartLocal & {
|
|
406
|
+
/** The image URL. */
|
|
407
|
+
src: string;
|
|
408
|
+
/** The alternative text. Pass an empty string for a purely decorative picture. */
|
|
409
|
+
alt: string;
|
|
410
|
+
/** Width over height. Space is reserved from it, so the layout does not move when the image loads. */
|
|
411
|
+
aspectRatio: number;
|
|
412
|
+
/** The `sizes` attribute, for a responsive `srcSet`. */
|
|
413
|
+
sizes?: string;
|
|
414
|
+
/** The `srcset` attribute: the same picture at several widths. */
|
|
415
|
+
srcSet?: string;
|
|
416
|
+
/** The largest paint of the page: loaded eagerly, fetched first. */
|
|
417
|
+
priority?: boolean;
|
|
418
|
+
};
|
|
419
|
+
/** An image that always reserves its space (an inline `aspect-ratio`). */
|
|
420
|
+
declare function Image({ src, alt, aspectRatio, sizes, srcSet, priority, classNames, className, unstyled }: ImageProps): react_jsx_runtime.JSX.Element;
|
|
421
|
+
|
|
422
|
+
/** The catalog list and product answers' `priceContext`. */
|
|
423
|
+
type PriceContext = 'anonymous' | 'customer' | 'email_unverified' | 'anonymous_fallback';
|
|
424
|
+
/** One price: a `Money` with the labels a customer price or an unverified email needs. */
|
|
425
|
+
type PriceProps = UsePartLocal & {
|
|
426
|
+
/** The price in the currency's minor units. */
|
|
427
|
+
minor: number;
|
|
428
|
+
/** The ISO 4217 code of the price. */
|
|
429
|
+
currency: string;
|
|
430
|
+
/** The price it was before, in minor units. Shown struck through when higher than `minor`. */
|
|
431
|
+
compareAtMinor?: number;
|
|
432
|
+
/**
|
|
433
|
+
* Whose price this is, from the catalog answer. `customer` adds the "Your price" label; `email_unverified` adds a hint to verify the email.
|
|
434
|
+
*/
|
|
435
|
+
priceContext?: PriceContext;
|
|
436
|
+
};
|
|
437
|
+
/**
|
|
438
|
+
* One price. A `customer` price carries the "Your price" label and hides the
|
|
439
|
+
* compare-at price unless `card.showCompareAt`; an `email_unverified` one
|
|
440
|
+
* carries the verify hint; the others are the plain price.
|
|
441
|
+
*/
|
|
442
|
+
declare function Price({ minor, currency, compareAtMinor, priceContext, classNames, className, unstyled }: PriceProps): react_jsx_runtime.JSX.Element;
|
|
443
|
+
|
|
444
|
+
/** A rating as five stars. */
|
|
445
|
+
type StarRatingProps = UsePartLocal & {
|
|
446
|
+
/** The average, 0 to 5. */
|
|
447
|
+
value: number;
|
|
448
|
+
/** The number of ratings, shown beside the stars. */
|
|
449
|
+
count?: number;
|
|
450
|
+
/** The star size. Default `md`. */
|
|
451
|
+
size?: 'sm' | 'md';
|
|
452
|
+
};
|
|
453
|
+
/** Five stars filled to the average (halves rounded to the nearest half), one image to a screen reader. */
|
|
454
|
+
declare function StarRating({ value, count, size, classNames, className, unstyled }: StarRatingProps): react_jsx_runtime.JSX.Element;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* How a card is drawn: `standard`, `minimal` (no frame), `overlay` (text over the picture) or `row` (picture beside text).
|
|
458
|
+
*/
|
|
459
|
+
type ProductCardVariant = 'standard' | 'minimal' | 'overlay' | 'row';
|
|
460
|
+
/** The small line above a card's title: the product's brand, or its category (the catalog's product type). */
|
|
461
|
+
type ProductCardMeta = 'brand' | 'category';
|
|
462
|
+
type Local$2 = Pick<UsePartLocal, 'classNames' | 'unstyled'>;
|
|
463
|
+
/** What a `Title` slot of a card receives. */
|
|
464
|
+
type CardTitleProps = Local$2 & {
|
|
465
|
+
/** The product the card shows. */
|
|
466
|
+
product: ListProduct;
|
|
467
|
+
/** The text to show as the title. */
|
|
468
|
+
title: string;
|
|
469
|
+
/** The product page's link. */
|
|
470
|
+
href: string;
|
|
471
|
+
/** Called when the shopper follows the link (for analytics). */
|
|
472
|
+
onSelect?: () => void;
|
|
473
|
+
};
|
|
474
|
+
/** What a `Badges` slot of a card receives. */
|
|
475
|
+
type CardBadgesProps = Local$2 & {
|
|
476
|
+
/** The badges the settings and the product ask for. */
|
|
477
|
+
badges: CardBadge[];
|
|
478
|
+
/** The product cannot be bought: a sold-out mark is shown. */
|
|
479
|
+
soldOut: boolean;
|
|
480
|
+
};
|
|
481
|
+
/** What a `QuickAdd` or `WishlistButton` slot of a card receives. */
|
|
482
|
+
type CardProductProps = Local$2 & {
|
|
483
|
+
/** The product the card shows. */
|
|
484
|
+
product: ListProduct;
|
|
485
|
+
};
|
|
486
|
+
/** The pieces of a card a store may replace. Each takes the props its default takes. */
|
|
487
|
+
type ProductCardSlots = {
|
|
488
|
+
Image: ComponentType<ImageProps>;
|
|
489
|
+
Title: ComponentType<CardTitleProps>;
|
|
490
|
+
Price: ComponentType<PriceProps>;
|
|
491
|
+
Rating: ComponentType<StarRatingProps>;
|
|
492
|
+
Badges: ComponentType<CardBadgesProps>;
|
|
493
|
+
QuickAdd: ComponentType<CardProductProps>;
|
|
494
|
+
WishlistButton: ComponentType<CardProductProps>;
|
|
495
|
+
};
|
|
496
|
+
/**
|
|
497
|
+
* A product in a list: picture, title, price, rating, badges and quick add, drawn by the merchant's card settings.
|
|
498
|
+
*/
|
|
499
|
+
type ProductCardProps = Local$2 & {
|
|
500
|
+
/** The product, as the catalog's list answer carries it. */
|
|
501
|
+
product: ListProduct;
|
|
502
|
+
/** Default: `settings.card.style`. */
|
|
503
|
+
variant?: ProductCardVariant;
|
|
504
|
+
/**
|
|
505
|
+
* What the line above the title says. Default `'brand'` (when `settings.card.showBrand` is on); `'category'`
|
|
506
|
+
* shows the product type, whatever `showBrand` says, and nothing when the product has none.
|
|
507
|
+
*/
|
|
508
|
+
meta?: ProductCardMeta;
|
|
509
|
+
/** The card's place in its list (0-based), for analytics. */
|
|
510
|
+
position?: number;
|
|
511
|
+
/** The list's name, for analytics. */
|
|
512
|
+
listName?: string;
|
|
513
|
+
/** When the data was made (ISO). The `new` badge ages against it, never against the browser's clock. */
|
|
514
|
+
generatedAt: string;
|
|
515
|
+
/** The list answer's `priceContext`. */
|
|
516
|
+
priceContext?: PriceContext;
|
|
517
|
+
/** Whether lists carry ratings. Default: the provider's `reviewsOnLists`. */
|
|
518
|
+
reviewsOnLists?: boolean;
|
|
519
|
+
/** Draw the quick add button on the card. Default: `settings.card.quickAdd`. A `QuickAdd` slot replaces it. */
|
|
520
|
+
quickAdd?: boolean;
|
|
521
|
+
/** Replace any piece of the card (`Image`, `Title`, `Price`, `Rating`, `Badges`, `QuickAdd`, `WishlistButton`). */
|
|
522
|
+
slots?: Partial<ProductCardSlots>;
|
|
523
|
+
/** Called when the shopper follows the card's link, with the product. */
|
|
524
|
+
onSelect?(product: ListProduct): void;
|
|
525
|
+
};
|
|
526
|
+
/**
|
|
527
|
+
* A product in a list: image, badges, brand, title, swatches, rating and price,
|
|
528
|
+
* each of them from the catalog settings (`card.*`, `badges.*`, `stock.words`).
|
|
529
|
+
* The variant follows `settings.card.style` unless the prop is set. Pieces can
|
|
530
|
+
* be replaced through `slots`; `QuickAdd` is the shopper's quick add when `settings.card.quickAdd`
|
|
531
|
+
* (or the `quickAdd` prop) is set and nothing otherwise, and `WishlistButton` renders nothing
|
|
532
|
+
* until a store gives one.
|
|
533
|
+
*/
|
|
534
|
+
declare function ProductCard(props: ProductCardProps): react_jsx_runtime.JSX.Element;
|
|
535
|
+
|
|
536
|
+
/** A small label on a card or product (`Sale`, `New`). */
|
|
537
|
+
type BadgeProps = UsePartLocal & {
|
|
538
|
+
/** What the badge says it is (`sale`, `new`, `lowStock`, `custom`): `data-badge`, and the colour it starts from. */
|
|
539
|
+
kind?: string;
|
|
540
|
+
/** A hex background the settings chose; the text colour is picked to read on it. Anything but hex is ignored. */
|
|
541
|
+
tone?: string;
|
|
542
|
+
/** The badge's text. */
|
|
543
|
+
children: ReactNode;
|
|
544
|
+
};
|
|
545
|
+
/** A small label on a card or a product. */
|
|
546
|
+
declare function Badge({ kind, tone, children, classNames, className, unstyled }: BadgeProps): react_jsx_runtime.JSX.Element;
|
|
547
|
+
|
|
548
|
+
/** A colour or texture dot for an option value. */
|
|
549
|
+
type SwatchProps = UsePartLocal & {
|
|
550
|
+
/** The option value; it names the swatch to a screen reader. */
|
|
551
|
+
value: string;
|
|
552
|
+
/** A hex colour; anything else is ignored. */
|
|
553
|
+
hex?: string;
|
|
554
|
+
/** An image URL, for a swatch that is a texture. */
|
|
555
|
+
image?: string;
|
|
556
|
+
/** This value is the chosen one. */
|
|
557
|
+
selected?: boolean;
|
|
558
|
+
/** No variant with this value can be bought. */
|
|
559
|
+
disabled?: boolean;
|
|
560
|
+
};
|
|
561
|
+
/** A colour or texture dot. It only draws; a picker wraps it in the control that selects. */
|
|
562
|
+
declare function Swatch({ value, hex, image, selected, disabled, classNames, className, unstyled }: SwatchProps): react_jsx_runtime.JSX.Element;
|
|
563
|
+
|
|
564
|
+
/** An amount in its own currency, drawn by `formatMoney`. */
|
|
565
|
+
type MoneyProps = UsePartLocal & {
|
|
566
|
+
/** The amount in the currency's minor units (cents for USD, whole yen for JPY). */
|
|
567
|
+
minor: number;
|
|
568
|
+
/** The ISO 4217 code of this amount: the record's own currency, never a default. */
|
|
569
|
+
currency: string;
|
|
570
|
+
/** Shown struck through beside the amount when it is higher. */
|
|
571
|
+
compareAtMinor?: number;
|
|
572
|
+
};
|
|
573
|
+
/** An amount in its own currency, by `formatMoney` and nothing else. */
|
|
574
|
+
declare function Money({ minor, currency, compareAtMinor, classNames, className, unstyled }: MoneyProps): react_jsx_runtime.JSX.Element;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Cleans untrusted HTML to an allow-list: known tags with known attributes,
|
|
578
|
+
* `http(s)`/`mailto`/`tel`/relative URLs only, text escaped, every tag closed.
|
|
579
|
+
* Server-safe (no DOM): a tokenizer, not a regex over the whole string.
|
|
580
|
+
*/
|
|
581
|
+
declare function sanitizeHtml(html: string, options?: {
|
|
582
|
+
linkClass?: string;
|
|
583
|
+
}): string;
|
|
584
|
+
/** Catalog HTML, drawn through an allow-list. */
|
|
585
|
+
type RichTextProps = UsePartLocal & {
|
|
586
|
+
/** Untrusted HTML (a product description, a content page). It is cleaned before it reaches the page. */
|
|
587
|
+
html: string;
|
|
588
|
+
};
|
|
589
|
+
/** Renders catalog HTML through an allow-list, so a description can never carry a script or a handler. */
|
|
590
|
+
declare function RichText({ html, classNames, className, unstyled }: RichTextProps): react_jsx_runtime.JSX.Element;
|
|
591
|
+
|
|
592
|
+
/** A link through the store's link component. Any anchor attribute is passed on. */
|
|
593
|
+
type LinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & UsePartLocal & {
|
|
594
|
+
/** The destination. A site-relative path stays in the app; an absolute URL leaves it. */
|
|
595
|
+
href: string;
|
|
596
|
+
/** Whether the link component may prefetch the destination (honoured by `next/link`; a plain `<a>` ignores it). */
|
|
597
|
+
prefetch?: boolean;
|
|
598
|
+
};
|
|
599
|
+
/** A link through the store's link component (a plain `<a>`, or `next/link` under the Next provider). */
|
|
600
|
+
declare function Link({ classNames, unstyled, className, ...anchor }: LinkProps): react_jsx_runtime.JSX.Element;
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Places Phase 3 fills (wishlist, back in stock, bundles, review media and
|
|
604
|
+
* votes, questions and answers). Each renders nothing today; a store may
|
|
605
|
+
* already pass them as a slot and a later release gives them a body.
|
|
606
|
+
*/
|
|
607
|
+
type ReservedProps = Record<string, unknown>;
|
|
608
|
+
/** Reserved for the wishlist (a later release). Renders nothing today; a store may already pass it as a slot. */
|
|
609
|
+
declare function WishlistButton(_props: ReservedProps): null;
|
|
610
|
+
/** Reserved for back-in-stock notices (a later release). Renders nothing today. */
|
|
611
|
+
declare function BackInStock(_props: ReservedProps): null;
|
|
612
|
+
/** Reserved for bundles (a later release). Renders nothing today. */
|
|
613
|
+
declare function FrequentlyBoughtTogether(_props: ReservedProps): null;
|
|
614
|
+
/** Reserved for review photos (a later release). Renders nothing today. */
|
|
615
|
+
declare function ReviewPhotos(_props: ReservedProps): null;
|
|
616
|
+
/** Reserved for review votes (a later release). Renders nothing today. */
|
|
617
|
+
declare function ReviewVotes(_props: ReservedProps): null;
|
|
618
|
+
/** Reserved for questions and answers (a later release). Renders nothing today. */
|
|
619
|
+
declare function QuestionsAndAnswers(_props: ReservedProps): null;
|
|
620
|
+
|
|
621
|
+
/** The selection as chips, each one removes its filter, and a clear-all. Nothing when nothing is selected. */
|
|
622
|
+
declare function ActiveFilters(local: UsePartLocal): react_jsx_runtime.JSX.Element | null;
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* The filters in a row above the list: the first four as dropdowns, then a
|
|
626
|
+
* "More filters" button that opens the rest in a drawer. Hidden on phones.
|
|
627
|
+
*/
|
|
628
|
+
declare function FilterBar(local: UsePartLocal): react_jsx_runtime.JSX.Element | null;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* A "Filters" button that opens every filter in a drawer from the inline-end
|
|
632
|
+
* edge. It is the layout on phones and for `filterLayout: 'drawer'`.
|
|
633
|
+
*/
|
|
634
|
+
declare function FilterDrawer(local: UsePartLocal): react_jsx_runtime.JSX.Element | null;
|
|
635
|
+
|
|
636
|
+
/** The filters in a column beside the list. Hidden on phones, where `FilterDrawer` takes over. */
|
|
637
|
+
declare function FilterSidebar(local: UsePartLocal): react_jsx_runtime.JSX.Element | null;
|
|
638
|
+
|
|
639
|
+
/** The pager for the layout the settings (or the `pagination` prop) choose. */
|
|
640
|
+
declare function Pagination(local: UsePartLocal): react_jsx_runtime.JSX.Element;
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* The cards of the list, in the columns the settings give. Numbered paging
|
|
644
|
+
* shows one page; load more and infinite scroll show every page from the
|
|
645
|
+
* first one loaded to the URL's, one grid under the other.
|
|
646
|
+
*/
|
|
647
|
+
declare function ProductGrid(local: UsePartLocal): react_jsx_runtime.JSX.Element;
|
|
648
|
+
|
|
649
|
+
/** How many products the selection has (`listing.count`). */
|
|
650
|
+
declare function ResultCount(local: UsePartLocal): react_jsx_runtime.JSX.Element | null;
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* The sort menu: the sorts the merchant enabled, in its order and its words.
|
|
654
|
+
* "Best match" is offered only for a search and "Collection order" only for a
|
|
655
|
+
* manual collection, as the catalog accepts nothing else.
|
|
656
|
+
*/
|
|
657
|
+
declare function SortSelect(local: UsePartLocal): react_jsx_runtime.JSX.Element | null;
|
|
658
|
+
|
|
659
|
+
/** Where the filters sit: a `sidebar`, a `topbar` or a `drawer`. */
|
|
660
|
+
type ShopFilterLayout = 'sidebar' | 'topbar' | 'drawer';
|
|
661
|
+
/** How pages are reached: `numbered` links, a `load_more` button or `infinite` scroll. */
|
|
662
|
+
type ShopPagination = 'numbered' | 'load_more' | 'infinite';
|
|
663
|
+
/** A numeric filter's selected range (a price, in the filter's own unit). */
|
|
664
|
+
type ShopRange = {
|
|
665
|
+
min?: number;
|
|
666
|
+
max?: number;
|
|
667
|
+
};
|
|
668
|
+
/** What `ShopAll.Root` takes besides its children. */
|
|
669
|
+
type ShopAllOptions = {
|
|
670
|
+
/** What is listed: the whole shop, a collection, a category, a tag or a search. */
|
|
671
|
+
source: ShopSource;
|
|
672
|
+
/** The server's answer for the URL (`loadShopAll`). With it, nothing is fetched on mount. */
|
|
673
|
+
initialData?: ShopAllData;
|
|
674
|
+
/** Default: `settings.listing.filterLayout`. */
|
|
675
|
+
filterLayout?: ShopFilterLayout;
|
|
676
|
+
/** Default: `settings.listing.pagination`. */
|
|
677
|
+
pagination?: ShopPagination;
|
|
678
|
+
/** Default: `settings.listing.columns`. */
|
|
679
|
+
columns?: {
|
|
680
|
+
desktop: number;
|
|
681
|
+
mobile: number;
|
|
682
|
+
};
|
|
683
|
+
/** Default: `settings.card.style`. */
|
|
684
|
+
cardVariant?: ProductCardVariant;
|
|
685
|
+
/** The line above each card's title: the brand (default) or the category. */
|
|
686
|
+
cardMeta?: ProductCardMeta;
|
|
687
|
+
/** The site's origin, for the absolute URLs of the JSON-LD (`https://shop.example`). Default: site-relative URLs. */
|
|
688
|
+
baseUrl?: string;
|
|
689
|
+
/** Default true. Set false when the page renders the structured data itself. */
|
|
690
|
+
jsonLd?: boolean;
|
|
691
|
+
};
|
|
692
|
+
/** One request of a load-more list: pages `from` to `to`, drawn as one grid. */
|
|
693
|
+
type ListSegment = {
|
|
694
|
+
key: string;
|
|
695
|
+
from: number;
|
|
696
|
+
to: number;
|
|
697
|
+
query: ProductsQuery;
|
|
698
|
+
/** The server's answer, when this is the page it rendered. */
|
|
699
|
+
seed?: StorefrontListAnswer;
|
|
700
|
+
};
|
|
701
|
+
/** The shop-all page's data and state, with the URL as the source of truth. */
|
|
702
|
+
type ShopAllState = {
|
|
703
|
+
source: ShopSource;
|
|
704
|
+
/** The URL as state: the selected filters and ranges, the sort, the page and the search. */
|
|
705
|
+
query: ShopQuery;
|
|
706
|
+
/** The catalog's answer for the current page (the last one while the next loads: `isPrevious`). */
|
|
707
|
+
data: StorefrontListAnswer | undefined;
|
|
708
|
+
status: 'ready' | 'loading' | 'error';
|
|
709
|
+
/** `data` answers an earlier query; the new one is on its way. */
|
|
710
|
+
isPrevious: boolean;
|
|
711
|
+
facets: Filter[];
|
|
712
|
+
total: number | undefined;
|
|
713
|
+
pageCount: number;
|
|
714
|
+
/** The `products.list` query of the current page. */
|
|
715
|
+
listQuery: ProductsQuery;
|
|
716
|
+
/**
|
|
717
|
+
* Load more and infinite scroll: the requests for the pages shown above the current one, oldest first. A
|
|
718
|
+
* cold load of `?page=3` is one request for pages 1 to 3, so this is empty; a list the server rendered
|
|
719
|
+
* has the pages before it here, and every page loaded since is one entry.
|
|
720
|
+
*/
|
|
721
|
+
earlier: ListSegment[];
|
|
722
|
+
/** The first page the list shows: a link to the page before it is offered when it is above 1. */
|
|
723
|
+
firstLoadedPage: number;
|
|
724
|
+
/** An earlier segment's answer arrived. Scroll restoration waits for all of them. */
|
|
725
|
+
reportReady(key: string): void;
|
|
726
|
+
/** The URL (path and query) of a state. */
|
|
727
|
+
hrefFor(query: ShopQuery): string;
|
|
728
|
+
toggleValue(key: string, value: string): void;
|
|
729
|
+
/** Replaces all the values of one filter. */
|
|
730
|
+
setValues(key: string, values: string[]): void;
|
|
731
|
+
/** Sets a range filter; `null` removes it. */
|
|
732
|
+
setRange(key: string, range: ShopRange | null): void;
|
|
733
|
+
/** Removes one filter, or every filter and range. */
|
|
734
|
+
clear(key?: string): void;
|
|
735
|
+
setSort(sort: string): void;
|
|
736
|
+
/** A new history entry; the view returns to the top of the list. */
|
|
737
|
+
setPage(page: number): void;
|
|
738
|
+
/** The next page, replacing the history entry: back leaves the list instead of stepping through its pages. */
|
|
739
|
+
loadMore(): void;
|
|
740
|
+
refetch(): void;
|
|
741
|
+
/** Filter values and ranges the URL selects. */
|
|
742
|
+
selectedCount: number;
|
|
743
|
+
/** Changes with the selection but not with the page. */
|
|
744
|
+
announceKey: string;
|
|
745
|
+
title: string;
|
|
746
|
+
description?: string;
|
|
747
|
+
breadcrumbs: Crumb[];
|
|
748
|
+
listName: string;
|
|
749
|
+
/** When the data was made (ISO): cards age the `new` badge against it. */
|
|
750
|
+
generatedAt: string;
|
|
751
|
+
reviewsOnLists?: boolean;
|
|
752
|
+
/** Whether a collection's own order can be chosen. */
|
|
753
|
+
manualCollection: boolean;
|
|
754
|
+
/** A card was chosen: reports `select_item` and remembers the scroll position. */
|
|
755
|
+
selectProduct(product: ListProduct, index: number): void;
|
|
756
|
+
/** Where the list starts: the view scrolls here on a page change. */
|
|
757
|
+
topRef: RefObject<HTMLDivElement | null>;
|
|
758
|
+
};
|
|
759
|
+
/** What `useShopAll()` answers: the page's state and the layout options as resolved (props over settings). */
|
|
760
|
+
type ShopAllContextValue = ShopAllState & {
|
|
761
|
+
filterLayout: ShopFilterLayout;
|
|
762
|
+
pagination: ShopPagination;
|
|
763
|
+
columns: {
|
|
764
|
+
desktop: number;
|
|
765
|
+
mobile: number;
|
|
766
|
+
};
|
|
767
|
+
cardVariant?: ProductCardVariant;
|
|
768
|
+
cardMeta?: ProductCardMeta;
|
|
769
|
+
baseUrl: string;
|
|
770
|
+
jsonLd: boolean;
|
|
771
|
+
};
|
|
772
|
+
/**
|
|
773
|
+
* The shop-all state: the URL's selection, the catalog's answer for it, and
|
|
774
|
+
* the actions that change the URL. Reads the nearest `ShopAll.Root`; throws
|
|
775
|
+
* outside one.
|
|
776
|
+
*/
|
|
777
|
+
declare function useShopAll(): ShopAllContextValue;
|
|
778
|
+
|
|
779
|
+
type Local$1 = Pick<UsePartLocal, 'classNames' | 'unstyled'>;
|
|
780
|
+
/** The props of `ShopAll.Root` (and `ShopAll`): what is listed, the server's answer and the layout options. */
|
|
781
|
+
type ShopAllRootProps = Local$1 & ShopAllOptions & {
|
|
782
|
+
/** Extra class names for the page's root element. */
|
|
783
|
+
className?: string;
|
|
784
|
+
/** Your own layout, built from `ShopAll.*` pieces. */
|
|
785
|
+
children?: ReactNode;
|
|
786
|
+
};
|
|
787
|
+
/**
|
|
788
|
+
* The state and the one wrapper element of a shop-all page. Everything inside
|
|
789
|
+
* (`ShopAll.FilterSidebar`, `ShopAll.ProductGrid`, ...) reads it, so a store
|
|
790
|
+
* can lay the pieces out as it likes.
|
|
791
|
+
*/
|
|
792
|
+
declare function Root$1({ children, className, classNames, unstyled, ...options }: ShopAllRootProps): react_jsx_runtime.JSX.Element;
|
|
793
|
+
/** `shop.above`: where a Builder adds content after the heading and before the controls. */
|
|
794
|
+
declare function SlotAbove$1(): react_jsx_runtime.JSX.Element;
|
|
795
|
+
/** `shop.below`: where a Builder adds content after the pagination. */
|
|
796
|
+
declare function SlotBelow$1(): react_jsx_runtime.JSX.Element;
|
|
797
|
+
/** The trail to the list (`Store / Shop / Tops`), the last item the current page. */
|
|
798
|
+
declare function Breadcrumbs$1(local: UsePartLocal): react_jsx_runtime.JSX.Element | null;
|
|
799
|
+
/** The list's heading and, when the collection or category has one, its description. */
|
|
800
|
+
declare function Heading(local: UsePartLocal): react_jsx_runtime.JSX.Element;
|
|
801
|
+
/** The props of `ShopAll`: the same as `ShopAll.Root`. */
|
|
802
|
+
type ShopAllProps = ShopAllRootProps;
|
|
803
|
+
/**
|
|
804
|
+
* A shop, collection, category, tag or search listing: heading, controls,
|
|
805
|
+
* filters, grid and pagination, laid out by the merchant's settings (each
|
|
806
|
+
* overridable by a prop). Give it `initialData` from `loadShopAll` and it
|
|
807
|
+
* renders at once and fetches nothing until the shopper changes the selection.
|
|
808
|
+
* With `children` it is `ShopAll.Root` around them.
|
|
809
|
+
*/
|
|
810
|
+
declare function ShopAllPage({ children, ...props }: ShopAllProps): react_jsx_runtime.JSX.Element;
|
|
811
|
+
/**
|
|
812
|
+
* The listing page, as one component or as pieces: `<ShopAll source={...} initialData={data} />`, or `ShopAll.Root` with `ShopAll.ProductGrid`, `ShopAll.FilterSidebar`, `ShopAll.Pagination` and the other pieces inside.
|
|
813
|
+
*/
|
|
814
|
+
declare const ShopAll: typeof ShopAllPage & {
|
|
815
|
+
Root: typeof Root$1;
|
|
816
|
+
Heading: typeof Heading;
|
|
817
|
+
Breadcrumbs: typeof Breadcrumbs$1;
|
|
818
|
+
FilterSidebar: typeof FilterSidebar;
|
|
819
|
+
FilterBar: typeof FilterBar;
|
|
820
|
+
FilterDrawer: typeof FilterDrawer;
|
|
821
|
+
ActiveFilters: typeof ActiveFilters;
|
|
822
|
+
SortSelect: typeof SortSelect;
|
|
823
|
+
ResultCount: typeof ResultCount;
|
|
824
|
+
ProductGrid: typeof ProductGrid;
|
|
825
|
+
Pagination: typeof Pagination;
|
|
826
|
+
SlotAbove: typeof SlotAbove$1;
|
|
827
|
+
SlotBelow: typeof SlotBelow$1;
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
/** One filter of the listing: a collapsible group of its values (or a price range). */
|
|
831
|
+
type FacetGroupProps = UsePartLocal & {
|
|
832
|
+
/** The filter as the catalog's list answer carries it. */
|
|
833
|
+
facet: Filter;
|
|
834
|
+
/** `section`: a collapsible block (sidebar, drawer). `dropdown`: a button that opens a panel (the top bar). */
|
|
835
|
+
presentation?: 'section' | 'dropdown';
|
|
836
|
+
};
|
|
837
|
+
/**
|
|
838
|
+
* One filter of the list answer, drawn as its `display` says: checkbox values,
|
|
839
|
+
* colour swatches, a dropdown, a yes/no choice or a numeric range. Values OR
|
|
840
|
+
* within a filter and AND across filters.
|
|
841
|
+
*/
|
|
842
|
+
declare function FacetGroup({ facet, presentation, classNames, unstyled }: FacetGroupProps): react_jsx_runtime.JSX.Element;
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Announces the result count when the selection changes (a filter, the sort or
|
|
846
|
+
* a search), not on first load and not on a page change. Always mounted, so
|
|
847
|
+
* assistive technology registers it before its text changes.
|
|
848
|
+
*/
|
|
849
|
+
declare function LiveRegion(local: UsePartLocal): react_jsx_runtime.JSX.Element;
|
|
850
|
+
|
|
851
|
+
/** Remembers how far the page is scrolled, under the current URL. Called when a shopper follows a product link. */
|
|
852
|
+
declare function rememberScroll(): void;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* The add button and what an add said. The add sends the SKU and the quantity
|
|
856
|
+
* only: the price is the catalog's, never the browser's. While an add runs the
|
|
857
|
+
* button is `aria-disabled` (not `disabled`), so it keeps keyboard focus; it is
|
|
858
|
+
* `disabled` only when pressing cannot help (sold out, no price in the currency).
|
|
859
|
+
*/
|
|
860
|
+
declare function AddToCart({ classNames, className, unstyled }: UsePartLocal): react_jsx_runtime.JSX.Element;
|
|
861
|
+
|
|
862
|
+
/** One step of a product's trail: a name and a site-relative link. */
|
|
863
|
+
type ProductCrumb = {
|
|
864
|
+
name: string;
|
|
865
|
+
href: string;
|
|
866
|
+
};
|
|
867
|
+
/**
|
|
868
|
+
* The trail to a product, site-relative: the store (its name, or `homeLabel`),
|
|
869
|
+
* the category trail the catalog answers, then the product itself.
|
|
870
|
+
*/
|
|
871
|
+
declare function productCrumbs(product: Pick<StorefrontProduct, 'title' | 'handle' | 'breadcrumbs'>, settings: NormalizedSettings, homeLabel: string): ProductCrumb[];
|
|
872
|
+
/** The trail as links with the product last (`aria-current="page"`). */
|
|
873
|
+
declare function Breadcrumbs({ classNames, className, unstyled }: UsePartLocal): react_jsx_runtime.JSX.Element;
|
|
874
|
+
|
|
875
|
+
/** A variant as `products.get` answers it. */
|
|
876
|
+
type Variant = StorefrontProduct['variants'][number];
|
|
877
|
+
/** The values of one option as the picker reads them. */
|
|
878
|
+
type PickerOption = {
|
|
879
|
+
name: string;
|
|
880
|
+
values: {
|
|
881
|
+
value: string;
|
|
882
|
+
swatch?: unknown | null;
|
|
883
|
+
}[];
|
|
884
|
+
};
|
|
885
|
+
/** The picker an option gets by default. */
|
|
886
|
+
type PickerKind = 'swatch' | 'buttons' | 'dropdown';
|
|
887
|
+
/**
|
|
888
|
+
* `swatch` when every value has a swatch, `dropdown` when there are more than
|
|
889
|
+
* 8 values, else `buttons`. An option with no values is `buttons`.
|
|
890
|
+
*/
|
|
891
|
+
declare function pickerKind(option: PickerOption): PickerKind;
|
|
892
|
+
/**
|
|
893
|
+
* What choosing `name = value` gives, with the other choices kept. A
|
|
894
|
+
* combination that is sold out is still a choice (`soldOut`, with its `sku`);
|
|
895
|
+
* one the product does not make has no `sku`.
|
|
896
|
+
*/
|
|
897
|
+
declare function selectOption(product: Pick<StorefrontProduct, 'variants'>, current: Record<string, string>, name: string, value: string): {
|
|
898
|
+
selection: Record<string, string>;
|
|
899
|
+
sku: string | null;
|
|
900
|
+
soldOut: boolean;
|
|
901
|
+
};
|
|
902
|
+
/** What the buy box says about a variant. */
|
|
903
|
+
type Stock = 'in_stock' | 'low' | 'preorder' | 'backorder' | 'out' | 'no_currency';
|
|
904
|
+
|
|
905
|
+
type Local = Pick<UsePartLocal, 'classNames' | 'unstyled'>;
|
|
906
|
+
/** What the reserved places (wishlist, back in stock) are given. */
|
|
907
|
+
type ReservedSlotProps = Local & {
|
|
908
|
+
/** The product on the page. */
|
|
909
|
+
product: StorefrontProduct;
|
|
910
|
+
/** The chosen variant, or `undefined` for a product with none. */
|
|
911
|
+
variant: Variant | undefined;
|
|
912
|
+
};
|
|
913
|
+
/** The pieces of the buy box a store may replace. Each takes the props its default takes. */
|
|
914
|
+
type BuyBoxSlots = {
|
|
915
|
+
Price: ComponentType<PriceProps>;
|
|
916
|
+
VariantPicker: ComponentType<UsePartLocal>;
|
|
917
|
+
StockStatus: ComponentType<UsePartLocal>;
|
|
918
|
+
QuantityInput: ComponentType<UsePartLocal>;
|
|
919
|
+
AddToCart: ComponentType<UsePartLocal>;
|
|
920
|
+
WishlistButton: ComponentType<ReservedSlotProps>;
|
|
921
|
+
BackInStock: ComponentType<ReservedSlotProps>;
|
|
922
|
+
};
|
|
923
|
+
/** The buy box: title, price, options, quantity and add to cart. */
|
|
924
|
+
type BuyBoxProps = UsePartLocal & {
|
|
925
|
+
/**
|
|
926
|
+
* Replace any piece of the buy box (`Price`, `VariantPicker`, `StockStatus`, `QuantityInput`, `AddToCart`, `WishlistButton`, `BackInStock`).
|
|
927
|
+
*/
|
|
928
|
+
slots?: Partial<BuyBoxSlots>;
|
|
929
|
+
/** The product title's heading level (default 1, the page's own heading). A modal that has its own title uses 2. */
|
|
930
|
+
headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
931
|
+
};
|
|
932
|
+
/**
|
|
933
|
+
* The buy box: title, rating, price, options, availability, quantity and add
|
|
934
|
+
* to cart, of the chosen variant. Each piece can be replaced through `slots`.
|
|
935
|
+
* The price is the variant's own (`priceContext` says whose); it is never computed here.
|
|
936
|
+
*/
|
|
937
|
+
declare function BuyBox({ slots, classNames, className, unstyled, headingLevel }: BuyBoxProps): react_jsx_runtime.JSX.Element;
|
|
938
|
+
|
|
939
|
+
/** The product's categories, each a link to its category page. Nothing without categories. */
|
|
940
|
+
declare function CategoryList({ classNames, className, unstyled }: UsePartLocal): react_jsx_runtime.JSX.Element | null;
|
|
941
|
+
|
|
942
|
+
/** The product's photos and videos. Takes the styling props only; the media come from the page's product. */
|
|
943
|
+
type GalleryProps = UsePartLocal;
|
|
944
|
+
/**
|
|
945
|
+
* The product's photos: the one shown, thumbnails, previous and next, a swipe
|
|
946
|
+
* on touch, a zoom under a mouse, and a lightbox (loaded on first use). A
|
|
947
|
+
* media item of `kind: 'video'` plays in place. Choosing a variant shows its
|
|
948
|
+
* photo. The arrow keys move between photos (inverted in a right-to-left page).
|
|
949
|
+
*/
|
|
950
|
+
declare function Gallery({ classNames, className, unstyled }: GalleryProps): react_jsx_runtime.JSX.Element;
|
|
951
|
+
|
|
952
|
+
/** The product page's arrangement: `classic` (gallery beside the buy box), `stacked` or `editorial`. */
|
|
953
|
+
type ProductLayout = 'classic' | 'stacked' | 'editorial';
|
|
954
|
+
/** The reviews section: the summary above the list (`stack`), or beside it from 768 px (`columns`). */
|
|
955
|
+
type ReviewsLayout = 'stack' | 'columns';
|
|
956
|
+
/** How the sections are drawn: `tabs`, `accordion`, `stacked`, or `auto` (tabs, accordions under 768 px). */
|
|
957
|
+
type SectionsStyle = 'auto' | 'tabs' | 'accordion' | 'stacked';
|
|
958
|
+
/** What an add to the cart last said. */
|
|
959
|
+
type AddMessage = {
|
|
960
|
+
tone: 'ok' | 'refused';
|
|
961
|
+
text: string;
|
|
962
|
+
};
|
|
963
|
+
/**
|
|
964
|
+
* What `useProductPage()` answers inside a product page: the product, the chosen variant and options, stock, the quantity and `add()`.
|
|
965
|
+
*/
|
|
966
|
+
type ProductPageValue = {
|
|
967
|
+
product: StorefrontProduct;
|
|
968
|
+
/** The product answer's price context (`customer` for a signed-in shopper's own price). */
|
|
969
|
+
priceContext: PriceContext | undefined;
|
|
970
|
+
/** The chosen value of each option. */
|
|
971
|
+
selection: Record<string, string>;
|
|
972
|
+
/** The chosen variant's SKU; null for a product with no variants. */
|
|
973
|
+
sku: string | null;
|
|
974
|
+
variant: Variant | undefined;
|
|
975
|
+
stock: Stock | null;
|
|
976
|
+
/** Chooses `name = value`. A value that does not go with the other choices lands on the nearest variant that has it. */
|
|
977
|
+
selectOption(name: string, value: string): void;
|
|
978
|
+
quantity: number;
|
|
979
|
+
/** Held to 1 and the variant's `maxOrderQuantity`. */
|
|
980
|
+
setQuantity(quantity: number): void;
|
|
981
|
+
maxQuantity: number | undefined;
|
|
982
|
+
add(): Promise<void>;
|
|
983
|
+
adding: boolean;
|
|
984
|
+
message: AddMessage | null;
|
|
985
|
+
layout: ProductLayout;
|
|
986
|
+
sectionsStyle: SectionsStyle;
|
|
987
|
+
reviewsLayout: ReviewsLayout;
|
|
988
|
+
/** The related products the server sent; undefined without server data. */
|
|
989
|
+
related: ListProduct[] | undefined;
|
|
990
|
+
/** When the server built the data (ISO), for the `new` badge. */
|
|
991
|
+
generatedAt: string | undefined;
|
|
992
|
+
/** Absolute origin of the store for JSON-LD links; empty makes them site-relative. */
|
|
993
|
+
baseUrl: string;
|
|
994
|
+
/** The first page of reviews the server loaded (`null`: none to show); undefined when it did not ask. */
|
|
995
|
+
initialReviews: ProductData['reviews'];
|
|
996
|
+
/** The shipping page's body the server loaded (`null`: missing); undefined when it did not ask. */
|
|
997
|
+
shippingPage: ProductData['shippingPage'];
|
|
998
|
+
/** One id for this page's sections, so two product pages in one document (a quick view) never share ids. */
|
|
999
|
+
sectionsId: string;
|
|
1000
|
+
/** The main AddToCart sets this so the sticky bar knows when it leaves the viewport. */
|
|
1001
|
+
addToCartRef: MutableRefObject<HTMLElement | null>;
|
|
1002
|
+
/** `ProductSections` sets this: shows a section (opens its tab or accordion) and says whether it has one. */
|
|
1003
|
+
revealSectionRef: MutableRefObject<((key: string) => boolean) | null>;
|
|
1004
|
+
};
|
|
1005
|
+
/** The product page state: the product, the chosen variant and quantity, and `add()`. Throws outside `ProductPage.Root`. */
|
|
1006
|
+
declare function useProductPage(): ProductPageValue;
|
|
1007
|
+
|
|
1008
|
+
/** The product's description, details, shipping and reviews sections. */
|
|
1009
|
+
type ProductSectionsProps = UsePartLocal & {
|
|
1010
|
+
/** Default: the page's (`Root`'s `sectionsStyle`, else `settings.product.sectionsStyle`). */
|
|
1011
|
+
style?: SectionsStyle;
|
|
1012
|
+
};
|
|
1013
|
+
/**
|
|
1014
|
+
* The product's sections in the order and with the titles of
|
|
1015
|
+
* `settings.product.sections`, those that are enabled and have something to
|
|
1016
|
+
* show, as tabs, accordions or a stack (`auto` is tabs, and accordions under
|
|
1017
|
+
* 768 px). Each is `data-section="<key>"` with a `data-section-title` heading.
|
|
1018
|
+
* A closed tab or accordion makes no request; the reviews link opens the reviews.
|
|
1019
|
+
*/
|
|
1020
|
+
declare function ProductSections({ style, classNames, className, unstyled }: ProductSectionsProps): react_jsx_runtime.JSX.Element | null;
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* The quantity: a number field with one-fewer and one-more buttons. The
|
|
1024
|
+
* minimum is always 1; the maximum is the variant's `maxOrderQuantity` (none
|
|
1025
|
+
* without it). What is typed is held to those bounds at once; an empty field
|
|
1026
|
+
* is allowed while typing and returns to the quantity on blur.
|
|
1027
|
+
*/
|
|
1028
|
+
declare function QuantityInput({ classNames, className, unstyled }: UsePartLocal): react_jsx_runtime.JSX.Element;
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* The related products: what the server sent, else a request, at most
|
|
1032
|
+
* `settings.product.relatedLimit`. It asks the catalog with the shared cache
|
|
1033
|
+
* policy (no override). For a signed-in shopper the answer is read again so
|
|
1034
|
+
* the cards carry their prices. With `active` false nothing is requested.
|
|
1035
|
+
*/
|
|
1036
|
+
declare function useRelatedProducts(active?: boolean): {
|
|
1037
|
+
products: ListProduct[];
|
|
1038
|
+
priceContext: PriceContext | undefined;
|
|
1039
|
+
};
|
|
1040
|
+
/** The related products of the page's product, as cards. */
|
|
1041
|
+
type RelatedProductsProps = UsePartLocal & {
|
|
1042
|
+
/** False while the section is not shown (a closed tab): no request is made. Default true. */
|
|
1043
|
+
active?: boolean;
|
|
1044
|
+
/** How the related cards are drawn: their `variant`, `meta` line and `slots`. */
|
|
1045
|
+
card?: Pick<ProductCardProps, 'variant' | 'meta' | 'slots'>;
|
|
1046
|
+
};
|
|
1047
|
+
/** The related products as cards. Nothing when there are none. */
|
|
1048
|
+
declare function RelatedProducts({ active, card, classNames, className, unstyled }: RelatedProductsProps): react_jsx_runtime.JSX.Element | null;
|
|
1049
|
+
|
|
1050
|
+
/**
|
|
1051
|
+
* Writing a review, for a shopper who may (`Reviews` shows it only then).
|
|
1052
|
+
* Every field has a label; a missing one is marked inline and takes focus.
|
|
1053
|
+
* One idempotency key per submission is the SDK's: a retry never makes two reviews.
|
|
1054
|
+
*/
|
|
1055
|
+
declare function ReviewForm({ handle, classNames, className, unstyled }: UsePartLocal & {
|
|
1056
|
+
handle?: string;
|
|
1057
|
+
}): react_jsx_runtime.JSX.Element;
|
|
1058
|
+
|
|
1059
|
+
/** The reviews section: the average, a histogram, a sort, the list and the form. */
|
|
1060
|
+
type ReviewsProps = UsePartLocal & {
|
|
1061
|
+
/** False while the section is not shown (a closed tab): no request is made. Default true. */
|
|
1062
|
+
active?: boolean;
|
|
1063
|
+
/** The first page of reviews when the server has it (default: the page's own, from `loadProduct`); no request is made for it. */
|
|
1064
|
+
initialData?: StorefrontReviewsAnswer;
|
|
1065
|
+
/** Default: the page's (`Root`'s `reviewsLayout`, else `stack`). `columns` puts the summary beside the list from 768 px. */
|
|
1066
|
+
layout?: ReviewsLayout;
|
|
1067
|
+
};
|
|
1068
|
+
/**
|
|
1069
|
+
* Reviews: the average and a histogram whose rows filter by rating, a sort, the
|
|
1070
|
+
* list with "load more", and (for a shopper who may) the form. A rating filter
|
|
1071
|
+
* and a sort ask the catalog again; the catalog's `summary` stays the product's whole.
|
|
1072
|
+
*/
|
|
1073
|
+
declare function Reviews({ active, initialData, layout, classNames, className, unstyled }: ReviewsProps): react_jsx_runtime.JSX.Element | null;
|
|
1074
|
+
|
|
1075
|
+
/** What a shipping section shows: the Builder's page, the catalog's page body, or nothing. */
|
|
1076
|
+
type ShippingContent = {
|
|
1077
|
+
kind: 'outlet';
|
|
1078
|
+
Outlet: SlotRenderer;
|
|
1079
|
+
} | {
|
|
1080
|
+
kind: 'page';
|
|
1081
|
+
html: string;
|
|
1082
|
+
} | {
|
|
1083
|
+
kind: 'hidden';
|
|
1084
|
+
};
|
|
1085
|
+
/**
|
|
1086
|
+
* R14. With a Builder (`site.source === 'builder'`) the section is the Builder's
|
|
1087
|
+
* published page for `pageHandle` (`site.pageOutlet`); with no outlet, or none
|
|
1088
|
+
* for the handle, it is hidden and no catalog request is made. Without a
|
|
1089
|
+
* Builder it is the catalog content page's body, hidden while that page loads
|
|
1090
|
+
* or when it is missing.
|
|
1091
|
+
*/
|
|
1092
|
+
declare function useShippingContent(pageHandle: string | null): ShippingContent;
|
|
1093
|
+
/** The shipping information of the store (R14), for a product's `shipping` section. */
|
|
1094
|
+
declare function ShippingSection({ pageHandle, classNames, className, unstyled }: UsePartLocal & {
|
|
1095
|
+
pageHandle: string | null;
|
|
1096
|
+
}): react_jsx_runtime.JSX.Element | null;
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* A bar fixed to the bottom of the screen that shows when the main add button
|
|
1100
|
+
* has scrolled out of view (an IntersectionObserver), with the title, the
|
|
1101
|
+
* price and an add button. Nothing shows without an observer.
|
|
1102
|
+
*/
|
|
1103
|
+
declare function StickyAddToCart({ classNames, className, unstyled }: UsePartLocal): react_jsx_runtime.JSX.Element | null;
|
|
1104
|
+
|
|
1105
|
+
type StockWordKey = keyof NormalizedSettings['stock']['words'];
|
|
1106
|
+
/**
|
|
1107
|
+
* The store's word for a stock state (`settings.stock.words`). `{count}` fills
|
|
1108
|
+
* when the caller knows a count; the catalog's product answer carries none, so
|
|
1109
|
+
* a word that needs one falls back to the low-stock badge's label rather than
|
|
1110
|
+
* show a bare placeholder. An empty word is the English default.
|
|
1111
|
+
*/
|
|
1112
|
+
declare function stockWord(settings: Pick<NormalizedSettings, 'stock' | 'badges'>, key: StockWordKey, count?: number): string;
|
|
1113
|
+
/** The chosen variant's availability in the merchant's words, with `data-stock-words` naming which word. */
|
|
1114
|
+
declare function StockStatus({ classNames, className, unstyled }: UsePartLocal): react_jsx_runtime.JSX.Element;
|
|
1115
|
+
|
|
1116
|
+
/** The product's tags, each a link to its tag page. Nothing without tags. */
|
|
1117
|
+
declare function TagList({ classNames, className, unstyled }: UsePartLocal): react_jsx_runtime.JSX.Element | null;
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* One group per option of the product, each a swatch row, a button row or a
|
|
1121
|
+
* dropdown by `pickerKind`. Every value can be pressed: one that is sold out
|
|
1122
|
+
* with the other choices is marked `data-sold-out` (drawn crossed out) and
|
|
1123
|
+
* still selects it; one the product does not make with them (`data-unavailable`)
|
|
1124
|
+
* moves the other choices to the nearest variant that has it.
|
|
1125
|
+
*/
|
|
1126
|
+
declare function VariantPicker({ classNames, className, unstyled }: UsePartLocal): react_jsx_runtime.JSX.Element | null;
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* The props of `ProductPage.Root` (and `ProductPage`): the product to show, from `initialData` or the URL, and the layout options.
|
|
1130
|
+
*/
|
|
1131
|
+
type ProductPageRootProps = UsePartLocal & {
|
|
1132
|
+
/** The product's handle. Default: `initialData`'s, else read from the URL by `settings.routes.product`. */
|
|
1133
|
+
handle?: string;
|
|
1134
|
+
/** What `loadProduct` answered: the page renders from it and makes no request on mount. */
|
|
1135
|
+
initialData?: ProductData;
|
|
1136
|
+
/** Default: `settings.product.layout`. */
|
|
1137
|
+
layout?: ProductLayout;
|
|
1138
|
+
/** Default: `settings.product.sectionsStyle`. */
|
|
1139
|
+
sectionsStyle?: SectionsStyle;
|
|
1140
|
+
/** The reviews section's layout. Default `stack`. */
|
|
1141
|
+
reviewsLayout?: ReviewsLayout;
|
|
1142
|
+
/** The store's origin (`https://shop.example`), so JSON-LD links are absolute. Default: site-relative. */
|
|
1143
|
+
baseUrl?: string;
|
|
1144
|
+
/**
|
|
1145
|
+
* Your own layout, drawn inside the page's state (`ProductPage.Gallery`, `ProductPage.BuyBox`, ...). Without it the default page is drawn.
|
|
1146
|
+
*/
|
|
1147
|
+
children?: ReactNode;
|
|
1148
|
+
};
|
|
1149
|
+
/**
|
|
1150
|
+
* The product page's state and data, with no markup of its own (a root
|
|
1151
|
+
* element aside): put the sections you want inside. It reads the product from
|
|
1152
|
+
* `initialData` (no request on mount) or the catalog by `handle`.
|
|
1153
|
+
*/
|
|
1154
|
+
declare function Root(props: ProductPageRootProps): react_jsx_runtime.JSX.Element;
|
|
1155
|
+
/** The product's JSON-LD: the `Product` and its `BreadcrumbList`. Rendered once by the assembled page. */
|
|
1156
|
+
declare function ProductJsonLd(): react_jsx_runtime.JSX.Element;
|
|
1157
|
+
declare function SlotAbove(): react_jsx_runtime.JSX.Element;
|
|
1158
|
+
declare function SlotBelow(): react_jsx_runtime.JSX.Element;
|
|
1159
|
+
/** The props of the whole `ProductPage`: the same as `ProductPage.Root`. */
|
|
1160
|
+
type ProductPageProps = ProductPageRootProps;
|
|
1161
|
+
/**
|
|
1162
|
+
* The whole product page: breadcrumbs, `product.above`, the gallery and buy
|
|
1163
|
+
* box in the layout, `product.below`, the sections and the sticky add bar.
|
|
1164
|
+
* Give it `children` to lay the page out yourself (inside the same state).
|
|
1165
|
+
*/
|
|
1166
|
+
declare function ProductPageImpl(props: ProductPageProps): react_jsx_runtime.JSX.Element;
|
|
1167
|
+
/**
|
|
1168
|
+
* `<ProductPage initialData={data} />`, or compose it:
|
|
1169
|
+
* `<ProductPage.Root initialData={data}><ProductPage.Gallery /><ProductPage.BuyBox /></ProductPage.Root>`.
|
|
1170
|
+
*/
|
|
1171
|
+
declare const ProductPage: typeof ProductPageImpl & {
|
|
1172
|
+
Root: typeof Root;
|
|
1173
|
+
JsonLd: typeof ProductJsonLd;
|
|
1174
|
+
Breadcrumbs: typeof Breadcrumbs;
|
|
1175
|
+
SlotAbove: typeof SlotAbove;
|
|
1176
|
+
Gallery: typeof Gallery;
|
|
1177
|
+
BuyBox: typeof BuyBox;
|
|
1178
|
+
VariantPicker: typeof VariantPicker;
|
|
1179
|
+
Price: typeof Price;
|
|
1180
|
+
StockStatus: typeof StockStatus;
|
|
1181
|
+
QuantityInput: typeof QuantityInput;
|
|
1182
|
+
AddToCart: typeof AddToCart;
|
|
1183
|
+
StickyAddToCart: typeof StickyAddToCart;
|
|
1184
|
+
ProductSections: typeof ProductSections;
|
|
1185
|
+
ShippingSection: typeof ShippingSection;
|
|
1186
|
+
TagList: typeof TagList;
|
|
1187
|
+
CategoryList: typeof CategoryList;
|
|
1188
|
+
RelatedProducts: typeof RelatedProducts;
|
|
1189
|
+
Reviews: typeof Reviews;
|
|
1190
|
+
ReviewForm: typeof ReviewForm;
|
|
1191
|
+
SlotBelow: typeof SlotBelow;
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
/** The footer: an optional brand block, the footer menu and the copyright line. */
|
|
1195
|
+
type FooterProps = UsePartLocal & {
|
|
1196
|
+
/** The year in the copyright line. Default: the current year. */
|
|
1197
|
+
year?: number;
|
|
1198
|
+
/** Shown before the menu: a logo and a line about the store. Nothing is drawn when absent. */
|
|
1199
|
+
brand?: ReactNode;
|
|
1200
|
+
/** Shown between the menu and the copyright line: a newsletter form, social links, payment marks. */
|
|
1201
|
+
children?: ReactNode;
|
|
1202
|
+
};
|
|
1203
|
+
/**
|
|
1204
|
+
* The footer: the site design's footer menu (`data-menu="footer"`) and the copyright line from the site
|
|
1205
|
+
* string `footer.copyright` (`{year}` and `{store}` fill in). `brand` goes before the menu and `children`
|
|
1206
|
+
* after it, each in a block of its own.
|
|
1207
|
+
*/
|
|
1208
|
+
declare function Footer({ year, brand, children, ...local }: FooterProps): react_jsx_runtime.JSX.Element;
|
|
1209
|
+
|
|
1210
|
+
/** A link to the account page. */
|
|
1211
|
+
type AccountButtonProps = UsePartLocal & {
|
|
1212
|
+
/** The account page. Default `/account`. */
|
|
1213
|
+
href?: string;
|
|
1214
|
+
};
|
|
1215
|
+
/** A link to the account page, named by the site string `nav.account`. Whether the shopper is signed in is the account page's business. */
|
|
1216
|
+
declare function AccountButton({ href, ...local }: AccountButtonProps): react_jsx_runtime.JSX.Element;
|
|
1217
|
+
|
|
1218
|
+
/** The header's cart button. Takes the styling props only. */
|
|
1219
|
+
type CartButtonProps = UsePartLocal;
|
|
1220
|
+
/**
|
|
1221
|
+
* The header's cart: a button with the unit count that opens the cart drawer (`useCartDrawer`). Its
|
|
1222
|
+
* name is one string with the count ("Cart, 3 items"), so a screen reader hears what the badge shows.
|
|
1223
|
+
*/
|
|
1224
|
+
declare function CartButton(props: CartButtonProps): react_jsx_runtime.JSX.Element;
|
|
1225
|
+
|
|
1226
|
+
/** The header navigation row. */
|
|
1227
|
+
type CategoryNavProps = UsePartLocal & {
|
|
1228
|
+
/** The entries to show (the site design's header menu, or the category tree). */
|
|
1229
|
+
items: SiteMenuItem[];
|
|
1230
|
+
/**
|
|
1231
|
+
* `menu`: the site design's header menu (`data-menu="header"`). `categories`: the catalog's category
|
|
1232
|
+
* tree, which carries `data-category-handle` and `data-category-parent` on every entry.
|
|
1233
|
+
*/
|
|
1234
|
+
source: 'menu' | 'categories';
|
|
1235
|
+
/** Every child list is open and nested (the menu drawer); no disclosure buttons. */
|
|
1236
|
+
stacked?: boolean;
|
|
1237
|
+
/** The nav's accessible name. Default: `frame.header.mainNav`, or `frame.header.categoriesNav` for the tree. */
|
|
1238
|
+
label?: string;
|
|
1239
|
+
};
|
|
1240
|
+
/**
|
|
1241
|
+
* The header's navigation. Each top-level entry is a link; an entry with children also has a disclosure
|
|
1242
|
+
* button (`aria-expanded`) that opens its list, and a pointer over the entry opens it too.
|
|
1243
|
+
*
|
|
1244
|
+
* Keys, on a top-level link: Left and Right move between entries (reversed in right-to-left), Home and
|
|
1245
|
+
* End go to the first and last, Down opens the list and enters it. In a list: Up and Down move through
|
|
1246
|
+
* the links. Escape closes an open list and returns to its entry; leaving the entry closes it.
|
|
1247
|
+
*/
|
|
1248
|
+
declare function CategoryNav(props: CategoryNavProps): react_jsx_runtime.JSX.Element;
|
|
1249
|
+
|
|
1250
|
+
/** A select that changes the currency prices are shown in. */
|
|
1251
|
+
type CurrencySwitchProps = UsePartLocal & {
|
|
1252
|
+
/** The currencies offered. Default: the catalog's (`/config` `currencies`). */
|
|
1253
|
+
currencies?: readonly string[];
|
|
1254
|
+
/**
|
|
1255
|
+
* Called with the chosen currency. It may be async (moving a cart takes a request): the select stays
|
|
1256
|
+
* focused and marks itself `aria-busy`, and a second change is ignored until it settles. Without it
|
|
1257
|
+
* nothing could happen, so the switch renders nothing.
|
|
1258
|
+
*/
|
|
1259
|
+
onChange?(currency: string): void | Promise<void>;
|
|
1260
|
+
};
|
|
1261
|
+
/** The currency switch: a labelled select of the currencies the catalog offers (`data-currency-option` on each). Nothing renders with fewer than two. */
|
|
1262
|
+
declare function CurrencySwitch(props: CurrencySwitchProps): react_jsx_runtime.JSX.Element | null;
|
|
1263
|
+
|
|
1264
|
+
/** A select that changes the language. */
|
|
1265
|
+
type LocaleSwitchProps = UsePartLocal & {
|
|
1266
|
+
/** The languages offered. Default: the catalog's (`/config` `locales`). */
|
|
1267
|
+
locales?: readonly string[];
|
|
1268
|
+
/** Called with the chosen language. Without it nothing could happen, so the switch renders nothing. */
|
|
1269
|
+
onChange?(locale: string): void;
|
|
1270
|
+
};
|
|
1271
|
+
/**
|
|
1272
|
+
* The language switch: a labelled select of the languages the catalog offers (`data-locale-option` on
|
|
1273
|
+
* each). The store decides what a change does (a cookie and a refresh, a route); the switch only asks.
|
|
1274
|
+
* Nothing renders with fewer than two languages or without `onChange`.
|
|
1275
|
+
*/
|
|
1276
|
+
declare function LocaleSwitch(props: LocaleSwitchProps): react_jsx_runtime.JSX.Element | null;
|
|
1277
|
+
|
|
1278
|
+
/** A search field with suggestions. Takes the styling props only. */
|
|
1279
|
+
type SearchBoxProps = UsePartLocal;
|
|
1280
|
+
/**
|
|
1281
|
+
* The header search: a GET form to the store's search route (so it works before scripts load), with
|
|
1282
|
+
* live suggestions as an ARIA 1.2 combobox. The input keeps focus and the arrow keys move
|
|
1283
|
+
* `aria-activedescendant` through the options (wrapping); Enter opens the active option or, with none,
|
|
1284
|
+
* runs the search; Escape closes the list, and a second Escape clears the box. Options are links.
|
|
1285
|
+
*
|
|
1286
|
+
* The input is uncontrolled: a shopper can type before the page hydrates, and a controlled value would
|
|
1287
|
+
* be written over by React's initial state. On mount the box takes whatever was typed.
|
|
1288
|
+
*/
|
|
1289
|
+
declare function SearchBox(props: SearchBoxProps): react_jsx_runtime.JSX.Element;
|
|
1290
|
+
|
|
1291
|
+
/** The pieces of the header a store may replace. Each takes the props its default takes. */
|
|
1292
|
+
type HeaderSlots = {
|
|
1293
|
+
SearchBox: ComponentType<SearchBoxProps>;
|
|
1294
|
+
AccountButton: ComponentType<AccountButtonProps>;
|
|
1295
|
+
CartButton: ComponentType<CartButtonProps>;
|
|
1296
|
+
CategoryNav: ComponentType<CategoryNavProps>;
|
|
1297
|
+
LocaleSwitch: ComponentType<LocaleSwitchProps>;
|
|
1298
|
+
CurrencySwitch: ComponentType<CurrencySwitchProps>;
|
|
1299
|
+
};
|
|
1300
|
+
/** The header: brand, search, account, cart and the navigation. */
|
|
1301
|
+
type HeaderProps = UsePartLocal & {
|
|
1302
|
+
/**
|
|
1303
|
+
* Replace any piece of the header (`SearchBox`, `AccountButton`, `CartButton`, `CategoryNav`, `LocaleSwitch`, `CurrencySwitch`).
|
|
1304
|
+
*/
|
|
1305
|
+
slots?: Partial<HeaderSlots>;
|
|
1306
|
+
/** The navigation row (the header menu, or the category tree when the site has no menu). Default true. */
|
|
1307
|
+
showCategoryNav?: boolean;
|
|
1308
|
+
/** The account page. Default `/account`. */
|
|
1309
|
+
accountHref?: string;
|
|
1310
|
+
/** What choosing a language does; without it the language switch is not drawn. */
|
|
1311
|
+
onLocaleChange?(locale: string): void;
|
|
1312
|
+
/** What choosing a currency does; without it the currency switch is not drawn. */
|
|
1313
|
+
onCurrencyChange?(currency: string): void | Promise<void>;
|
|
1314
|
+
};
|
|
1315
|
+
/**
|
|
1316
|
+
* The store header: the logo or the store name, the navigation, the search with suggestions, the
|
|
1317
|
+
* language and currency switches, the account link and the cart button. Below 960 px the navigation
|
|
1318
|
+
* and the switches move into a drawer behind the Menu button. The store name, logo and menu come from
|
|
1319
|
+
* the resolved site design, so a Builder's brand and menu win over the catalog's.
|
|
1320
|
+
*/
|
|
1321
|
+
declare function Header(props: HeaderProps): react_jsx_runtime.JSX.Element;
|
|
1322
|
+
|
|
1323
|
+
/** The page frame: skip link, announcement bar, header, `<main>` and footer. */
|
|
1324
|
+
type StoreFrameProps = UsePartLocal & {
|
|
1325
|
+
/** The page's content, drawn inside `<main>`. */
|
|
1326
|
+
children?: ReactNode;
|
|
1327
|
+
/** Props for the header (slots, the account link, the language and currency handlers). */
|
|
1328
|
+
header?: Omit<HeaderProps, 'classNames' | 'unstyled'>;
|
|
1329
|
+
/** Props for the footer: the `brand` block, the `children` between the menu and the copyright line, the `year`. */
|
|
1330
|
+
footer?: Omit<FooterProps, 'classNames' | 'unstyled'>;
|
|
1331
|
+
/** The `id` of the `<main>` the skip link targets. Default `main-content`. */
|
|
1332
|
+
mainId?: string;
|
|
1333
|
+
};
|
|
1334
|
+
/**
|
|
1335
|
+
* The page around every store page: a skip link, the announcement bar, the header, the one `<main>` and
|
|
1336
|
+
* the footer. Landmarks are banner, navigation, main and contentinfo; the skip link is the first thing
|
|
1337
|
+
* a keyboard reaches and takes it to `<main>`. The cart drawer (loaded when first opened) is mounted here.
|
|
1338
|
+
*/
|
|
1339
|
+
declare function StoreFrame({ children, header, footer, mainId, ...local }: StoreFrameProps): react_jsx_runtime.JSX.Element;
|
|
1340
|
+
|
|
1341
|
+
/**
|
|
1342
|
+
* The site design's announcement. Takes the styling props only; nothing is drawn when there is no announcement or it was dismissed.
|
|
1343
|
+
*/
|
|
1344
|
+
type AnnouncementBarProps = UsePartLocal;
|
|
1345
|
+
/**
|
|
1346
|
+
* The announcement from the site design (`data-throttle-setting="announcement"` carries the message),
|
|
1347
|
+
* with its link when it has a safe one. Nothing renders when the site has no announcement. A shopper
|
|
1348
|
+
* can dismiss it; the choice is kept per message in `localStorage` and read after hydration, so the
|
|
1349
|
+
* server's markup and the first client render agree.
|
|
1350
|
+
*/
|
|
1351
|
+
declare function AnnouncementBar(props: AnnouncementBarProps): react_jsx_runtime.JSX.Element | null;
|
|
1352
|
+
|
|
1353
|
+
/** What a section lists. Plain data, so a Builder can store it as a widget's prop. */
|
|
1354
|
+
type ProductSource = {
|
|
1355
|
+
kind: 'collection' | 'category' | 'tag';
|
|
1356
|
+
handle: string;
|
|
1357
|
+
} | {
|
|
1358
|
+
kind: 'featured' | 'newest' | 'best_rated';
|
|
1359
|
+
} | {
|
|
1360
|
+
kind: 'manual';
|
|
1361
|
+
handles: string[];
|
|
1362
|
+
};
|
|
1363
|
+
/** The catalog's `products.list` query. */
|
|
1364
|
+
type ListQuery = ProductsQuery;
|
|
1365
|
+
/**
|
|
1366
|
+
* What `loadMerchProducts` answers and a section's `initialData` takes. Plain JSON.
|
|
1367
|
+
* `title` is a collection's own title and `priceContext` is the list answer's; both are optional.
|
|
1368
|
+
*/
|
|
1369
|
+
type MerchProductsData = {
|
|
1370
|
+
products: ListProduct[];
|
|
1371
|
+
/** When the server built this answer (ISO 8601). The `new` badge ages against it. */
|
|
1372
|
+
generatedAt: string;
|
|
1373
|
+
title?: string;
|
|
1374
|
+
priceContext?: 'anonymous' | 'customer' | 'email_unverified' | 'anonymous_fallback';
|
|
1375
|
+
};
|
|
1376
|
+
/**
|
|
1377
|
+
* The `products.list` query for a source: the shelf mapping of Meridian
|
|
1378
|
+
* `lib/home.ts` (`featured` is the featured flag; `newest` and `best_rated` are
|
|
1379
|
+
* those sorts). A `manual` source asks for its handles in one request; the
|
|
1380
|
+
* catalog does not promise their order, so `orderByHandles` restores it.
|
|
1381
|
+
* `fields` is `cardFields(settings)`, the same one the server loader uses.
|
|
1382
|
+
*/
|
|
1383
|
+
declare function productSourceQuery(source: ProductSource, limit: number, o?: {
|
|
1384
|
+
fields?: readonly string[];
|
|
1385
|
+
}): ListQuery;
|
|
1386
|
+
|
|
1387
|
+
/** A collection's first products under a heading, with a link to the whole collection. */
|
|
1388
|
+
type CollectionShelfProps = UsePartLocal & {
|
|
1389
|
+
/** The collection's handle. */
|
|
1390
|
+
handle: string;
|
|
1391
|
+
/** Default: the collection's own title. */
|
|
1392
|
+
title?: string;
|
|
1393
|
+
/** A small label above the title ("New in"). Nothing when empty. */
|
|
1394
|
+
eyebrow?: string;
|
|
1395
|
+
/** Default 4. */
|
|
1396
|
+
limit?: number;
|
|
1397
|
+
/** Draw the products as a `grid` (default) or a scrolling `carousel`. */
|
|
1398
|
+
layout?: 'grid' | 'carousel';
|
|
1399
|
+
/** The grid's columns. Default: `settings.listing.columns`. */
|
|
1400
|
+
columns?: {
|
|
1401
|
+
desktop: number;
|
|
1402
|
+
mobile: number;
|
|
1403
|
+
};
|
|
1404
|
+
/** Default true. */
|
|
1405
|
+
showViewAll?: boolean;
|
|
1406
|
+
/** The cards' variant. Default: `settings.card.style`. */
|
|
1407
|
+
cardVariant?: ProductCardVariant;
|
|
1408
|
+
/** The line above each card's title: the brand (default) or the category. */
|
|
1409
|
+
cardMeta?: ProductCardMeta;
|
|
1410
|
+
/** From `loadMerchProducts`: the first render has the products and makes no request. */
|
|
1411
|
+
initialData?: MerchProductsData;
|
|
1412
|
+
};
|
|
1413
|
+
/**
|
|
1414
|
+
* A collection's first products under its title, as a grid or a carousel, with
|
|
1415
|
+
* a "View all" link to the collection. The collection's products (and its
|
|
1416
|
+
* title, unless `title` or `initialData` gives it) come in one request each;
|
|
1417
|
+
* it renders nothing when the collection has no products.
|
|
1418
|
+
*/
|
|
1419
|
+
declare function CollectionShelf(props: CollectionShelfProps): react_jsx_runtime.JSX.Element | null;
|
|
1420
|
+
|
|
1421
|
+
/** One product shown large, with its picture, title, price and a link. */
|
|
1422
|
+
type FeaturedProductProps = UsePartLocal & {
|
|
1423
|
+
/** The product's handle. */
|
|
1424
|
+
handle: string;
|
|
1425
|
+
/** Where the image sits next to the text. Default `image-left`; `stacked` puts it above. */
|
|
1426
|
+
layout?: 'image-left' | 'image-right' | 'stacked';
|
|
1427
|
+
/** Default true. */
|
|
1428
|
+
showDescription?: boolean;
|
|
1429
|
+
/** From `loadProduct`: the first render has the product and makes no request. */
|
|
1430
|
+
initialData?: ProductData;
|
|
1431
|
+
};
|
|
1432
|
+
/**
|
|
1433
|
+
* One product shown large: image, title, rating, price, a description excerpt
|
|
1434
|
+
* and a link to the product page. There is no buy box here; a store composes
|
|
1435
|
+
* one beside it. It renders nothing when the product is missing.
|
|
1436
|
+
*/
|
|
1437
|
+
declare function FeaturedProduct(props: FeaturedProductProps): react_jsx_runtime.JSX.Element | null;
|
|
1438
|
+
|
|
1439
|
+
/** Products from a source (a collection, category or tag, the featured, newest or best rated products, or a list of handles) in a scrolling row. */
|
|
1440
|
+
type ProductCarouselProps = UsePartLocal & {
|
|
1441
|
+
/** Where the products come from: `{ kind: 'collection' | 'category' | 'tag', handle }`, `{ kind: 'featured' | 'newest' | 'best_rated' }` or `{ kind: 'manual', handles }`. */
|
|
1442
|
+
source: ProductSource;
|
|
1443
|
+
/** The heading. Nothing is drawn above the row when empty. */
|
|
1444
|
+
title?: string;
|
|
1445
|
+
/** A small label above the title ("New in"). Nothing when empty or when there is no `title`. */
|
|
1446
|
+
eyebrow?: string;
|
|
1447
|
+
/** Default 8. */
|
|
1448
|
+
limit?: number;
|
|
1449
|
+
/** Default: `settings.card.style`. */
|
|
1450
|
+
cardVariant?: ProductCardVariant;
|
|
1451
|
+
/** The line above each card's title: the brand (default) or the category. */
|
|
1452
|
+
cardMeta?: ProductCardMeta;
|
|
1453
|
+
/** From `loadMerchProducts`: the first render has the products and makes no request. */
|
|
1454
|
+
initialData?: MerchProductsData;
|
|
1455
|
+
};
|
|
1456
|
+
/**
|
|
1457
|
+
* A row of product cards on a scroll-snap track, with previous and next
|
|
1458
|
+
* buttons (disabled at the ends) and arrow keys that move one card. It reads
|
|
1459
|
+
* its source with one request, reports `view_item_list` once under the
|
|
1460
|
+
* title, and renders nothing when the source has no products.
|
|
1461
|
+
*/
|
|
1462
|
+
declare function ProductCarousel(props: ProductCarouselProps): react_jsx_runtime.JSX.Element | null;
|
|
1463
|
+
|
|
1464
|
+
/** The category tree as a grid or a list of links. */
|
|
1465
|
+
type CategoryDirectoryProps = UsePartLocal & {
|
|
1466
|
+
/** A category's handle: list its subtree instead of the whole store. */
|
|
1467
|
+
parent?: string;
|
|
1468
|
+
/** Levels shown: 1 is the top level, 2 adds each one's children. Default 1. */
|
|
1469
|
+
depth?: 1 | 2;
|
|
1470
|
+
/** How the categories are laid out. Default `grid`. */
|
|
1471
|
+
layout?: 'grid' | 'list';
|
|
1472
|
+
/** Draws a category's image when the catalog sends one. Default false. */
|
|
1473
|
+
showImages?: boolean;
|
|
1474
|
+
/** Default false. */
|
|
1475
|
+
showCounts?: boolean;
|
|
1476
|
+
/** The category tree as `client.categories.tree()` answers it: the first render has the links and makes no request. */
|
|
1477
|
+
initialData?: {
|
|
1478
|
+
categories: CategoryNode[];
|
|
1479
|
+
};
|
|
1480
|
+
};
|
|
1481
|
+
/**
|
|
1482
|
+
* The store's category tree as links: the top level, or the subtree under
|
|
1483
|
+
* `parent`, one or two levels deep. One request reads the tree. It renders
|
|
1484
|
+
* nothing while loading, on error, and when there is nothing to list. (A
|
|
1485
|
+
* product page's own categories are `CategoryList`.)
|
|
1486
|
+
*/
|
|
1487
|
+
declare function CategoryDirectory(props: CategoryDirectoryProps): react_jsx_runtime.JSX.Element | null;
|
|
1488
|
+
|
|
1489
|
+
type CatalogReview = Extract<StorefrontReviewsAnswer, {
|
|
1490
|
+
reviews: unknown;
|
|
1491
|
+
}>['reviews'][number];
|
|
1492
|
+
/**
|
|
1493
|
+
* A review as the catalog answers it, plus the product it is about when a
|
|
1494
|
+
* store-level list names it. Plain data, so a Builder can pass it as a prop.
|
|
1495
|
+
*/
|
|
1496
|
+
type MerchReview = CatalogReview & {
|
|
1497
|
+
productHandle?: string;
|
|
1498
|
+
productTitle?: string;
|
|
1499
|
+
};
|
|
1500
|
+
/** A list of reviews for a home or content page: one product's latest, or ones you choose. */
|
|
1501
|
+
type ReviewsListProps = UsePartLocal & {
|
|
1502
|
+
/** Read this product's latest approved reviews. */
|
|
1503
|
+
productHandle?: string;
|
|
1504
|
+
/** Show these, in this order, and read nothing. Beats `productHandle`. */
|
|
1505
|
+
reviews?: MerchReview[];
|
|
1506
|
+
/** Default 5. */
|
|
1507
|
+
limit?: number;
|
|
1508
|
+
/** Name the product a review is about (when the review says which). Default false. */
|
|
1509
|
+
showProduct?: boolean;
|
|
1510
|
+
};
|
|
1511
|
+
/**
|
|
1512
|
+
* A list of reviews: the ones it is given, else a product's latest approved
|
|
1513
|
+
* reviews (one request, newest first), else nothing.
|
|
1514
|
+
*/
|
|
1515
|
+
declare function ReviewsList(props: ReviewsListProps): react_jsx_runtime.JSX.Element | null;
|
|
1516
|
+
|
|
1517
|
+
/** What a merchandising read answers: the products, a status and when the data was made. */
|
|
1518
|
+
type MerchProducts = {
|
|
1519
|
+
products: ListProduct[];
|
|
1520
|
+
/** `loading` until the first answer (a section shows a placeholder), `error` when there is none (a section renders nothing). */
|
|
1521
|
+
status: 'ready' | 'loading' | 'error';
|
|
1522
|
+
/** When the data was made (ISO). The server's time for `initialData`, else when the browser got the answer. */
|
|
1523
|
+
generatedAt: string;
|
|
1524
|
+
/** A collection's title, when `withTitle` asked for it and the catalog has one. */
|
|
1525
|
+
title?: string;
|
|
1526
|
+
priceContext?: MerchProductsData['priceContext'];
|
|
1527
|
+
};
|
|
1528
|
+
/**
|
|
1529
|
+
* The products of a source: one `products.list` request however many cards it
|
|
1530
|
+
* shows (a manual source's handles go in one request). With `initialData` (from
|
|
1531
|
+
* `loadMerchProducts`) the first render has the answer and makes no request.
|
|
1532
|
+
* `withTitle` also reads a collection's title, unless `initialData` has it.
|
|
1533
|
+
*/
|
|
1534
|
+
declare function useMerchProducts(source: ProductSource, o: {
|
|
1535
|
+
limit: number;
|
|
1536
|
+
initialData?: MerchProductsData;
|
|
1537
|
+
withTitle?: boolean;
|
|
1538
|
+
}): MerchProducts;
|
|
1539
|
+
|
|
1540
|
+
/** The cart, as a drawer opened by `CartButton`, or inline on a cart page. */
|
|
1541
|
+
type CartDrawerProps = UsePartLocal & {
|
|
1542
|
+
/**
|
|
1543
|
+
* Draw the cart in the page (a `/cart` page) instead of a drawer: the same lines, subtotal and
|
|
1544
|
+
* checkout button, with no overlay and no focus trap.
|
|
1545
|
+
*/
|
|
1546
|
+
inline?: boolean;
|
|
1547
|
+
/** Where Throttle's checkout sends the shopper back to, or when they cancel. Default: the store's home and the current page. Absolute http(s) URLs. */
|
|
1548
|
+
checkoutUrls?: {
|
|
1549
|
+
returnUrl?: string;
|
|
1550
|
+
cancelUrl?: string;
|
|
1551
|
+
};
|
|
1552
|
+
};
|
|
1553
|
+
/**
|
|
1554
|
+
* The cart as a drawer, opened by the header's cart button (`useCartDrawer`), or in the page with
|
|
1555
|
+
* `inline`. It lists the lines with a quantity stepper and Remove, shows the subtotal in the cart's
|
|
1556
|
+
* currency, and hands the cart to Throttle's checkout. It is never cached: it is read from the cart session.
|
|
1557
|
+
*/
|
|
1558
|
+
declare function CartDrawer({ inline, ...local }: CartDrawerProps): react_jsx_runtime.JSX.Element | null;
|
|
1559
|
+
|
|
1560
|
+
/** One line of the shared cart (`useCart().cart.lineItems`). */
|
|
1561
|
+
type CartLineData = NonNullable<ThrottleCart['lineItems']>[number];
|
|
1562
|
+
/** One cart line and what it needs to change itself. */
|
|
1563
|
+
type CartLineProps = UsePartLocal & {
|
|
1564
|
+
/** The cart line to draw. */
|
|
1565
|
+
line: CartLineData;
|
|
1566
|
+
/** `useCart().format`: minor units in the cart's currency. */
|
|
1567
|
+
format(minor: number): string;
|
|
1568
|
+
/** A change is running: the buttons wait. */
|
|
1569
|
+
busy: boolean;
|
|
1570
|
+
/** Called with the new quantity when the stepper changes. */
|
|
1571
|
+
onQuantity(quantity: number): void;
|
|
1572
|
+
/** Called when the shopper removes the line. */
|
|
1573
|
+
onRemove(): void;
|
|
1574
|
+
};
|
|
1575
|
+
/** One line of the cart: the picture, the name, the price, a quantity stepper, the line total and Remove. */
|
|
1576
|
+
declare function CartLine({ line, format, busy, onQuantity, onRemove, ...local }: CartLineProps): react_jsx_runtime.JSX.Element;
|
|
1577
|
+
|
|
1578
|
+
/** A dialog with a product's buy box, opened over a list. */
|
|
1579
|
+
type QuickViewProps = UsePartLocal & {
|
|
1580
|
+
/** The product to show; nothing is drawn without one. */
|
|
1581
|
+
handle: string | null;
|
|
1582
|
+
/** Whether the dialog is open. */
|
|
1583
|
+
open: boolean;
|
|
1584
|
+
/** Called when the shopper closes the dialog (Escape, the close button, the backdrop). */
|
|
1585
|
+
onOpenChange(open: boolean): void;
|
|
1586
|
+
};
|
|
1587
|
+
/**
|
|
1588
|
+
* A product in a modal, with the gallery and the buy box of the product page. Escape, the overlay and
|
|
1589
|
+
* the close button close it, focus stays inside while it is open and returns to what opened it.
|
|
1590
|
+
* The variant chosen in it never touches the address of the page behind.
|
|
1591
|
+
*/
|
|
1592
|
+
declare function QuickView({ handle, open, onOpenChange, ...local }: QuickViewProps): react_jsx_runtime.JSX.Element | null;
|
|
1593
|
+
|
|
1594
|
+
/** The quick add button of a card: a one-click add for a product with one variant, an options panel for the rest. */
|
|
1595
|
+
type QuickAddProps = UsePartLocal & {
|
|
1596
|
+
/** The product the card shows. */
|
|
1597
|
+
product: ListProduct;
|
|
1598
|
+
};
|
|
1599
|
+
/**
|
|
1600
|
+
* Adds a product to the cart from its card. A product with one variant is added at once (one
|
|
1601
|
+
* quantity); otherwise the button opens a small panel with the product's options and its own add
|
|
1602
|
+
* button. The sold-out product has no quick add.
|
|
1603
|
+
*
|
|
1604
|
+
* Keyboard: opening the panel moves focus into it. Tab through its controls; Tab past the last control or
|
|
1605
|
+
* Shift+Tab out of the first closes the panel and returns focus to the button, so the next Tab continues
|
|
1606
|
+
* from the card (the panel sits at the end of the storefront root, not after the button). Escape also closes
|
|
1607
|
+
* it and returns focus to the button, and so does a click outside.
|
|
1608
|
+
*/
|
|
1609
|
+
declare function QuickAdd({ product, ...local }: QuickAddProps): react_jsx_runtime.JSX.Element;
|
|
1610
|
+
|
|
1611
|
+
/** A short list of ids kept in `localStorage` (and readable by `useSyncExternalStore`). */
|
|
1612
|
+
type StoredList = {
|
|
1613
|
+
/** The ids now, or none on the server and while the browser's storage cannot be read. */
|
|
1614
|
+
useIds(): readonly string[];
|
|
1615
|
+
read(): readonly string[];
|
|
1616
|
+
/** Replaces the list: blanks and repeats dropped, at most `max` kept, in the order given. */
|
|
1617
|
+
write(ids: readonly string[]): void;
|
|
1618
|
+
/** Forgets what was read, so the next read asks the storage again. */
|
|
1619
|
+
reset(): void;
|
|
1620
|
+
};
|
|
1621
|
+
/**
|
|
1622
|
+
* A short list of ids kept in `localStorage` under `key`. Ids only (a product handle), never a name,
|
|
1623
|
+
* an email or an account. Every access is in try/catch: a blocked or full storage, or one that throws
|
|
1624
|
+
* (private windows, a disabled setting), reads as an empty list and the page keeps working. If a write
|
|
1625
|
+
* fails the list lives in memory for the rest of the visit.
|
|
1626
|
+
*
|
|
1627
|
+
* `useIds` is a `useSyncExternalStore`: the server snapshot is always empty, so the server markup and
|
|
1628
|
+
* the first client render agree, then the stored ids appear once hydrated. Other tabs are followed
|
|
1629
|
+
* through the `storage` event.
|
|
1630
|
+
*/
|
|
1631
|
+
declare function createStoredList(key: string, max: number): StoredList;
|
|
1632
|
+
|
|
1633
|
+
/**
|
|
1634
|
+
* The handles of the products this browser looked at last, newest first, kept in `localStorage`
|
|
1635
|
+
* (handles only). Empty on the server and before hydration. `push` moves a handle to the front.
|
|
1636
|
+
*/
|
|
1637
|
+
declare function useRecentlyViewed(): {
|
|
1638
|
+
handles: string[];
|
|
1639
|
+
push(handle: string): void;
|
|
1640
|
+
};
|
|
1641
|
+
/** The products the shopper looked at last, as cards. Only handles are kept, in the browser. */
|
|
1642
|
+
type RecentlyViewedProps = UsePartLocal & {
|
|
1643
|
+
/** How many to show; at most 12, which is all that is kept. Default 12. */
|
|
1644
|
+
limit?: number;
|
|
1645
|
+
/** The product being looked at: it is added to the list, and left out of what is shown. */
|
|
1646
|
+
current?: string;
|
|
1647
|
+
/** Default: `settings.card.style`. */
|
|
1648
|
+
cardVariant?: ProductCardVariant;
|
|
1649
|
+
/** The line above each card's title: the brand (default) or the category. */
|
|
1650
|
+
cardMeta?: ProductCardMeta;
|
|
1651
|
+
/** Default: `shopper.recent.title`. */
|
|
1652
|
+
title?: string;
|
|
1653
|
+
};
|
|
1654
|
+
/**
|
|
1655
|
+
* A row of the products this browser looked at last. It draws nothing on the server and until the
|
|
1656
|
+
* stored handles are read, then asks the catalog once for all of them (one batched request, never one
|
|
1657
|
+
* for each product), and nothing at all when there are none.
|
|
1658
|
+
*/
|
|
1659
|
+
declare function RecentlyViewed(props: RecentlyViewedProps): react_jsx_runtime.JSX.Element | null;
|
|
1660
|
+
|
|
1661
|
+
/**
|
|
1662
|
+
* The comparison table of the chosen products. Takes the styling props only; the products come from `useCompare()`.
|
|
1663
|
+
*/
|
|
1664
|
+
type CompareProps = UsePartLocal;
|
|
1665
|
+
/**
|
|
1666
|
+
* The comparison of the products chosen with `CompareButton` (2 to 4): their price, availability,
|
|
1667
|
+
* rating and every attribute they carry, side by side in a table. The products are read with one
|
|
1668
|
+
* request. The table is loaded on first use.
|
|
1669
|
+
*/
|
|
1670
|
+
declare function Compare(props: CompareProps): react_jsx_runtime.JSX.Element;
|
|
1671
|
+
|
|
1672
|
+
/** What `useCompare()` answers: the handles chosen and how to change them. */
|
|
1673
|
+
type CompareState = {
|
|
1674
|
+
/** The handles being compared, in the order they were added. Empty on the server and before hydration. */
|
|
1675
|
+
items: string[];
|
|
1676
|
+
/** Adds the handle, or removes it when it is there. A fifth product is not added. */
|
|
1677
|
+
toggle(handle: string): void;
|
|
1678
|
+
clear(): void;
|
|
1679
|
+
has(handle: string): boolean;
|
|
1680
|
+
/** Four are chosen: only a removal changes the list. */
|
|
1681
|
+
full: boolean;
|
|
1682
|
+
};
|
|
1683
|
+
/** The products to compare (2 to 4), kept in `localStorage` as handles only. */
|
|
1684
|
+
declare function useCompare(): CompareState;
|
|
1685
|
+
/** A toggle that adds a product to the comparison or removes it. */
|
|
1686
|
+
type CompareButtonProps = UsePartLocal & {
|
|
1687
|
+
/** The product to add or remove: its handle and its title (the button's accessible name). */
|
|
1688
|
+
product: Pick<ListProduct, 'handle' | 'title'>;
|
|
1689
|
+
};
|
|
1690
|
+
/**
|
|
1691
|
+
* Adds a product to the comparison, or takes it out. A toggle button: its name stays the same and
|
|
1692
|
+
* `aria-pressed` says whether the product is in. With four chosen it is disabled for the others.
|
|
1693
|
+
*/
|
|
1694
|
+
declare function CompareButton({ product, ...local }: CompareButtonProps): react_jsx_runtime.JSX.Element;
|
|
1695
|
+
|
|
1696
|
+
/** The not-found page. Takes the styling props only. */
|
|
1697
|
+
type NotFoundProps = UsePartLocal;
|
|
1698
|
+
/**
|
|
1699
|
+
* The not-found page: a 404 mark, the site string `error.notFound` as the heading, and links to the
|
|
1700
|
+
* shop and home. It is its own `<main>`, except inside `StoreFrame`, which already draws the page's one.
|
|
1701
|
+
*/
|
|
1702
|
+
declare function NotFound(props: NotFoundProps): react_jsx_runtime.JSX.Element;
|
|
1703
|
+
|
|
1704
|
+
/** The search results page. */
|
|
1705
|
+
type SearchResultsProps = UsePartLocal & {
|
|
1706
|
+
/** What the shopper searched for (the `q` of the URL). */
|
|
1707
|
+
q: string;
|
|
1708
|
+
/** The server's answer (`loadSearch`): the page hydrates from it with no request. */
|
|
1709
|
+
initialData?: ShopAllData;
|
|
1710
|
+
};
|
|
1711
|
+
/**
|
|
1712
|
+
* The search results page: the shop-all listing on a search source (it draws the `search.results` heading
|
|
1713
|
+
* itself), so filters, sorting, paging and the URL state work as on any listing. With no query
|
|
1714
|
+
* it asks for one. The route must render dynamically and read the catalog uncached (`loadSearch` does).
|
|
1715
|
+
*/
|
|
1716
|
+
declare function SearchResults(props: SearchResultsProps): react_jsx_runtime.JSX.Element;
|
|
1717
|
+
|
|
1718
|
+
export { AccountButton, type AccountButtonProps, ActiveFilters, type AddMessage, AddToCart, AnnouncementBar, type AnnouncementBarProps, BackInStock, Badge, type BadgeProps, Breadcrumbs, BuyBox, type BuyBoxProps, type BuyBoxSlots, type CardBadge, type CardBadgesProps, type CardProductProps, type CardTitleProps, CartButton, type CartButtonProps, CartDrawer, type CartDrawerProps, CartLine, type CartLineData, type CartLineProps, CategoryDirectory, type CategoryDirectoryProps, CategoryList, CategoryNav, type CategoryNavProps, CollectionShelf, type CollectionShelfProps, Compare, CompareButton, type CompareButtonProps, type CompareProps, type CompareState, CurrencySwitch, type CurrencySwitchProps, FacetGroup, type FacetGroupProps, FeaturedProduct, type FeaturedProductProps, FilterBar, FilterDrawer, FilterSidebar, Footer, type FooterProps, FrequentlyBoughtTogether, Ga4Item, Gallery, type GalleryProps, Header, type HeaderProps, type HeaderSlots, Image, type ImageProps, JsonLd, Link, type LinkProps, type ListQuery, type ListingContext, LiveRegion, LocaleSwitch, type LocaleSwitchProps, type MerchProducts, type MerchProductsData, type MerchReview, Money, type MoneyProps, NormalizedSettings, NotFound, type NotFoundProps, Pagination, type PickerKind, Price, type PriceContext, type PriceProps, ProductCard, type ProductCardMeta, type ProductCardProps, type ProductCardSlots, type ProductCardVariant, ProductCarousel, type ProductCarouselProps, type ProductCrumb, ProductGrid, type ProductLayout, ProductPage, type ProductPageProps, type ProductPageRootProps, type ProductPageValue, ProductSections, type ProductSectionsProps, type ProductSource, QuantityInput, QuestionsAndAnswers, QuickAdd, type QuickAddProps, QuickView, type QuickViewProps, RecentlyViewed, type RecentlyViewedProps, RelatedProducts, type RelatedProductsProps, type ReservedSlotProps, ResultCount, ReviewForm, ReviewPhotos, ReviewVotes, Reviews, type ReviewsLayout, ReviewsList, type ReviewsListProps, type ReviewsProps, RichText, type RichTextProps, STOREFRONT_LAYER_ORDER_ID, STOREFRONT_STYLES, STOREFRONT_STYLE_ID, SYNC_ATTRIBUTES, SearchBox, type SearchBoxProps, type SearchParamsInput, SearchResults, type SearchResultsProps, type SectionsStyle, SfStringKey, type SfVariables, type ShippingContent, ShippingSection, ShopAll, type ShopAllContextValue, type ShopAllOptions, type ShopAllProps, type ShopAllRootProps, type ShopAllState, type ShopFilterLayout, type ShopPagination, type ShopQuery, type ShopRange, type ShopSource, type SlotContext, SlotOutlet, type SlotOutletProps, SortSelect, StarRating, type StarRatingProps, StickyAddToCart, StockStatus, StoreFrame, type StoreFrameProps, type StoredList, StorefrontAnalytics, type StorefrontMetadata, type StorefrontSlotName, Swatch, type SwatchProps, type SyncAttribute, TagList, Unstyled, UnstyledContext, UsePartLocal, VariantPicker, WishlistButton, breadcrumbJsonLd, canonicalForShopQuery, cardBadges, cardFields, catalogSiteDesign, createStoredList, gaAnalytics, itemListJsonLd, menuHref, menuItems, noopAnalytics, pageWindow, parseShopQuery, pickerKind, productCrumbs, productJsonLd, productMetadata, productSourceQuery, rememberScroll, robotsForShopQuery, sanitizeHtml, searchMetadata, selectOption, shopAllMetadata, shopListQuery, shopQueryToSearch, stockWord, themeToVariables, throttleScriptsAnalytics, toGa4Item, useCartDrawer, useCompare, useMerchProducts, useProductPage, useRecentlyViewed, useRelatedProducts, useShippingContent, useShopAll, useStrings, useTrack, useUnstyled, variantFromSearch };
|