@thorprovider/storefront 0.6.3 → 0.9.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 +22 -2
- package/assets/templates/AGENTS.md +14 -2
- package/assets/templates/app/app/[[...slug]]/page.tsx +9 -2
- package/assets/templates/app/lib/__STOREFRONT__/account-address.ts +129 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-lifecycle.client.tsx +2 -2
- package/assets/templates/app/lib/__STOREFRONT__/account-private.core.ts +143 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-profile.ts +220 -0
- package/assets/templates/app/lib/__STOREFRONT__/actions.ts +1234 -75
- package/assets/templates/app/lib/__STOREFRONT__/addresses-port.ts +107 -0
- package/assets/templates/app/lib/__STOREFRONT__/checkout-shipping.core.ts +37 -0
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +460 -35
- package/assets/templates/app/lib/__STOREFRONT__/confirmation.core.ts +240 -0
- package/assets/templates/app/lib/__STOREFRONT__/customer-profile-port.ts +103 -0
- package/assets/templates/app/lib/__STOREFRONT__/order-detail-port.ts +26 -0
- package/assets/templates/app/lib/__STOREFRONT__/orders-port.ts +30 -0
- package/assets/templates/app/lib/__STOREFRONT__/ports.ts +18 -0
- package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.client.tsx +4 -4
- package/assets/templates/app/lib/__STOREFRONT__/session.ts +24 -6
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +28 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/address-book-advanced.client.tsx +29 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.client.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.tsx +16 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/customer-profile.client.tsx +27 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +5 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/marketplace-product-card.client.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/marketplace-product-card.tsx +16 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.client.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.tsx +16 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.address-book-advanced.ts +437 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.checkout-commerce-v1.ts +398 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.customer-profile.ts +138 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.marketplace-product-card.ts +67 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.mega-menu-universal.ts +76 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-banner.ts +217 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.client.tsx +24 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.tsx +16 -0
- package/assets/templates/features/checkout/handlers.ts +348 -33
- package/assets/templates/features/checkout/state.ts +79 -3
- package/assets/templates/features/customer-addresses/handlers.ts +11 -0
- package/assets/templates/features/customer-addresses/state.ts +33 -0
- package/assets/templates/features/customer-auth/state.ts +10 -0
- package/assets/templates/features/customer-profile/handlers.ts +11 -0
- package/assets/templates/features/customer-profile/state.ts +18 -0
- package/assets/templates/views/account/address-book-advanced.defaults.ts +534 -0
- package/assets/templates/views/account/assembly/assembly.json +41 -0
- package/assets/templates/views/account/assembly/index.skeleton.tsx +229 -0
- package/assets/templates/views/account/assembly/registry.skeleton.tsx +1116 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/binding.json +5 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/addresses/cards/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/addresses/cards/element.part +10 -0
- package/assets/templates/views/account/assembly/slots/addresses/cards/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/login/card/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/login/card/element.part +13 -0
- package/assets/templates/views/account/assembly/slots/login/card/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistory/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistory/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistory/registry.part +2 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/binding.json +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/binding.json +5 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/profile/form/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/profile/form/element.part +10 -0
- package/assets/templates/views/account/assembly/slots/profile/form/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/register/SignUpPage1/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/register/SignUpPage1/element.part +13 -0
- package/assets/templates/views/account/assembly/slots/register/SignUpPage1/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/summary/stack/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/stack/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/stack/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/summary/tabs/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/tabs/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/tabs/registry.part +1 -0
- package/assets/templates/views/account/content.ts +326 -0
- package/assets/templates/views/account/customer-profile.defaults.ts +136 -0
- package/assets/templates/views/account/index.tsx +218 -35
- package/assets/templates/views/account/order-detail.client.tsx +35 -0
- package/assets/templates/views/account/order-detail.defaults.ts +457 -0
- package/assets/templates/views/account/orders-advanced.client.tsx +166 -0
- package/assets/templates/views/account/orders-advanced.defaults.ts +230 -0
- package/assets/templates/views/account/registry.tsx +944 -369
- package/assets/templates/views/account/schema.ts +50 -0
- package/assets/templates/views/account/sections-data.ts +2 -0
- package/assets/templates/views/cart/content.ts +1 -0
- package/assets/templates/views/category/assembly/index.skeleton.tsx +1 -0
- package/assets/templates/views/category/assembly/slots/filter/CategoryListing/element.part +1 -0
- package/assets/templates/views/category/content.ts +2 -0
- package/assets/templates/views/category/index.tsx +2 -0
- package/assets/templates/views/category/sections-data.ts +2 -0
- package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +1089 -0
- package/assets/templates/views/checkout/content.ts +114 -2
- package/assets/templates/views/checkout/index.tsx +7 -1
- package/assets/templates/views/checkout/props.ts +70 -22
- package/assets/templates/views/checkout/registry.tsx +400 -71
- package/assets/templates/views/checkout/schema.ts +260 -9
- package/assets/templates/views/home/assembly/assembly.json +28 -0
- package/assets/templates/views/home/assembly/index.skeleton.tsx +1 -0
- package/assets/templates/views/home/content.ts +2 -0
- package/assets/templates/views/home/index.tsx +1 -0
- package/assets/templates/views/home/sections-data.ts +2 -0
- package/assets/templates/views/product/content.ts +1 -0
- package/assets/templates/views/static/content.ts +1 -0
- package/bin/storefront.js +343 -13
- package/package.json +2 -1
- package/recipes/adapter-surface.json +158 -0
- package/recipes/archetypes.json +38 -3
- package/recipes/catalog.json +138 -1
- package/recipes/feature.schema.json +9 -0
- package/recipes/features.json +72 -1
- package/recipes/manifest.schema.json +5 -0
- package/recipes/recipe.schema.json +14 -2
- package/recipes/recipes.json +35 -5
- package/recipes/section.schema.json +112 -0
- package/recipes/sections.json +289 -3
- package/recipes/validate.mjs +83 -1
- package/scripts/adapter-surface.mjs +41 -0
- package/scripts/agent-blocks.mjs +700 -0
- package/scripts/block-validator.mjs +45 -0
- package/scripts/candidate.mjs +5 -4
- package/scripts/composers.mjs +7 -2
- package/scripts/default-sections.mjs +78 -0
- package/scripts/file-classes.mjs +15 -0
- package/scripts/generate-adapter-surface.mjs +148 -0
- package/scripts/operations.mjs +100 -0
- package/scripts/reconcile.mjs +67 -39
- package/scripts/section-configure.mjs +316 -0
- package/scripts/sync-assets.mjs +1 -0
- package/scripts/view-assembly.mjs +101 -14
- package/skills/sf-feature/SKILL.md +19 -0
- package/skills/sf-view-gen/SKILL.md +79 -7
- package/skills/sf-view-gen/assets/recipes/archetypes.json +38 -3
- package/skills/sf-view-gen/assets/recipes/catalog.json +138 -1
- package/skills/sf-view-gen/assets/recipes/features.json +72 -1
- package/skills/sf-view-gen/assets/recipes/recipes.json +35 -5
- package/skills/sf-view-gen/assets/recipes/section.schema.json +112 -0
- package/skills/sf-view-gen/assets/recipes/sections.json +289 -3
- package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.client.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.tsx +16 -0
- package/skills/sf-view-gen/assets/templates/views/sections/marketplace-product-card.client.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/marketplace-product-card.tsx +16 -0
- package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.client.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.tsx +16 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.checkout-commerce-v1.ts +398 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.marketplace-product-card.ts +67 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.mega-menu-universal.ts +76 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.universal-banner.ts +217 -0
- package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.client.tsx +24 -0
- package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.tsx +16 -0
- package/skills/sf-view-gen/scripts/validate.mjs +83 -1
- package/skills/storefront-workflow/SKILL.md +5 -0
- package/skills/storefront-workflow/references/mobile-responsiveness.md +1 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// Optional section fragment: universal-banner (mirrors recipes/sections.json) — shared contract.
|
|
2
|
+
// Zod mirror of the UniversalBanner block contract (delivery universal-banner, contract version 4.1.0),
|
|
3
|
+
// shared by the server catalog (universal-banner.tsx) and the client registry (universal-banner.client.tsx).
|
|
4
|
+
// The React-only callbacks (onBannerClick, onCtaClick) are intentionally excluded.
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod'
|
|
7
|
+
|
|
8
|
+
export const universalBannerDataSchema = z.object({
|
|
9
|
+
campaign: z.object({
|
|
10
|
+
schemaVersion: z.number(),
|
|
11
|
+
campaignId: z.string(),
|
|
12
|
+
banners: z.array(z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
campaignId: z.string(),
|
|
15
|
+
content: z.object({
|
|
16
|
+
name: z.string(),
|
|
17
|
+
alt: z.string(),
|
|
18
|
+
title: z.string().optional(),
|
|
19
|
+
subtitle: z.string().optional(),
|
|
20
|
+
description: z.string().optional(),
|
|
21
|
+
badge: z.string().optional(),
|
|
22
|
+
target: z.object({
|
|
23
|
+
kind: z.string(),
|
|
24
|
+
id: z.string().optional(),
|
|
25
|
+
slug: z.string().optional(),
|
|
26
|
+
query: z.string().optional(),
|
|
27
|
+
url: z.string().optional(),
|
|
28
|
+
}).optional(),
|
|
29
|
+
ctas: z.array(z.object({
|
|
30
|
+
id: z.string(),
|
|
31
|
+
label: z.string(),
|
|
32
|
+
target: z.object({
|
|
33
|
+
kind: z.string(),
|
|
34
|
+
id: z.string().optional(),
|
|
35
|
+
slug: z.string().optional(),
|
|
36
|
+
query: z.string().optional(),
|
|
37
|
+
url: z.string().optional(),
|
|
38
|
+
}),
|
|
39
|
+
tone: z.enum(["primary", "secondary"]),
|
|
40
|
+
})),
|
|
41
|
+
}),
|
|
42
|
+
media: z.object({
|
|
43
|
+
desktop: z.string().optional(),
|
|
44
|
+
tablet: z.string().optional(),
|
|
45
|
+
mobile: z.string().optional(),
|
|
46
|
+
}),
|
|
47
|
+
presentation: z.object({
|
|
48
|
+
mode: z.enum(["image-only", "overlay", "split"]),
|
|
49
|
+
width: z.enum(["full", "content", "custom"]),
|
|
50
|
+
maxWidth: z.enum(["sm", "md", "lg", "xl"]).optional(),
|
|
51
|
+
height: z.enum(["auto", "fixed", "adaptive"]),
|
|
52
|
+
heightToken: z.enum(["sm", "md", "lg", "xl"]).optional(),
|
|
53
|
+
aspect: z.enum(["square", "video", "photo", "wide", "tall", "natural"]),
|
|
54
|
+
fit: z.enum(["natural", "cover", "contain"]),
|
|
55
|
+
focal: z.enum(["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"]),
|
|
56
|
+
align: z.enum(["center", "start", "end"]),
|
|
57
|
+
radius: z.enum(["md", "lg", "xl", "none", "2xl"]),
|
|
58
|
+
surface: z.enum(["primary", "secondary", "none", "card", "muted", "accent"]),
|
|
59
|
+
overlay: z.enum(["none", "scrim", "gradient"]),
|
|
60
|
+
overlayOpacity: z.enum(["light", "medium", "strong"]),
|
|
61
|
+
padding: z.enum(["sm", "md", "lg", "none"]),
|
|
62
|
+
textScale: z.enum(["sm", "md", "lg"]),
|
|
63
|
+
splitSide: z.enum(["media-start", "media-end"]).optional(),
|
|
64
|
+
hiddenFields: z.array(z.string()).optional(),
|
|
65
|
+
}),
|
|
66
|
+
responsive: z.object({
|
|
67
|
+
md: z.object({
|
|
68
|
+
mode: z.enum(["image-only", "overlay", "split"]).optional(),
|
|
69
|
+
width: z.enum(["full", "content", "custom"]).optional(),
|
|
70
|
+
maxWidth: z.enum(["sm", "md", "lg", "xl"]).optional(),
|
|
71
|
+
height: z.enum(["auto", "fixed", "adaptive"]).optional(),
|
|
72
|
+
heightToken: z.enum(["sm", "md", "lg", "xl"]).optional(),
|
|
73
|
+
aspect: z.enum(["square", "video", "photo", "wide", "tall", "natural"]).optional(),
|
|
74
|
+
fit: z.enum(["natural", "cover", "contain"]).optional(),
|
|
75
|
+
focal: z.enum(["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"]).optional(),
|
|
76
|
+
align: z.enum(["center", "start", "end"]).optional(),
|
|
77
|
+
radius: z.enum(["md", "lg", "xl", "none", "2xl"]).optional(),
|
|
78
|
+
surface: z.enum(["primary", "secondary", "none", "card", "muted", "accent"]).optional(),
|
|
79
|
+
overlay: z.enum(["none", "scrim", "gradient"]).optional(),
|
|
80
|
+
overlayOpacity: z.enum(["light", "medium", "strong"]).optional(),
|
|
81
|
+
padding: z.enum(["sm", "md", "lg", "none"]).optional(),
|
|
82
|
+
textScale: z.enum(["sm", "md", "lg"]).optional(),
|
|
83
|
+
splitSide: z.enum(["media-start", "media-end"]).optional(),
|
|
84
|
+
hiddenFields: z.array(z.string()).optional(),
|
|
85
|
+
}).optional(),
|
|
86
|
+
"2xl": z.object({
|
|
87
|
+
mode: z.enum(["image-only", "overlay", "split"]).optional(),
|
|
88
|
+
width: z.enum(["full", "content", "custom"]).optional(),
|
|
89
|
+
maxWidth: z.enum(["sm", "md", "lg", "xl"]).optional(),
|
|
90
|
+
height: z.enum(["auto", "fixed", "adaptive"]).optional(),
|
|
91
|
+
heightToken: z.enum(["sm", "md", "lg", "xl"]).optional(),
|
|
92
|
+
aspect: z.enum(["square", "video", "photo", "wide", "tall", "natural"]).optional(),
|
|
93
|
+
fit: z.enum(["natural", "cover", "contain"]).optional(),
|
|
94
|
+
focal: z.enum(["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"]).optional(),
|
|
95
|
+
align: z.enum(["center", "start", "end"]).optional(),
|
|
96
|
+
radius: z.enum(["md", "lg", "xl", "none", "2xl"]).optional(),
|
|
97
|
+
surface: z.enum(["primary", "secondary", "none", "card", "muted", "accent"]).optional(),
|
|
98
|
+
overlay: z.enum(["none", "scrim", "gradient"]).optional(),
|
|
99
|
+
overlayOpacity: z.enum(["light", "medium", "strong"]).optional(),
|
|
100
|
+
padding: z.enum(["sm", "md", "lg", "none"]).optional(),
|
|
101
|
+
textScale: z.enum(["sm", "md", "lg"]).optional(),
|
|
102
|
+
splitSide: z.enum(["media-start", "media-end"]).optional(),
|
|
103
|
+
hiddenFields: z.array(z.string()).optional(),
|
|
104
|
+
}).optional(),
|
|
105
|
+
base: z.object({
|
|
106
|
+
mode: z.enum(["image-only", "overlay", "split"]).optional(),
|
|
107
|
+
width: z.enum(["full", "content", "custom"]).optional(),
|
|
108
|
+
maxWidth: z.enum(["sm", "md", "lg", "xl"]).optional(),
|
|
109
|
+
height: z.enum(["auto", "fixed", "adaptive"]).optional(),
|
|
110
|
+
heightToken: z.enum(["sm", "md", "lg", "xl"]).optional(),
|
|
111
|
+
aspect: z.enum(["square", "video", "photo", "wide", "tall", "natural"]).optional(),
|
|
112
|
+
fit: z.enum(["natural", "cover", "contain"]).optional(),
|
|
113
|
+
focal: z.enum(["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"]).optional(),
|
|
114
|
+
align: z.enum(["center", "start", "end"]).optional(),
|
|
115
|
+
radius: z.enum(["md", "lg", "xl", "none", "2xl"]).optional(),
|
|
116
|
+
surface: z.enum(["primary", "secondary", "none", "card", "muted", "accent"]).optional(),
|
|
117
|
+
overlay: z.enum(["none", "scrim", "gradient"]).optional(),
|
|
118
|
+
overlayOpacity: z.enum(["light", "medium", "strong"]).optional(),
|
|
119
|
+
padding: z.enum(["sm", "md", "lg", "none"]).optional(),
|
|
120
|
+
textScale: z.enum(["sm", "md", "lg"]).optional(),
|
|
121
|
+
splitSide: z.enum(["media-start", "media-end"]).optional(),
|
|
122
|
+
hiddenFields: z.array(z.string()).optional(),
|
|
123
|
+
}).optional(),
|
|
124
|
+
}).optional(),
|
|
125
|
+
schedule: z.object({
|
|
126
|
+
from: z.string().optional(),
|
|
127
|
+
to: z.string().optional(),
|
|
128
|
+
timezone: z.string(),
|
|
129
|
+
}).optional(),
|
|
130
|
+
visible: z.boolean(),
|
|
131
|
+
})),
|
|
132
|
+
}),
|
|
133
|
+
config: z.object({
|
|
134
|
+
schemaVersion: z.number(),
|
|
135
|
+
blockId: z.string(),
|
|
136
|
+
name: z.string(),
|
|
137
|
+
visible: z.boolean(),
|
|
138
|
+
schedule: z.object({
|
|
139
|
+
from: z.string().optional(),
|
|
140
|
+
to: z.string().optional(),
|
|
141
|
+
timezone: z.string(),
|
|
142
|
+
}).optional(),
|
|
143
|
+
scheduleAware: z.boolean(),
|
|
144
|
+
responsiveEnabled: z.boolean(),
|
|
145
|
+
presentation: z.enum(["single", "grid", "carousel"]),
|
|
146
|
+
preset: z.enum(["custom", "one", "two", "three", "four", "mosaic", "hero-two", "hero-three"]),
|
|
147
|
+
refs: z.array(z.object({
|
|
148
|
+
bannerId: z.string(),
|
|
149
|
+
overrides: z.object({
|
|
150
|
+
mode: z.enum(["image-only", "overlay", "split"]).optional(),
|
|
151
|
+
width: z.enum(["full", "content", "custom"]).optional(),
|
|
152
|
+
maxWidth: z.enum(["sm", "md", "lg", "xl"]).optional(),
|
|
153
|
+
height: z.enum(["auto", "fixed", "adaptive"]).optional(),
|
|
154
|
+
heightToken: z.enum(["sm", "md", "lg", "xl"]).optional(),
|
|
155
|
+
aspect: z.enum(["square", "video", "photo", "wide", "tall", "natural"]).optional(),
|
|
156
|
+
fit: z.enum(["natural", "cover", "contain"]).optional(),
|
|
157
|
+
focal: z.enum(["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"]).optional(),
|
|
158
|
+
align: z.enum(["center", "start", "end"]).optional(),
|
|
159
|
+
radius: z.enum(["md", "lg", "xl", "none", "2xl"]).optional(),
|
|
160
|
+
surface: z.enum(["primary", "secondary", "none", "card", "muted", "accent"]).optional(),
|
|
161
|
+
overlay: z.enum(["none", "scrim", "gradient"]).optional(),
|
|
162
|
+
overlayOpacity: z.enum(["light", "medium", "strong"]).optional(),
|
|
163
|
+
padding: z.enum(["sm", "md", "lg", "none"]).optional(),
|
|
164
|
+
textScale: z.enum(["sm", "md", "lg"]).optional(),
|
|
165
|
+
splitSide: z.enum(["media-start", "media-end"]).optional(),
|
|
166
|
+
hiddenFields: z.array(z.string()).optional(),
|
|
167
|
+
}).optional(),
|
|
168
|
+
})),
|
|
169
|
+
layout: z.object({
|
|
170
|
+
gapX: z.enum(["sm", "md", "lg", "xl", "none"]),
|
|
171
|
+
gapY: z.enum(["sm", "md", "lg", "xl", "none"]),
|
|
172
|
+
maxWidth: z.enum(["full", "sm", "md", "lg", "xl"]),
|
|
173
|
+
maxHeight: z.enum(["sm", "md", "lg", "xl", "none"]),
|
|
174
|
+
align: z.enum(["center", "start", "end"]),
|
|
175
|
+
radius: z.enum(["md", "lg", "xl", "none", "2xl"]),
|
|
176
|
+
columns: z.object({
|
|
177
|
+
md: z.number(),
|
|
178
|
+
"2xl": z.number(),
|
|
179
|
+
base: z.number(),
|
|
180
|
+
}).optional(),
|
|
181
|
+
spans: z.array(z.number()).optional(),
|
|
182
|
+
}),
|
|
183
|
+
carousel: z.object({
|
|
184
|
+
visible: z.object({
|
|
185
|
+
md: z.number(),
|
|
186
|
+
"2xl": z.number(),
|
|
187
|
+
base: z.number(),
|
|
188
|
+
}),
|
|
189
|
+
autoplay: z.boolean(),
|
|
190
|
+
intervalMs: z.number(),
|
|
191
|
+
loop: z.boolean(),
|
|
192
|
+
indicators: z.boolean(),
|
|
193
|
+
carouselOnMobile: z.boolean(),
|
|
194
|
+
peek: z.boolean(),
|
|
195
|
+
story: z.boolean(),
|
|
196
|
+
}),
|
|
197
|
+
rules: z.object({
|
|
198
|
+
emptyLabel: z.string(),
|
|
199
|
+
inactiveLabel: z.string(),
|
|
200
|
+
danglingLabel: z.string(),
|
|
201
|
+
}),
|
|
202
|
+
}),
|
|
203
|
+
now: z.string(),
|
|
204
|
+
banner: z.object({
|
|
205
|
+
carouselPrevious: z.string(),
|
|
206
|
+
carouselNext: z.string(),
|
|
207
|
+
carouselStatus: z.string(),
|
|
208
|
+
carouselRole: z.string(),
|
|
209
|
+
storyPrevious: z.string(),
|
|
210
|
+
storyNext: z.string(),
|
|
211
|
+
storyRole: z.string(),
|
|
212
|
+
}),
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
export const universalBannerPropsSchema = z.object({
|
|
216
|
+
data: universalBannerDataSchema,
|
|
217
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// Optional section fragment: universal-banner (mirrors recipes/sections.json) — client registry.
|
|
4
|
+
// The matching server-side catalog lives in universal-banner.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 { useEffect, useState } from 'react'
|
|
9
|
+
import { UniversalBanner } from '@thorprovider/blocks'
|
|
10
|
+
import { universalBannerPropsSchema } from './schema.universal-banner'
|
|
11
|
+
import type { ViewRegistry } from '../types'
|
|
12
|
+
|
|
13
|
+
export const universalBannerRegistry: ViewRegistry = {
|
|
14
|
+
UniversalBanner: ({ props }) => {
|
|
15
|
+
const parsed = universalBannerPropsSchema.parse(props)
|
|
16
|
+
const [now, setNow] = useState(parsed.data.now)
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setNow(new Date().toISOString())
|
|
19
|
+
}, [])
|
|
20
|
+
return (
|
|
21
|
+
<UniversalBanner data={{ ...parsed.data, now }} />
|
|
22
|
+
)
|
|
23
|
+
},
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Optional section fragment: universal-banner (mirrors recipes/sections.json)
|
|
2
|
+
// Server-side part: element type + zod catalog entry. The component mappings
|
|
3
|
+
// live in universal-banner.client.tsx ('use client') and are composed via composeSections.
|
|
4
|
+
|
|
5
|
+
import { universalBannerPropsSchema } from './schema.universal-banner'
|
|
6
|
+
|
|
7
|
+
export const universalBannerSection = {
|
|
8
|
+
elementType: 'UniversalBanner',
|
|
9
|
+
catalog: {
|
|
10
|
+
UniversalBanner: {
|
|
11
|
+
props: universalBannerPropsSchema,
|
|
12
|
+
description: 'UniversalBanner presentation section (delivery universal-banner).',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
registryModule: './universal-banner.client',
|
|
16
|
+
}
|
|
@@ -506,6 +506,88 @@ export function isCuratedFeature(name) {
|
|
|
506
506
|
return getFeature(name)?.mvp === true
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
+
/**
|
|
510
|
+
* The feature's declared lifecycle status. Absent status defaults to
|
|
511
|
+
* `executable` for a curated feature and `held` for a non-curated one, so an
|
|
512
|
+
* older registry keeps its previous meaning without a migration pass.
|
|
513
|
+
*/
|
|
514
|
+
export function featureStatus(name) {
|
|
515
|
+
const feature = getFeature(name)
|
|
516
|
+
if (!feature) return null
|
|
517
|
+
if (feature.status === 'executable' || feature.status === 'gated' || feature.status === 'held') {
|
|
518
|
+
return feature.status
|
|
519
|
+
}
|
|
520
|
+
return feature.mvp === true ? 'executable' : 'held'
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
const FEATURE_STATUSES = new Set(['executable', 'gated', 'held'])
|
|
524
|
+
const FEATURE_LIST_FIELDS = ['requires', 'backendCapabilities']
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Validate the feature registry's lifecycle declarations. The published JSON
|
|
528
|
+
* schema covers shape; this covers the cross-entry invariants the schema cannot
|
|
529
|
+
* express (held needs a reason and an owner, status and `mvp` agree, a
|
|
530
|
+
* dependency names a real feature, and no feature depends on itself).
|
|
531
|
+
*
|
|
532
|
+
* Returns `{ ok, errors }`; the registry is read-only input.
|
|
533
|
+
*/
|
|
534
|
+
export function validateFeatureRegistry(registry = features) {
|
|
535
|
+
const errors = []
|
|
536
|
+
const list = Array.isArray(registry?.features) ? registry.features : []
|
|
537
|
+
const names = new Set()
|
|
538
|
+
|
|
539
|
+
for (const feature of list) {
|
|
540
|
+
if (!isPlainObject(feature) || typeof feature.name !== 'string' || feature.name === '') {
|
|
541
|
+
errors.push('Every feature entry needs a non-empty string "name".')
|
|
542
|
+
continue
|
|
543
|
+
}
|
|
544
|
+
const { name } = feature
|
|
545
|
+
if (names.has(name)) errors.push(`Feature "${name}" is declared more than once.`)
|
|
546
|
+
names.add(name)
|
|
547
|
+
|
|
548
|
+
const status = feature.status ?? (feature.mvp === true ? 'executable' : 'held')
|
|
549
|
+
if (!FEATURE_STATUSES.has(status)) {
|
|
550
|
+
errors.push(
|
|
551
|
+
`Feature "${name}" declares unknown status "${String(feature.status)}". Allowed: executable, gated, held.`
|
|
552
|
+
)
|
|
553
|
+
}
|
|
554
|
+
if (status === 'held') {
|
|
555
|
+
if (feature.mvp === true) {
|
|
556
|
+
errors.push(`Feature "${name}" is held and must not declare mvp: true.`)
|
|
557
|
+
}
|
|
558
|
+
if (typeof feature.reason !== 'string' || feature.reason.trim() === '') {
|
|
559
|
+
errors.push(`Held feature "${name}" must declare a non-empty "reason".`)
|
|
560
|
+
}
|
|
561
|
+
if (typeof feature.owner !== 'string' || feature.owner.trim() === '') {
|
|
562
|
+
errors.push(`Held feature "${name}" must declare a non-empty "owner".`)
|
|
563
|
+
}
|
|
564
|
+
} else if (feature.mvp !== true) {
|
|
565
|
+
errors.push(`Feature "${name}" is "${status}" and must declare mvp: true.`)
|
|
566
|
+
}
|
|
567
|
+
for (const field of FEATURE_LIST_FIELDS) {
|
|
568
|
+
if (!hasOwn(feature, field)) continue
|
|
569
|
+
const value = feature[field]
|
|
570
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string' || item === '')) {
|
|
571
|
+
errors.push(`Feature "${name}" field "${field}" must be an array of non-empty strings.`)
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
for (const feature of list) {
|
|
577
|
+
if (!isPlainObject(feature) || typeof feature.name !== 'string') continue
|
|
578
|
+
const requires = Array.isArray(feature.requires) ? feature.requires : []
|
|
579
|
+
for (const dependency of requires) {
|
|
580
|
+
if (dependency === feature.name) {
|
|
581
|
+
errors.push(`Feature "${feature.name}" must not require itself.`)
|
|
582
|
+
} else if (!names.has(dependency)) {
|
|
583
|
+
errors.push(`Feature "${feature.name}" requires unknown feature "${dependency}".`)
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
return { ok: errors.length === 0, errors }
|
|
589
|
+
}
|
|
590
|
+
|
|
509
591
|
/**
|
|
510
592
|
* The starter composition: every curated (installable) feature plus every
|
|
511
593
|
* curated view no installed curated feature owns. A feature-owned view (for
|
|
@@ -523,7 +605,7 @@ export function starterComposition(registries = {}) {
|
|
|
523
605
|
const recipeSource = registries.recipes ?? recipes
|
|
524
606
|
const featureSource = registries.features ?? features
|
|
525
607
|
const featureNames = featureSource.features
|
|
526
|
-
.filter((f) => f.mvp === true)
|
|
608
|
+
.filter((f) => f.mvp === true && f.starter !== false)
|
|
527
609
|
.map((f) => f.name)
|
|
528
610
|
const ownedViews = new Set()
|
|
529
611
|
for (const name of featureNames) {
|
|
@@ -168,6 +168,11 @@ customization cannot invent a canonical.
|
|
|
168
168
|
- The `checkout` feature ships structural wiring only; the purchase flow is
|
|
169
169
|
owned by the separate `single-tenant-commerce-mvp` change. A generated
|
|
170
170
|
storefront is not a complete commerce implementation on its own.
|
|
171
|
+
- The canonical `Checkout` block is controlled and structured: contact,
|
|
172
|
+
shipping/billing addresses, `sameAsShipping`, payment, shipping groups, and
|
|
173
|
+
totals are host state. Country, province/state, and city are host-supplied
|
|
174
|
+
selectors; authenticated customer profile/address prefill is host-owned. Do
|
|
175
|
+
not add fetch or prefill logic to the block.
|
|
171
176
|
|
|
172
177
|
## References
|
|
173
178
|
|
|
@@ -98,7 +98,7 @@ Over 60% of ecommerce traffic is mobile. Mobile-first design is essential for co
|
|
|
98
98
|
- 44-48px input height minimum
|
|
99
99
|
- Proper keyboard types (`inputMode="email"`, `"numeric"`, `"tel"`)
|
|
100
100
|
- Autocomplete attributes for autofill (`autocomplete="email"`, `"name"`, `"address-line1"`)
|
|
101
|
-
- Consider single-page layout over
|
|
101
|
+
- Consider the single-page layout over a step-by-step flow when it reduces mobile friction. Checkout also has an `accordion` presentation: all step headers stay visible while one section is open. The consumer chooses among `single-page`, `accordion`, and `stepper` rather than switching layouts automatically by viewport.
|
|
102
102
|
|
|
103
103
|
## Touch-Friendly Interactions
|
|
104
104
|
|