@thorprovider/storefront 0.4.0 → 0.5.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/README.md +3 -1
- package/assets/templates/app/app/[[...slug]]/page.tsx +19 -1
- package/assets/templates/app/lib/__STOREFRONT__/composition.ts +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +15 -13
- package/assets/templates/app/lib/__STOREFRONT__/schema.ts +34 -4
- package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +3 -8
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/testimonials.tsx +26 -19
- package/assets/templates/features/checkout/state.ts +0 -5
- package/assets/templates/views/account/registry.tsx +72 -43
- package/assets/templates/views/account/schema.ts +1 -1
- package/assets/templates/views/category/assembly/assembly.json +1 -1
- package/assets/templates/views/category/assembly/index.skeleton.tsx +11 -7
- package/assets/templates/views/category/assembly/registry.skeleton.tsx +8 -8
- package/assets/templates/views/category/assembly/slots/filter/CategoryListing/catalog.part +5 -0
- package/assets/templates/views/category/assembly/slots/filter/{CategoryFilter2 → CategoryListing}/element.part +5 -3
- package/assets/templates/views/category/assembly/slots/filter/{CategoryFilter2 → CategoryListing}/registry.part +9 -5
- package/assets/templates/views/category/content.ts +2 -1
- package/assets/templates/views/category/index.tsx +19 -13
- package/assets/templates/views/category/props.ts +1 -1
- package/assets/templates/views/category/registry.tsx +17 -13
- package/assets/templates/views/category/schema.ts +48 -21
- package/assets/templates/views/checkout/content.ts +60 -0
- package/assets/templates/views/checkout/props.ts +4 -5
- package/assets/templates/views/checkout/registry.tsx +10 -6
- package/assets/templates/views/checkout/schema.ts +10 -16
- package/assets/templates/views/home/assembly/index.skeleton.tsx +0 -2
- package/assets/templates/views/home/index.tsx +0 -2
- package/examples/merchandising/category-led.json +1 -1
- package/examples/merchandising/collection-led.json +1 -1
- package/package.json +1 -1
- package/recipes/archetypes.json +14 -18
- package/recipes/catalog.json +27 -70
- package/recipes/features.json +2 -2
- package/recipes/recipes.json +7 -11
- package/recipes/sections.json +2 -2
- package/scripts/composers.mjs +2 -2
- package/scripts/logical-controls.mjs +4 -4
- package/scripts/operation-registry.mjs +1 -1
- package/scripts/view-assembly.mjs +2 -2
- package/skills/sf-view-gen/assets/recipes/archetypes.json +14 -18
- package/skills/sf-view-gen/assets/recipes/catalog.json +27 -70
- package/skills/sf-view-gen/assets/recipes/features.json +2 -2
- package/skills/sf-view-gen/assets/recipes/recipes.json +7 -11
- package/skills/sf-view-gen/assets/recipes/sections.json +2 -2
- package/skills/sf-view-gen/assets/templates/views/sections/schema.testimonials.ts +21 -11
- package/skills/sf-view-gen/assets/templates/views/sections/testimonials.client.tsx +2 -8
- package/assets/templates/views/category/assembly/slots/filter/CategoryFilter2/catalog.part +0 -5
package/README.md
CHANGED
|
@@ -453,6 +453,8 @@ surface and footer copy are configured without touching derived files. Configure
|
|
|
453
453
|
and the scaffold ships no submit callback, so a content-only newsletter renders no form
|
|
454
454
|
— never a fake form. `shippingNote` defaults to `''`: while it is empty (and there are
|
|
455
455
|
no utility links) the navbar renders no utility strip, so no placeholder note is shown.
|
|
456
|
+
The generated footer uses canonical `FooterSection` with `brand-columns` and
|
|
457
|
+
native link behavior; numbered footer adapters are no longer part of the Blocks API.
|
|
456
458
|
|
|
457
459
|
A view's derived `index.tsx` imports the user-owned `content.ts`/`props.ts`/
|
|
458
460
|
`data.ts`, so a customization changes real spec/loader output and survives `sync`.
|
|
@@ -497,4 +499,4 @@ of the contract with consumers: revisit them whenever the CLI surface changes
|
|
|
497
499
|
(flags, actions, validation) or the scaffold's preconditions change (target-directory
|
|
498
500
|
rules, linker, backend variables), and update the corresponding entry in
|
|
499
501
|
`packages/storefront/README.md`. The packaging test suite asserts these
|
|
500
|
-
sections and that every failure-mode entry carries a remedy.
|
|
502
|
+
sections and that every failure-mode entry carries a remedy.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { notFound } from 'next/navigation'
|
|
4
4
|
import { buildBreadcrumbListJsonLd, serializeJsonLd } from '@thorprovider/runtime/contracts'
|
|
5
|
+
import { getCatalog } from '@thorprovider/runtime/commerce'
|
|
5
6
|
import { __STOREFRONT_CAMEL__App } from '@/lib/__STOREFRONT__/runtime'
|
|
6
7
|
import { readCartStateForRender } from '@/lib/__STOREFRONT__/cart-state'
|
|
7
8
|
import { readAccountSession } from '@/lib/__STOREFRONT__/account-session'
|
|
@@ -23,6 +24,18 @@ export default async function Page({
|
|
|
23
24
|
const data = await __STOREFRONT_CAMEL__App.getPageData({ params, searchParams })
|
|
24
25
|
if (!data) return notFound()
|
|
25
26
|
|
|
27
|
+
// The shared shell is rendered for every route, so resolve its category links
|
|
28
|
+
// here rather than relying on a particular view loader. `getCatalog()` is
|
|
29
|
+
// request-cached by the commerce bridge and is shared with the view loader.
|
|
30
|
+
let navCategories: { label: string; href: string }[] = []
|
|
31
|
+
try {
|
|
32
|
+
navCategories = (await getCatalog()).categories.map(({ label, href }) => ({ label, href }))
|
|
33
|
+
} catch (error) {
|
|
34
|
+
// A failed catalog read must not invent links or take down otherwise usable
|
|
35
|
+
// page content; keep the shell empty and leave a diagnostic for operators.
|
|
36
|
+
console.error('[storefront] Failed to resolve shared navigation categories', error)
|
|
37
|
+
}
|
|
38
|
+
|
|
26
39
|
// Read the signed cookie and load the backend cart for the initial render.
|
|
27
40
|
// This never creates a cart; a guest identity is issued by a Server Action.
|
|
28
41
|
const cartState = await readCartStateForRender()
|
|
@@ -36,7 +49,12 @@ export default async function Page({
|
|
|
36
49
|
? toAccountInitialState(await readAccountSession())
|
|
37
50
|
: {}
|
|
38
51
|
|
|
39
|
-
const initialState = {
|
|
52
|
+
const initialState = {
|
|
53
|
+
...(data.initialState ?? {}),
|
|
54
|
+
navCategories,
|
|
55
|
+
...cartState,
|
|
56
|
+
...accountState,
|
|
57
|
+
}
|
|
40
58
|
|
|
41
59
|
// Entity structured data is server-rendered from the real loaded entity and
|
|
42
60
|
// sanitized so entity text cannot terminate the script element.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Installed manifest catalog features, in stable order, with their persisted
|
|
4
4
|
// config. This is the generation seam the catalog URL boundary consumes to
|
|
5
5
|
// reject parameters owned by a feature that is not installed, and the seam the
|
|
6
|
-
// single controlled
|
|
6
|
+
// single controlled CategoryListing reads to select its control
|
|
7
7
|
// visibility/config from the installed manifest only.
|
|
8
8
|
|
|
9
9
|
import type { CatalogFeatureName } from '@thorprovider/runtime/contracts'
|
|
@@ -3,7 +3,7 @@
|
|
|
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 shell renders the live backend cart: the
|
|
6
|
+
// The shell renders the live backend cart: the StorefrontNavbar mini-cart and the cart
|
|
7
7
|
// drawer read the authoritative cart state and dispatch cart mutations to the
|
|
8
8
|
// Server Actions. A listing card's add-to-cart adds the product's first
|
|
9
9
|
// purchasable variant (the card shortcut); opening a product from a listing
|
|
@@ -16,9 +16,7 @@ import { BackToTop as BackToTopBlock } from '@thorprovider/blocks/blocks/e-comme
|
|
|
16
16
|
import { MobileBottomNav as MobileBottomNavBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
|
|
17
17
|
import { SkipToContent as SkipToContentBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/skip-to-content'
|
|
18
18
|
import Banner1 from '@thorprovider/blocks/blocks/marketing/banners/banner-1'
|
|
19
|
-
import
|
|
20
|
-
import Navbar1 from '@thorprovider/blocks/blocks/marketing/navbars/navbar-1'
|
|
21
|
-
import Navbar4 from '@thorprovider/blocks/blocks/marketing/navbars/navbar-4'
|
|
19
|
+
import { FooterSection, Navbar, StorefrontNavbar } from '@thorprovider/blocks'
|
|
22
20
|
import { ProductGrid as ProductGridBlock } from '@thorprovider/blocks/blocks/e-commerce/product-list/product-grid'
|
|
23
21
|
import type { BackToTopProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/back-to-top'
|
|
24
22
|
import type { MobileBottomNavProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
|
|
@@ -40,7 +38,7 @@ import {
|
|
|
40
38
|
} from './schema'
|
|
41
39
|
import { viewRegistries } from './views/registry'
|
|
42
40
|
|
|
43
|
-
//
|
|
41
|
+
// StorefrontNavbar accepts its own mini-cart line shape (`qty`), distinct from the block
|
|
44
42
|
// `CartItem` contract (`quantity`). Types are local so the asymmetry is explicit.
|
|
45
43
|
interface NavCartItem {
|
|
46
44
|
id: string
|
|
@@ -52,7 +50,7 @@ interface NavCartItem {
|
|
|
52
50
|
lineTotal?: Money
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
/** CartLineState ->
|
|
53
|
+
/** CartLineState -> StorefrontNavbar cart line. `price` is legacy; the authoritative
|
|
56
54
|
* subtotal and per-line total are passed separately, so neither is computed
|
|
57
55
|
* from the line. */
|
|
58
56
|
function toNavCartItems(cart: CartLineState[]): NavCartItem[] {
|
|
@@ -179,7 +177,7 @@ const baseComponents = {
|
|
|
179
177
|
isAvailableMoney(totals.subtotal) &&
|
|
180
178
|
isAvailableMoney(totals.total)
|
|
181
179
|
return (
|
|
182
|
-
<
|
|
180
|
+
<StorefrontNavbar
|
|
183
181
|
storeCategories={parsed.storeCategories}
|
|
184
182
|
shippingNote={parsed.shippingNote}
|
|
185
183
|
utilityLinks={parsed.utilityLinks}
|
|
@@ -259,18 +257,20 @@ const baseComponents = {
|
|
|
259
257
|
/>
|
|
260
258
|
)
|
|
261
259
|
},
|
|
262
|
-
Navbar: ({ props
|
|
260
|
+
Navbar: ({ props }: { props: Record<string, unknown>; emit: (event: string) => void }) => {
|
|
263
261
|
const parsed = navbarPropsSchema.parse(props)
|
|
264
262
|
return (
|
|
265
|
-
<
|
|
266
|
-
|
|
263
|
+
<Navbar
|
|
264
|
+
presentation={parsed.presentation}
|
|
267
265
|
logoText={parsed.logoText}
|
|
268
266
|
logoHref={parsed.logoHref}
|
|
269
267
|
currentPath={parsed.currentPath}
|
|
268
|
+
links={parsed.links}
|
|
269
|
+
featured={parsed.featured}
|
|
270
270
|
signIn={parsed.signIn}
|
|
271
271
|
cta={parsed.cta}
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
// Page-level navigation owns no commerce state: the cart affordance and
|
|
273
|
+
// its `openCart` intent belong to the StorefrontNavbar shell (D5).
|
|
274
274
|
/>
|
|
275
275
|
)
|
|
276
276
|
},
|
|
@@ -307,12 +307,14 @@ const baseComponents = {
|
|
|
307
307
|
Footer: ({ props }: { props: Record<string, unknown> }) => {
|
|
308
308
|
const parsed = footerPropsSchema.parse(props)
|
|
309
309
|
return (
|
|
310
|
-
<
|
|
310
|
+
<FooterSection
|
|
311
|
+
presentation="brand-columns"
|
|
311
312
|
brandName={parsed.brandName}
|
|
312
313
|
brandAccent={parsed.brandAccent}
|
|
313
314
|
brandDescription={parsed.brandDescription}
|
|
314
315
|
linkColumns={parsed.linkColumns}
|
|
315
316
|
className={parsed.className}
|
|
317
|
+
linkBehavior="native"
|
|
316
318
|
// The scaffold ships no newsletter submit callback. The seam's
|
|
317
319
|
// `newsletter` is content only, so the block swallows it and renders no
|
|
318
320
|
// form. Wiring a real host callback (which would enable the form) is an
|
|
@@ -11,9 +11,34 @@ export const ctaSchema = z.object({
|
|
|
11
11
|
href: z.string().optional(),
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const navbarItemSchema = z.object({
|
|
15
|
+
label: z.string(),
|
|
16
|
+
href: z.string(),
|
|
17
|
+
description: z.string().optional(),
|
|
18
|
+
/** Key resolved through the shell's host-bound icon map. */
|
|
19
|
+
icon: z.string().optional(),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export const navbarGroupSchema = z.object({
|
|
23
|
+
title: z.string().optional(),
|
|
24
|
+
items: z.array(navbarItemSchema),
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const navbarLinkSchema = z.object({
|
|
15
28
|
label: z.string(),
|
|
16
29
|
href: z.string().optional(),
|
|
30
|
+
groups: z.array(navbarGroupSchema).optional(),
|
|
31
|
+
emphasis: z.boolean().optional(),
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
export const navbarFeaturedSchema = z.object({
|
|
35
|
+
eyebrow: z.string(),
|
|
36
|
+
title: z.string(),
|
|
37
|
+
description: z.string().optional(),
|
|
38
|
+
href: z.string(),
|
|
39
|
+
linkLabel: z.string().optional(),
|
|
40
|
+
image: z.string().optional(),
|
|
41
|
+
imageAlt: z.string().optional(),
|
|
17
42
|
})
|
|
18
43
|
|
|
19
44
|
const footerLinkSchema = z.object({
|
|
@@ -45,14 +70,19 @@ export const productPresentationSchema = z.object({
|
|
|
45
70
|
badge: z.string().optional(),
|
|
46
71
|
})
|
|
47
72
|
|
|
73
|
+
// Mirrors the canonical page-level `Navbar` contract. Presentation is bounded to
|
|
74
|
+
// `bar`/`mega`/`floating`; the cart and account affordances belong to the
|
|
75
|
+
// `StorefrontNavbar` shell below, so no cart prop exists here.
|
|
48
76
|
export const navbarPropsSchema = z.object({
|
|
49
|
-
|
|
77
|
+
presentation: z.enum(['bar', 'mega', 'floating']).optional(),
|
|
50
78
|
logoText: z.string(),
|
|
51
79
|
logoHref: z.string().optional(),
|
|
52
80
|
currentPath: z.string().optional(),
|
|
81
|
+
links: z.array(navbarLinkSchema),
|
|
82
|
+
featured: navbarFeaturedSchema.optional(),
|
|
53
83
|
signIn: ctaSchema.optional(),
|
|
54
84
|
cta: ctaSchema.optional(),
|
|
55
|
-
|
|
85
|
+
className: z.string().optional(),
|
|
56
86
|
})
|
|
57
87
|
|
|
58
88
|
// Mirrors the StorefrontNavbar block contract in this scaffold. `storeCategories`
|
|
@@ -65,7 +95,7 @@ export const navCategorySchema = z.object({
|
|
|
65
95
|
emphasis: z.boolean().optional(),
|
|
66
96
|
})
|
|
67
97
|
|
|
68
|
-
// Optional brand seam mirroring the Navbar4 /
|
|
98
|
+
// Optional brand seam mirroring the Navbar4 / FooterSection accent props and
|
|
69
99
|
// the StorefrontHero editorial image. Declared locally (see
|
|
70
100
|
// productPresentationSchema) so the scaffold's zod version is the only one in
|
|
71
101
|
// play.
|
|
@@ -24,7 +24,7 @@ export const navbarShellProps = {
|
|
|
24
24
|
// Global navigation search is held until a verified backend search contract
|
|
25
25
|
// exists (E2 task 5.4), so the generated storefront presents NO search
|
|
26
26
|
// control. A merchant may set this to `true` to opt in once the contract is
|
|
27
|
-
// verified; the `
|
|
27
|
+
// verified; the `StorefrontNavbar` block still defaults to visible for legacy
|
|
28
28
|
// consumers that do not set this prop.
|
|
29
29
|
showSearch: false,
|
|
30
30
|
}
|
|
@@ -52,7 +52,7 @@ export interface CartTotalsState {
|
|
|
52
52
|
total: Money
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/** Mirrors the
|
|
55
|
+
/** Mirrors the canonical Checkout values contract (no card fields). */
|
|
56
56
|
export interface CheckoutFormData {
|
|
57
57
|
email: string
|
|
58
58
|
firstName: string
|
|
@@ -64,12 +64,7 @@ export interface CheckoutFormData {
|
|
|
64
64
|
zipCode: string
|
|
65
65
|
country: string
|
|
66
66
|
paymentMethod: string
|
|
67
|
-
cardNumber: string
|
|
68
|
-
expiryDate: string
|
|
69
|
-
cvv: string
|
|
70
|
-
cardName: string
|
|
71
67
|
saveInfo: boolean
|
|
72
|
-
sameAsBilling: boolean
|
|
73
68
|
newsletter: boolean
|
|
74
69
|
promoCode: string
|
|
75
70
|
}
|
|
@@ -167,7 +162,8 @@ export interface StorefrontCoreState {
|
|
|
167
162
|
heroProducts: FeaturedProduct[]
|
|
168
163
|
categories: ProductCategoryItem[]
|
|
169
164
|
categoryQuery: string
|
|
170
|
-
|
|
165
|
+
/** Seeded by the catch-all host so a missing navigation source cannot look empty. */
|
|
166
|
+
navCategories?: NavCategory[]
|
|
171
167
|
categoryProducts: CardProduct[]
|
|
172
168
|
/** Canonical product detail: real variants, options, availability, and Money. */
|
|
173
169
|
selectedProduct: ProductDetailProduct | null
|
|
@@ -231,7 +227,6 @@ export const storefrontCoreState: StorefrontCoreState = {
|
|
|
231
227
|
heroProducts: [],
|
|
232
228
|
categories: [],
|
|
233
229
|
categoryQuery: '',
|
|
234
|
-
navCategories: [],
|
|
235
230
|
categoryProducts: [],
|
|
236
231
|
selectedProduct: null,
|
|
237
232
|
selectedVariantId: null,
|
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
// Optional section fragment: testimonials (mirrors recipes/sections.json)
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { TestimonialSection } from '@thorprovider/blocks'
|
|
4
4
|
import { z } from 'zod'
|
|
5
5
|
|
|
6
|
-
// Mirrors the Testimonial1Item/Testimonial1Props block contracts.
|
|
7
6
|
const testimonialItemSchema = z.object({
|
|
8
7
|
id: z.string(),
|
|
9
8
|
name: z.string(),
|
|
10
|
-
role: z.string(),
|
|
11
|
-
avatar: z.string(),
|
|
12
9
|
content: z.string(),
|
|
13
|
-
|
|
10
|
+
role: z.string().optional(),
|
|
11
|
+
avatar: z.string().optional(),
|
|
12
|
+
rating: z.number().optional(),
|
|
14
13
|
})
|
|
15
14
|
|
|
16
|
-
const testimonialsPropsSchema = z.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
const testimonialsPropsSchema = z.discriminatedUnion('presentation', [
|
|
16
|
+
z.object({
|
|
17
|
+
presentation: z.literal('carousel'),
|
|
18
|
+
carouselLabels: z.object({
|
|
19
|
+
previous: z.string(),
|
|
20
|
+
next: z.string(),
|
|
21
|
+
slide: z.string(),
|
|
22
|
+
}),
|
|
23
|
+
items: z.array(testimonialItemSchema),
|
|
24
|
+
title: z.string().optional(),
|
|
25
|
+
description: z.string().optional(),
|
|
26
|
+
className: z.string().optional(),
|
|
27
|
+
}),
|
|
28
|
+
z.object({
|
|
29
|
+
presentation: z.literal('bento'),
|
|
30
|
+
items: z.array(testimonialItemSchema),
|
|
31
|
+
title: z.string().optional(),
|
|
32
|
+
description: z.string().optional(),
|
|
33
|
+
className: z.string().optional(),
|
|
34
|
+
}),
|
|
35
|
+
])
|
|
23
36
|
|
|
24
37
|
export const testimonialsSection = {
|
|
25
38
|
elementType: 'Testimonials',
|
|
@@ -33,13 +46,7 @@ export const testimonialsSection = {
|
|
|
33
46
|
Testimonials: ({ props }: { props: Record<string, unknown> }) => {
|
|
34
47
|
const parsed = testimonialsPropsSchema.parse(props)
|
|
35
48
|
return (
|
|
36
|
-
<
|
|
37
|
-
title={parsed.title ?? 'Lo que dicen nuestros clientes'}
|
|
38
|
-
items={parsed.items}
|
|
39
|
-
prevLabel={parsed.prevLabel ?? 'Anterior'}
|
|
40
|
-
nextLabel={parsed.nextLabel ?? 'Siguiente'}
|
|
41
|
-
slideAriaLabel={parsed.slideAriaLabel ?? 'Testimonio'}
|
|
42
|
-
/>
|
|
49
|
+
<TestimonialSection {...parsed} />
|
|
43
50
|
)
|
|
44
51
|
},
|
|
45
52
|
},
|
|
@@ -22,12 +22,7 @@ const checkoutFormDefaults: CheckoutFormData = {
|
|
|
22
22
|
zipCode: '',
|
|
23
23
|
country: '',
|
|
24
24
|
paymentMethod: '',
|
|
25
|
-
cardNumber: '',
|
|
26
|
-
expiryDate: '',
|
|
27
|
-
cvv: '',
|
|
28
|
-
cardName: '',
|
|
29
25
|
saveInfo: false,
|
|
30
|
-
sameAsBilling: false,
|
|
31
26
|
newsletter: false,
|
|
32
27
|
promoCode: '',
|
|
33
28
|
}
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
// HTML, or logs. Only the non-secret result (customer/error) is stored.
|
|
13
13
|
|
|
14
14
|
import { useCallback, useEffect, useRef } from 'react'
|
|
15
|
+
import type { ReactNode } from 'react'
|
|
15
16
|
import { Button } from '@thorprovider/blocks/ui/button'
|
|
16
|
-
import
|
|
17
|
+
import { LoginPage } from '@thorprovider/blocks'
|
|
17
18
|
import OrderHistory2 from '@thorprovider/blocks/blocks/e-commerce/order-history/order-history-2'
|
|
18
19
|
import SignUpBlock from '@thorprovider/blocks/blocks/application/signup-forms/signup-page-1'
|
|
19
20
|
import { useStateStore } from '@json-render/react'
|
|
@@ -48,6 +49,28 @@ function AuthNotice({ pending, error }: { pending: boolean; error: string | null
|
|
|
48
49
|
)
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
// The page side of the auth contract. The blocks render only the form: they no
|
|
53
|
+
// longer paint a viewport-height surface, declare a page landmark, or centre
|
|
54
|
+
// themselves, because a generated storefront mounts them inside the default
|
|
55
|
+
// chrome (notice + banner + navbar + footer) and the page — not the block — owns
|
|
56
|
+
// the viewport. This wrapper is the extracted shell, kept so the shopper-visible
|
|
57
|
+
// result of every auth surface is unchanged. It lives in a derived template
|
|
58
|
+
// (CLI-owned) and stays theme-driven: the backdrop uses the same semantic
|
|
59
|
+
// tokens, so dark mode and any preset resolve here too.
|
|
60
|
+
function AuthCanvas({ stack = false, children }: { stack?: boolean; children: ReactNode }) {
|
|
61
|
+
return (
|
|
62
|
+
<section
|
|
63
|
+
className={`from-background to-muted/50 relative isolate flex min-h-dvh w-full items-center justify-center overflow-hidden bg-linear-to-br ${stack ? 'flex-col' : ''}`}
|
|
64
|
+
>
|
|
65
|
+
<div
|
|
66
|
+
className={`relative z-10 container mx-auto flex min-h-dvh items-center justify-center px-4 py-12 ${stack ? 'flex-col' : ''}`}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
</div>
|
|
70
|
+
</section>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
51
74
|
// Neutral pending surface shown while a cross-tab/foreground reconciliation is
|
|
52
75
|
// in flight (task 4.2). It replaces the previously held identity/orders so no
|
|
53
76
|
// stale private data is presented as current during the server round-trip; it
|
|
@@ -188,26 +211,30 @@ export const registry: ViewRegistry = {
|
|
|
188
211
|
them, and `display: contents` leaves the layout untouched. The
|
|
189
212
|
shared lifecycle also drops a same-tick duplicate before React
|
|
190
213
|
re-renders, so no duplicate request is issued in the interim. */}
|
|
191
|
-
<
|
|
192
|
-
<
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
214
|
+
<AuthCanvas>
|
|
215
|
+
<fieldset disabled={pending} aria-busy={pending} className="contents">
|
|
216
|
+
<LoginPage
|
|
217
|
+
presentation="card"
|
|
218
|
+
logoText={parsed.logoText}
|
|
219
|
+
welcomeTitleLabel={parsed.welcomeTitleLabel}
|
|
220
|
+
welcomeDescriptionLabel={parsed.welcomeDescriptionLabel}
|
|
221
|
+
emailLabel={parsed.emailLabel}
|
|
222
|
+
passwordLabel={parsed.passwordLabel}
|
|
223
|
+
signInLabel={parsed.signInLabel}
|
|
224
|
+
createAccountLabel={parsed.createAccountLabel}
|
|
225
|
+
rememberMeLabel="Recuérdame"
|
|
226
|
+
// The credentials stay in the block's local state and go straight to
|
|
227
|
+
// the shared lifecycle (which calls the Server Action); they are never
|
|
228
|
+
// written to the store. The lifecycle owns pending/error, the
|
|
229
|
+
// generation guard, duplicate prevention, and the server refresh, so
|
|
230
|
+
// the mounted form is never remounted and its input survives a failure.
|
|
231
|
+
onSubmit={(data) => {
|
|
232
|
+
void lifecycle.login({ email: data.email, password: data.password })
|
|
233
|
+
}}
|
|
234
|
+
onCreateAccount={() => emit('showRegister')}
|
|
235
|
+
/>
|
|
236
|
+
</fieldset>
|
|
237
|
+
</AuthCanvas>
|
|
211
238
|
</>
|
|
212
239
|
)
|
|
213
240
|
},
|
|
@@ -222,28 +249,30 @@ export const registry: ViewRegistry = {
|
|
|
222
249
|
<AuthNotice pending={pending} error={error} />
|
|
223
250
|
{/* Same native pending-disable as the login form (the block exposes no
|
|
224
251
|
pending prop); input values persist across a failed mutation. */}
|
|
225
|
-
<
|
|
226
|
-
<
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
252
|
+
<AuthCanvas stack>
|
|
253
|
+
<fieldset disabled={pending} aria-busy={pending} className="contents">
|
|
254
|
+
<SignUpBlock
|
|
255
|
+
logoText={parsed.logoText}
|
|
256
|
+
createAccountTitleLabel={parsed.createAccountTitleLabel}
|
|
257
|
+
createAccountDescriptionLabel={parsed.createAccountDescriptionLabel}
|
|
258
|
+
fullNameLabel={parsed.fullNameLabel}
|
|
259
|
+
emailLabel={parsed.emailLabel}
|
|
260
|
+
passwordLabel={parsed.passwordLabel}
|
|
261
|
+
createAccountLabel={parsed.createAccountLabel}
|
|
262
|
+
signInLabel={parsed.signInLabel}
|
|
263
|
+
onSubmit={(data) => {
|
|
264
|
+
const parts = data.fullName.trim().split(/\s+/).filter(Boolean)
|
|
265
|
+
void lifecycle.register({
|
|
266
|
+
email: data.email,
|
|
267
|
+
password: data.password,
|
|
268
|
+
firstName: parts[0] ?? '',
|
|
269
|
+
lastName: parts.slice(1).join(' '),
|
|
270
|
+
})
|
|
271
|
+
}}
|
|
272
|
+
onSignIn={() => emit('showLogin')}
|
|
273
|
+
/>
|
|
274
|
+
</fieldset>
|
|
275
|
+
</AuthCanvas>
|
|
247
276
|
</>
|
|
248
277
|
)
|
|
249
278
|
},
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { z } from 'zod'
|
|
11
11
|
|
|
12
|
-
// Mirrors the
|
|
12
|
+
// Mirrors the canonical LoginPage optional props. Every prop is optional with a neutral
|
|
13
13
|
// default in the block, so the curated view forwards only the labels it owns.
|
|
14
14
|
export const accountLoginPropsSchema = z.object({
|
|
15
15
|
logoText: z.string().optional(),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"view": "category",
|
|
3
3
|
"slots": [
|
|
4
4
|
{ "id": "category.breadcrumb", "slot": "breadcrumb", "default": "Breadcrumb" },
|
|
5
|
-
{ "id": "category.filter", "slot": "filter", "default": "
|
|
5
|
+
{ "id": "category.filter", "slot": "filter", "default": "CategoryListing" },
|
|
6
6
|
{
|
|
7
7
|
"id": "category.productCard",
|
|
8
8
|
"slot": "productCard",
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
// module imports them as data so the RSC graph never evaluates @json-render/react
|
|
5
5
|
// on the server. Registered by importing it in ../index.ts. Recipe: recipes.json -> "category".
|
|
6
6
|
//
|
|
7
|
-
// E2 task 6.1: the category listing is ONE controlled `
|
|
7
|
+
// E2 task 6.1: the category listing is ONE controlled `CategoryListing` — the
|
|
8
8
|
// base listing slot `category.filter`, always present. The optional
|
|
9
9
|
// `catalog-search` / `category-filters` features are control contributions to
|
|
10
|
-
// that single block (logical mounts `category.search` / `category
|
|
10
|
+
// that single block (logical mounts `category.search` / `category-listing`),
|
|
11
11
|
// never a second listing/controller. Their visibility and config are read from
|
|
12
12
|
// the installed manifest (`mountedFeatures` / `mountedFeatureConfigs`) that
|
|
13
13
|
// `sync` derives from `storefront.config.json`; no loader is hand-edited to add
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
getCollectionOptions,
|
|
22
22
|
loadCategoryListing,
|
|
23
23
|
mapCatalogOutcomeToStatus,
|
|
24
|
-
|
|
24
|
+
mapCatalogResultsToCategoryListing,
|
|
25
25
|
} from '@thorprovider/runtime/commerce'
|
|
26
26
|
import { getDataSource, getStoreContext, isRealMode } from '../../store-context'
|
|
27
27
|
import { mountedFeatureConfigs, mountedFeatureNames, mountedFeatures } from '../../composition'
|
|
@@ -29,10 +29,10 @@ import { pageRoot } from '../../spec/page-root'
|
|
|
29
29
|
import type { StorefrontElement } from '../../spec/types'
|
|
30
30
|
import type { ViewModule } from '../types'
|
|
31
31
|
import { registry } from './registry'
|
|
32
|
-
import { categoryBreadcrumbProps,
|
|
33
|
-
import { breadcrumbPropsSchema,
|
|
32
|
+
import { categoryBreadcrumbProps, categoryListingProps } from './props'
|
|
33
|
+
import { breadcrumbPropsSchema, categoryListingPropsSchema } from './schema'@@SECTION_IMPORTS@@
|
|
34
34
|
|
|
35
|
-
// The single controlled `
|
|
35
|
+
// The single controlled `CategoryListing` base listing. The search/filter
|
|
36
36
|
// controls are shown only when the matching feature is installed; the base
|
|
37
37
|
// listing always owns the route scope, `sort`, `page`, `pageSize`, the products,
|
|
38
38
|
// and pagination.
|
|
@@ -79,6 +79,8 @@ const emptyFilterState = () => ({
|
|
|
79
79
|
categoryFilterCategories: [],
|
|
80
80
|
categoryFilterCollections: [],
|
|
81
81
|
categoryFilterPriceRange: undefined,
|
|
82
|
+
categoryFilterSelectedFacets: {} as Record<string, string[]>,
|
|
83
|
+
categoryFilterFacets: [],
|
|
82
84
|
breadcrumbItems: [] as { label: string; href?: string }[],
|
|
83
85
|
})
|
|
84
86
|
|
|
@@ -197,7 +199,7 @@ export const category: ViewModule = {
|
|
|
197
199
|
}))
|
|
198
200
|
: []
|
|
199
201
|
const collections = allCollections.length > 0 ? allCollections : undefined
|
|
200
|
-
const presentation =
|
|
202
|
+
const presentation = mapCatalogResultsToCategoryListing({
|
|
201
203
|
query: listing.query,
|
|
202
204
|
results: listing.results,
|
|
203
205
|
// A scoped listing (`/categories/<handle>`) must not offer the
|
|
@@ -236,6 +238,8 @@ export const category: ViewModule = {
|
|
|
236
238
|
categoryFilterCategories: presentation.categories ?? [],
|
|
237
239
|
categoryFilterCollections: presentation.collections ?? [],
|
|
238
240
|
categoryFilterPriceRange: presentation.priceRange,
|
|
241
|
+
categoryFilterSelectedFacets: presentation.selectedFacets ?? {},
|
|
242
|
+
categoryFilterFacets: presentation.facets ?? [],
|
|
239
243
|
}
|
|
240
244
|
} catch (error) {
|
|
241
245
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
// Thor Commerce view registry fragment: category
|
|
4
|
-
// The category view's single client boundary: one controlled `
|
|
4
|
+
// The category view's single client boundary: one controlled `CategoryListing`
|
|
5
5
|
// (the base listing slot `category.filter`). Search/filters/sort/pagination are
|
|
6
6
|
// URL-backed: the block emits a change, this registry rewrites the URL through
|
|
7
7
|
// the pure `buildCategoryQueryHref` seam, and the server loader re-seeds the
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
// the client. The search and filter controls are only present because the
|
|
10
10
|
// installed manifest enabled them; the block never adds a second listing.
|
|
11
11
|
|
|
12
|
-
import
|
|
12
|
+
import CategoryListingBlock from '@thorprovider/blocks/blocks/e-commerce/category-filters/category-listing'
|
|
13
13
|
import type {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from '@thorprovider/blocks/blocks/e-commerce/category-filters/category-
|
|
14
|
+
CategoryListingActiveFilter,
|
|
15
|
+
CategoryListingFilters,
|
|
16
|
+
CategoryListingProps,
|
|
17
|
+
} from '@thorprovider/blocks/blocks/e-commerce/category-filters/category-listing'
|
|
18
18
|
@@BLOCK_IMPORTS@@@@SECTION_REGISTRY_IMPORTS@@
|
|
19
19
|
import { buildCategoryQueryHref, catalogHistoryMode, type CategoryQueryChange } from '@thorprovider/runtime/commerce'
|
|
20
20
|
import type { CatalogFeatureName } from '@thorprovider/runtime/contracts'
|
|
@@ -23,9 +23,9 @@ import { usePathname, useRouter } from 'next/navigation'
|
|
|
23
23
|
import type { ViewRegistry } from '../types'
|
|
24
24
|
|
|
25
25
|
// The generated view module injects the installed-feature context as an element
|
|
26
|
-
// prop (task 4.11); it is composition context, not a `
|
|
26
|
+
// prop (task 4.11); it is composition context, not a `CategoryListing` prop, so
|
|
27
27
|
// it is read separately from the block props.
|
|
28
|
-
type
|
|
28
|
+
type CategoryListingRegistryProps = CategoryListingProps & {
|
|
29
29
|
mountedFeatures?: readonly CatalogFeatureName[]
|
|
30
30
|
}
|
|
31
31
|
|