@thorprovider/storefront 0.15.0 → 0.15.2

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.
Files changed (28) hide show
  1. package/README.md +9 -4
  2. package/assets/templates/app/app/[[...slug]]/page.tsx +22 -4
  3. package/assets/templates/app/app/layout.tsx +2 -2
  4. package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +11 -4
  5. package/assets/templates/app/lib/__STOREFRONT__/confirmation.core.ts +7 -4
  6. package/assets/templates/app/lib/__STOREFRONT__/header-universal.ts +363 -0
  7. package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +49 -1
  8. package/assets/templates/app/lib/__STOREFRONT__/schema.ts +52 -0
  9. package/assets/templates/app/lib/__STOREFRONT__/shell/content.ts +43 -0
  10. package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +4 -0
  11. package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +16 -43
  12. package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +8 -0
  13. package/assets/templates/app/lib/__STOREFRONT__/store-context.ts +84 -18
  14. package/assets/templates/app/lib/__STOREFRONT__/views/sections/header-universal.client.tsx +33 -0
  15. package/assets/templates/app/lib/__STOREFRONT__/views/sections/header-universal.tsx +16 -0
  16. package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +2 -1
  17. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.header-universal.ts +360 -0
  18. package/assets/templates/views/cart/registry.tsx +9 -0
  19. package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +5 -1
  20. package/package.json +1 -1
  21. package/recipes/sections.json +18 -0
  22. package/scripts/candidate.mjs +2 -2
  23. package/scripts/env-file.mjs +5 -0
  24. package/scripts/file-classes.mjs +7 -2
  25. package/skills/sf-view-gen/assets/recipes/sections.json +18 -0
  26. package/skills/sf-view-gen/assets/templates/views/sections/header-universal.client.tsx +33 -0
  27. package/skills/sf-view-gen/assets/templates/views/sections/header-universal.tsx +16 -0
  28. package/skills/sf-view-gen/assets/templates/views/sections/schema.header-universal.ts +360 -0
@@ -7,6 +7,7 @@
7
7
  import { z } from 'zod'
8
8
 
9
9
  import { footerContentSchema } from './footer-content'
10
+ import { universalMainMenuDataSchema } from './views/sections/schema.universal-main-menu'
10
11
 
