@thorprovider/blocks 1.0.0 → 2.0.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/CHANGELOG.md +48 -0
- package/README.md +156 -40
- package/package.json +1 -1
- package/src/blocks/application/login-forms/login-page.test.tsx +190 -0
- package/src/blocks/application/login-forms/login-page.tsx +240 -0
- package/src/blocks/application/password-recovery/forgot-password-page-1.tsx +6 -8
- package/src/blocks/application/signup-forms/signup-page-1.tsx +127 -129
- package/src/blocks/application/verification/verify-1.tsx +2 -2
- package/src/blocks/application/viewport-ownership.test.tsx +41 -0
- package/src/blocks/e-commerce/category-filters/category-listing-filter-fields.tsx +218 -0
- package/src/blocks/e-commerce/category-filters/{category-filter-2.test.tsx → category-listing.test.tsx} +287 -199
- package/src/blocks/e-commerce/category-filters/category-listing.tsx +934 -0
- package/src/blocks/e-commerce/checkout-forms/checkout-contact-step.tsx +149 -0
- package/src/blocks/e-commerce/checkout-forms/{checkout-form-1-country-field.tsx → checkout-country-field.tsx} +10 -8
- package/src/blocks/e-commerce/checkout-forms/checkout-order-summary.tsx +230 -0
- package/src/blocks/e-commerce/checkout-forms/checkout-payment-step.tsx +100 -0
- package/src/blocks/e-commerce/checkout-forms/checkout-progress.tsx +62 -0
- package/src/blocks/e-commerce/checkout-forms/checkout-review-step.tsx +59 -0
- package/src/blocks/e-commerce/checkout-forms/{checkout-form-1-shipping-step.tsx → checkout-shipping-step.tsx} +65 -41
- package/src/blocks/e-commerce/checkout-forms/checkout.test.tsx +478 -0
- package/src/blocks/e-commerce/checkout-forms/checkout.tsx +550 -0
- package/src/blocks/{marketing/navbars/navbar-4-account-menu.test.tsx → e-commerce/navigation/storefront-navbar-account-menu.test.tsx} +8 -8
- package/src/blocks/{marketing/navbars/navbar-4-account-menu.tsx → e-commerce/navigation/storefront-navbar-account-menu.tsx} +3 -3
- package/src/blocks/{marketing/navbars/navbar-4-cart-sheet.test.tsx → e-commerce/navigation/storefront-navbar-cart-sheet.test.tsx} +22 -22
- package/src/blocks/{marketing/navbars/navbar-4-cart-sheet.tsx → e-commerce/navigation/storefront-navbar-cart-sheet.tsx} +3 -3
- package/src/blocks/{marketing/navbars/navbar-4-mobile-nav.tsx → e-commerce/navigation/storefront-navbar-mobile-nav.tsx} +4 -12
- package/src/blocks/{marketing/navbars/navbar-4-search-bar.tsx → e-commerce/navigation/storefront-navbar-search-bar.tsx} +3 -3
- package/src/blocks/{marketing/navbars/navbar-4.test.tsx → e-commerce/navigation/storefront-navbar.test.tsx} +40 -40
- package/src/blocks/{marketing/navbars/navbar-4.tsx → e-commerce/navigation/storefront-navbar.tsx} +17 -17
- package/src/blocks/e-commerce/product-list/product-card.tsx +63 -40
- package/src/blocks/e-commerce/shopping-carts/shopping-cart.test.tsx +2 -2
- package/src/blocks/marketing/footers/footer-section-accessibility.test.tsx +118 -0
- package/src/blocks/marketing/footers/footer-section-actions.test.tsx +131 -0
- package/src/blocks/marketing/footers/footer-section-data.test.tsx +127 -0
- package/src/blocks/marketing/footers/footer-section-native-links.test.tsx +100 -0
- package/src/blocks/marketing/footers/footer-section-public-api.test.tsx +11 -0
- package/src/blocks/marketing/footers/footer-section.test.tsx +46 -0
- package/src/blocks/marketing/footers/footer-section.tsx +532 -0
- package/src/blocks/marketing/navbars/navbar-public-api.test.tsx +57 -0
- package/src/blocks/marketing/navbars/navbar.mega.test.tsx +149 -0
- package/src/blocks/marketing/navbars/navbar.test.tsx +155 -0
- package/src/blocks/marketing/navbars/navbar.tsx +735 -0
- package/src/blocks/marketing/testimonials/testimonial-section.test.tsx +171 -0
- package/src/blocks/marketing/testimonials/testimonial-section.tsx +237 -0
- package/src/index.ts +80 -81
- package/src/lib/contracts-curated.test.ts +5 -5
- package/src/lib/contracts.test.ts +55 -0
- package/src/lib/contracts.ts +64 -2
- package/tsup.config.ts +1 -1
- package/src/blocks/application/login-forms/login-page-1.tsx +0 -246
- package/src/blocks/application/login-forms/login-page-2.tsx +0 -207
- package/src/blocks/e-commerce/category-filters/category-filter-1.tsx +0 -260
- package/src/blocks/e-commerce/category-filters/category-filter-2-filter-panel.tsx +0 -222
- package/src/blocks/e-commerce/category-filters/category-filter-2.tsx +0 -921
- package/src/blocks/e-commerce/category-filters/category-filter-4-chip-rail.tsx +0 -57
- package/src/blocks/e-commerce/category-filters/category-filter-4-drawer.tsx +0 -124
- package/src/blocks/e-commerce/category-filters/category-filter-4-fields.tsx +0 -170
- package/src/blocks/e-commerce/category-filters/category-filter-4-sidebar.tsx +0 -52
- package/src/blocks/e-commerce/category-filters/category-filter-4-sort-sheet.tsx +0 -57
- package/src/blocks/e-commerce/category-filters/category-filter-4-state.ts +0 -68
- package/src/blocks/e-commerce/category-filters/category-filter-4.tsx +0 -298
- package/src/blocks/e-commerce/checkout-forms/card-formatting.test.ts +0 -47
- package/src/blocks/e-commerce/checkout-forms/card-formatting.ts +0 -9
- package/src/blocks/e-commerce/checkout-forms/checkout-form-1-contact-step.tsx +0 -96
- package/src/blocks/e-commerce/checkout-forms/checkout-form-1-order-summary.tsx +0 -252
- package/src/blocks/e-commerce/checkout-forms/checkout-form-1-payment-step.tsx +0 -188
- package/src/blocks/e-commerce/checkout-forms/checkout-form-1-progress.tsx +0 -36
- package/src/blocks/e-commerce/checkout-forms/checkout-form-1.test.tsx +0 -216
- package/src/blocks/e-commerce/checkout-forms/checkout-form-1.tsx +0 -338
- package/src/blocks/e-commerce/checkout-forms/checkout-form-2-order-summary.tsx +0 -130
- package/src/blocks/e-commerce/checkout-forms/checkout-form-2-payment-card.tsx +0 -175
- package/src/blocks/e-commerce/checkout-forms/checkout-form-2-shipping-card.tsx +0 -190
- package/src/blocks/e-commerce/checkout-forms/checkout-form-2.tsx +0 -312
- package/src/blocks/e-commerce/checkout-forms/checkout-form-3-information-step.tsx +0 -91
- package/src/blocks/e-commerce/checkout-forms/checkout-form-3-order-summary.tsx +0 -110
- package/src/blocks/e-commerce/checkout-forms/checkout-form-3-payment-step.tsx +0 -137
- package/src/blocks/e-commerce/checkout-forms/checkout-form-3-progress.tsx +0 -68
- package/src/blocks/e-commerce/checkout-forms/checkout-form-3-review-step.tsx +0 -79
- package/src/blocks/e-commerce/checkout-forms/checkout-form-3-shipping-step.tsx +0 -172
- package/src/blocks/e-commerce/checkout-forms/checkout-form-3.tsx +0 -392
- package/src/blocks/marketing/footers/footer-section-1.test.tsx +0 -117
- package/src/blocks/marketing/footers/footer-section-1.tsx +0 -178
- package/src/blocks/marketing/footers/footer-section-3.tsx +0 -192
- package/src/blocks/marketing/footers/footer-section-4.tsx +0 -355
- package/src/blocks/marketing/navbars/navbar-1.tsx +0 -267
- package/src/blocks/marketing/navbars/navbar-2.tsx +0 -351
- package/src/blocks/marketing/navbars/navbar-3.tsx +0 -303
- package/src/blocks/marketing/navbars/navbar-4-like-button.tsx +0 -177
- package/src/blocks/marketing/navbars/navbar-4-product-grid.tsx +0 -219
- package/src/blocks/marketing/testimonials/testimonial-1.tsx +0 -141
- package/src/blocks/marketing/testimonials/testimonial-2.tsx +0 -108
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useId } from 'react'
|
|
4
|
+
|
|
5
|
+
import { Button } from '../../../ui/button'
|
|
6
|
+
import { CardTitle } from '../../../ui/card'
|
|
7
|
+
import { Input } from '../../../ui/input'
|
|
8
|
+
import { CheckboxCheck } from '../checkout-forms/checkbox-check'
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
CategoryListingFacetGroup,
|
|
12
|
+
CategoryListingOption,
|
|
13
|
+
CategoryListingPriceRange,
|
|
14
|
+
} from './category-listing'
|
|
15
|
+
|
|
16
|
+
export interface CategoryListingFilterFieldsProps {
|
|
17
|
+
selectedText?: string
|
|
18
|
+
clearAllLabel?: string
|
|
19
|
+
priceRangeTitle?: string
|
|
20
|
+
priceRange: [number, number]
|
|
21
|
+
/**
|
|
22
|
+
* Real provider range only. When absent the price section is not rendered —
|
|
23
|
+
* the block never fabricates a `0..1000` range.
|
|
24
|
+
*/
|
|
25
|
+
priceRangeConfig?: CategoryListingPriceRange
|
|
26
|
+
minLabel?: string
|
|
27
|
+
maxLabel?: string
|
|
28
|
+
onPriceChange: (range: [number, number]) => void
|
|
29
|
+
categoriesTitle?: string
|
|
30
|
+
categories: CategoryListingOption[]
|
|
31
|
+
selectedCategories: string[]
|
|
32
|
+
onCategoryChange: (category: string, checked: boolean) => void
|
|
33
|
+
collectionsTitle?: string
|
|
34
|
+
collections: CategoryListingOption[]
|
|
35
|
+
selectedCollections: string[]
|
|
36
|
+
onCollectionChange: (collection: string, checked: boolean) => void
|
|
37
|
+
/**
|
|
38
|
+
* Generic provider-backed facet groups. A group renders only when it carries
|
|
39
|
+
* at least one option; the block never invents groups, options or counts.
|
|
40
|
+
*/
|
|
41
|
+
facets?: CategoryListingFacetGroup[]
|
|
42
|
+
selectedFacets: Record<string, string[]>
|
|
43
|
+
onFacetChange: (group: CategoryListingFacetGroup, value: string, checked: boolean) => void
|
|
44
|
+
onClearAll: () => void
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Render a count only when it is a real, non-negative, finite number. */
|
|
48
|
+
function readableCount(count: number | undefined): number | undefined {
|
|
49
|
+
return typeof count === 'number' && Number.isFinite(count) && count >= 0 ? count : undefined
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The control set shared by both presentations. The presentation only decides
|
|
54
|
+
* where these fields live (persistent sidebar, mobile sheet, or drawer); the
|
|
55
|
+
* fields, their semantics and the emitted values are identical.
|
|
56
|
+
*/
|
|
57
|
+
export function CategoryListingFilterFields({
|
|
58
|
+
selectedText = 'Filtros',
|
|
59
|
+
clearAllLabel = 'Restablecer',
|
|
60
|
+
priceRangeTitle = 'Rango de precio',
|
|
61
|
+
priceRange,
|
|
62
|
+
priceRangeConfig,
|
|
63
|
+
minLabel = 'Mínimo',
|
|
64
|
+
maxLabel = 'Máximo',
|
|
65
|
+
onPriceChange,
|
|
66
|
+
categoriesTitle = 'Categoría',
|
|
67
|
+
categories,
|
|
68
|
+
selectedCategories,
|
|
69
|
+
onCategoryChange,
|
|
70
|
+
collectionsTitle = 'Colección',
|
|
71
|
+
collections,
|
|
72
|
+
selectedCollections,
|
|
73
|
+
onCollectionChange,
|
|
74
|
+
facets = [],
|
|
75
|
+
selectedFacets,
|
|
76
|
+
onFacetChange,
|
|
77
|
+
onClearAll,
|
|
78
|
+
}: CategoryListingFilterFieldsProps) {
|
|
79
|
+
const priceInputId = useId()
|
|
80
|
+
const categoryInputId = useId()
|
|
81
|
+
const collectionInputId = useId()
|
|
82
|
+
const facetInputId = useId()
|
|
83
|
+
const visibleFacets = facets.filter(group => group.options.length > 0)
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<>
|
|
87
|
+
<div className='flex flex-col gap-6'>
|
|
88
|
+
<div className='mb-3 flex items-center justify-between'>
|
|
89
|
+
<h2 className='font-semibold'>{selectedText}</h2>
|
|
90
|
+
<Button variant='ghost' size='sm' className='h-8 cursor-pointer px-2 text-xs' onClick={onClearAll}>
|
|
91
|
+
{clearAllLabel}
|
|
92
|
+
</Button>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
{priceRangeConfig ? (
|
|
97
|
+
<div className='mt-4 flex flex-col gap-4'>
|
|
98
|
+
<CardTitle className='font-semibold'>{priceRangeTitle}</CardTitle>
|
|
99
|
+
<div className='flex items-center gap-3'>
|
|
100
|
+
<div className='flex flex-1 flex-col gap-1'>
|
|
101
|
+
<label htmlFor={`${priceInputId}-min`}>{minLabel}</label>
|
|
102
|
+
<Input
|
|
103
|
+
id={`${priceInputId}-min`}
|
|
104
|
+
type='number'
|
|
105
|
+
value={priceRange[0]}
|
|
106
|
+
onChange={event => {
|
|
107
|
+
const value = parseInt(event.target.value)
|
|
108
|
+
if (!Number.isNaN(value) && value >= priceRangeConfig.min && value <= priceRange[1]) {
|
|
109
|
+
onPriceChange([value, priceRange[1]])
|
|
110
|
+
}
|
|
111
|
+
}}
|
|
112
|
+
min={priceRangeConfig.min}
|
|
113
|
+
max={priceRange[1]}
|
|
114
|
+
step={priceRangeConfig.step}
|
|
115
|
+
className='h-9'
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
<div className='mt-5 flex-none'>-</div>
|
|
119
|
+
<div className='flex flex-1 flex-col gap-1'>
|
|
120
|
+
<label htmlFor={`${priceInputId}-max`}>{maxLabel}</label>
|
|
121
|
+
<Input
|
|
122
|
+
id={`${priceInputId}-max`}
|
|
123
|
+
type='number'
|
|
124
|
+
value={priceRange[1]}
|
|
125
|
+
onChange={event => {
|
|
126
|
+
const value = parseInt(event.target.value)
|
|
127
|
+
if (!Number.isNaN(value) && value >= priceRange[0] && value <= priceRangeConfig.max) {
|
|
128
|
+
onPriceChange([priceRange[0], value])
|
|
129
|
+
}
|
|
130
|
+
}}
|
|
131
|
+
min={priceRange[0]}
|
|
132
|
+
max={priceRangeConfig.max}
|
|
133
|
+
step={priceRangeConfig.step}
|
|
134
|
+
className='h-9'
|
|
135
|
+
/>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
) : null}
|
|
140
|
+
|
|
141
|
+
{categories.length > 0 ? (
|
|
142
|
+
<div className='mt-4 flex flex-col gap-4'>
|
|
143
|
+
<CardTitle className='font-semibold'>{categoriesTitle}</CardTitle>
|
|
144
|
+
<div className='flex flex-col gap-2'>
|
|
145
|
+
{categories.map(category => (
|
|
146
|
+
<div key={category.id} className='flex items-center gap-2'>
|
|
147
|
+
<CheckboxCheck
|
|
148
|
+
id={`${categoryInputId}-${category.id}`}
|
|
149
|
+
checked={selectedCategories.includes(category.id)}
|
|
150
|
+
onCheckedChange={checked => onCategoryChange(category.id, checked as boolean)}
|
|
151
|
+
/>
|
|
152
|
+
<label htmlFor={`${categoryInputId}-${category.id}`} className='text-sm'>
|
|
153
|
+
{category.label}
|
|
154
|
+
</label>
|
|
155
|
+
</div>
|
|
156
|
+
))}
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
) : null}
|
|
160
|
+
|
|
161
|
+
{collections.length > 0 ? (
|
|
162
|
+
<div className='mt-4 flex flex-col gap-4'>
|
|
163
|
+
<CardTitle className='font-semibold'>{collectionsTitle}</CardTitle>
|
|
164
|
+
<div className='flex flex-col gap-2'>
|
|
165
|
+
{collections.map(collection => (
|
|
166
|
+
<div key={collection.id} className='flex items-center gap-2'>
|
|
167
|
+
<CheckboxCheck
|
|
168
|
+
id={`${collectionInputId}-${collection.id}`}
|
|
169
|
+
checked={selectedCollections.includes(collection.id)}
|
|
170
|
+
onCheckedChange={checked => onCollectionChange(collection.id, checked as boolean)}
|
|
171
|
+
/>
|
|
172
|
+
<label htmlFor={`${collectionInputId}-${collection.id}`} className='text-sm'>
|
|
173
|
+
{collection.label}
|
|
174
|
+
</label>
|
|
175
|
+
</div>
|
|
176
|
+
))}
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
) : null}
|
|
180
|
+
|
|
181
|
+
{visibleFacets.map(group => {
|
|
182
|
+
const selected = selectedFacets[group.id] ?? []
|
|
183
|
+
return (
|
|
184
|
+
<div key={group.id} className='mt-4 flex flex-col gap-4' data-slot='facet-group' data-facet-id={group.id}>
|
|
185
|
+
<CardTitle className='font-semibold'>{group.label}</CardTitle>
|
|
186
|
+
<div className='flex flex-col gap-2'>
|
|
187
|
+
{group.options.map(option => {
|
|
188
|
+
const count = readableCount(option.count)
|
|
189
|
+
return (
|
|
190
|
+
<div key={option.value} className='flex items-center gap-2'>
|
|
191
|
+
<CheckboxCheck
|
|
192
|
+
id={`${facetInputId}-${group.id}-${option.value}`}
|
|
193
|
+
checked={selected.includes(option.value)}
|
|
194
|
+
onCheckedChange={checked => onFacetChange(group, option.value, checked as boolean)}
|
|
195
|
+
/>
|
|
196
|
+
<label
|
|
197
|
+
htmlFor={`${facetInputId}-${group.id}-${option.value}`}
|
|
198
|
+
className='flex flex-1 items-center justify-between gap-2 text-sm'
|
|
199
|
+
>
|
|
200
|
+
<span>{option.label}</span>
|
|
201
|
+
{count === undefined ? null : (
|
|
202
|
+
<span data-slot='facet-count' className='text-muted-foreground text-xs'>
|
|
203
|
+
{count}
|
|
204
|
+
</span>
|
|
205
|
+
)}
|
|
206
|
+
</label>
|
|
207
|
+
</div>
|
|
208
|
+
)
|
|
209
|
+
})}
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
)
|
|
213
|
+
})}
|
|
214
|
+
</>
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export default CategoryListingFilterFields
|