@thorprovider/blocks 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/.turbo/turbo-build.log +15 -15
  2. package/.turbo/turbo-test.log +32 -5
  3. package/AGENTS.md +1 -1
  4. package/README.md +52 -0
  5. package/dist/.tsbuildinfo +1 -1
  6. package/dist/contracts.d.mts +1111 -90
  7. package/dist/contracts.d.ts +1111 -90
  8. package/dist/contracts.js +189 -6
  9. package/dist/contracts.js.map +1 -1
  10. package/dist/contracts.mjs +173 -7
  11. package/dist/contracts.mjs.map +1 -1
  12. package/dist/index.d.mts +467 -89
  13. package/dist/index.d.ts +467 -89
  14. package/dist/index.js +2967 -2250
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +2989 -2282
  17. package/dist/index.mjs.map +1 -1
  18. package/docs/standards/theming.md +32 -5
  19. package/package.json +4 -3
  20. package/src/blocks/e-commerce/category-filters/category-filter-2-filter-panel.tsx +136 -93
  21. package/src/blocks/e-commerce/category-filters/category-filter-2.test.tsx +513 -0
  22. package/src/blocks/e-commerce/category-filters/category-filter-2.tsx +728 -148
  23. package/src/blocks/e-commerce/checkout-forms/checkout-confirmation-fulfilment-progress.tsx +14 -8
  24. package/src/blocks/e-commerce/checkout-forms/checkout-confirmation.test.tsx +136 -0
  25. package/src/blocks/e-commerce/checkout-forms/checkout-confirmation.tsx +145 -99
  26. package/src/blocks/e-commerce/checkout-forms/checkout-form-1-order-summary.tsx +215 -102
  27. package/src/blocks/e-commerce/checkout-forms/checkout-form-1-payment-step.tsx +6 -2
  28. package/src/blocks/e-commerce/checkout-forms/checkout-form-1-shipping-step.tsx +51 -2
  29. package/src/blocks/e-commerce/checkout-forms/checkout-form-1.test.tsx +216 -0
  30. package/src/blocks/e-commerce/checkout-forms/checkout-form-1.tsx +114 -11
  31. package/src/blocks/e-commerce/navigation/mobile-category-drawer.test.tsx +42 -2
  32. package/src/blocks/e-commerce/navigation/mobile-category-drawer.tsx +10 -8
  33. package/src/blocks/e-commerce/product-categories/product-category-2.test.tsx +51 -0
  34. package/src/blocks/e-commerce/product-categories/product-category-2.tsx +56 -36
  35. package/src/blocks/e-commerce/product-overview/product-overview-1.test.tsx +182 -0
  36. package/src/blocks/e-commerce/product-overview/product-overview-1.tsx +298 -129
  37. package/src/blocks/e-commerce/shopping-carts/shopping-cart-4.test.tsx +137 -0
  38. package/src/blocks/e-commerce/shopping-carts/shopping-cart-4.tsx +231 -89
  39. package/src/blocks/e-commerce/storefront-hero/storefront-hero-1.test.tsx +65 -0
  40. package/src/blocks/e-commerce/storefront-hero/storefront-hero-1.tsx +19 -0
  41. package/src/blocks/marketing/footers/footer-section-1.test.tsx +117 -0
  42. package/src/blocks/marketing/footers/footer-section-1.tsx +46 -9
  43. package/src/blocks/marketing/navbars/navbar-4-cart-sheet.test.tsx +54 -0
  44. package/src/blocks/marketing/navbars/navbar-4-cart-sheet.tsx +43 -13
  45. package/src/blocks/marketing/navbars/navbar-4.test.tsx +112 -0
  46. package/src/blocks/marketing/navbars/navbar-4.tsx +101 -28
  47. package/src/index.ts +38 -0
  48. package/src/lib/cart.test.ts +15 -0
  49. package/src/lib/cart.ts +11 -0
  50. package/src/lib/contracts-curated.test.ts +207 -0
  51. package/src/lib/contracts-server-boundary.test.ts +52 -0
  52. package/src/lib/contracts.ts +182 -4
  53. package/src/lib/money.test.ts +64 -0
  54. package/src/lib/money.ts +65 -0
  55. package/styles.css +1 -0
  56. package/tsup.config.ts +0 -1
  57. package/vitest.config.ts +9 -1
@@ -6,19 +6,19 @@ CLI Target: esnext
6
6
  CLI Cleaning output folder
7
7
  CJS Build start
8
8
  ESM Build start
9
- CJS dist/contracts.js 8.15 KB
10
- CJS dist/index.js 801.34 KB
11
- CJS dist/contracts.js.map 12.65 KB
12
- CJS dist/index.js.map 1.13 MB
13
- CJS ⚡️ Build success in 801ms
14
- ESM dist/contracts.mjs 5.12 KB
15
- ESM dist/index.mjs 708.79 KB
16
- ESM dist/contracts.mjs.map 12.54 KB
17
- ESM dist/index.mjs.map 1.14 MB
18
- ESM ⚡️ Build success in 815ms
19
9
  DTS Build start