11
12
  export const ctaSchema = z.object({
12
13
  label: z.string(),
@@ -126,6 +127,40 @@ export const accountMenuItemSchema = z.object({
126
127
  icon: z.enum(['orders', 'wishlist', 'addresses', 'settings']).optional(),
127
128
  })
128
129
 
130
+ // Chrome copy mirror of the block's `StorefrontNavbarLabels` (quality baseline
131
+ // D3). Plain strings only; every field optional so an omitted label keeps the
132
+ // block's shipped English default. `{count}`/`{name}` tokens are filled by the
133
+ // block, so they survive serialization untouched.
134
+ export const storefrontNavbarLabelsSchema = z.object({
135
+ openMenu: z.string().optional(),
136
+ storeNav: z.string().optional(),
137
+ account: z.string().optional(),
138
+ search: z.string().optional(),
139
+ loadingAccount: z.string().optional(),
140
+ accountRetry: z.string().optional(),
141
+ accountUnavailableTitle: z.string().optional(),
142
+ accountMenu: z.string().optional(),
143
+ help: z.string().optional(),
144
+ signOut: z.string().optional(),
145
+ cartCount: z.string().optional(),
146
+ cartCountOne: z.string().optional(),
147
+ cartContains: z.string().optional(),
148
+ cartContainsOne: z.string().optional(),
149
+ cartTitle: z.string().optional(),
150
+ cartClose: z.string().optional(),
151
+ decreaseQuantity: z.string().optional(),
152
+ increaseQuantity: z.string().optional(),
153
+ remove: z.string().optional(),
154
+ removeItem: z.string().optional(),
155
+ emptyTitle: z.string().optional(),
156
+ emptyDescription: z.string().optional(),
157
+ continueShopping: z.string().optional(),
158
+ subtotal: z.string().optional(),
159
+ shippingTaxes: z.string().optional(),
160
+ checkout: z.string().optional(),
161
+ viewCart: z.string().optional(),
162
+ })
163
+
129
164
  export const storefrontNavbarPropsSchema = z.object({
130
165
  storeCategories: z.array(navCategorySchema),
131
166
  shippingNote: z.string().optional(),
@@ -145,6 +180,8 @@ export const storefrontNavbarPropsSchema = z.object({
145
180
  // Held global search (E2 task 5.4): the generated shell opts out of the
146
181
  // navbar search control while no verified global search contract exists.
147
182
  showSearch: z.boolean().optional(),
183
+ // Chrome copy in the store language, from the user-owned shell seam.
184
+ labels: storefrontNavbarLabelsSchema.optional(),
148
185
  })
149
186
 
150
187
  export const bannerPropsSchema = z.object({
@@ -153,6 +190,8 @@ export const bannerPropsSchema = z.object({
153
190
  href: z.string(),
154
191
  linkLabel: z.string(),
155
192
  avatars: z.array(z.string()).optional(),
193
+ // Dismiss copy in the store language; the block defaults to English.
194
+ dismissLabel: z.string().optional(),
156
195
  })
157
196
 
158
197
  export const productGridPropsSchema = z.object({
@@ -204,3 +243,16 @@ export const mobileBottomNavPropsSchema = z.object({
204
243
  ariaLabel: z.string().optional(),
205
244
  className: z.string().optional(),
206
245
  })
246
+
247
+ // The universal header's shell props. The config and labels are authored in
248
+ // the shell data module (`../header-universal`) and the runtime `HeaderContext`
249
+ // is built from the site name and the host-fed menu, so the shell only declares
250
+ // the serializable chrome: the site name, the menu data, and the user-owned
251
+ // brand seam (wordmark accent + surface class). `menu` is optional so a failed
252
+ // catalog read still renders the wordmark.
253
+ export const universalHeaderShellPropsSchema = z.object({
254
+ siteName: z.string(),
255
+ menu: universalMainMenuDataSchema.optional(),
256
+ logoAccent: shellAccentSchema.optional(),
257
+ className: z.string().optional(),
258
+ })
@@ -14,6 +14,7 @@
14
14
  // the footer content contract, not here: `GET /store/footer` is what a backend
15
15
  // implements, and `../footer-content.ts` documents its shape and defaults.
16
16
 
17
+ import type { StorefrontNavbarLabels } from '@thorprovider/blocks'
17
18
  import type { FooterContent } from '../footer-content'
18
19
 
19
20
  export interface ShellAccent {
@@ -59,6 +60,48 @@ export const navbarClassName: string | undefined = undefined
59
60
  */
60
61
  export const footerClassName: string | undefined = undefined
61
62
 
63
+ /**
64
+ * Accessible name of the announcement banner's dismiss control. The block
65
+ * defaults to English; the generated store speaks Spanish from here.
66
+ */
67
+ export const bannerDismissLabel: string = 'Cerrar anuncio'
68
+
69
+ /**
70
+ * Chrome copy for the navbar and its cart sheet (header, search, account,
71
+ * cart count, sheet actions). The blocks default to English; the generated
72
+ * store speaks Spanish from here. `{count}`/`{name}` are filled by the block;
73
+ * keep them in any translation. Omit a key to keep the block's default.
74
+ */
75
+ export const navbarLabels: StorefrontNavbarLabels = {
76
+ openMenu: 'Abrir menú',
77
+ storeNav: 'Tienda',
78
+ account: 'Cuenta',
79
+ search: 'Buscar productos',
80
+ loadingAccount: 'Cargando sesión de cuenta',
81
+ accountRetry: 'Reintentar sesión de cuenta',
82
+ accountUnavailableTitle: 'Sesión de cuenta no disponible',
83
+ accountMenu: 'Menú de cuenta de {name}',
84
+ help: 'Ayuda y soporte',
85
+ signOut: 'Cerrar sesión',
86
+ cartCount: 'Carrito, {count} artículos',
87
+ cartCountOne: 'Carrito, {count} artículo',
88
+ cartContains: 'El carrito contiene {count} artículos',
89
+ cartContainsOne: 'El carrito contiene {count} artículo',
90
+ cartTitle: 'Carrito',
91
+ cartClose: 'Cerrar',
92
+ decreaseQuantity: 'Disminuir cantidad',
93
+ increaseQuantity: 'Aumentar cantidad',
94
+ remove: 'Quitar',
95
+ removeItem: 'Quitar {name} del carrito',
96
+ emptyTitle: 'Tu carrito está vacío',
97
+ emptyDescription: 'Cuando agregues algo, aparecerá aquí.',
98
+ continueShopping: 'Seguir comprando',
99
+ subtotal: 'Subtotal',
100
+ shippingTaxes: 'El envío y los impuestos se calculan al finalizar la compra.',
101
+ checkout: 'Finalizar compra',
102
+ viewCart: 'Ver carrito',
103
+ }
104
+
62
105
  /** Neutral footer brand description. No delivery/shipping promise. */
63
106
  export const brandDescription: string =
64
107
  'Catálogo en línea de productos para tu hogar y tu negocio.'
@@ -12,6 +12,7 @@ import {
12
12
  linkColumns,
13
13
  logoAccent,
14
14
  navbarClassName,
15
+ navbarLabels,
15
16
  shippingNote,
16
17
  } from './content'
17
18
  import { footerContentDefaults } from '../footer-content'
@@ -19,6 +20,9 @@ import { footerContentDefaults } from '../footer-content'
19
20
  export const navbarShellProps = {
20
21
  logoAccent,
21
22
  className: navbarClassName,
23
+ // Chrome copy in the store language; the blocks keep English defaults for
24
+ // consumers that supply nothing (quality baseline D3).
25
+ labels: navbarLabels,
22
26
  // Optional utility-strip note. Empty by default, so the strip renders only
23
27
  // once a real note (or a utility link) is configured.
24
28
  shippingNote,
@@ -6,7 +6,7 @@ import type { NextAppSpec } from '@json-render/next'
6
6
  import { storefrontInitialState } from '../state'
7
7
  import { views } from '../views'
8
8
  import { footerShellProps, navbarShellProps } from '../shell/props'
9
- import { mobileBottomNavItems } from '../shell/content'
9
+ import { bannerDismissLabel, mobileBottomNavItems } from '../shell/content'
10
10
  import { mountedFeatureConfigs, mountedFeatureNames } from '../composition'
11
11
  import type { StorefrontElement } from './types'
12
12
 
@@ -52,16 +52,11 @@ const navigabilityConfig = (mountedFeatureConfigs['navigability'] ?? {}) as {
52
52
  }
53
53
  const showBackToTop = navigabilityConfig.showBackToTop !== false
54
54
 
55
- // Account chrome is contributed only when customer-auth is mounted. The default
56
- // account menu is DERIVED and minimal — the account surface only, with a real
57
- // link (no dead `#`); extra account destinations are a deferred, per-storefront
58
- // concern. A user-owned shell may override the destination/items via
59
- // `navbarShellProps` (spread last).
60
- const authMounted = mountedFeatureNames.includes('customer-auth')
61
- const DEFAULT_ACCOUNT_MENU_ITEMS = [
62
- { label: 'Pedidos', href: '/account', icon: 'orders' as const },
63
- ]
64
-
55
+ // The universal header replaces the canonical sticky navbar as the shell's
56
+ // navigation: its menu IS the universal main menu (ghost trigger, container
57
+ // anchor) and it carries no horizontal category strip. The wordmark accent and
58
+ // surface class still come from the user-owned shell seam (`navbarShellProps`,
59
+ // spread last).
65
60
  const shellElements: Record<string, StorefrontElement> = {
66
61
  // Navigability chrome, present only when the feature is installed. The skip
67
62
  // link is the first focusable element (rendered before the notices); the
@@ -102,46 +97,24 @@ const shellElements: Record<string, StorefrontElement> = {
102
97
  message: 'Descubre el catálogo de __SITE_NAME__.',
103
98
  href: '/categories',
104
99
  linkLabel: 'Ver catálogo',
100
+ // Dismiss copy comes from the user-owned shell seam, like the navbar
101
+ // labels; the block itself defaults to English.
102
+ dismissLabel: bannerDismissLabel,
105
103
  },
106
104
  visible: { $state: '/bannerDismissed', not: true },
107
105
  on: { dismissBanner: { action: 'dismissBanner' } },
108
106
  },
109
- navbar: {
110
- type: 'StorefrontNavbar',
107
+ 'universal-header': {
108
+ type: 'HeaderUniversal',
111
109
  props: {
112
- storeCategories: { $state: '/navCategories' },
113
- // No shipping/delivery/COD note is shipped by default; the note comes
114
- // from the user-owned shell seam (`...navbarShellProps` below) and is
115
- // empty unless the merchant sets one, so no placeholder strip renders.
116
- utilityLinks: [],
117
- logoText: '__SITE_NAME__',
118
- logoHref: '/',
119
- // Gated account defaults, injected BEFORE the shell spread so an authored
120
- // `accountHref`/`accountMenuItems` in the user-owned shell wins. A
121
- // non-adopter passes neither and keeps its baseline chrome exactly.
122
- ...(authMounted
123
- ? { accountHref: '/account', accountMenuItems: DEFAULT_ACCOUNT_MENU_ITEMS }
124
- : {}),
110
+ siteName: '__SITE_NAME__',
111
+ // The menu is the storefront's real catalog taxonomy, built server-side
112
+ // in the catch-all page and carried through state.
113
+ menu: { $state: '/headerMenu' },
125
114
  // Optional wordmark accent and surface classes, configured in the
126
115
  // user-owned shell seam. Spread last so merchant edits win.
127
116
  ...navbarShellProps,
128
117
  },
129
- on: {
130
- openCart: { action: 'openCart' },
131
- goToCart: { action: 'goToCart' },
132
- goToCheckout: { action: 'goToCheckout' },
133
- applyQuantityDelta: { action: 'applyQuantityDelta' },
134
- removeFromCart: { action: 'removeFromCart' },
135
- // The account sign-out and retry reuse customer-auth's existing `logout`
136
- // and `retryAccountSession` actions (the latter is what the account
137
- // boundary emits too); wired only while the capability is mounted.
138
- ...(authMounted
139
- ? {
140
- logout: { action: 'logout' },
141
- retryAccountSession: { action: 'retryAccountSession' },
142
- }
143
- : {}),
144
- },
145
118
  },
146
119
  footer: {
147
120
  type: 'Footer',
@@ -176,7 +149,7 @@ export const __STOREFRONT_CAMEL__Spec: NextAppSpec = {
176
149
  ? { chrome: ['skipToContent', 'backToTop', 'mobileBottomNav'] }
177
150
  : {}),
178
151
  notices: ['notice'],
179
- header: ['banner', 'navbar'],
152
+ header: ['banner', 'universal-header'],
180
153
  footer: ['footer'],
181
154
  },
182
155
  children: ['slot'],
@@ -14,6 +14,7 @@ import type {
14
14
  ProductDetailProduct,
15
15
  } from '@thorprovider/blocks'
16
16
  import type { Money, PaymentMethod } from '@thorprovider/types'
17
+ import { DEFAULT_STORE_LOCALE } from './store-context'
17
18
 
18
19
  /** Real review, rendered only when the backend supplies it. */
19
20
  export interface ProductReview {
@@ -208,6 +209,12 @@ export interface StorefrontCoreState {
208
209
  dataNoticeDismissed: boolean
209
210
  /** Explicit data source; `'mock'` is always labelled as demo data. */
210
211
  dataSource: 'mock' | 'medusa'
212
+ /**
213
+ * The store's shopper locale (BCP-47). Seeded by the catch-all host from the
214
+ * store context so every client surface formats money with the same locale
215
+ * the server rendered `<html lang>` with; the default matches the scaffold.
216
+ */
217
+ storeLocale: string
211
218
  /** Visible real-mode failure; null when the data loaded. */
212
219
  dataError: string | null
213
220
  cartOpen: boolean
@@ -269,6 +276,7 @@ export const storefrontCoreState: StorefrontCoreState = {
269
276
  bannerDismissed: false,
270
277
  dataNoticeDismissed: false,
271
278
  dataSource: 'mock',
279
+ storeLocale: DEFAULT_STORE_LOCALE,
272
280
  dataError: null,
273
281
  cartOpen: false,
274
282
  cart: [],
@@ -5,8 +5,11 @@
5
5
  // any commerce call, so an incomplete or invalid configuration fails visibly
6
6
  // instead of silently falling back to demo data.
7
7
  //
8
- // Boundary: this module is server-only and reads no Next.js or React API. It
9
- // owns the environment contract; the commerce bridge owns the backend calls.
8
+ // Boundary: the environment-reading functions are server-only and read no
9
+ // Next.js or React API. This module owns the environment contract; the
10
+ // commerce bridge owns the backend calls. The pure exports (locale default,
11
+ // `createStoreMoneyFormatter`) carry no env reads and are safe in the client
12
+ // registries, which receive the resolved locale through the seeded state.
10
13
  //
11
14
  // The values are the multitenancy seam: a future tenancy layer varies
12
15
  // storeId/channel/region/currency without redefining the commerce shapes. In
@@ -14,7 +17,7 @@
14
17
  // environment; mock mode resolves a labelled fixture context so the store runs
15
18
  // with no environment configured at all.
16
19
 
17
- import type { StoreContext } from '@thorprovider/types'
20
+ import type { Money, StoreContext } from '@thorprovider/types'
18
21
  import { storeContextSchema } from '@thorprovider/runtime/contracts'
19
22
 
20
23
  /** Data source selected explicitly by the host; never inferred from a failure. */
@@ -44,6 +47,66 @@ export const DATA_SOURCE_ENV = 'THOR_DATA_SOURCE'
44
47
  */
45
48
  export const SITE_URL_ENV = 'THOR_SITE_URL'
46
49
 
50
+ /**
51
+ * Host environment variable with the shopper locale (BCP-47, e.g. `es-UY`).
52
+ * One locale governs `<html lang>` and every monetary surface. Optional: when
53
+ * unset or blank the store falls back to `DEFAULT_STORE_LOCALE`.
54
+ */
55
+ export const LOCALE_ENV = 'THOR_STORE_LOCALE'
56
+
57
+ /**
58
+ * The scaffold's default shopper locale: the generated starter is a Spanish
59
+ * shop for a Uruguayan merchant, matching the mock Uruguay region (design D4).
60
+ */
61
+ export const DEFAULT_STORE_LOCALE = 'es-UY'
62
+
63
+ /**
64
+ * The store's shopper locale (BCP-47). Pure env read with a safe default; it
65
+ * never throws, so a missing override degrades to the scaffold default instead
66
+ * of failing the render.
67
+ */
68
+ export function getStoreLocale(): string {
69
+ const value = process.env[LOCALE_ENV]?.trim()
70
+ return value ? value : DEFAULT_STORE_LOCALE
71
+ }
72
+
73
+ /**
74
+ * The generated store's context: the shared validated `StoreContext` plus the
75
+ * shopper locale. The locale is a presentation concern owned by the host, so
76
+ * it extends the shared commerce shape here rather than in the backend
77
+ * contract.
78
+ */
79
+ export interface StorefrontStoreContext extends StoreContext {
80
+ /** BCP-47 shopper locale governing the document language and money. */
81
+ locale: string
82
+ }
83
+
84
+ /**
85
+ * Build the store's single money formatter from a locale. Pure and total, so
86
+ * the client registries can build the identical formatter from the locale the
87
+ * server seeded into the state store; `formatStoreMoney` below is the
88
+ * server-side convenience that resolves the locale itself. The currency always
89
+ * comes from the `Money` value — never hardcoded.
90
+ */
91
+ export function createStoreMoneyFormatter(locale: string): (value: Money) => string {
92
+ return (value) =>
93
+ new Intl.NumberFormat(locale, {
94
+ style: 'currency',
95
+ currency: value.currencyCode,
96
+ }).format(Number(value.amount))
97
+ }
98
+
99
+ /**
100
+ * Format a `Money` with the store's shopper locale. Server-side surfaces use
101
+ * this directly; client surfaces receive the same rendering through
102
+ * `createStoreMoneyFormatter(state.storeLocale)`. Callers gate availability
103
+ * first (the blocks' `formatMoney` safety gate) — this helper formats the
104
+ * canonical `Money` it is given.
105
+ */
106
+ export function formatStoreMoney(value: Money): string {
107
+ return createStoreMoneyFormatter(getStoreContext().locale)(value)
108
+ }
109
+
47
110
  /**
48
111
  * Visible configuration failure. Thrown before commerce so a missing or invalid
49
112
  * store context surfaces as an error instead of fictional data.
@@ -94,15 +157,17 @@ export function getSiteUrl(): string | undefined {
94
157
 
95
158
  /**
96
159
  * Fixture context resolved in mock mode. It satisfies `storeContextSchema` and
97
- * mirrors the values the bundled mock provider serves, so a store with no
98
- * environment configured still has a valid context to render and operate its
99
- * cart against. It is a labelled fixture, never a real backend identity.
160
+ * mirrors the values the bundled mock provider serves — the Uruguay region in
161
+ * UYU with the `es-UY` shopper locale — so a store with no environment
162
+ * configured still has a valid context whose country and currency agree with
163
+ * the commerce data. It is a labelled fixture, never a real backend identity.
100
164
  */
101
- export const MOCK_STORE_CONTEXT: StoreContext = {
165
+ export const MOCK_STORE_CONTEXT: StorefrontStoreContext = {
102
166
  storeId: 'mock-store',
103
167
  salesChannelId: 'mock-sales-channel',
104
- regionId: 'mock-region-us',
105
- currencyCode: 'USD',
168
+ regionId: 'mock-region-uy',
169
+ currencyCode: 'UYU',
170
+ locale: DEFAULT_STORE_LOCALE,
106
171
  }
107
172
 
108
173
  function requireEnv(name: string): string {
@@ -118,15 +183,16 @@ function requireEnv(name: string): string {
118
183
  /**
119
184
  * Resolve and validate the single-store context.
120
185
  *
121
- * Mock mode returns the labelled fixture context and reads no environment
122
- * variables, so a created store runs with no configuration. Real mode resolves
123
- * the four variables from the host environment and validates them through the
124
- * shared runtime schema, so an invalid context is rejected before any commerce
125
- * call. Throws `StoreConfigError` naming the missing variable — never a secret
126
- * value.
186
+ * Mock mode returns the labelled fixture context and reads none of the four
187
+ * backend variables, so a created store runs with no configuration; only the
188
+ * optional shopper-locale override (`THOR_STORE_LOCALE`) is honoured. Real mode
189
+ * resolves the four variables from the host environment and validates them
190
+ * through the shared runtime schema, so an invalid context is rejected before
191
+ * any commerce call. The shopper locale is attached in both modes. Throws
192
+ * `StoreConfigError` naming the missing variable — never a secret value.
127
193
  */
128
- export function getStoreContext(): StoreContext {
129
- if (!isRealMode()) return MOCK_STORE_CONTEXT
194
+ export function getStoreContext(): StorefrontStoreContext {
195
+ if (!isRealMode()) return { ...MOCK_STORE_CONTEXT, locale: getStoreLocale() }
130
196
  const candidate = {
131
197
  storeId: requireEnv(STORE_CONTEXT_ENV.storeId),
132
198
  salesChannelId: requireEnv(STORE_CONTEXT_ENV.salesChannelId),
@@ -140,7 +206,7 @@ export function getStoreContext(): StoreContext {
140
206
  .join('; ')
141
207
  throw new StoreConfigError(`Invalid store context: ${issues}`)
142
208
  }
143
- return parsed.data
209
+ return { ...parsed.data, locale: getStoreLocale() }
144
210
  }
145
211
 
146
212
  /**
@@ -0,0 +1,33 @@
1
+ 'use client'
2
+
3
+ // Optional section fragment: header-universal (mirrors recipes/sections.json) — client registry.
4
+ // The matching server-side catalog lives in header-universal.tsx. @thorprovider/blocks ships a
5
+ // 'use client' boundary, but this fragment keeps the explicit client boundary so
6
+ // the section composes identically in any consumer graph.
7
+
8
+ import { useRouter } from 'next/navigation'
9
+ import { HeaderUniversal } from '@thorprovider/blocks'
10
+ import { universalHeaderPropsSchema } from './schema.header-universal'
11
+ import type { ViewRegistry } from '../types'
12
+
13
+ export const headerUniversalRegistry: ViewRegistry = {
14
+ HeaderUniversal: ({ props }) => {
15
+ const router = useRouter()
16
+ const parsed = universalHeaderPropsSchema.parse(props)
17
+ return (
18
+ <HeaderUniversal
19
+ config={parsed.config}
20
+ context={parsed.context}
21
+ labels={parsed.labels}
22
+ breakpoint={parsed.breakpoint}
23
+ className={parsed.className}
24
+ onAction={(action) => {
25
+ if (action.name === 'navigate') {
26
+ const href = action.payload?.href
27
+ if (typeof href === 'string' && href.startsWith('/')) router.push(href)
28
+ }
29
+ }}
30
+ />
31
+ )
32
+ },
33
+ }
@@ -0,0 +1,16 @@
1
+ // Optional section fragment: header-universal (mirrors recipes/sections.json)
2
+ // Server-side part: element type + zod catalog entry. The component mappings
3
+ // live in header-universal.client.tsx ('use client') and are composed via composeSections.
4
+
5
+ import { universalHeaderPropsSchema } from './schema.header-universal'
6
+
7
+ export const headerUniversalSection = {
8
+ elementType: 'HeaderUniversal',
9
+ catalog: {
10
+ HeaderUniversal: {
11
+ props: universalHeaderPropsSchema,
12
+ description: 'HeaderUniversal presentation section (delivery header-universal).',
13
+ },
14
+ },
15
+ registryModule: './header-universal.client',
16
+ }
@@ -9,13 +9,14 @@ import type { ViewCatalogEntry } from '../types'
9
9
  import { checkoutCommerceV1Section } from './checkout-commerce-v1'
10
10
  import { ctaSection } from './cta'
11
11
  import { faqSection } from './faq'
12
+ import { headerUniversalSection } from './header-universal'
12
13
  import { marketplaceProductCardSection } from './marketplace-product-card'
13
14
  import { megaMenuUniversalSection } from './mega-menu-universal'
14
15
  import { productsSection } from './products'
15
16
  import { universalBannerSection } from './universal-banner'
16
17
  import { universalMainMenuSection } from './universal-main-menu'
17
18
 
18
- export const sectionModules = [checkoutCommerceV1Section, faqSection, ctaSection, marketplaceProductCardSection, megaMenuUniversalSection, productsSection, universalBannerSection, universalMainMenuSection] as const
19
+ export const sectionModules = [checkoutCommerceV1Section, faqSection, headerUniversalSection, ctaSection, marketplaceProductCardSection, megaMenuUniversalSection, productsSection, universalBannerSection, universalMainMenuSection] as const
19
20
 
20
21
  export const sectionCatalog: Record<string, ViewCatalogEntry> = Object.assign(
21
22
  {},