@thorprovider/storefront 0.15.2 → 0.15.4
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/README.md +1 -1
- package/assets/templates/app/app/[[...slug]]/page.tsx +4 -0
- package/assets/templates/app/lib/__STOREFRONT__/header-universal.ts +112 -33
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +236 -71
- package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +37 -1
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +6 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-banner.ts +2 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.client.tsx +4 -1
- package/assets/templates/app/public/demo/accessories.svg +7 -0
- package/assets/templates/app/public/demo/dresses.svg +6 -0
- package/assets/templates/app/public/demo/furniture.svg +9 -0
- package/assets/templates/app/public/demo/home.svg +8 -0
- package/assets/templates/app/public/demo/jackets.svg +11 -0
- package/assets/templates/app/public/demo/promo-invierno.svg +8 -0
- package/assets/templates/features/checkout/state.ts +2 -0
- package/assets/templates/views/category/assembly/slots/filter/CategoryListing/element.part +1 -0
- package/assets/templates/views/category/assembly/slots/filter/CategoryListing/registry.part +2 -0
- package/assets/templates/views/category/content.ts +1 -0
- package/assets/templates/views/category/index.tsx +1 -0
- package/assets/templates/views/category/registry.tsx +2 -0
- package/assets/templates/views/category/schema.ts +2 -0
- package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +19 -0
- package/assets/templates/views/checkout/registry.tsx +22 -5
- package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/registry.part +6 -1
- package/assets/templates/views/home/content.ts +5 -1
- package/assets/templates/views/home/props.ts +8 -1
- package/assets/templates/views/home/registry.tsx +6 -1
- package/assets/templates/views/home/schema.ts +2 -1
- package/package.json +1 -1
- package/scripts/candidate.mjs +2 -2
- package/scripts/env-file.mjs +5 -0
- package/scripts/reconcile.mjs +4 -1
- package/scripts/render-templates.mjs +106 -1
- package/skills/sf-view-gen/assets/templates/views/sections/schema.universal-banner.ts +1 -1
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
// Generated by Thor Commerce storefront (template: assets/templates/app/lib/__STOREFRONT__/registry.tsx)
|
|
4
4
|
// Base registry for the app shell plus every registered view's registry fragment.
|
|
5
5
|
//
|
|
6
|
-
// The
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// navigates to the detail, where a variant is chosen explicitly.
|
|
6
|
+
// The universal header's cart access and its adjacent sheet share the live cart
|
|
7
|
+
// state and dispatch mutations to the Server Actions. A listing card's
|
|
8
|
+
// add-to-cart adds the product's first purchasable variant (the card shortcut);
|
|
9
|
+
// opening a product from a listing navigates to the detail for explicit choice.
|
|
11
10
|
|
|
12
11
|
import { defineRegistry, useStateStore } from '@json-render/react'
|
|
13
12
|
import { useNextApp } from '@json-render/next'
|
|
@@ -17,9 +16,10 @@ import { BackToTop as BackToTopBlock } from '@thorprovider/blocks/blocks/e-comme
|
|
|
17
16
|
import { MobileBottomNav as MobileBottomNavBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
|
|
18
17
|
import { SkipToContent as SkipToContentBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/skip-to-content'
|
|
19
18
|
import Banner1 from '@thorprovider/blocks/blocks/marketing/banners/banner-1'
|
|
20
|
-
import { HeaderUniversal, Navbar, StorefrontNavbar, UniversalFooter } from '@thorprovider/blocks'
|
|
19
|
+
import { HeaderUniversal, Navbar, StorefrontAccountDrawer, StorefrontCartDrawer, StorefrontNavbar, StorefrontSearchDialog, UniversalFooter } from '@thorprovider/blocks'
|
|
21
20
|
import { ProductGrid as ProductGridBlock } from '@thorprovider/blocks/blocks/e-commerce/product-list/product-grid'
|
|
22
21
|
import type { BackToTopProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/back-to-top'
|
|
22
|
+
import type { CartSheetState } from '@thorprovider/blocks/blocks/e-commerce/navigation/storefront-navbar-cart-sheet'
|
|
23
23
|
import type { MobileBottomNavProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
|
|
24
24
|
import type { SkipToContentProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/skip-to-content'
|
|
25
25
|
import { isAvailableMoney } from '@thorprovider/blocks/contracts'
|
|
@@ -31,7 +31,8 @@ import { useStorefrontHandlers } from './handlers'
|
|
|
31
31
|
import { cartViewAvailable, checkoutAvailable, mountedFeatureNames } from './composition'
|
|
32
32
|
import { accountStoreUser } from './account-user.core'
|
|
33
33
|
import { toUniversalFooterProps } from './footer-content'
|
|
34
|
-
import { buildHeaderContext, createStorefrontHeaderConfig, storefrontHeaderLabels } from './header-universal'
|
|
34
|
+
import { buildHeaderContext, createStorefrontHeaderConfig, storefrontAccountDrawerLabels, storefrontAccountMenuItems, storefrontCartDrawerLabels, storefrontHeaderLabels, storefrontSearchDialogLabels } from './header-universal'
|
|
35
|
+
import { navbarLabels } from './shell/content'
|
|
35
36
|
import type { AccountIdentity, AccountResolution } from './account-session.core'
|
|
36
37
|
import {
|
|
37
38
|
bannerPropsSchema,
|
|
@@ -43,8 +44,8 @@ import {
|
|
|
43
44
|
} from './schema'
|
|
44
45
|
import { viewRegistries } from './views/registry'
|
|
45
46
|
|
|
46
|
-
//
|
|
47
|
-
// `
|
|
47
|
+
// The cart sheet accepts `qty`, distinct from the backend line shape's
|
|
48
|
+
// `quantity`. Types are local so the mapping stays explicit.
|
|
48
49
|
interface NavCartItem {
|
|
49
50
|
id: string
|
|
50
51
|
name: string
|
|
@@ -55,7 +56,7 @@ interface NavCartItem {
|
|
|
55
56
|
lineTotal?: Money
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
/** CartLineState ->
|
|
59
|
+
/** CartLineState -> cart-sheet line. `price` is legacy; the authoritative
|
|
59
60
|
* subtotal and per-line total are passed separately, so neither is computed
|
|
60
61
|
* from the line. */
|
|
61
62
|
function toNavCartItems(cart: CartLineState[]): NavCartItem[] {
|
|
@@ -70,6 +71,78 @@ function toNavCartItems(cart: CartLineState[]): NavCartItem[] {
|
|
|
70
71
|
}))
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
// Chrome copy for the shared cart lateral. The block keeps English defaults for
|
|
75
|
+
// consumers that supply nothing; the generated store speaks Spanish from the
|
|
76
|
+
// user-owned shell content.
|
|
77
|
+
const cartSheetLabels = {
|
|
78
|
+
decreaseLabel: navbarLabels.decreaseQuantity,
|
|
79
|
+
increaseLabel: navbarLabels.increaseQuantity,
|
|
80
|
+
removeLabel: navbarLabels.remove,
|
|
81
|
+
removeItemLabel: navbarLabels.removeItem,
|
|
82
|
+
emptyTitleLabel: navbarLabels.emptyTitle,
|
|
83
|
+
emptyDescriptionLabel: navbarLabels.emptyDescription,
|
|
84
|
+
continueShoppingLabel: navbarLabels.continueShopping,
|
|
85
|
+
subtotalLabel: navbarLabels.subtotal,
|
|
86
|
+
shippingTaxesLabel: navbarLabels.shippingTaxes,
|
|
87
|
+
checkoutLabel: navbarLabels.checkout,
|
|
88
|
+
viewCartLabel: navbarLabels.viewCart,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The one cart wiring every shell chrome surface shares: the legacy
|
|
93
|
+
* `StorefrontNavbar` and the universal header render the same authoritative cart
|
|
94
|
+
* and open it through the same shared `cartOpen` state, so a successful add
|
|
95
|
+
* opens whichever surface the shell mounts. Checkout stays offered only when the
|
|
96
|
+
* required backend amounts are present and valid (AC-CART-4.4 / UC-CART-7).
|
|
97
|
+
*/
|
|
98
|
+
function useShellCart(emit: (event: string) => void) {
|
|
99
|
+
const { state, set } = useStateStore()
|
|
100
|
+
const cart = (state.cart ?? []) as CartLineState[]
|
|
101
|
+
const totals = state.cartTotals as CartTotalsState | null
|
|
102
|
+
// One money formatter for the whole shell, built from the shopper locale the
|
|
103
|
+
// catch-all host seeded (the same locale as `<html lang>`).
|
|
104
|
+
const storeLocale =
|
|
105
|
+
typeof state.storeLocale === 'string' && state.storeLocale.trim() !== ''
|
|
106
|
+
? state.storeLocale
|
|
107
|
+
: DEFAULT_STORE_LOCALE
|
|
108
|
+
const formatMoney = createStoreMoneyFormatter(storeLocale)
|
|
109
|
+
const cartError = typeof state.cartError === 'string' ? state.cartError : undefined
|
|
110
|
+
const readError = typeof state.cartReadError === 'string' ? state.cartReadError : undefined
|
|
111
|
+
const errorLabel = cartError ?? readError
|
|
112
|
+
const cartState: CartSheetState = state.cartPending ? 'pending' : errorLabel ? 'error' : 'idle'
|
|
113
|
+
const amountsValid =
|
|
114
|
+
cart.every((line) => isAvailableMoney(line.lineTotal)) &&
|
|
115
|
+
totals !== null &&
|
|
116
|
+
isAvailableMoney(totals.subtotal) &&
|
|
117
|
+
isAvailableMoney(totals.total)
|
|
118
|
+
return {
|
|
119
|
+
items: toNavCartItems(cart),
|
|
120
|
+
subtotal: totals?.subtotal,
|
|
121
|
+
formatMoney,
|
|
122
|
+
errorLabel,
|
|
123
|
+
cartState,
|
|
124
|
+
quantity: cart.reduce((total, line) => total + line.quantity, 0),
|
|
125
|
+
lineCount: cart.length,
|
|
126
|
+
currency: totals?.subtotal?.currencyCode ?? 'EUR',
|
|
127
|
+
open: state.cartOpen === true,
|
|
128
|
+
setOpen: (open: boolean) => set('/cartOpen', open),
|
|
129
|
+
checkoutUnavailable: !checkoutAvailable,
|
|
130
|
+
checkoutDisabled: cartState !== 'idle' || cart.length === 0 || !amountsValid,
|
|
131
|
+
viewCartUnavailable: !cartViewAvailable,
|
|
132
|
+
onViewCart: () => emit('goToCart'),
|
|
133
|
+
onCheckout: () => emit('goToCheckout'),
|
|
134
|
+
onRetry: () => emit('refreshCart'),
|
|
135
|
+
onQtyChange: (id: string, delta: number) => {
|
|
136
|
+
set('/qtyDelta', { id, delta })
|
|
137
|
+
emit('applyQuantityDelta')
|
|
138
|
+
},
|
|
139
|
+
onRemove: (id: string) => {
|
|
140
|
+
set('/lastRemoved', id)
|
|
141
|
+
emit('removeFromCart')
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
73
146
|
const baseComponents = {
|
|
74
147
|
Layout: ({ children, slots }: { children?: React.ReactNode; slots?: Record<string, React.ReactNode> }) => {
|
|
75
148
|
useStorefrontHandlers()
|
|
@@ -79,9 +152,12 @@ const baseComponents = {
|
|
|
79
152
|
// main content reserves bottom padding so the fixed bar never obscures it.
|
|
80
153
|
const hasBottomNav = mountedFeatureNames.includes('navigability')
|
|
81
154
|
// Central dismissal: any route or history change closes the shared cart
|
|
82
|
-
// lateral
|
|
155
|
+
// lateral and the header's account/search surfaces, so they never linger
|
|
156
|
+
// across navigation (forward/back included).
|
|
83
157
|
useEffect(() => {
|
|
84
158
|
set('/cartOpen', false)
|
|
159
|
+
set('/accountOpen', false)
|
|
160
|
+
set('/searchOpen', false)
|
|
85
161
|
}, [pathname, set])
|
|
86
162
|
return (
|
|
87
163
|
<div className="flex min-h-screen flex-col">
|
|
@@ -156,7 +232,7 @@ const baseComponents = {
|
|
|
156
232
|
},
|
|
157
233
|
StorefrontNavbar: ({ props, emit }: { props: Record<string, unknown>; emit: (event: string) => void }) => {
|
|
158
234
|
const parsed = storefrontNavbarPropsSchema.parse(props)
|
|
159
|
-
const { state
|
|
235
|
+
const { state } = useStateStore()
|
|
160
236
|
// The one session→chrome bridge. It reads the shared account state the
|
|
161
237
|
// lifecycle seeds/writes directly from the store (never importing the
|
|
162
238
|
// lifecycle module, so an unmounted customer-auth leaves no account wiring in
|
|
@@ -167,28 +243,9 @@ const baseComponents = {
|
|
|
167
243
|
const accountResolution = (
|
|
168
244
|
typeof state.accountResolution === 'string' ? state.accountResolution : 'unresolved'
|
|
169
245
|
) as AccountResolution | 'unresolved'
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// the catch-all host seeded (the same locale as `<html lang>`). The navbar
|
|
174
|
-
// forwards it to the cart sheet, so every chrome money surface agrees.
|
|
175
|
-
const storeLocale =
|
|
176
|
-
typeof state.storeLocale === 'string' && state.storeLocale.trim() !== ''
|
|
177
|
-
? state.storeLocale
|
|
178
|
-
: DEFAULT_STORE_LOCALE
|
|
179
|
-
const formatMoney = createStoreMoneyFormatter(storeLocale)
|
|
180
|
-
const cartError = typeof state.cartError === 'string' ? state.cartError : undefined
|
|
181
|
-
const readError = typeof state.cartReadError === 'string' ? state.cartReadError : undefined
|
|
182
|
-
const errorLabel = cartError ?? readError
|
|
183
|
-
const cartState = state.cartPending ? 'pending' : errorLabel ? 'error' : 'idle'
|
|
184
|
-
// Checkout is offered only when the required backend amounts are present and
|
|
185
|
-
// valid: a missing/malformed subtotal, total, or line amount blocks it, while
|
|
186
|
-
// an undetermined shipping amount does not (AC-CART-4.4 / UC-CART-7).
|
|
187
|
-
const amountsValid =
|
|
188
|
-
cart.every((line) => isAvailableMoney(line.lineTotal)) &&
|
|
189
|
-
totals !== null &&
|
|
190
|
-
isAvailableMoney(totals.subtotal) &&
|
|
191
|
-
isAvailableMoney(totals.total)
|
|
246
|
+
// One shared lateral: visibility is driven by the shared `cartOpen` state (a
|
|
247
|
+
// successful add opens it; navigation dismisses it).
|
|
248
|
+
const cart = useShellCart(emit)
|
|
192
249
|
return (
|
|
193
250
|
<StorefrontNavbar
|
|
194
251
|
storeCategories={parsed.storeCategories}
|
|
@@ -228,64 +285,172 @@ const baseComponents = {
|
|
|
228
285
|
// search is presented while the contract is unverified; the user-owned
|
|
229
286
|
// shell seam may opt in with `showSearch: true`.
|
|
230
287
|
showSearch={parsed.showSearch ?? false}
|
|
231
|
-
items={
|
|
232
|
-
subtotal={
|
|
233
|
-
formatMoney={formatMoney}
|
|
234
|
-
// One shared lateral: visibility is driven by the shared `cartOpen`
|
|
235
|
-
// state (a successful add opens it; navigation dismisses it). The
|
|
236
|
-
// canonical line amounts and lifecycle states come from the same cart
|
|
237
|
-
// state the standalone `/cart` view reads.
|
|
288
|
+
items={cart.items}
|
|
289
|
+
subtotal={cart.subtotal}
|
|
290
|
+
formatMoney={cart.formatMoney}
|
|
238
291
|
canonicalCart
|
|
239
|
-
cartState={cartState}
|
|
240
|
-
cartErrorLabel={errorLabel}
|
|
241
|
-
onCartRetry={
|
|
242
|
-
cartOpen={
|
|
243
|
-
onCartOpenChange={
|
|
244
|
-
checkoutUnavailable={
|
|
245
|
-
checkoutDisabled={
|
|
246
|
-
viewCartUnavailable={
|
|
247
|
-
onViewCart={
|
|
248
|
-
onCheckout={
|
|
249
|
-
onQtyChange={
|
|
250
|
-
|
|
251
|
-
emit('applyQuantityDelta')
|
|
252
|
-
}}
|
|
253
|
-
onRemove={(id) => {
|
|
254
|
-
set('/lastRemoved', id)
|
|
255
|
-
emit('removeFromCart')
|
|
256
|
-
}}
|
|
292
|
+
cartState={cart.cartState}
|
|
293
|
+
cartErrorLabel={cart.errorLabel}
|
|
294
|
+
onCartRetry={cart.onRetry}
|
|
295
|
+
cartOpen={cart.open}
|
|
296
|
+
onCartOpenChange={cart.setOpen}
|
|
297
|
+
checkoutUnavailable={cart.checkoutUnavailable}
|
|
298
|
+
checkoutDisabled={cart.checkoutDisabled}
|
|
299
|
+
viewCartUnavailable={cart.viewCartUnavailable}
|
|
300
|
+
onViewCart={cart.onViewCart}
|
|
301
|
+
onCheckout={cart.onCheckout}
|
|
302
|
+
onQtyChange={cart.onQtyChange}
|
|
303
|
+
onRemove={cart.onRemove}
|
|
257
304
|
/>
|
|
258
305
|
)
|
|
259
306
|
},
|
|
260
|
-
HeaderUniversal: ({ props }: { props: Record<string, unknown
|
|
307
|
+
HeaderUniversal: ({ props, emit }: { props: Record<string, unknown>; emit: (event: string) => void }) => {
|
|
261
308
|
const parsed = universalHeaderShellPropsSchema.parse(props)
|
|
262
309
|
const { navigate } = useNextApp()
|
|
310
|
+
const { state, set } = useStateStore()
|
|
311
|
+
const pathname = usePathname()
|
|
263
312
|
const config = createStorefrontHeaderConfig()
|
|
313
|
+
// Session→chrome bridge, gated on the mounted capability exactly like the
|
|
314
|
+
// legacy navbar: an unmounted customer-auth leaves no account wiring here.
|
|
315
|
+
const authMounted = mountedFeatureNames.includes('customer-auth')
|
|
316
|
+
const identity = (state.accountCustomer ?? null) as AccountIdentity | null
|
|
317
|
+
const user = authMounted ? accountStoreUser(identity) ?? undefined : undefined
|
|
318
|
+
const cart = useShellCart(emit)
|
|
319
|
+
// The header badge reads the authoritative cart, never a demo count.
|
|
264
320
|
const context = buildHeaderContext(
|
|
265
321
|
parsed.siteName,
|
|
266
322
|
parsed.menu,
|
|
267
323
|
parsed.logoAccent?.text.trim() || undefined,
|
|
324
|
+
{
|
|
325
|
+
cart: {
|
|
326
|
+
quantity: cart.quantity,
|
|
327
|
+
lineCount: cart.lineCount,
|
|
328
|
+
currency: cart.currency,
|
|
329
|
+
...(cart.errorLabel ? { error: cart.errorLabel } : {}),
|
|
330
|
+
},
|
|
331
|
+
account: user
|
|
332
|
+
? { state: 'authenticated', user, menu: storefrontAccountMenuItems }
|
|
333
|
+
: { state: 'guest', menu: [] },
|
|
334
|
+
},
|
|
268
335
|
)
|
|
336
|
+
// The cart module announces its count from the same authoritative quantity
|
|
337
|
+
// the badge reads (never the design demo count).
|
|
338
|
+
const cartLabel = (
|
|
339
|
+
cart.quantity === 1 ? navbarLabels.cartCountOne : navbarLabels.cartCount
|
|
340
|
+
).replace('{count}', String(cart.quantity))
|
|
341
|
+
const labels = { ...storefrontHeaderLabels, cart: { label: cartLabel } }
|
|
342
|
+
// The header mounts the three lateral surfaces, so it owns their dismissal.
|
|
343
|
+
// `Layout` resets them on a pathname change too, but that reset only exists
|
|
344
|
+
// while the shell layout is mounted and lands a frame after the route does;
|
|
345
|
+
// a lateral opened from here must never outlive the page it was opened on.
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
set('/accountOpen', false)
|
|
348
|
+
set('/cartOpen', false)
|
|
349
|
+
set('/searchOpen', false)
|
|
350
|
+
}, [pathname, set])
|
|
269
351
|
// The block prevents the default anchor navigation and emits `navigate`
|
|
270
352
|
// instead, so the host resolves it to client navigation (the logo and every
|
|
271
|
-
// menu destination).
|
|
272
|
-
//
|
|
353
|
+
// menu destination). `openComponent` targets are the header's lateral
|
|
354
|
+
// surfaces, mounted below with the header element: no dead affordance is
|
|
355
|
+
// rendered.
|
|
273
356
|
const handleAction = (action: {
|
|
274
357
|
name: string
|
|
275
358
|
payload?: Record<string, string | number | boolean>
|
|
276
359
|
}) => {
|
|
277
360
|
if (action.name === 'navigate' && typeof action.payload?.href === 'string') {
|
|
361
|
+
// Close first, so the destination never paints underneath an open
|
|
362
|
+
// lateral and no layer outlives the route that opened it.
|
|
363
|
+
set('/accountOpen', false)
|
|
364
|
+
set('/cartOpen', false)
|
|
365
|
+
set('/searchOpen', false)
|
|
278
366
|
navigate(action.payload.href)
|
|
367
|
+
return
|
|
368
|
+
}
|
|
369
|
+
// The cart module opens the shared live cart state: the lateral mounted
|
|
370
|
+
// beside this header reads the same store, so the action reaches the sheet
|
|
371
|
+
// through the shell handler instead of a second, private sheet.
|
|
372
|
+
if (action.name === 'openCart') {
|
|
373
|
+
emit('openCart')
|
|
374
|
+
return
|
|
375
|
+
}
|
|
376
|
+
if (action.name !== 'openComponent') return
|
|
377
|
+
switch (action.payload?.target) {
|
|
378
|
+
case 'universal-cart':
|
|
379
|
+
set('/cartOpen', true)
|
|
380
|
+
break
|
|
381
|
+
case 'universal-account':
|
|
382
|
+
set('/accountOpen', true)
|
|
383
|
+
break
|
|
384
|
+
case 'universal-search':
|
|
385
|
+
set('/searchOpen', true)
|
|
386
|
+
break
|
|
279
387
|
}
|
|
280
388
|
}
|
|
281
389
|
return (
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
390
|
+
<>
|
|
391
|
+
<HeaderUniversal
|
|
392
|
+
config={config}
|
|
393
|
+
context={context}
|
|
394
|
+
labels={labels}
|
|
395
|
+
className={parsed.className}
|
|
396
|
+
onAction={handleAction}
|
|
397
|
+
/>
|
|
398
|
+
<StorefrontCartDrawer
|
|
399
|
+
open={cart.open}
|
|
400
|
+
onOpenChange={cart.setOpen}
|
|
401
|
+
title={navbarLabels.cartTitle}
|
|
402
|
+
closeLabel={navbarLabels.cartClose}
|
|
403
|
+
items={cart.items}
|
|
404
|
+
subtotal={cart.subtotal}
|
|
405
|
+
formatMoney={cart.formatMoney}
|
|
406
|
+
canonical
|
|
407
|
+
state={cart.cartState}
|
|
408
|
+
errorLabel={cart.errorLabel}
|
|
409
|
+
retryLabel={storefrontCartDrawerLabels.retryLabel}
|
|
410
|
+
onRetry={cart.onRetry}
|
|
411
|
+
onContinueShopping={() => {
|
|
412
|
+
// The sheet closes itself; a continue-shopping click also leaves the
|
|
413
|
+
// product context for the catalog, so the affordance does something
|
|
414
|
+
// the shopper can see instead of only dismissing the lateral.
|
|
415
|
+
cart.setOpen(false)
|
|
416
|
+
navigate('/categories')
|
|
417
|
+
}}
|
|
418
|
+
checkoutUnavailable={cart.checkoutUnavailable}
|
|
419
|
+
checkoutDisabled={cart.checkoutDisabled}
|
|
420
|
+
viewCartUnavailable={cart.viewCartUnavailable}
|
|
421
|
+
onCheckout={cart.onCheckout}
|
|
422
|
+
onViewCart={cart.onViewCart}
|
|
423
|
+
onQtyChange={cart.onQtyChange}
|
|
424
|
+
onRemove={cart.onRemove}
|
|
425
|
+
{...cartSheetLabels}
|
|
426
|
+
/>
|
|
427
|
+
<StorefrontAccountDrawer
|
|
428
|
+
open={state.accountOpen === true}
|
|
429
|
+
onOpenChange={(open) => set('/accountOpen', open)}
|
|
430
|
+
user={user}
|
|
431
|
+
items={storefrontAccountMenuItems}
|
|
432
|
+
// The guest CTA is a shell navigation, like the logo and every menu
|
|
433
|
+
// destination. A plain `signInHref` anchor would leave the document
|
|
434
|
+
// for `/account` while the lateral was still open on top of it, so the
|
|
435
|
+
// host closes the surface and routes instead.
|
|
436
|
+
onSignIn={() => {
|
|
437
|
+
set('/accountOpen', false)
|
|
438
|
+
navigate(storefrontAccountMenuItems[0]?.href ?? '/account')
|
|
439
|
+
}}
|
|
440
|
+
onSignOut={authMounted ? () => emit('logout') : undefined}
|
|
441
|
+
pending={authMounted && (state.accountPending === true || state.accountReconciling === true)}
|
|
442
|
+
{...storefrontAccountDrawerLabels}
|
|
443
|
+
/>
|
|
444
|
+
<StorefrontSearchDialog
|
|
445
|
+
open={state.searchOpen === true}
|
|
446
|
+
onOpenChange={(open) => set('/searchOpen', open)}
|
|
447
|
+
onSubmit={(query) => {
|
|
448
|
+
set('/searchOpen', false)
|
|
449
|
+
navigate(`/categories?search=${encodeURIComponent(query)}`)
|
|
450
|
+
}}
|
|
451
|
+
{...storefrontSearchDialogLabels}
|
|
452
|
+
/>
|
|
453
|
+
</>
|
|
289
454
|
)
|
|
290
455
|
},
|
|
291
456
|
Banner: ({ props, emit }: { props: Record<string, unknown>; emit: (event: string) => void }) => {
|
|
@@ -318,8 +483,8 @@ const baseComponents = {
|
|
|
318
483
|
featured={parsed.featured}
|
|
319
484
|
signIn={parsed.signIn}
|
|
320
485
|
cta={parsed.cta}
|
|
321
|
-
// Page-level navigation owns no commerce state: the
|
|
322
|
-
// its
|
|
486
|
+
// Page-level navigation owns no commerce state: the shell header and
|
|
487
|
+
// its cart sheet own the cart affordance and `openCart` intent.
|
|
323
488
|
/>
|
|
324
489
|
)
|
|
325
490
|
},
|
|
@@ -7,7 +7,7 @@ import { storefrontInitialState } from '../state'
|
|
|
7
7
|
import { views } from '../views'
|
|
8
8
|
import { footerShellProps, navbarShellProps } from '../shell/props'
|
|
9
9
|
import { bannerDismissLabel, mobileBottomNavItems } from '../shell/content'
|
|
10
|
-
import { mountedFeatureConfigs, mountedFeatureNames } from '../composition'
|
|
10
|
+
import { checkoutAvailable, mountedFeatureConfigs, mountedFeatureNames } from '../composition'
|
|
11
11
|
import type { StorefrontElement } from './types'
|
|
12
12
|
|
|
13
13
|
export type { StorefrontElement }
|
|
@@ -47,6 +47,35 @@ const routes = Object.fromEntries(
|
|
|
47
47
|
// boundary), so a removed feature leaves no dangling skip link, back-to-top, or
|
|
48
48
|
// bottom navigation behind.
|
|
49
49
|
const hasNavigability = mountedFeatureNames.includes('navigability')
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The events the shell header's registry component emits, bound to the shell's
|
|
53
|
+
* registered handlers. json-render only resolves an emitted event when the
|
|
54
|
+
* element declares it (`element.on`): an undeclared event is silently dropped.
|
|
55
|
+
* That is why every action the header's cart and account surfaces dispatch must
|
|
56
|
+
* appear here, and why feature-owned actions are bound only when their feature is
|
|
57
|
+
* installed (an absent handler would be an unknown action).
|
|
58
|
+
*/
|
|
59
|
+
export function headerSurfaceEvents(
|
|
60
|
+
mounted: readonly string[],
|
|
61
|
+
): NonNullable<StorefrontElement['on']> {
|
|
62
|
+
return {
|
|
63
|
+
// The header's cart module opens the shared live cart lateral through the
|
|
64
|
+
// shell's `openCart` handler, so the surface is the one the shell mounts.
|
|
65
|
+
openCart: { action: 'openCart' },
|
|
66
|
+
goToCart: { action: 'goToCart' },
|
|
67
|
+
refreshCart: { action: 'refreshCart' },
|
|
68
|
+
applyQuantityDelta: { action: 'applyQuantityDelta' },
|
|
69
|
+
removeFromCart: { action: 'removeFromCart' },
|
|
70
|
+
...(checkoutAvailable ? { goToCheckout: { action: 'goToCheckout' } } : {}),
|
|
71
|
+
...(mounted.includes('customer-auth')
|
|
72
|
+
? {
|
|
73
|
+
logout: { action: 'logout' },
|
|
74
|
+
retryAccountSession: { action: 'retryAccountSession' },
|
|
75
|
+
}
|
|
76
|
+
: {}),
|
|
77
|
+
}
|
|
78
|
+
}
|
|
50
79
|
const navigabilityConfig = (mountedFeatureConfigs['navigability'] ?? {}) as {
|
|
51
80
|
showBackToTop?: boolean
|
|
52
81
|
}
|
|
@@ -115,6 +144,13 @@ const shellElements: Record<string, StorefrontElement> = {
|
|
|
115
144
|
// user-owned shell seam. Spread last so merchant edits win.
|
|
116
145
|
...navbarShellProps,
|
|
117
146
|
},
|
|
147
|
+
// The header's lateral surfaces (cart, account, search) dispatch through the
|
|
148
|
+
// shell's registered handlers. json-render resolves an emitted event ONLY
|
|
149
|
+
// when the element declares it here: an undeclared event is silently
|
|
150
|
+
// dropped, which is why the cart action, checkout/view-cart,
|
|
151
|
+
// quantity/remove and sign-out must be bound. Feature-owned handlers are
|
|
152
|
+
// bound only when their feature is installed.
|
|
153
|
+
on: headerSurfaceEvents(mountedFeatureNames),
|
|
118
154
|
},
|
|
119
155
|
footer: {
|
|
120
156
|
type: 'Footer',
|
|
@@ -218,6 +218,10 @@ export interface StorefrontCoreState {
|
|
|
218
218
|
/** Visible real-mode failure; null when the data loaded. */
|
|
219
219
|
dataError: string | null
|
|
220
220
|
cartOpen: boolean
|
|
221
|
+
/** Account lateral visibility, owned by the header's account module. */
|
|
222
|
+
accountOpen: boolean
|
|
223
|
+
/** Global search dialog visibility, owned by the header's search module. */
|
|
224
|
+
searchOpen: boolean
|
|
221
225
|
// ---- cart (backend-authoritative) ----
|
|
222
226
|
cart: CartLineState[]
|
|
223
227
|
cartTotals: CartTotalsState | null
|
|
@@ -279,6 +283,8 @@ export const storefrontCoreState: StorefrontCoreState = {
|
|
|
279
283
|
storeLocale: DEFAULT_STORE_LOCALE,
|
|
280
284
|
dataError: null,
|
|
281
285
|
cartOpen: false,
|
|
286
|
+
accountOpen: false,
|
|
287
|
+
searchOpen: false,
|
|
282
288
|
cart: [],
|
|
283
289
|
cartTotals: null,
|
|
284
290
|
cartId: null,
|
|
@@ -169,7 +169,7 @@ export const universalBannerDataSchema = z.object({
|
|
|
169
169
|
layout: z.object({
|
|
170
170
|
gapX: z.enum(["sm", "md", "lg", "xl", "none"]),
|
|
171
171
|
gapY: z.enum(["sm", "md", "lg", "xl", "none"]),
|
|
172
|
-
maxWidth: z.enum(["full", "sm", "md", "lg", "xl"]),
|
|
172
|
+
maxWidth: z.enum(["full", "page", "sm", "md", "lg", "xl"]),
|
|
173
173
|
maxHeight: z.enum(["sm", "md", "lg", "xl", "none"]),
|
|
174
174
|
align: z.enum(["center", "start", "end"]),
|
|
175
175
|
radius: z.enum(["md", "lg", "xl", "none", "2xl"]),
|
|
@@ -214,4 +214,5 @@ export const universalBannerDataSchema = z.object({
|
|
|
214
214
|
|
|
215
215
|
export const universalBannerPropsSchema = z.object({
|
|
216
216
|
data: universalBannerDataSchema,
|
|
217
|
+
headingLevel: z.union([z.literal(1), z.literal(2), z.literal(3)]).optional(),
|
|
217
218
|
})
|
|
@@ -18,7 +18,10 @@ export const universalBannerRegistry: ViewRegistry = {
|
|
|
18
18
|
setNow(new Date().toISOString())
|
|
19
19
|
}, [])
|
|
20
20
|
return (
|
|
21
|
-
<UniversalBanner
|
|
21
|
+
<UniversalBanner
|
|
22
|
+
data={{ ...parsed.data, now }}
|
|
23
|
+
headingLevel={parsed.headingLevel}
|
|
24
|
+
/>
|
|
22
25
|
)
|
|
23
26
|
},
|
|
24
27
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
|
|
2
|
+
<rect width="400" height="300" fill="#F4F1EC"/>
|
|
3
|
+
<path d="M156 138 a44 44 0 0 1 88 0" fill="none" stroke="#C7BDA9" stroke-width="12"/>
|
|
4
|
+
<rect x="138" y="140" width="124" height="92" rx="18" fill="#E3DCCF"/>
|
|
5
|
+
<path d="M138 168 h124 l-18 42 h-88 z" fill="#C6774B"/>
|
|
6
|
+
<circle cx="200" cy="170" r="6" fill="#C7BDA9"/>
|
|
7
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
|
|
2
|
+
<rect width="400" height="300" fill="#F4F1EC"/>
|
|
3
|
+
<path d="M176 96 h48 l-8 42 h-32 z" fill="#C7BDA9"/>
|
|
4
|
+
<path d="M168 138 h64 l48 92 a14 14 0 0 1 -14 14 h-132 a14 14 0 0 1 -14 -14 z" fill="#E3DCCF"/>
|
|
5
|
+
<rect x="168" y="134" width="64" height="10" fill="#C6774B"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
|
|
2
|
+
<rect width="400" height="300" fill="#F4F1EC"/>
|
|
3
|
+
<rect x="132" y="110" width="136" height="88" rx="20" fill="#E3DCCF"/>
|
|
4
|
+
<rect x="122" y="174" width="156" height="42" rx="16" fill="#C7BDA9"/>
|
|
5
|
+
<rect x="112" y="148" width="34" height="68" rx="16" fill="#C6774B"/>
|
|
6
|
+
<rect x="254" y="148" width="34" height="68" rx="16" fill="#C6774B"/>
|
|
7
|
+
<rect x="140" y="216" width="14" height="24" rx="4" fill="#C7BDA9"/>
|
|
8
|
+
<rect x="246" y="216" width="14" height="24" rx="4" fill="#C7BDA9"/>
|
|
9
|
+
</svg>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
|
|
2
|
+
<rect width="400" height="300" fill="#F4F1EC"/>
|
|
3
|
+
<rect x="138" y="150" width="124" height="96" rx="4" fill="#E3DCCF"/>
|
|
4
|
+
<path d="M124 154 L200 96 L276 154 z" fill="#C7BDA9"/>
|
|
5
|
+
<rect x="186" y="196" width="28" height="50" rx="3" fill="#C6774B"/>
|
|
6
|
+
<rect x="154" y="166" width="26" height="22" rx="2" fill="#F4F1EC" stroke="#C7BDA9" stroke-width="3"/>
|
|
7
|
+
<rect x="220" y="166" width="26" height="22" rx="2" fill="#F4F1EC" stroke="#C7BDA9" stroke-width="3"/>
|
|
8
|
+
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
|
|
2
|
+
<rect width="400" height="300" fill="#F4F1EC"/>
|
|
3
|
+
<rect x="118" y="120" width="56" height="118" rx="26" fill="#C7BDA9"/>
|
|
4
|
+
<rect x="226" y="120" width="56" height="118" rx="26" fill="#C7BDA9"/>
|
|
5
|
+
<path d="M162 102 h76 l12 14 v106 a16 16 0 0 1 -16 16 h-68 a16 16 0 0 1 -16 -16 V116 z" fill="#E3DCCF"/>
|
|
6
|
+
<path d="M162 102 l18 -26 h40 l18 26 z" fill="#C7BDA9"/>
|
|
7
|
+
<line x1="200" y1="116" x2="200" y2="232" stroke="#C7BDA9" stroke-width="3"/>
|
|
8
|
+
<circle cx="200" cy="148" r="4" fill="#C6774B"/>
|
|
9
|
+
<circle cx="200" cy="182" r="4" fill="#C6774B"/>
|
|
10
|
+
<circle cx="200" cy="216" r="4" fill="#C6774B"/>
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
|
|
2
|
+
<rect width="400" height="300" fill="#F4F1EC"/>
|
|
3
|
+
<rect x="118" y="168" width="164" height="30" rx="9" fill="#C7BDA9"/>
|
|
4
|
+
<rect x="126" y="138" width="148" height="30" rx="9" fill="#E3DCCF"/>
|
|
5
|
+
<rect x="134" y="108" width="132" height="30" rx="9" fill="#C6774B"/>
|
|
6
|
+
<line x1="200" y1="108" x2="200" y2="138" stroke="#F4F1EC" stroke-width="2" opacity="0.6"/>
|
|
7
|
+
<line x1="200" y1="138" x2="200" y2="168" stroke="#C7BDA9" stroke-width="2" opacity="0.5"/>
|
|
8
|
+
</svg>
|
|
@@ -70,6 +70,7 @@ export interface CheckoutState {
|
|
|
70
70
|
checkoutSelectedShippingOptionId: string | null
|
|
71
71
|
checkoutFieldErrors: CheckoutFieldErrors
|
|
72
72
|
checkoutContact: CheckoutContactValues
|
|
73
|
+
checkoutContactEdited: boolean
|
|
73
74
|
checkoutShippingAddress: CheckoutAddressValues
|
|
74
75
|
checkoutBillingAddress: CheckoutAddressValues
|
|
75
76
|
checkoutSameAsShipping: boolean
|
|
@@ -106,6 +107,7 @@ export const checkoutState: CheckoutState = {
|
|
|
106
107
|
checkoutSelectedShippingOptionId: null,
|
|
107
108
|
checkoutFieldErrors: {},
|
|
108
109
|
checkoutContact: emptyContact,
|
|
110
|
+
checkoutContactEdited: false,
|
|
109
111
|
checkoutShippingAddress: emptyAddress,
|
|
110
112
|
checkoutBillingAddress: emptyAddress,
|
|
111
113
|
checkoutSameAsShipping: true,
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
return (
|
|
27
27
|
<CategoryListingBlock
|
|
28
28
|
presentation={p.presentation}
|
|
29
|
+
categoryTitle={p.categoryTitle}
|
|
29
30
|
products={p.products}
|
|
30
31
|
categories={p.categories}
|
|
31
32
|
collections={p.collections}
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
viewOptions={p.viewOptions}
|
|
49
50
|
status={p.status}
|
|
50
51
|
activeFilters={p.activeFilters}
|
|
52
|
+
closeLabel={p.closeLabel}
|
|
51
53
|
filtersTitle={p.filtersTitle}
|
|
52
54
|
searchLabel={p.searchLabel}
|
|
53
55
|
searchPlaceholder={p.searchPlaceholder}
|
|
@@ -76,6 +76,7 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
76
76
|
showFilters: hasFilters,
|
|
77
77
|
showSort: true,
|
|
78
78
|
showPrice: filtersConfig.showPrice === true,
|
|
79
|
+
categoryTitle: { $state: '/categoryEntity/name' },
|
|
79
80
|
...(hasSearch && searchConfig.placeholder
|
|
80
81
|
? { searchPlaceholder: searchConfig.placeholder }
|
|
81
82
|
: {}),
|