20
- DTS ⚡️ Build success in 17297ms
21
- DTS dist/index.d.ts 86.38 KB
22
- DTS dist/contracts.d.ts 17.94 KB
23
- DTS dist/index.d.mts 86.38 KB
24
- DTS dist/contracts.d.mts 17.94 KB
10
+ ESM dist/contracts.mjs 10.65 KB
11
+ ESM dist/index.mjs 751.64 KB
12
+ ESM dist/contracts.mjs.map 26.52 KB
13
+ ESM dist/index.mjs.map 1.24 MB
14
+ ESM ⚡️ Build success in 1060ms
15
+ CJS dist/contracts.js 15.38 KB
16
+ CJS dist/index.js 849.47 KB
17
+ CJS dist/contracts.js.map 26.72 KB
18
+ CJS dist/index.js.map 1.22 MB
19
+ CJS ⚡️ Build success in 1061ms
20
+ DTS ⚡️ Build success in 15393ms
21
+ DTS dist/index.d.ts 107.68 KB
22
+ DTS dist/contracts.d.ts 52.25 KB
23
+ DTS dist/index.d.mts 107.68 KB
24
+ DTS dist/contracts.d.mts 52.25 KB
@@ -1,10 +1,37 @@
1
1
 
2
2
  RUN v3.2.4 /home/nelson/dev/active/thorprovider/repos/thorcommerce/packages/blocks
3
3
 
4
- ✓ src/blocks/e-commerce/checkout-forms/card-formatting.test.ts (10 tests) 14ms
4
+ ✓ src/lib/money.test.ts (10 tests) 391ms
5
+ ✓ formatMoney > uses the money currency rather than a hardcoded one 335ms
6
+ ✓ src/blocks/e-commerce/navigation/mega-menu.test.tsx (9 tests) 546ms
7
+ ✓ src/blocks/e-commerce/navigation/mobile-category-drawer.test.tsx (12 tests) 271ms
8
+ ✓ src/blocks/e-commerce/product-overview/product-overview-1.test.tsx (14 tests) 87ms
9
+ ✓ src/blocks/e-commerce/navigation/category-icon.test.tsx (7 tests) 195ms
10
+ ✓ src/blocks/e-commerce/checkout-forms/checkout-confirmation.test.tsx (7 tests) 449ms
11
+ ✓ src/blocks/e-commerce/shopping-carts/shopping-cart-4.test.tsx (10 tests) 435ms
12
+ ✓ src/blocks/e-commerce/product-categories/product-category-2.test.tsx (5 tests) 351ms
13
+ ✓ src/blocks/marketing/footers/footer-section-1.test.tsx (9 tests) 371ms
14
+ ✓ src/lib/contracts-curated.test.ts (22 tests) 78ms
15
+ ✓ src/lib/contracts-server-boundary.test.ts (3 tests) 662ms
16
+ ✓ blocks entrypoint boundaries (6.7) > builds a contracts bundle with no use client directive and a UI bundle with it 655ms
17
+ ✓ src/blocks/marketing/navbars/navbar-4.test.tsx (11 tests) 709ms
18
+ ✓ Navbar4 — optional logo accent > accents a matched trailing segment without duplicating the wordmark 399ms
19
+ ✓ src/lib/contracts.test.ts (3 tests) 67ms
20
+ ✓ src/blocks/e-commerce/checkout-forms/card-formatting.test.ts (10 tests) 49ms
21
+ ✓ src/lib/cart.test.ts (2 tests) 24ms
22
+ stderr | src/blocks/e-commerce/checkout-forms/checkout-form-1.test.tsx > CheckoutForm1 payment step — launch flow collects no raw card data > renders card fields only in the explicit legacy mode
23
+ Received `true` for a non-boolean attribute `inline-end`.
5
24
 
6
- Test Files 1 passed (1)
7
- Tests 10 passed (10)
8
- Start at 16:54:02
9
- Duration 1.03s (transform 162ms, setup 0ms, collect 93ms, tests 14ms, environment 0ms, prepare 252ms)
25
+ If you want to write it to the DOM, pass a string instead: inline-end="true" or inline-end={value.toString()}.
26
+
27
+ ✓ src/blocks/e-commerce/category-filters/category-filter-2.test.tsx (39 tests) 1069ms
28
+ ✓ CategoryFilter2 — controlled canonical query > renders the query-selected search, category, sort and page values 307ms
29
+ ✓ src/blocks/e-commerce/checkout-forms/checkout-form-1.test.tsx (10 tests) 739ms
30
+ ✓ src/blocks/e-commerce/storefront-hero/storefront-hero-1.test.tsx (5 tests) 107ms
31
+ ✓ src/blocks/marketing/navbars/navbar-4-cart-sheet.test.tsx (3 tests) 52ms
32
+
33
+ Test Files 19 passed (19)
34
+ Tests 191 passed (191)
35
+ Start at 10:20:45
36
+ Duration 9.78s (transform 6.28s, setup 0ms, collect 46.63s, tests 6.65s, environment 7ms, prepare 11.77s)
10
37
 
