@thorprovider/storefront 0.15.1 → 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.
- package/assets/templates/app/app/[[...slug]]/page.tsx +16 -4
- package/assets/templates/app/lib/__STOREFRONT__/header-universal.ts +363 -0
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +39 -1
- package/assets/templates/app/lib/__STOREFRONT__/schema.ts +52 -0
- package/assets/templates/app/lib/__STOREFRONT__/shell/content.ts +43 -0
- package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +4 -0
- package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +16 -43
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/header-universal.client.tsx +33 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/header-universal.tsx +16 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +2 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.header-universal.ts +360 -0
- package/package.json +1 -1
- package/recipes/sections.json +18 -0
- package/scripts/candidate.mjs +1 -1
- package/scripts/file-classes.mjs +7 -2
- package/skills/sf-view-gen/assets/recipes/sections.json +18 -0
- package/skills/sf-view-gen/assets/templates/views/sections/header-universal.client.tsx +33 -0
- package/skills/sf-view-gen/assets/templates/views/sections/header-universal.tsx +16 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.header-universal.ts +360 -0
|
@@ -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
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//
|
|
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
|
-
|
|
110
|
-
type: '
|
|
107
|
+
'universal-header': {
|
|
108
|
+
type: 'HeaderUniversal',
|
|
111
109
|
props: {
|
|
112
|
-
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
|
|
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', '
|
|
152
|
+
header: ['banner', 'universal-header'],
|
|
180
153
|
footer: ['footer'],
|
|
181
154
|
},
|
|
182
155
|
children: ['slot'],
|
|
@@ -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
|
{},
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
// Optional section fragment: header-universal (mirrors recipes/sections.json) — shared contract.
|
|
2
|
+
// Zod mirror of the HeaderUniversal block contract (delivery header-universal),
|
|
3
|
+
// shared by the server catalog (header-universal.tsx) and the client registry
|
|
4
|
+
// (header-universal.client.tsx). The React-only callback (`onAction`) is
|
|
5
|
+
// intentionally excluded; the runtime commerce data (`context.cart`,
|
|
6
|
+
// `context.account`, …) is carried through `context` exactly as the host feeds
|
|
7
|
+
// it, so the section serializes the same shape the block renders.
|
|
8
|
+
|
|
9
|
+
import { z } from 'zod'
|
|
10
|
+
import { universalMainMenuDataSchema } from './schema.universal-main-menu'
|
|
11
|
+
|
|
12
|
+
const surfaceToken = z.enum(['transparent', 'background', 'card', 'muted', 'primary', 'accent'])
|
|
13
|
+
const accentToken = z.enum(['none', 'primary', 'accent', 'success'])
|
|
14
|
+
const densityToken = z.enum(['compact', 'comfortable'])
|
|
15
|
+
const radiusToken = z.enum(['none', 'sm', 'md', 'lg', 'xl'])
|
|
16
|
+
const spaceToken = z.enum(['none', 'xs', 'sm', 'md', 'lg', 'xl'])
|
|
17
|
+
const heightToken = z.enum(['xs', 'sm', 'md', 'lg', 'xl'])
|
|
18
|
+
const borderToken = z.enum(['none', 'bottom', 'top', 'all'])
|
|
19
|
+
const shadowToken = z.enum(['none', 'sm', 'md'])
|
|
20
|
+
const positionToken = z.enum(['static', 'sticky', 'fixed'])
|
|
21
|
+
const breakpointToken = z.enum(['base', 'md', '2xl'])
|
|
22
|
+
const zoneName = z.enum(['start', 'center', 'end'])
|
|
23
|
+
const presetId = z.enum(['commerce', 'minimal', 'marketplace', 'b2b', 'checkout', 'landing'])
|
|
24
|
+
const contextKind = z.enum(['guest', 'authenticated', 'b2b', 'checkout', 'landing'])
|
|
25
|
+
const pageKind = z.enum(['home', 'category', 'product', 'checkout', 'account', 'landing'])
|
|
26
|
+
|
|
27
|
+
const moduleType = z.enum([
|
|
28
|
+
'logo',
|
|
29
|
+
'navigation',
|
|
30
|
+
'search',
|
|
31
|
+
'cart',
|
|
32
|
+
'account',
|
|
33
|
+
'wishlist',
|
|
34
|
+
'region',
|
|
35
|
+
'language',
|
|
36
|
+
'location',
|
|
37
|
+
'organization',
|
|
38
|
+
'announcement',
|
|
39
|
+
'promotion-progress',
|
|
40
|
+
'support',
|
|
41
|
+
'notifications',
|
|
42
|
+
'spacer',
|
|
43
|
+
'divider',
|
|
44
|
+
'text-label',
|
|
45
|
+
'custom-link',
|
|
46
|
+
'custom-button',
|
|
47
|
+
'icon-action',
|
|
48
|
+
'main-menu',
|
|
49
|
+
])
|
|
50
|
+
|
|
51
|
+
const capabilityId = z.enum([
|
|
52
|
+
'catalog',
|
|
53
|
+
'catalog-search',
|
|
54
|
+
'checkout',
|
|
55
|
+
'customer-account',
|
|
56
|
+
'saved-items',
|
|
57
|
+
'reviews',
|
|
58
|
+
'recommendations',
|
|
59
|
+
'newsletter',
|
|
60
|
+
'b2b',
|
|
61
|
+
'notifications',
|
|
62
|
+
'promotions',
|
|
63
|
+
'locations',
|
|
64
|
+
])
|
|
65
|
+
|
|
66
|
+
const headerActionName = z.enum([
|
|
67
|
+
'navigate',
|
|
68
|
+
'openCart',
|
|
69
|
+
'closeCart',
|
|
70
|
+
'goToCart',
|
|
71
|
+
'goToCheckout',
|
|
72
|
+
'openSearch',
|
|
73
|
+
'closeSearch',
|
|
74
|
+
'openAccount',
|
|
75
|
+
'closeAccount',
|
|
76
|
+
'openNotifications',
|
|
77
|
+
'login',
|
|
78
|
+
'register',
|
|
79
|
+
'logout',
|
|
80
|
+
'selectRegion',
|
|
81
|
+
'selectLanguage',
|
|
82
|
+
'selectLocation',
|
|
83
|
+
'selectOrganization',
|
|
84
|
+
'openComponent',
|
|
85
|
+
'closeComponent',
|
|
86
|
+
'changeCartQuantity',
|
|
87
|
+
'removeCartLine',
|
|
88
|
+
'selectNotification',
|
|
89
|
+
'dismissAnnouncement',
|
|
90
|
+
])
|
|
91
|
+
|
|
92
|
+
const modulePropsSchema = z.record(z.union([z.string(), z.number(), z.boolean()]))
|
|
93
|
+
|
|
94
|
+
const themeSchema = z.object({
|
|
95
|
+
surface: surfaceToken,
|
|
96
|
+
accent: accentToken,
|
|
97
|
+
density: densityToken,
|
|
98
|
+
radius: radiusToken,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const behaviorSchema = z.object({
|
|
102
|
+
position: positionToken,
|
|
103
|
+
transparent: z.boolean(),
|
|
104
|
+
overHero: z.boolean(),
|
|
105
|
+
scrolledSurface: z.boolean(),
|
|
106
|
+
compactOnScroll: z.boolean(),
|
|
107
|
+
hideOnScrollDown: z.boolean(),
|
|
108
|
+
showOnScrollUp: z.boolean(),
|
|
109
|
+
threshold: z.number(),
|
|
110
|
+
zIndex: z.number(),
|
|
111
|
+
reducedMotion: z.boolean(),
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
const rowStyleSchema = z.object({
|
|
115
|
+
minHeight: heightToken,
|
|
116
|
+
maxHeight: z.union([heightToken, z.literal('none')]),
|
|
117
|
+
paddingX: spaceToken,
|
|
118
|
+
paddingY: spaceToken,
|
|
119
|
+
gap: spaceToken,
|
|
120
|
+
align: z.enum(['start', 'center', 'end']),
|
|
121
|
+
justify: z.enum(['start', 'center', 'between', 'end']),
|
|
122
|
+
maxWidth: z.enum(['full', 'sm', 'md', 'lg', 'xl']),
|
|
123
|
+
surface: surfaceToken,
|
|
124
|
+
border: borderToken,
|
|
125
|
+
shadow: shadowToken,
|
|
126
|
+
separator: z.boolean(),
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
const headerActionSchema = z.object({
|
|
130
|
+
name: headerActionName,
|
|
131
|
+
payload: modulePropsSchema.optional(),
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
const moduleSchema = z.object({
|
|
135
|
+
id: z.string(),
|
|
136
|
+
type: moduleType,
|
|
137
|
+
enabled: z.boolean(),
|
|
138
|
+
requires: capabilityId.optional(),
|
|
139
|
+
props: modulePropsSchema,
|
|
140
|
+
style: z
|
|
141
|
+
.object({
|
|
142
|
+
surface: surfaceToken.optional(),
|
|
143
|
+
size: z.enum(['sm', 'md', 'lg']).optional(),
|
|
144
|
+
emphasis: z.enum(['none', 'accent']).optional(),
|
|
145
|
+
})
|
|
146
|
+
.optional(),
|
|
147
|
+
visibility: z
|
|
148
|
+
.object({
|
|
149
|
+
breakpoints: z.array(breakpointToken).optional(),
|
|
150
|
+
contexts: z.array(contextKind).optional(),
|
|
151
|
+
})
|
|
152
|
+
.optional(),
|
|
153
|
+
responsive: z
|
|
154
|
+
.record(
|
|
155
|
+
breakpointToken,
|
|
156
|
+
z.object({
|
|
157
|
+
row: z.string().optional(),
|
|
158
|
+
zone: zoneName.optional(),
|
|
159
|
+
order: z.number().optional(),
|
|
160
|
+
hidden: z.boolean().optional(),
|
|
161
|
+
props: modulePropsSchema.optional(),
|
|
162
|
+
}),
|
|
163
|
+
)
|
|
164
|
+
.optional(),
|
|
165
|
+
bindings: z.record(z.string(), z.string()).optional(),
|
|
166
|
+
actions: z.record(z.string(), headerActionSchema).optional(),
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
const rowSchema = rowStyleSchema.extend({
|
|
170
|
+
id: z.string(),
|
|
171
|
+
enabled: z.boolean(),
|
|
172
|
+
zones: z.record(zoneName, z.array(z.string())),
|
|
173
|
+
responsive: z
|
|
174
|
+
.record(
|
|
175
|
+
breakpointToken,
|
|
176
|
+
rowStyleSchema
|
|
177
|
+
.partial()
|
|
178
|
+
.extend({
|
|
179
|
+
zones: z.record(zoneName, z.array(z.string()).optional()).optional(),
|
|
180
|
+
hidden: z.boolean().optional(),
|
|
181
|
+
}),
|
|
182
|
+
)
|
|
183
|
+
.optional(),
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
const visibilityRuleSchema = z.object({
|
|
187
|
+
id: z.string(),
|
|
188
|
+
target: z.object({
|
|
189
|
+
rows: z.array(z.string()).optional(),
|
|
190
|
+
modules: z.array(z.string()).optional(),
|
|
191
|
+
}),
|
|
192
|
+
when: z.object({
|
|
193
|
+
capability: capabilityId.optional(),
|
|
194
|
+
context: contextKind.optional(),
|
|
195
|
+
page: pageKind.optional(),
|
|
196
|
+
from: z.string().optional(),
|
|
197
|
+
to: z.string().optional(),
|
|
198
|
+
}),
|
|
199
|
+
mode: z.literal('hide'),
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
export const headerConfigSchema = z.object({
|
|
203
|
+
schemaVersion: z.number(),
|
|
204
|
+
id: z.string(),
|
|
205
|
+
name: z.string(),
|
|
206
|
+
preset: presetId,
|
|
207
|
+
theme: themeSchema,
|
|
208
|
+
behavior: behaviorSchema,
|
|
209
|
+
layout: z.array(rowSchema),
|
|
210
|
+
modules: z.array(moduleSchema),
|
|
211
|
+
capabilities: z.record(capabilityId, z.boolean().optional()),
|
|
212
|
+
visibilityRules: z.array(visibilityRuleSchema),
|
|
213
|
+
fallbacks: z.object({
|
|
214
|
+
missingCapability: z.enum(['hide', 'placeholder']),
|
|
215
|
+
missingImage: z.enum(['fallback', 'label']),
|
|
216
|
+
missingAction: z.enum(['disable', 'hide']),
|
|
217
|
+
}),
|
|
218
|
+
analytics: z.object({ events: z.array(z.string()) }).optional(),
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
const moneySchema = z.object({ amount: z.string(), currencyCode: z.string() })
|
|
222
|
+
|
|
223
|
+
const brandSchema = z.object({
|
|
224
|
+
name: z.string(),
|
|
225
|
+
href: z.string(),
|
|
226
|
+
logo: z.string().optional(),
|
|
227
|
+
logoLight: z.string().optional(),
|
|
228
|
+
logoDark: z.string().optional(),
|
|
229
|
+
accent: z.string().optional(),
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
const cartStateKind = z.enum(['ready', 'empty', 'loading', 'error'])
|
|
233
|
+
const accountStateKind = z.enum(['guest', 'authenticated', 'loading', 'expired', 'error'])
|
|
234
|
+
|
|
235
|
+
const cartLineSchema = z.object({
|
|
236
|
+
id: z.string(),
|
|
237
|
+
name: z.string(),
|
|
238
|
+
price: z.number(),
|
|
239
|
+
quantity: z.number(),
|
|
240
|
+
variant: z.string().optional(),
|
|
241
|
+
image: z.string().optional(),
|
|
242
|
+
unitPrice: moneySchema.optional(),
|
|
243
|
+
lineTotal: moneySchema.optional(),
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
const headerCartSchema = z.object({
|
|
247
|
+
state: cartStateKind,
|
|
248
|
+
lines: z.array(cartLineSchema),
|
|
249
|
+
totals: z
|
|
250
|
+
.object({
|
|
251
|
+
subtotal: moneySchema,
|
|
252
|
+
total: moneySchema,
|
|
253
|
+
discount: moneySchema.optional(),
|
|
254
|
+
tax: moneySchema.optional(),
|
|
255
|
+
shipping: moneySchema.optional(),
|
|
256
|
+
})
|
|
257
|
+
.optional(),
|
|
258
|
+
quantity: z.number(),
|
|
259
|
+
lineCount: z.number(),
|
|
260
|
+
currency: z.string(),
|
|
261
|
+
shippingGroups: z.number(),
|
|
262
|
+
shippingNote: z.string().optional(),
|
|
263
|
+
subtotalUnavailableLabel: z.string(),
|
|
264
|
+
promotions: z.array(z.string()),
|
|
265
|
+
error: z.string().optional(),
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
const accountUserSchema = z.object({
|
|
269
|
+
email: z.string(),
|
|
270
|
+
name: z.string(),
|
|
271
|
+
initials: z.string(),
|
|
272
|
+
avatar: z.string().optional(),
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
const accountMenuItemSchema = z.object({
|
|
276
|
+
label: z.string(),
|
|
277
|
+
href: z.string(),
|
|
278
|
+
icon: z.enum(['orders', 'wishlist', 'addresses', 'settings']).optional(),
|
|
279
|
+
description: z.string().optional(),
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
const headerAccountSchema = z.object({
|
|
283
|
+
state: accountStateKind,
|
|
284
|
+
user: accountUserSchema.optional(),
|
|
285
|
+
menu: z.array(accountMenuItemSchema),
|
|
286
|
+
error: z.string().optional(),
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
const headerContextSchema = z.object({
|
|
290
|
+
brand: brandSchema,
|
|
291
|
+
menu: universalMainMenuDataSchema.optional(),
|
|
292
|
+
cart: headerCartSchema,
|
|
293
|
+
account: headerAccountSchema,
|
|
294
|
+
wishlist: z.object({ count: z.number(), lists: z.number() }),
|
|
295
|
+
regions: z.object({
|
|
296
|
+
activeId: z.string(),
|
|
297
|
+
options: z.array(z.object({ id: z.string(), label: z.string(), currencyCode: z.string() })),
|
|
298
|
+
}),
|
|
299
|
+
languages: z.object({
|
|
300
|
+
activeCode: z.string(),
|
|
301
|
+
options: z.array(z.object({ code: z.string(), label: z.string() })),
|
|
302
|
+
}),
|
|
303
|
+
locations: z.object({
|
|
304
|
+
activeId: z.string().optional(),
|
|
305
|
+
enabled: z.boolean(),
|
|
306
|
+
options: z.array(z.object({ id: z.string(), label: z.string(), detail: z.string().optional() })),
|
|
307
|
+
}),
|
|
308
|
+
organization: z
|
|
309
|
+
.object({
|
|
310
|
+
activeId: z.string(),
|
|
311
|
+
options: z.array(
|
|
312
|
+
z.object({
|
|
313
|
+
id: z.string(),
|
|
314
|
+
name: z.string(),
|
|
315
|
+
role: z.string(),
|
|
316
|
+
permissions: z.array(z.string()),
|
|
317
|
+
}),
|
|
318
|
+
),
|
|
319
|
+
})
|
|
320
|
+
.optional(),
|
|
321
|
+
announcements: z.array(
|
|
322
|
+
z.object({
|
|
323
|
+
id: z.string(),
|
|
324
|
+
message: z.string(),
|
|
325
|
+
href: z.string().optional(),
|
|
326
|
+
linkLabel: z.string().optional(),
|
|
327
|
+
tone: z.enum(['info', 'accent', 'muted']),
|
|
328
|
+
from: z.string().optional(),
|
|
329
|
+
to: z.string().optional(),
|
|
330
|
+
dismissible: z.boolean(),
|
|
331
|
+
}),
|
|
332
|
+
),
|
|
333
|
+
promotion: z
|
|
334
|
+
.object({
|
|
335
|
+
state: z.enum(['not-eligible', 'in-progress', 'complete']),
|
|
336
|
+
threshold: z.string().optional(),
|
|
337
|
+
current: z.string().optional(),
|
|
338
|
+
remaining: z.string().optional(),
|
|
339
|
+
message: z.string().optional(),
|
|
340
|
+
})
|
|
341
|
+
.optional(),
|
|
342
|
+
notifications: z.object({
|
|
343
|
+
available: z.boolean(),
|
|
344
|
+
unread: z.number(),
|
|
345
|
+
items: z.array(z.object({ id: z.string(), title: z.string(), href: z.string(), read: z.boolean() })),
|
|
346
|
+
}),
|
|
347
|
+
openComponents: z.array(z.string()),
|
|
348
|
+
now: z.string(),
|
|
349
|
+
capabilities: z.record(capabilityId, z.boolean().optional()),
|
|
350
|
+
context: contextKind,
|
|
351
|
+
page: pageKind,
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
export const universalHeaderPropsSchema = z.object({
|
|
355
|
+
config: headerConfigSchema,
|
|
356
|
+
context: headerContextSchema,
|
|
357
|
+
labels: z.record(z.string(), z.record(z.string(), z.string())).optional(),
|
|
358
|
+
breakpoint: breakpointToken.optional(),
|
|
359
|
+
className: z.string().optional(),
|
|
360
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thorprovider/storefront",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "Deterministic storefront scaffolder and installable OpenCode skill suite for Thor Commerce (Next.js, @thorprovider/blocks, @thorprovider/adapters, Medusa)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "bin/storefront.js",
|
package/recipes/sections.json
CHANGED
|
@@ -366,6 +366,24 @@
|
|
|
366
366
|
"propsHint": "data (categories[], config, labels, promotion, preview)",
|
|
367
367
|
"status": "executable",
|
|
368
368
|
"agent": {"status":"pending","section":"universal-main-menu","elementType":"UniversalMainMenu","variants":["UniversalMainMenu"],"kind":"pending-card","reason":"The menu's data is the shop's catalog taxonomy; an agent-editable card needs a reviewed authoring contract for recursive category trees before automatic configuration is enabled.","owner":"design intake — universal-main-menu"}
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
"name": "header-universal",
|
|
372
|
+
"description": "HeaderUniversal presentation section (delivery header-universal).",
|
|
373
|
+
"elementType": "HeaderUniversal",
|
|
374
|
+
"variants": ["HeaderUniversal"],
|
|
375
|
+
"defaultVariant": "HeaderUniversal",
|
|
376
|
+
"propsHint": "config (header configuration), context (brand, menu, capabilities)",
|
|
377
|
+
"status": "executable",
|
|
378
|
+
"agent": {
|
|
379
|
+
"status": "exempt",
|
|
380
|
+
"section": "header-universal",
|
|
381
|
+
"elementType": "HeaderUniversal",
|
|
382
|
+
"variants": ["HeaderUniversal"],
|
|
383
|
+
"kind": "host-only",
|
|
384
|
+
"reason": "The header and its menu are storefront-shell concerns: the header is the shop's navigation chrome and its menu data is the host's catalog taxonomy, so this section must be configured by the host rather than selected as page content.",
|
|
385
|
+
"owner": "Wave 1 — storefront shell"
|
|
386
|
+
}
|
|
369
387
|
}
|
|
370
388
|
]
|
|
371
389
|
}
|
package/scripts/candidate.mjs
CHANGED
|
@@ -47,7 +47,7 @@ export const CANDIDATE_TOOLSET = Object.freeze({
|
|
|
47
47
|
'@json-render/next': '0.21.0',
|
|
48
48
|
}),
|
|
49
49
|
local: Object.freeze({
|
|
50
|
-
'@thorprovider/blocks': '4.
|
|
50
|
+
'@thorprovider/blocks': '4.10.0',
|
|
51
51
|
'@thorprovider/adapters': '5.8.1',
|
|
52
52
|
'@thorprovider/runtime': '0.10.0',
|
|
53
53
|
'@thorprovider/types': '7.8.0',
|
package/scripts/file-classes.mjs
CHANGED
|
@@ -64,6 +64,9 @@ const RULES = [
|
|
|
64
64
|
// The footer content contract and its neutral defaults are package-owned;
|
|
65
65
|
// a merchant overrides copy through the user-owned shell content seam.
|
|
66
66
|
'app/lib/*/footer-content.ts',
|
|
67
|
+
// The universal header's authored config and menu builder are package-owned
|
|
68
|
+
// shell chrome, not merchant content.
|
|
69
|
+
'app/lib/*/header-universal.ts',
|
|
67
70
|
'app/lib/*/account-lifecycle.client.tsx',
|
|
68
71
|
'app/lib/*/account-boundary.client.tsx',
|
|
69
72
|
'app/lib/*/account-mutation.client.ts',
|
|
@@ -74,8 +77,7 @@ const RULES = [
|
|
|
74
77
|
'app/lib/*/commerce.ts',
|
|
75
78
|
'app/lib/*/ports.ts',
|
|
76
79
|
'app/lib/*/orders-port.ts',
|
|
77
|
-
'app/lib/*/order-detail
|
|
78
|
-
'app/lib/*/order-detail-mapper.ts',
|
|
80
|
+
'app/lib/*/order-detail-*.ts',
|
|
79
81
|
'app/lib/*/fulfillment-evidence-port.ts',
|
|
80
82
|
'app/lib/*/addresses-port.ts',
|
|
81
83
|
'app/lib/*/customer-profile-port.ts',
|
|
@@ -98,6 +100,9 @@ const RULES = [
|
|
|
98
100
|
'views/*/registry.tsx',
|
|
99
101
|
'views/*/orders-advanced.client.tsx',
|
|
100
102
|
'views/*/order-detail.client.tsx',
|
|
103
|
+
'views/*/order-detail-invoice.ts',
|
|
104
|
+
'views/*/order-detail-sheet.tsx',
|
|
105
|
+
'views/*/order-detail-sheets.tsx',
|
|
101
106
|
'views/*/fulfillment-evidence.client.tsx',
|
|
102
107
|
'views/*/fulfillment-evidence.schema.ts',
|
|
103
108
|
'views/*/*.defaults.ts',
|
|
@@ -366,6 +366,24 @@
|
|
|
366
366
|
"propsHint": "data (categories[], config, labels, promotion, preview)",
|
|
367
367
|
"status": "executable",
|
|
368
368
|
"agent": {"status":"pending","section":"universal-main-menu","elementType":"UniversalMainMenu","variants":["UniversalMainMenu"],"kind":"pending-card","reason":"The menu's data is the shop's catalog taxonomy; an agent-editable card needs a reviewed authoring contract for recursive category trees before automatic configuration is enabled.","owner":"design intake — universal-main-menu"}
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
"name": "header-universal",
|
|
372
|
+
"description": "HeaderUniversal presentation section (delivery header-universal).",
|
|
373
|
+
"elementType": "HeaderUniversal",
|
|
374
|
+
"variants": ["HeaderUniversal"],
|
|
375
|
+
"defaultVariant": "HeaderUniversal",
|
|
376
|
+
"propsHint": "config (header configuration), context (brand, menu, capabilities)",
|
|
377
|
+
"status": "executable",
|
|
378
|
+
"agent": {
|
|
379
|
+
"status": "exempt",
|
|
380
|
+
"section": "header-universal",
|
|
381
|
+
"elementType": "HeaderUniversal",
|
|
382
|
+
"variants": ["HeaderUniversal"],
|
|
383
|
+
"kind": "host-only",
|
|
384
|
+
"reason": "The header and its menu are storefront-shell concerns: the header is the shop's navigation chrome and its menu data is the host's catalog taxonomy, so this section must be configured by the host rather than selected as page content.",
|
|
385
|
+
"owner": "Wave 1 — storefront shell"
|
|
386
|
+
}
|
|
369
387
|
}
|
|
370
388
|
]
|
|
371
389
|
}
|
|
@@ -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
|
+
}
|