package/AGENTS.md CHANGED
@@ -1 +1 @@
1
- <!-- BLOCKS-AGENTS-MD-START -->[@thorprovider/blocks Docs]|root: ./blocks|Documentation for @thorprovider/blocks. Always read package docs before making changes.|To regenerate: yarn workspace @thorprovider/blocks generate:agent-index|.:{README.md}|docs/standards:{data-contracts.md,theming.md}<!-- BLOCKS-AGENTS-MD-END -->
1
+ <!-- BLOCKS-AGENTS-MD-START -->[@thorprovider/blocks Docs]|root: ./blocks|Electrostore MVP: see director roadmap.|To regenerate: yarn workspace @thorprovider/blocks generate:agent-index|.:{README.md}|docs/standards:{data-contracts.md,theming.md}<!-- BLOCKS-AGENTS-MD-END -->
package/README.md CHANGED
@@ -91,6 +91,53 @@ Blocks follow `src/blocks/<category>/<section>/<block>.tsx`. Each block co-locat
91
91
 
92
92
  Interactions are exposed as callbacks (e.g. `onAddToCart`, `onBuyNow`, `onSelectColor`). Elements stay in the DOM with no-op behavior when a callback is absent.
93
93
 
94
+ ## Optional brand props
95
+
96
+ Three existing blocks expose an optional brand seam. Omitting the prop renders
97
+ the block's current output unchanged; no demo content is added.
98
+
99
+ - `Navbar4` — `logoAccent?: { text: string; className?: string }` accents a
100
+ trailing segment of `logoText`. With `logoText="ElectroCuba"` and
101
+ `logoAccent={{ text: 'Cuba', className: 'text-brand-promo' }}`, the block
102
+ renders `Electro` plus an accented `Cuba` span. If `text` is not a trailing
103
+ segment of `logoText`, the wordmark renders unchanged.
104
+ - `FooterSection1` — `brandAccent?: { text: string; className?: string }` applies
105
+ the same trailing-segment accent to `brandName`.
106
+ - `StorefrontHero1` — `heroImage?: { src: string; alt: string }` renders a native
107
+ `<img>` when `src` is a non-empty string, and nothing when the prop is absent
108
+ or `src` is blank (never an empty `src`). The product grid is unaffected.
109
+
110
+ `className` carries the consumer's own semantic token (e.g. `text-brand-promo`);
111
+ the library hardcodes no brand color.
112
+
113
+ ## Custom surface `className`
114
+
115
+ `Navbar4` (outer `<header>`) and `FooterSection1` (outer `<footer>`) accept an
116
+ optional `className`, merged with the existing `cn` helper. It is purely
117
+ presentational: no layout, structure, or behavior prop, and no hardcoded color.
118
+
119
+ - **Omitted `className`** — the block renders its default surface unchanged.
120
+ `Navbar4` keeps `bg-background/95` **and** its
121
+ `supports-backdrop-filter:bg-background/80` variant; `FooterSection1` keeps
122
+ `bg-secondary`.
123
+ - **Supplied `className`** — the consumer owns the surface. The default
124
+ background **and its backdrop-filter variant** are not applied, so a semantic
125
+ surface such as `bg-brand-nav text-brand-nav-foreground` actually paints (the
126
+ `supports-backdrop-filter` variant would otherwise win on Chromium and mask
127
+ it). Layout, border, sticky, and `backdrop-blur-md` classes stay internal.
128
+
129
+ The consumer is responsible for the text, transparency, and context tokens of a
130
+ supplied surface. `Navbar4` adapts its primary nav links: they inherit the
131
+ surface text color and add `hover:text-foreground` so `hover:bg-muted` never
132
+ paints white-on-light. No magic colors are introduced by the block.
133
+
134
+ ## Footer newsletter
135
+
136
+ `FooterSection1` renders the interactive newsletter form (input + submit button)
137
+ **only** when `newsletter.onSubmit` is supplied. A `newsletter` object without
138
+ `onSubmit` renders no form, input, or button — never a fake form. Omit
139
+ `newsletter` entirely to hide the newsletter block.
140
+
94
141
  ## Checkout blocks (controlled)
95
142
 
96
143
  `CheckoutForm1` (3-step wizard) and `CheckoutForm2` (single page) are **controlled components**: they receive the current form values through a `values` prop and report every edit through `onChange`. They hold no internal form state, so a renderer's validation context can read field values from its own state model. `CheckoutForm3` (4-step wizard) keeps the same contract with internal step state.
@@ -149,6 +196,11 @@ unique by contract, not by convention. See
149
196
  [`docs/standards/data-contracts.md`](docs/standards/data-contracts.md) for the
150
197
  rules and the review checklist.
151
198
 
199
+ Optional numeric projections are omitted rather than fabricated: e.g.
200
+ `ProductCategory2Category.itemCount` renders a count only when it is a supplied
201
+ finite non-negative number (a real `0` is preserved); an unknown count renders
202
+ no count text, never a fabricated `0`.
203
+
152
204
  ## Block interaction contracts
153
205
 
154
206
  State and events between a block, its host registry, and the store must follow