@eldrajs/theme-cli 0.0.0-stage → 0.1.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.
Files changed (483) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/LICENSE +21 -0
  3. package/README.md +27 -2
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +203 -0
  6. package/dist/index.d.ts +174 -0
  7. package/dist/index.js +3 -0
  8. package/dist/validate-C6jB8_Oc.js +510 -0
  9. package/package.json +56 -3
  10. package/template/.eldra/block-types.d.ts +429 -0
  11. package/template/.eldra/manifest.json +9377 -0
  12. package/template/.eldra/previews.json +36 -0
  13. package/template/.github/workflows/eldra-deploy.yml +24 -0
  14. package/template/.gitlab-ci.yml +16 -0
  15. package/template/.storybook/eldra.ts +123 -0
  16. package/template/.storybook/i18n.ts +23 -0
  17. package/template/.storybook/main.ts +59 -0
  18. package/template/.storybook/nuxt-link-stub.ts +23 -0
  19. package/template/.storybook/preview.ts +52 -0
  20. package/template/.storybook/shims-vue.d.ts +10 -0
  21. package/template/.storybook/virtual-eldra.d.ts +27 -0
  22. package/template/README.md +288 -0
  23. package/template/app/app.vue +126 -0
  24. package/template/app/assets/main.css +404 -0
  25. package/template/app/components/EldraIcon.vue +66 -0
  26. package/template/app/components/EldraRouterLink.vue +62 -0
  27. package/template/app/components/ui/UiImage.stories.ts +30 -0
  28. package/template/app/components/ui/UiImage.vue +224 -0
  29. package/template/app/components/ui/__tests__/UiImage.spec.ts +292 -0
  30. package/template/app/composables/iconComponent.ts +84 -0
  31. package/template/app/composables/iconFetcher.ts +14 -0
  32. package/template/app/composables/useBlockData.ts +30 -0
  33. package/template/app/composables/useEditing.ts +31 -0
  34. package/template/app/composables/useEldraIcon.ts +46 -0
  35. package/template/app/composables/useRevalidating.ts +69 -0
  36. package/template/app/composables/useRichTextScrollRegions.ts +80 -0
  37. package/template/app/composables/useStorefront.ts +18 -0
  38. package/template/app/composables/useStorefrontFeedback.ts +49 -0
  39. package/template/app/composables/useUiId.ts +18 -0
  40. package/template/app/composables/useWishlist.ts +42 -0
  41. package/template/app/i18n.d.ts +28 -0
  42. package/template/app/icons.ts +185 -0
  43. package/template/app/pages/[...slug].vue +134 -0
  44. package/template/app/plugins/eldra-i18n.ts +98 -0
  45. package/template/app/plugins/eldra-storefront.ts +288 -0
  46. package/template/app/plugins/eldra-ui-messages.ts +112 -0
  47. package/template/app/storefront/cart.ts +245 -0
  48. package/template/app/storefront/categories.ts +283 -0
  49. package/template/app/storefront/collectionSelector.ts +60 -0
  50. package/template/app/storefront/commerce.ts +58 -0
  51. package/template/app/storefront/demo.ts +1313 -0
  52. package/template/app/storefront/facets.ts +476 -0
  53. package/template/app/storefront/feedback.ts +122 -0
  54. package/template/app/storefront/gateway.ts +2256 -0
  55. package/template/app/storefront/history.ts +233 -0
  56. package/template/app/storefront/money.ts +247 -0
  57. package/template/app/storefront/options.ts +71 -0
  58. package/template/app/storefront/prerender.ts +77 -0
  59. package/template/app/storefront/refresh.ts +222 -0
  60. package/template/app/storefront/toProductCard.ts +154 -0
  61. package/template/app/storefront/types.ts +815 -0
  62. package/template/app/storefront/volatile.ts +211 -0
  63. package/template/app/templates.ts +544 -0
  64. package/template/app/utils/classes.ts +40 -0
  65. package/template/app/utils/links.ts +70 -0
  66. package/template/app/utils/pageStructure.ts +77 -0
  67. package/template/app/utils/pageTitle.ts +37 -0
  68. package/template/app/virtual-eldra.d.ts +12 -0
  69. package/template/bitbucket-pipelines.yml +19 -0
  70. package/template/blocks/announcement-bar/Block.vue +203 -0
  71. package/template/blocks/announcement-bar/__tests__/Block.spec.ts +227 -0
  72. package/template/blocks/announcement-bar/block.json +45 -0
  73. package/template/blocks/announcement-bar/mock.json +7 -0
  74. package/template/blocks/announcement-bar/preview.png +0 -0
  75. package/template/blocks/article/Block.vue +317 -0
  76. package/template/blocks/article/__tests__/Block.spec.ts +229 -0
  77. package/template/blocks/article/block.json +148 -0
  78. package/template/blocks/article/mock.json +512 -0
  79. package/template/blocks/article/preview.json +16 -0
  80. package/template/blocks/article/preview.png +0 -0
  81. package/template/blocks/article-list/Block.vue +343 -0
  82. package/template/blocks/article-list/__tests__/Block.spec.ts +279 -0
  83. package/template/blocks/article-list/block.json +181 -0
  84. package/template/blocks/article-list/mock.json +68 -0
  85. package/template/blocks/article-list/preview.json +84 -0
  86. package/template/blocks/article-list/preview.png +0 -0
  87. package/template/blocks/breadcrumbs/Block.vue +278 -0
  88. package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +461 -0
  89. package/template/blocks/breadcrumbs/block.json +89 -0
  90. package/template/blocks/breadcrumbs/mock.json +11 -0
  91. package/template/blocks/breadcrumbs/preview.json +3 -0
  92. package/template/blocks/breadcrumbs/preview.png +0 -0
  93. package/template/blocks/cart/Block.vue +372 -0
  94. package/template/blocks/cart/__tests__/Block.spec.ts +561 -0
  95. package/template/blocks/cart/__tests__/ShippingBar.spec.ts +78 -0
  96. package/template/blocks/cart/__tests__/Summary.spec.ts +245 -0
  97. package/template/blocks/cart/block.json +74 -0
  98. package/template/blocks/cart/mock.json +11 -0
  99. package/template/blocks/cart/parts/CartLines.vue +257 -0
  100. package/template/blocks/cart/parts/ShippingBar.vue +105 -0
  101. package/template/blocks/cart/parts/Summary.vue +291 -0
  102. package/template/blocks/cart/preview.png +0 -0
  103. package/template/blocks/collection-grid/Block.vue +1832 -0
  104. package/template/blocks/collection-grid/__tests__/Block.spec.ts +3037 -0
  105. package/template/blocks/collection-grid/__tests__/groups.spec.ts +731 -0
  106. package/template/blocks/collection-grid/block.json +187 -0
  107. package/template/blocks/collection-grid/mock.json +23 -0
  108. package/template/blocks/collection-grid/parts/groups.ts +861 -0
  109. package/template/blocks/collection-grid/preview.json +7 -0
  110. package/template/blocks/collection-grid/preview.png +0 -0
  111. package/template/blocks/collection-header/Block.vue +533 -0
  112. package/template/blocks/collection-header/__tests__/Block.spec.ts +381 -0
  113. package/template/blocks/collection-header/block.json +140 -0
  114. package/template/blocks/collection-header/mock.json +28 -0
  115. package/template/blocks/collection-header/preview.json +14 -0
  116. package/template/blocks/collection-header/preview.png +0 -0
  117. package/template/blocks/contact/Block.vue +621 -0
  118. package/template/blocks/contact/__tests__/Block.spec.ts +347 -0
  119. package/template/blocks/contact/block.json +174 -0
  120. package/template/blocks/contact/mock.json +28 -0
  121. package/template/blocks/contact/preview.json +9 -0
  122. package/template/blocks/contact/preview.png +0 -0
  123. package/template/blocks/cta/Block.vue +383 -0
  124. package/template/blocks/cta/__tests__/Block.spec.ts +309 -0
  125. package/template/blocks/cta/block.json +86 -0
  126. package/template/blocks/cta/mock.json +10 -0
  127. package/template/blocks/cta/preview.json +9 -0
  128. package/template/blocks/cta/preview.png +0 -0
  129. package/template/blocks/faq/Block.vue +254 -0
  130. package/template/blocks/faq/__tests__/Block.spec.ts +312 -0
  131. package/template/blocks/faq/block.json +113 -0
  132. package/template/blocks/faq/mock.json +115 -0
  133. package/template/blocks/faq/preview.png +0 -0
  134. package/template/blocks/feature-grid/Block.vue +241 -0
  135. package/template/blocks/feature-grid/__tests__/Block.spec.ts +311 -0
  136. package/template/blocks/feature-grid/block.json +106 -0
  137. package/template/blocks/feature-grid/mock.json +29 -0
  138. package/template/blocks/feature-grid/preview.json +45 -0
  139. package/template/blocks/feature-grid/preview.png +0 -0
  140. package/template/blocks/footer/Block.vue +652 -0
  141. package/template/blocks/footer/__tests__/Block.spec.ts +700 -0
  142. package/template/blocks/footer/block.json +240 -0
  143. package/template/blocks/footer/mock.json +161 -0
  144. package/template/blocks/footer/preview.png +0 -0
  145. package/template/blocks/gallery/Block.vue +416 -0
  146. package/template/blocks/gallery/__tests__/Block.spec.ts +289 -0
  147. package/template/blocks/gallery/block.json +87 -0
  148. package/template/blocks/gallery/mock.json +16 -0
  149. package/template/blocks/gallery/preview.json +64 -0
  150. package/template/blocks/gallery/preview.png +0 -0
  151. package/template/blocks/hero/Block.vue +378 -0
  152. package/template/blocks/hero/__tests__/Block.spec.ts +324 -0
  153. package/template/blocks/hero/block.json +146 -0
  154. package/template/blocks/hero/mock.json +11 -0
  155. package/template/blocks/hero/preview.json +55 -0
  156. package/template/blocks/hero/preview.png +0 -0
  157. package/template/blocks/image/Block.vue +232 -0
  158. package/template/blocks/image/__tests__/Block.spec.ts +224 -0
  159. package/template/blocks/image/block.json +67 -0
  160. package/template/blocks/image/mock.json +7 -0
  161. package/template/blocks/image/preview.json +9 -0
  162. package/template/blocks/image/preview.png +0 -0
  163. package/template/blocks/logo-cloud/Block.vue +206 -0
  164. package/template/blocks/logo-cloud/__tests__/Block.spec.ts +210 -0
  165. package/template/blocks/logo-cloud/block.json +79 -0
  166. package/template/blocks/logo-cloud/mock.json +15 -0
  167. package/template/blocks/logo-cloud/preview.json +92 -0
  168. package/template/blocks/logo-cloud/preview.png +0 -0
  169. package/template/blocks/navigation/Block.vue +1348 -0
  170. package/template/blocks/navigation/__tests__/Block.spec.ts +2030 -0
  171. package/template/blocks/navigation/block.json +167 -0
  172. package/template/blocks/navigation/mock.json +191 -0
  173. package/template/blocks/navigation/preview.png +0 -0
  174. package/template/blocks/navigation/useMegaMenuKeys.ts +276 -0
  175. package/template/blocks/newsletter/Block.vue +399 -0
  176. package/template/blocks/newsletter/__tests__/Block.spec.ts +365 -0
  177. package/template/blocks/newsletter/block.json +105 -0
  178. package/template/blocks/newsletter/mock.json +31 -0
  179. package/template/blocks/newsletter/preview.png +0 -0
  180. package/template/blocks/order-status/Block.vue +754 -0
  181. package/template/blocks/order-status/__tests__/Block.spec.ts +515 -0
  182. package/template/blocks/order-status/block.json +138 -0
  183. package/template/blocks/order-status/mock.json +19 -0
  184. package/template/blocks/order-status/preview.png +0 -0
  185. package/template/blocks/pricing-table/Block.vue +297 -0
  186. package/template/blocks/pricing-table/__tests__/Block.spec.ts +357 -0
  187. package/template/blocks/pricing-table/block.json +155 -0
  188. package/template/blocks/pricing-table/mock.json +47 -0
  189. package/template/blocks/pricing-table/preview.png +0 -0
  190. package/template/blocks/product-carousel/Block.vue +459 -0
  191. package/template/blocks/product-carousel/__tests__/Block.spec.ts +957 -0
  192. package/template/blocks/product-carousel/block.json +71 -0
  193. package/template/blocks/product-carousel/mock.json +9 -0
  194. package/template/blocks/product-carousel/preview.json +7 -0
  195. package/template/blocks/product-carousel/preview.png +0 -0
  196. package/template/blocks/product-detail/Block.vue +886 -0
  197. package/template/blocks/product-detail/__tests__/Block.spec.ts +1495 -0
  198. package/template/blocks/product-detail/__tests__/stock.spec.ts +119 -0
  199. package/template/blocks/product-detail/block.json +155 -0
  200. package/template/blocks/product-detail/mock.json +113 -0
  201. package/template/blocks/product-detail/parts/Gallery.vue +181 -0
  202. package/template/blocks/product-detail/parts/StickyBuyBar.vue +99 -0
  203. package/template/blocks/product-detail/preview.png +0 -0
  204. package/template/blocks/product-detail/stock.ts +150 -0
  205. package/template/blocks/quote/Block.vue +206 -0
  206. package/template/blocks/quote/__tests__/Block.spec.ts +265 -0
  207. package/template/blocks/quote/block.json +76 -0
  208. package/template/blocks/quote/mock.json +9 -0
  209. package/template/blocks/quote/preview.json +16 -0
  210. package/template/blocks/quote/preview.png +0 -0
  211. package/template/blocks/rich-text/Block.vue +143 -0
  212. package/template/blocks/rich-text/__tests__/Block.spec.ts +191 -0
  213. package/template/blocks/rich-text/block.json +57 -0
  214. package/template/blocks/rich-text/mock.json +87 -0
  215. package/template/blocks/rich-text/preview.png +0 -0
  216. package/template/blocks/search/Block.vue +589 -0
  217. package/template/blocks/search/PopularChips.vue +40 -0
  218. package/template/blocks/search/TypeSection.vue +148 -0
  219. package/template/blocks/search/__tests__/Block.spec.ts +718 -0
  220. package/template/blocks/search/__tests__/results.spec.ts +166 -0
  221. package/template/blocks/search/block.json +102 -0
  222. package/template/blocks/search/mock.json +18 -0
  223. package/template/blocks/search/preview.png +0 -0
  224. package/template/blocks/search/results.ts +85 -0
  225. package/template/blocks/split-content/Block.vue +195 -0
  226. package/template/blocks/split-content/__tests__/Block.spec.ts +225 -0
  227. package/template/blocks/split-content/block.json +70 -0
  228. package/template/blocks/split-content/mock.json +45 -0
  229. package/template/blocks/split-content/preview.json +58 -0
  230. package/template/blocks/split-content/preview.png +0 -0
  231. package/template/blocks/stats/Block.vue +159 -0
  232. package/template/blocks/stats/__tests__/Block.spec.ts +194 -0
  233. package/template/blocks/stats/block.json +73 -0
  234. package/template/blocks/stats/mock.json +12 -0
  235. package/template/blocks/stats/preview.png +0 -0
  236. package/template/blocks/tabs/Block.vue +278 -0
  237. package/template/blocks/tabs/__tests__/Block.spec.ts +303 -0
  238. package/template/blocks/tabs/block.json +97 -0
  239. package/template/blocks/tabs/mock.json +129 -0
  240. package/template/blocks/tabs/preview.json +153 -0
  241. package/template/blocks/tabs/preview.png +0 -0
  242. package/template/blocks/team/Block.vue +288 -0
  243. package/template/blocks/team/__tests__/Block.spec.ts +221 -0
  244. package/template/blocks/team/block.json +125 -0
  245. package/template/blocks/team/mock.json +39 -0
  246. package/template/blocks/team/preview.json +62 -0
  247. package/template/blocks/team/preview.png +0 -0
  248. package/template/blocks/testimonials/Block.vue +408 -0
  249. package/template/blocks/testimonials/__tests__/Block.spec.ts +319 -0
  250. package/template/blocks/testimonials/block.json +121 -0
  251. package/template/blocks/testimonials/mock.json +46 -0
  252. package/template/blocks/testimonials/preview.json +68 -0
  253. package/template/blocks/testimonials/preview.png +0 -0
  254. package/template/blocks/timeline/Block.vue +274 -0
  255. package/template/blocks/timeline/__tests__/Block.spec.ts +310 -0
  256. package/template/blocks/timeline/block.json +98 -0
  257. package/template/blocks/timeline/mock.json +27 -0
  258. package/template/blocks/timeline/preview.png +0 -0
  259. package/template/blocks/trust-strip/Block.vue +330 -0
  260. package/template/blocks/trust-strip/__tests__/Block.spec.ts +290 -0
  261. package/template/blocks/trust-strip/block.json +117 -0
  262. package/template/blocks/trust-strip/mock.json +37 -0
  263. package/template/blocks/trust-strip/preview.png +0 -0
  264. package/template/blocks/video-embed/Block.vue +354 -0
  265. package/template/blocks/video-embed/__tests__/Block.spec.ts +219 -0
  266. package/template/blocks/video-embed/__tests__/embed.spec.ts +76 -0
  267. package/template/blocks/video-embed/block.json +94 -0
  268. package/template/blocks/video-embed/embed.ts +84 -0
  269. package/template/blocks/video-embed/mock.json +13 -0
  270. package/template/blocks/video-embed/preview.json +9 -0
  271. package/template/blocks/video-embed/preview.png +0 -0
  272. package/template/blocks/wishlist/Block.vue +367 -0
  273. package/template/blocks/wishlist/__tests__/Block.spec.ts +508 -0
  274. package/template/blocks/wishlist/block.json +42 -0
  275. package/template/blocks/wishlist/mock.json +9 -0
  276. package/template/blocks/wishlist/preview.png +0 -0
  277. package/template/i18n/en-US.json +602 -0
  278. package/template/i18n/is-IS.json +602 -0
  279. package/template/nuxt.config.ts +148 -0
  280. package/template/package.json +55 -0
  281. package/template/pages/article.page.json +731 -0
  282. package/template/pages/cart.page.json +85 -0
  283. package/template/pages/category.page.json +133 -0
  284. package/template/pages/collection.page.json +194 -0
  285. package/template/pages/home.page.json +353 -0
  286. package/template/pages/product.page.json +323 -0
  287. package/template/pages/products.page.json +144 -0
  288. package/template/pages/search.page.json +83 -0
  289. package/template/pages/wishlist.page.json +88 -0
  290. package/template/public/demo/article-cover.svg +1 -0
  291. package/template/public/demo/article-figure.svg +1 -0
  292. package/template/public/demo/avatar-1.svg +3 -0
  293. package/template/public/demo/avatar-2.svg +3 -0
  294. package/template/public/demo/avatar-3.svg +3 -0
  295. package/template/public/demo/avatar-4.svg +3 -0
  296. package/template/public/demo/avatar-5.svg +3 -0
  297. package/template/public/demo/avatar-6.svg +3 -0
  298. package/template/public/demo/avatar-7.svg +3 -0
  299. package/template/public/demo/avatar-8.svg +3 -0
  300. package/template/public/demo/collection-1.svg +1 -0
  301. package/template/public/demo/collection-2.svg +1 -0
  302. package/template/public/demo/cta-split.svg +1 -0
  303. package/template/public/demo/feature-1.svg +1 -0
  304. package/template/public/demo/feature-2.svg +1 -0
  305. package/template/public/demo/feature-3.svg +1 -0
  306. package/template/public/demo/feature-4.svg +1 -0
  307. package/template/public/demo/gallery-1.svg +1 -0
  308. package/template/public/demo/gallery-2.svg +1 -0
  309. package/template/public/demo/gallery-3.svg +1 -0
  310. package/template/public/demo/gallery-4.svg +1 -0
  311. package/template/public/demo/gallery-5.svg +1 -0
  312. package/template/public/demo/gallery-6.svg +1 -0
  313. package/template/public/demo/gallery-7.svg +1 -0
  314. package/template/public/demo/gallery-8.svg +1 -0
  315. package/template/public/demo/hero-slide-1.svg +1 -0
  316. package/template/public/demo/hero-slide-2.svg +1 -0
  317. package/template/public/demo/hero-slide-3.svg +1 -0
  318. package/template/public/demo/hero-slide-4.svg +1 -0
  319. package/template/public/demo/hero-wide.svg +1 -0
  320. package/template/public/demo/hero.svg +1 -0
  321. package/template/public/demo/logo-1.svg +4 -0
  322. package/template/public/demo/logo-2.svg +4 -0
  323. package/template/public/demo/logo-3.svg +4 -0
  324. package/template/public/demo/logo-4.svg +4 -0
  325. package/template/public/demo/logo-5.svg +4 -0
  326. package/template/public/demo/logo-6.svg +4 -0
  327. package/template/public/demo/logo-7.svg +4 -0
  328. package/template/public/demo/logo-8.svg +4 -0
  329. package/template/public/demo/logo.svg +3 -0
  330. package/template/public/demo/map.svg +1 -0
  331. package/template/public/demo/poster.svg +1 -0
  332. package/template/public/demo/product-1.svg +4 -0
  333. package/template/public/demo/product-10.svg +4 -0
  334. package/template/public/demo/product-11.svg +4 -0
  335. package/template/public/demo/product-12.svg +4 -0
  336. package/template/public/demo/product-2.svg +4 -0
  337. package/template/public/demo/product-3.svg +4 -0
  338. package/template/public/demo/product-4.svg +4 -0
  339. package/template/public/demo/product-5.svg +4 -0
  340. package/template/public/demo/product-6.svg +4 -0
  341. package/template/public/demo/product-7.svg +4 -0
  342. package/template/public/demo/product-8.svg +4 -0
  343. package/template/public/demo/product-9.svg +4 -0
  344. package/template/public/demo/product-square-1.svg +4 -0
  345. package/template/public/demo/product-square-2.svg +4 -0
  346. package/template/public/demo/product-square-3.svg +4 -0
  347. package/template/public/demo/product-square-4.svg +4 -0
  348. package/template/public/demo/product-square-5.svg +4 -0
  349. package/template/public/demo/product-square-6.svg +4 -0
  350. package/template/public/demo/quote-portrait.svg +4 -0
  351. package/template/public/demo/split-1.svg +1 -0
  352. package/template/public/demo/split-2.svg +1 -0
  353. package/template/public/demo/split-3.svg +1 -0
  354. package/template/public/demo/split-4.svg +1 -0
  355. package/template/public/demo/team-1.svg +4 -0
  356. package/template/public/demo/team-2.svg +4 -0
  357. package/template/public/demo/team-3.svg +4 -0
  358. package/template/public/demo/team-4.svg +4 -0
  359. package/template/scripts/demo-images.mjs +393 -0
  360. package/template/scripts/generate-stories.mjs +156 -0
  361. package/template/scripts/previewHash.mjs +125 -0
  362. package/template/scripts/previews.mjs +149 -0
  363. package/template/stories/generated/announcement-bar.stories.ts +44 -0
  364. package/template/stories/generated/article-list.stories.ts +87 -0
  365. package/template/stories/generated/article.stories.ts +27 -0
  366. package/template/stories/generated/breadcrumbs.stories.ts +39 -0
  367. package/template/stories/generated/cart.stories.ts +38 -0
  368. package/template/stories/generated/collection-grid.stories.ts +117 -0
  369. package/template/stories/generated/collection-header.stories.ts +51 -0
  370. package/template/stories/generated/contact.stories.ts +45 -0
  371. package/template/stories/generated/cta.stories.ts +51 -0
  372. package/template/stories/generated/faq.stories.ts +56 -0
  373. package/template/stories/generated/feature-grid.stories.ts +69 -0
  374. package/template/stories/generated/footer.stories.ts +50 -0
  375. package/template/stories/generated/gallery.stories.ts +81 -0
  376. package/template/stories/generated/hero.stories.ts +75 -0
  377. package/template/stories/generated/image.stories.ts +99 -0
  378. package/template/stories/generated/logo-cloud.stories.ts +57 -0
  379. package/template/stories/generated/navigation.stories.ts +62 -0
  380. package/template/stories/generated/newsletter.stories.ts +68 -0
  381. package/template/stories/generated/order-status.stories.ts +32 -0
  382. package/template/stories/generated/pricing-table.stories.ts +44 -0
  383. package/template/stories/generated/product-carousel.stories.ts +75 -0
  384. package/template/stories/generated/product-detail.stories.ts +62 -0
  385. package/template/stories/generated/quote.stories.ts +69 -0
  386. package/template/stories/generated/rich-text.stories.ts +50 -0
  387. package/template/stories/generated/search.stories.ts +56 -0
  388. package/template/stories/generated/split-content.stories.ts +39 -0
  389. package/template/stories/generated/stats.stories.ts +68 -0
  390. package/template/stories/generated/tabs.stories.ts +45 -0
  391. package/template/stories/generated/team.stories.ts +45 -0
  392. package/template/stories/generated/testimonials.stories.ts +69 -0
  393. package/template/stories/generated/timeline.stories.ts +80 -0
  394. package/template/stories/generated/trust-strip.stories.ts +62 -0
  395. package/template/stories/generated/video-embed.stories.ts +63 -0
  396. package/template/stories/generated/wishlist.stories.ts +26 -0
  397. package/template/stories/pages/article.stories.ts +51 -0
  398. package/template/stories/pages/cart.stories.ts +56 -0
  399. package/template/stories/pages/category.stories.ts +56 -0
  400. package/template/stories/pages/collection.stories.ts +51 -0
  401. package/template/stories/pages/home.stories.ts +51 -0
  402. package/template/stories/pages/product.stories.ts +47 -0
  403. package/template/stories/pages/products.stories.ts +58 -0
  404. package/template/stories/pages/search.stories.ts +54 -0
  405. package/template/stories/pages/wishlist.stories.ts +53 -0
  406. package/template/stories/support/pageBlocks.ts +115 -0
  407. package/template/test/blocksEmptyData.spec.ts +52 -0
  408. package/template/test/carouselKeyboard.spec.ts +272 -0
  409. package/template/test/carouselRing.browser.spec.ts +193 -0
  410. package/template/test/carouselSlideWidth.browser.spec.ts +102 -0
  411. package/template/test/cartDrawer.spec.ts +295 -0
  412. package/template/test/cartToast.spec.ts +86 -0
  413. package/template/test/countPill.browser.spec.ts +196 -0
  414. package/template/test/demoImages.spec.ts +140 -0
  415. package/template/test/deps.spec.ts +102 -0
  416. package/template/test/eldraIcon.spec.ts +58 -0
  417. package/template/test/framing.spec.ts +76 -0
  418. package/template/test/i18n.spec.ts +200 -0
  419. package/template/test/iconComponent.spec.ts +91 -0
  420. package/template/test/inlineEditable.spec.ts +334 -0
  421. package/template/test/localePrefix.spec.ts +342 -0
  422. package/template/test/mainCss.spec.ts +107 -0
  423. package/template/test/mockGatewayContract.spec.ts +122 -0
  424. package/template/test/mocks/blocks.ts +20 -0
  425. package/template/test/mocks/breakpoints.ts +7 -0
  426. package/template/test/mocks/manifest.ts +11 -0
  427. package/template/test/moneyFormatting.spec.ts +89 -0
  428. package/template/test/pageTitle.spec.ts +49 -0
  429. package/template/test/pages/article.spec.ts +231 -0
  430. package/template/test/pages/category.spec.ts +185 -0
  431. package/template/test/pages/collection.spec.ts +396 -0
  432. package/template/test/pages/home.spec.ts +295 -0
  433. package/template/test/pages/hydration.spec.ts +557 -0
  434. package/template/test/pages/product.spec.ts +396 -0
  435. package/template/test/pages/seededPages.spec.ts +190 -0
  436. package/template/test/pages/ssr.spec.ts +393 -0
  437. package/template/test/prerenderCommerce.spec.ts +134 -0
  438. package/template/test/prerenderFailure.spec.ts +130 -0
  439. package/template/test/prerenderRefresh.browser.spec.ts +1431 -0
  440. package/template/test/previewsFresh.spec.ts +56 -0
  441. package/template/test/richText.spec.ts +161 -0
  442. package/template/test/richTextTypography.spec.ts +182 -0
  443. package/template/test/setup.ts +21 -0
  444. package/template/test/slugPage.spec.ts +244 -0
  445. package/template/test/slugPageTemplate.spec.ts +194 -0
  446. package/template/test/starter.spec.ts +1416 -0
  447. package/template/test/storefront/cart.spec.ts +404 -0
  448. package/template/test/storefront/categories.spec.ts +235 -0
  449. package/template/test/storefront/collectionSelector.spec.ts +74 -0
  450. package/template/test/storefront/demo.spec.ts +555 -0
  451. package/template/test/storefront/facets.spec.ts +425 -0
  452. package/template/test/storefront/feedback.spec.ts +97 -0
  453. package/template/test/storefront/gateway.spec.ts +2673 -0
  454. package/template/test/storefront/gatewayCart.spec.ts +289 -0
  455. package/template/test/storefront/gatewayPrerender.spec.ts +1037 -0
  456. package/template/test/storefront/history.spec.ts +341 -0
  457. package/template/test/storefront/money.spec.ts +171 -0
  458. package/template/test/storefront/toProductCard.spec.ts +138 -0
  459. package/template/test/storefront/volatile.spec.ts +284 -0
  460. package/template/test/support/axe.ts +14 -0
  461. package/template/test/support/dialog.ts +51 -0
  462. package/template/test/support/hydrate.ts +118 -0
  463. package/template/test/support/i18nText.ts +11 -0
  464. package/template/test/support/mockGateway.ts +1017 -0
  465. package/template/test/support/mountBlock.ts +194 -0
  466. package/template/test/support/mountPage.spec.ts +72 -0
  467. package/template/test/support/mountPage.ts +254 -0
  468. package/template/test/support/mountProbe.client.ts +69 -0
  469. package/template/test/support/renderSsr.ts +97 -0
  470. package/template/test/support/staticServer.ts +96 -0
  471. package/template/test/themeIcons.spec.ts +140 -0
  472. package/template/test/toastAnnouncement.spec.ts +133 -0
  473. package/template/test/tokens.spec.ts +102 -0
  474. package/template/test/uiMessagesPlugin.spec.ts +104 -0
  475. package/template/test/useBlockData.spec.ts +46 -0
  476. package/template/test/useEditing.spec.ts +54 -0
  477. package/template/test/useEldraIcon.spec.ts +126 -0
  478. package/template/test/useUiId.spec.ts +40 -0
  479. package/template/tokens.json +149 -0
  480. package/template/tsconfig.json +3 -0
  481. package/template/tsconfig.storybook.json +17 -0
  482. package/template/vitest-axe.d.ts +13 -0
  483. package/template/vitest.config.ts +44 -0
@@ -0,0 +1,815 @@
1
+ import type { InjectionKey, Ref } from 'vue';
2
+ import type { EldraClient } from '@eldrajs/sdk';
3
+ // Type-only, so nothing of the Nuxt module (a build-time entry that reaches for `@nuxt/kit` and
4
+ // `node:fs`) can reach an app bundle or a Storybook story through this import.
5
+ import type { StoreCommerce } from '@eldrajs/theme-nuxt/commerce';
6
+ import type { CartStore } from './cart';
7
+
8
+ /**
9
+ * The theme's own view types for commerce data. `@eldrajs/sdk`'s
10
+ * response types (`EldraContractResponse<...>`) are contract-derived and resolve to `unknown`
11
+ * without the Vite plugin's generated `contract.ts` augmentation (headless-kit `CLAUDE.md`
12
+ * invariant: "the SDK ships no response types"), so a block never consumes them directly —
13
+ * `gateway.ts` maps a live response into the narrow shapes below, and `demo.ts` builds the same
14
+ * shapes by hand from the Northwind fixtures. Both are checked by `pnpm --filter starter-nuxt
15
+ * typecheck`, which is the only place these types are proven against real usage (a block's own
16
+ * `.spec.ts` proves it renders them; nothing here talks to a network).
17
+ *
18
+ * Money fields (`StorefrontPrice.amount`/`compareAt`, cart line/total amounts, order totals) are
19
+ * always in **major units** — 28 is twenty-eight dollars, not twenty-eight cents — because that is
20
+ * what the gateway sends. `@eldrajs/ui`'s `Price`/`ProductCard` read minor units, so a value from
21
+ * here goes through `toMinorUnits()` (`app/storefront/money.ts`) on its way into one of those, and
22
+ * through `formatMoney()` when it has to appear inside a sentence. Which currency they are in is
23
+ * the store's own, never the content locale's: see `StorefrontCommerce` below.
24
+ */
25
+
26
+ /**
27
+ * What the store sells in, as the platform publishes it: the organisation's own commerce settings,
28
+ * read once at build by `@eldrajs/theme-nuxt` and handed to the app on
29
+ * `runtimeConfig.public.eldra.commerce`. `null` on a store that has not configured commerce.
30
+ *
31
+ * `{ currency, taxInclusivePricing, defaultTaxRate }`, and **not re-declared here**: the module
32
+ * that writes the key publishes its type, so this is an alias. A theme that hand-copies the record
33
+ * is a theme that stops compiling, or quietly stops reading a field, the first time the platform
34
+ * adds one.
35
+ *
36
+ * `currency` reaches `@eldrajs/ui`'s components through `CURRENCY_KEY`
37
+ * (`app/plugins/eldra-ui-messages.ts`), which is where every `<Price>` and every `useMoney()` call
38
+ * takes it from. The rest is what this type is carried around for: `taxInclusivePricing` tells a
39
+ * block whether the amounts it is showing already contain VAT ("incl. VAT" vs. "excl. VAT", tax
40
+ * "calculated at checkout"), and `defaultTaxRate` is the fraction applied to shipping and to
41
+ * products with no rate of their own.
42
+ */
43
+ export type StorefrontCommerce = StoreCommerce;
44
+
45
+ export interface StorefrontMedia {
46
+ src: string;
47
+ alt: string;
48
+ width?: number;
49
+ height?: number;
50
+ }
51
+
52
+ export interface StorefrontPrice {
53
+ /** Major units. */
54
+ amount: number;
55
+ /** Major units. Sale styling/badge only apply when this is greater than `amount`. */
56
+ compareAt?: number | null;
57
+ /** "From $X" for a product whose variants span more than one price. */
58
+ from?: boolean;
59
+ }
60
+
61
+ export interface StorefrontProductListItem {
62
+ handle: string;
63
+ title: string;
64
+ url: string;
65
+ featuredImage?: StorefrontMedia | null;
66
+ price: StorefrontPrice;
67
+ rating?: { value: number; count: number } | null;
68
+ /**
69
+ * The dots a card shows under its image, in the store's own order.
70
+ *
71
+ * **A source fills it from the product's `color`-kind option** — its values' `swatch` colours,
72
+ * named by their labels (`gateway.ts`'s `mapProductListItem`, `demo.ts`'s own fixture) — so a
73
+ * merchant who left the option on `none` gets no dots, whatever the option is called. **Absent**
74
+ * when the source cannot say: the platform's product *list* read carries no options at all today,
75
+ * which is a different answer from a product with no colours (`[]`), and
76
+ * `app/storefront/facets.ts` reads the two apart (`optionValuesOf`).
77
+ */
78
+ colours?: Array<{ name: string; swatch: string }>;
79
+ stock: 'in' | 'low' | 'out' | 'preorder';
80
+ available: boolean;
81
+ /**
82
+ * The **catalog product's** id — what a volatile refresh addresses this row by
83
+ * (`app/storefront/volatile.ts`) and what a cart add has to send as its `productId`.
84
+ *
85
+ * A list row deliberately carries no variant id: the products list read answers none, and a
86
+ * product's buyable variants are only in the detail read. So nothing can be put in the cart from
87
+ * a card alone — a quick-add on a card has to read the product first (`catalog.product`) and take
88
+ * the `variantId` off that, which is why no card in this theme offers one.
89
+ */
90
+ productId: string;
91
+ }
92
+
93
+ /**
94
+ * A product a **search** found. Every field is a catalogue card's, with one difference: the price
95
+ * may be unknown.
96
+ *
97
+ * The search endpoint carries no money at all, so `search.run()` reads the prices it can from the
98
+ * catalogue itself (`gateway.ts`'s `pricedSearchResponse`) and leaves this `null` for a product it
99
+ * could not — a pricing read that failed, or a found id the catalogue did not return (a stale
100
+ * index, a product deleted since the index was written).
101
+ *
102
+ * `null`, never `0`. A zero amount is a *real* price in the store's currency, and every consumer
103
+ * formats it: the shopper would read "$0.00", which is a worse answer than no answer. What each
104
+ * surface does with an unknown price is its own decision — `SearchResultItem.price` is optional, so
105
+ * a suggestion row keeps the product and drops the price; `ProductCardProduct.price` is required, so
106
+ * `toProductCard()` renders no card at all (see its own comment).
107
+ */
108
+ export interface StorefrontSearchProduct extends Omit<StorefrontProductListItem, 'price'> {
109
+ price: StorefrontPrice | null;
110
+ }
111
+
112
+ /**
113
+ * **How the merchant chose to display a variant option**, stored on the option itself by the
114
+ * platform and set in Studio's "Display as" select.
115
+ *
116
+ * `none` is every option that came before the field existed and every option a merchant left alone —
117
+ * a plain list of values. `color` means the values carry a `swatch` each and the picker draws
118
+ * circles. `custom` is a value-list option the merchant has given a **name** to
119
+ * (`StorefrontProductOption.metadata`): it draws as pills like `none`, and the name is there for a
120
+ * theme that wants to render that one option its own way.
121
+ *
122
+ * Read it from a platform that sends it, and **never from the option's key**. The whole point of the
123
+ * field is that `"Colour"`, `"Color"` and `"Litur"` are a merchant's words for an option, not an
124
+ * instruction to the theme, which is what every storefront used to guess from. (A source with no
125
+ * platform to ask derives it from what it does have — `app/storefront/facets.ts` reads the demo's
126
+ * own facets off its values' swatches — but never from the key either.)
127
+ */
128
+ export type StorefrontOptionKind = 'none' | 'color' | 'custom';
129
+
130
+ export interface StorefrontProductOption {
131
+ name: string;
132
+ label: string;
133
+ /** The merchant's own display choice, as the platform stores it. `none` for a source that does not
134
+ * say — a gateway older than the contract that added it, or a kind this theme cannot draw. */
135
+ kind: StorefrontOptionKind;
136
+ /**
137
+ * **The merchant's name for a `custom` option** — their own vocabulary (`fabric`, `fit`), limited
138
+ * to `[A-Za-z0-9_.-]` by the platform so it is safe to switch on. Absent on every other kind, and
139
+ * absent on a `custom` option a source could not name.
140
+ *
141
+ * Nothing in this theme branches on it: `custom` renders as pills, exactly as `none` does. It is
142
+ * carried so a customer's own fork can render one named option differently without having to match
143
+ * on a label a merchant may translate — see `docs/starter-kit.md`.
144
+ */
145
+ metadata?: string;
146
+ /**
147
+ * **Derived from `kind` and the values' own colours, never from the option's name**: swatches for a
148
+ * `color` option that has at least one `swatch` to show, pills for everything else — including a
149
+ * `color` option whose colours the merchant has not picked or has cleared, because a swatch picker
150
+ * with nothing to paint hides every value's name in visually hidden text. One place makes that
151
+ * decision, `app/storefront/options.ts`'s `optionDisplayType`, and a filter group makes the same
152
+ * one from the same evidence. Kept as its own field because it is what `@eldrajs/ui`'s
153
+ * `VariantPicker` takes.
154
+ */
155
+ type: 'swatches' | 'pills';
156
+ /** `swatch` is a CSS colour from the store — content, never a design token — and the platform
157
+ * allows one only on a `color`-kind option. */
158
+ values: Array<{ value: string; label: string; swatch?: string; available: boolean }>;
159
+ }
160
+
161
+ export interface StorefrontProduct extends StorefrontProductListItem {
162
+ /**
163
+ * The **variant** the page would add to the cart: the product's first buyable one
164
+ * (`gateway.ts`'s `mapProductDetails`). Distinct from the inherited `productId`, and both halves
165
+ * are sent on an add — the cart service looks the pair up together and refuses a variant that
166
+ * does not belong to the product it was given.
167
+ */
168
+ variantId: string;
169
+ images: StorefrontMedia[];
170
+ options: StorefrontProductOption[];
171
+ categoryTrail: Array<{ label: string; href: string }>;
172
+ description: string;
173
+ /**
174
+ * Real units of the variant this page would sell — `variantId` above — or `null`. `null` covers two
175
+ * different stores and one honest refusal: a store that tracks no units at all, a read that could
176
+ * not reach inventory, and a product whose count cannot be attributed to one variant (a source that
177
+ * knows M has two left but cannot say the shopper is looking at M sends none, because "only 2 left
178
+ * in L" is worse than no line at all). Either way the low-stock line is simply left off.
179
+ */
180
+ inventory: number | null;
181
+ shipsBy?: string | null;
182
+ }
183
+
184
+ export interface StorefrontCollectionInfo {
185
+ handle: string;
186
+ title: string;
187
+ description?: string | null;
188
+ image?: StorefrontMedia | null;
189
+ productCount: number;
190
+ }
191
+
192
+ /** One level of a category trail or child strip: what a shopper reads, and the canonical path its
193
+ * own page sits at (the ancestors' slugs, root first, then its own). */
194
+ export interface StorefrontCategoryRef {
195
+ slug: string;
196
+ title: string;
197
+ path: string;
198
+ }
199
+
200
+ /**
201
+ * **One category, placed in the store's tree** — what a category page is drawn from.
202
+ *
203
+ * The catalog's own read answers `{id, slug, title, parentId}` rows and no trail at all, so every
204
+ * field below the first three is the storefront's walk up and down that tree: `ancestors` root
205
+ * first and excluding the category itself (the page's breadcrumb trail), `children` the **direct**
206
+ * children only, in the list's own order (the header's strip of chips — one level, because a
207
+ * grandchild belongs on its own parent's page).
208
+ *
209
+ * A category the tree cannot place — a parent since unpublished, a `parentId` cycle — is not a
210
+ * category this answers at all: it has no canonical path, so it has no page.
211
+ */
212
+ export interface StorefrontCategory extends StorefrontCategoryRef {
213
+ /** The catalog id, which is what a subtree filter is sent as. */
214
+ id: string;
215
+ ancestors: StorefrontCategoryRef[];
216
+ children: StorefrontCategoryRef[];
217
+ }
218
+
219
+ /**
220
+ * One term of a `categories` / `collections` facet.
221
+ *
222
+ * `slug` is the value a filter is expressed with — it is what goes in the URL and in the request —
223
+ * while `title` is what the shopper reads and `id` is the catalog object's own id. The server-side
224
+ * facets carry a real `id`; the client-side fallback (`app/storefront/facets.ts`) has none to carry
225
+ * and repeats the slug there, so nothing may treat `id` as a catalog id without knowing which
226
+ * source filled it in.
227
+ */
228
+ export interface CatalogFacetTerm {
229
+ id: string;
230
+ slug: string;
231
+ title: string;
232
+ count: number;
233
+ /**
234
+ * **The id of this term's parent category, or `null` for a root** — what makes the `categories`
235
+ * facet a tree rather than a flat list, and what `collection-grid` draws its indented parent rows
236
+ * from.
237
+ *
238
+ * `undefined` means "this source cannot place the term", which is not the same answer as `null`
239
+ * ("it is a root"): the panel then renders the family flat, exactly as it did before any of this
240
+ * existed.
241
+ *
242
+ * **Only a source that placed its own terms sets it.** The gateway carries the platform's own facet
243
+ * `parentId` through (public contract 3.8.0, which omits the key for a root; it is normalised to
244
+ * `null` once any term in the family is placed), and the demo source fills it from its own fixture
245
+ * tree. It is never synthesised from the store's category list to fill a gap: a parent row is only
246
+ * worth drawing where the platform can also *filter* by one, which is what `categoryCounts` below
247
+ * says and why the two are read together. Never set on `collections`: collections are a flat
248
+ * vocabulary.
249
+ */
250
+ parentId?: string | null;
251
+ }
252
+
253
+ /** One value of a variant-option facet. `swatch` is a CSS colour from the store — content, never
254
+ * a design token — and is absent for an option that is not a colour. */
255
+ export interface CatalogFacetOptionValue {
256
+ value: string;
257
+ label: string;
258
+ swatch?: string;
259
+ count: number;
260
+ /**
261
+ * The size system this value belongs to ("Knitwear", "Socks (EU)"), so sizes are grouped under
262
+ * one sub-heading per system rather than mixed in one grid. Not sent by any storefront today —
263
+ * a Core follow-up, scheduled separately — so `blocks/collection-grid/parts/groups.ts` draws a
264
+ * `size` option as a plain `list` facet until a value here arrives, at which point the same
265
+ * option becomes a `size` facet with its tiles grouped by this field.
266
+ */
267
+ group?: string;
268
+ }
269
+
270
+ /** One variant option, by the key a filter names it with (`colour`, `size`). */
271
+ export interface CatalogFacetOption {
272
+ key: string;
273
+ name: string;
274
+ /**
275
+ * The merchant's display choice for this option (`StorefrontOptionKind`), carried through from the
276
+ * platform's own facets so a panel reads the same fact the product page does. `none` for a source
277
+ * that does not say.
278
+ *
279
+ * **It is not what decides the group's control** — that is the values' own swatches
280
+ * (`blocks/collection-grid/parts/groups.ts`'s `facetTypeFor`), the same evidence the product page's
281
+ * picker goes by (`StorefrontProductOption.type`), because a dot with no colour is worse than a
282
+ * pill: a `color`-kind option whose colours the store has not set has nothing to draw. The kind is
283
+ * what makes the platform send those swatches in the first place, and it is carried so a theme can
284
+ * read the merchant's intent even where there is nothing yet to paint.
285
+ */
286
+ kind: StorefrontOptionKind;
287
+ /** The merchant's name for a `custom` option, as on `StorefrontProductOption.metadata`. Absent on
288
+ * every other kind. */
289
+ metadata?: string;
290
+ values: CatalogFacetOptionValue[];
291
+ }
292
+
293
+ /**
294
+ * **How a catalog read describes the scope it answered from**: the price span it spans, every
295
+ * category, collection and variant-option value in it, and how many products each one would
296
+ * return. This is what the filter UI draws its groups from — values, labels, swatches and counts —
297
+ * so a shopper is never offered a filter the catalogue cannot honour.
298
+ *
299
+ * The shape is the platform's own (`facets` on `GET /catalog/v1/collections/{slug}/products` and
300
+ * `GET /catalog/v1/products/list`, requested with `facets=true`), carried here as a view type so a
301
+ * block reads one shape whichever storefront filled it in. `createGatewayStorefront` reads the
302
+ * response's own object, so its numbers describe the **whole collection** rather than the rows one
303
+ * read could reach; `createDemoStorefront` counts its own fixture by the same rules
304
+ * (`app/storefront/facets.ts`). A source that cannot describe its scope at all answers no facets,
305
+ * and the panel then draws only the groups it can fill without values.
306
+ *
307
+ * Two rules every source agrees on, because the filter UI is built on them:
308
+ *
309
+ * - **Counts ignore the facet's own filter.** A count says how many products *that value* would
310
+ * return, so it is computed over the scope with every other filter applied and this family's
311
+ * own left out — ticking "Oat" must not zero every other colour. A value whose count is 0 under
312
+ * the other filters is still listed, and the UI disables it rather than hiding it.
313
+ * - **Price bounds are the scope's own**, with every filter applied *except* price — so dragging
314
+ * the price thumbs never moves the track under the shopper's hand.
315
+ *
316
+ * `price` is in **major units**, like every other money field in this file — and **unlike the
317
+ * platform's own facets**, whose `price` is in the same minor units as the `minPrice`/`maxPrice`
318
+ * parameters it is counted over. The gateway implementation converts on the way in, the same way
319
+ * it converts the shopper's bounds on the way out; handing this type a minor-unit span would draw
320
+ * a slider a hundred times too wide on a two-decimal currency and a `?price=` nothing matches.
321
+ */
322
+ export interface CatalogFacets {
323
+ /**
324
+ * The scope's own lowest and highest price, in **major** units, counted with every filter except
325
+ * price applied.
326
+ *
327
+ * **Absent when the source could not span the scope at all** — the platform omits the key when the
328
+ * scope minus the price filter holds nothing — which is not the same answer as a span of 0 to 0. A
329
+ * price control handed a 0–0 span is a dead track labelled with the store's currency; absent, the
330
+ * panel falls back to the widest span it has seen for this collection instead.
331
+ */
332
+ price?: {
333
+ min: number;
334
+ max: number;
335
+ /**
336
+ * Product counts over 24 equal buckets spanning `[min, max]`, drawn as the filter panel's
337
+ * decorative histogram above the price track. The platform gateway sends it from contract 3.12.0;
338
+ * a source that leaves it out gets no histogram at all.
339
+ */
340
+ histogram?: number[];
341
+ };
342
+ categories: CatalogFacetTerm[];
343
+ /**
344
+ * **Whether a category term's `count` already includes its descendants'.**
345
+ *
346
+ * **It is also what decides whether the panel offers a parent row at all**, which is the whole
347
+ * reason it exists as a field rather than an implementation detail.
348
+ *
349
+ * `'direct'` — what an absent field reads as, and what a gateway older than public contract 3.8.0
350
+ * answers — means each count is the products *assigned to that category*, which in a real store are
351
+ * the leaves. The panel then keeps the family **flat**: no parent row, no indent, no implication.
352
+ * Not a display choice but the only honest one, because the contract that added the ancestor counts
353
+ * added the `categoryId` subtree match with them — so on `'direct'` a `Tableware` row would be a
354
+ * filter the gateway answers by direct membership only: an empty grid under a chip claiming
355
+ * otherwise, which is the one thing this whole filter path exists to remove.
356
+ *
357
+ * `'rolled-up'` means the counts are the whole answer, descendants deduplicated — which a
358
+ * client-side sum cannot be, since a product in two sibling categories is one product and two
359
+ * counts. **No count is ever derived**: the panel uses the numbers as they came, and nests the rows
360
+ * the source placed. The gateway reads this off the response rather than off a contract version:
361
+ * 3.8.0 adds `parentId`, the roll-ups and the subtree match together, so a term that can place
362
+ * itself is a term that has been counted up *and* one a parent filter can reach (`gateway.ts`'s
363
+ * `mapFacets`). The demo source declares it whenever it was given a tree, because its own ancestor
364
+ * counts are deduplicated the same way **and** its filter expands a ticked parent
365
+ * (`app/storefront/facets.ts`'s `categoryTermsOf` and `matchesClause`).
366
+ *
367
+ * **Order is the source's, never this theme's.** 3.8.0 answers depth-first by title, and the panel
368
+ * preserves whatever order it is handed — `parts/groups.ts`'s `nestCategoryTerms` only clusters each
369
+ * parent's children beneath it, which is a no-op on a list that is already depth-first.
370
+ */
371
+ categoryCounts?: 'direct' | 'rolled-up';
372
+ collections: CatalogFacetTerm[];
373
+ /**
374
+ * **Absent when the source could not read stock at all** — which is a different answer from
375
+ * "nothing is in stock", and the reason this one field is optional while the rest are not. The
376
+ * platform omits it rather than sending two zeroes when its inventory read fails, so a filter
377
+ * panel hides the availability group instead of offering a shopper two values it would be lying
378
+ * about. (An availability *filter* in that state is an error, not an empty answer: see
379
+ * `StorefrontResult.error`.)
380
+ */
381
+ availability?: { in_stock: number; out_of_stock: number };
382
+ options: CatalogFacetOption[];
383
+ /**
384
+ * Yes/no facets beyond availability (pre-order, on sale, …), each drawn as one more switch row
385
+ * beside "In stock only" in the same `toggle` facet. The platform gateway sends them from contract
386
+ * 3.12.0 (`on_sale` today); a source that leaves them out offers only availability.
387
+ */
388
+ toggles?: CatalogFacetToggle[];
389
+ }
390
+
391
+ /** One yes/no facet beyond availability — see `CatalogFacets.toggles`. */
392
+ export interface CatalogFacetToggle {
393
+ /** The platform's own key (`on_sale`, `pre_order`), snake_case. `parts/groups.ts` camelCases it
394
+ * for the one query key this toggle reads and writes (`onSale`, `preOrder`). */
395
+ key: string;
396
+ label: string;
397
+ count: number;
398
+ }
399
+
400
+ /**
401
+ * What `catalog.collectionProducts` answers with: the page of cards, the size of the filtered set,
402
+ * and — when the source can describe its scope at all — the facets above.
403
+ *
404
+ * `facets` is optional because describing the scope is a separate capability from listing it: a
405
+ * source reading a backend that cannot aggregate answers `undefined` and the filter panel then
406
+ * shows only the groups it can draw without values (the price range, from the loaded items). It is
407
+ * never an empty-but-present object standing in for "unknown".
408
+ */
409
+ export interface StorefrontCollectionProducts {
410
+ items: StorefrontProductListItem[];
411
+ total: number;
412
+ facets?: CatalogFacets;
413
+ /**
414
+ * **The `filters` keys this answer's own scope cannot narrow by.** Absent — the usual answer —
415
+ * means every source the caller sent was honoured.
416
+ *
417
+ * Describing a scope and *filtering* it are different capabilities, and a backend can offer the
418
+ * first without the second: the platform counts the other collections a collection's products are
419
+ * also in, but has no way to ask for the intersection, because its collection parameter is an OR
420
+ * over a list and the scope already is one collection. A source named here is therefore one whose
421
+ * counts may be perfectly real and whose filter would still change nothing.
422
+ *
423
+ * The filter panel **hides a group it names**, even one the author configured, because the
424
+ * alternative is a control that moves the chips and the URL and leaves the grid exactly as it was
425
+ * — the defect the whole server-side filter path exists to remove. A source is named by the same
426
+ * key the `filters` bag uses (`collection`, `option:size`), and a scope that can honour everything
427
+ * says nothing rather than listing every key it knows: a storefront that has never heard of this
428
+ * field is indistinguishable from one answering "all of them", which is the safe reading.
429
+ */
430
+ unfilterable?: readonly string[];
431
+ /**
432
+ * **The block's own sort ids this answer's scope cannot honour.** Absent — the usual answer —
433
+ * means every sort id the grid offers does something real.
434
+ *
435
+ * The same shape as `unfilterable`, for the same reason: a backend can read a sort id the grid
436
+ * knows about and simply have nothing to order by it. `best-selling` is the one example today —
437
+ * the theme offers it because a storefront's catalogue can have sales data to sort by, but the
438
+ * platform gateway's product list exposes none, so picking it would move nothing and the control
439
+ * would look broken. Described rather than silently dropped, because the grid has to know which
440
+ * of its own options are real: `blocks/collection-grid` drops a named id from "Sort by" once this
441
+ * answer arrives, and a shared link naming it falls back to the first option that is left, the
442
+ * same way it falls back from any sort id it does not recognise at all. A scope that can honour
443
+ * every sort id it offers says nothing, which also reads correctly for a source that has never
444
+ * heard of this field.
445
+ */
446
+ unsortable?: readonly string[];
447
+ }
448
+
449
+ export interface StorefrontCartLine {
450
+ id: string;
451
+ /** The catalog product this line's variant belongs to — the other half of an add (see
452
+ * `StorefrontProduct.variantId`), which is what lets Undo re-add a removed line. */
453
+ productId: string;
454
+ variantId: string;
455
+ title: string;
456
+ url: string;
457
+ variantLabel: string;
458
+ quantity: number;
459
+ /** Major units. */
460
+ unitPrice: number;
461
+ /** Major units. */
462
+ lineTotal: number;
463
+ image?: StorefrontMedia | null;
464
+ max: number | null;
465
+ }
466
+
467
+ export interface StorefrontCartTotals {
468
+ /** Major units. */
469
+ subtotal: number;
470
+ /** `amount` in major units. */
471
+ discount?: { code: string; amount: number } | null;
472
+ /** Major units. `null` renders "Calculated at checkout". */
473
+ shipping: number | null;
474
+ /** Major units. */
475
+ tax?: number | null;
476
+ /** Major units. */
477
+ total: number;
478
+ }
479
+
480
+ export type StorefrontOrderStatus =
481
+ | 'processing'
482
+ | 'shipped'
483
+ | 'delivered'
484
+ | 'delayed'
485
+ | 'cancelled';
486
+
487
+ export interface StorefrontOrder {
488
+ number: string;
489
+ placedAt: string;
490
+ itemCount: number;
491
+ status: StorefrontOrderStatus;
492
+ steps: Array<{
493
+ key: 'ordered' | 'packed' | 'shipped' | 'delivered';
494
+ label: string;
495
+ date: string | null;
496
+ state: 'done' | 'current' | 'upcoming' | 'warning';
497
+ }>;
498
+ carrier?: string;
499
+ eta?: string;
500
+ trackingNumber?: string;
501
+ trackingUrl?: string;
502
+ delayNote?: string;
503
+ cancelNote?: string;
504
+ lines: StorefrontCartLine[];
505
+ totals: StorefrontCartTotals;
506
+ shippingAddress: string[];
507
+ payment: { brand: string; last4: string };
508
+ }
509
+
510
+ export interface StorefrontSearchResponse {
511
+ query: string;
512
+ total: number;
513
+ products: StorefrontSearchProduct[];
514
+ articles: Array<{
515
+ title: string;
516
+ href: string;
517
+ category: string;
518
+ readingTime: string;
519
+ image?: StorefrontMedia | null;
520
+ }>;
521
+ pages: Array<{ title: string; href: string; path: string; snippet: string }>;
522
+ suggestion?: string | null;
523
+ }
524
+
525
+ export interface StorefrontAck {
526
+ ok: boolean;
527
+ reason?: 'unsupported' | 'invalid' | 'failed';
528
+ }
529
+
530
+ /**
531
+ * The two classes of value that go stale between builds. Everything else on a product — title,
532
+ * images, options, description, category trail — is content, and content changes trigger a
533
+ * rebuild, so the prerendered copy is the truth until the next one.
534
+ */
535
+ export type VolatileKey = 'price' | 'stock';
536
+
537
+ /**
538
+ * One product's volatile values as the backend has them *now*, keyed by the same id the page's
539
+ * own data carries (`StorefrontProductListItem.productId` — what the gateway's product list read
540
+ * fills from the product's `id`). `price` is the whole `StorefrontPrice` this theme already uses,
541
+ * not a second money shape: `amount` and `compareAt` are read off it, `from` is not (the price
542
+ * *spread* is a property of the product's variants, not a value that refreshes).
543
+ *
544
+ * `inventory` is optional and absent means "unknown, keep what the page already shows" — the
545
+ * products list read carries no inventory today (`StorefrontProduct.inventory` is `null` from the
546
+ * gateway), so only a source that genuinely knows sets it.
547
+ */
548
+ export interface VolatileSnapshot {
549
+ id: string;
550
+ price: StorefrontPrice;
551
+ available: boolean;
552
+ stock: StorefrontProductListItem['stock'];
553
+ inventory?: number | null;
554
+ }
555
+
556
+ /**
557
+ * **The prerender contract.** `data` is complete from the first paint: a page rendered at build
558
+ * time carries its real title, images, options, description, price and stock line, and hydration
559
+ * paints nothing new. `pending` is therefore the skeleton state and nothing else — a read in
560
+ * flight with nothing to show yet — so a consumer must never show a skeleton for a value it
561
+ * already has, and a read that has answered is not pending even when its answer was `null`
562
+ * ("no such product", "no such collection"): that is a result, not a wait.
563
+ *
564
+ * After mount only the volatile values refresh (`VolatileKey`: money amounts and the stock line).
565
+ * While a refresh is in flight the keys being refreshed appear in `revalidating`, and the
566
+ * prerendered value stays on screen — dimmed, with a small inline spinner beside it — so there is
567
+ * no layout shift and no flash. An empty set means nothing is refreshing, which is the whole of
568
+ * a page's life apart from those few hundred milliseconds. A failed refresh clears the set and
569
+ * keeps the value: a page never regresses to an error state for something it can already show,
570
+ * and `error` stays for the page that has nothing.
571
+ *
572
+ * `loading` is the third flag and the broadest: any read in flight, including the manual
573
+ * `refresh()` and a reload for changed sources. It is what a block shows a spinner from while the
574
+ * value it already has stays on screen.
575
+ *
576
+ * **What a block owes in return: sources that are final at setup time, on both sides.** A result
577
+ * is cached under a key built from its sources' values at creation, and that key is how the
578
+ * browser finds the value the build left for it. A source that resolves to one thing while the
579
+ * page is being generated and to another a moment after hydration — browser-local state, a value
580
+ * some other block settles first — mints a second key, misses the payload and refetches data the
581
+ * page is already showing. So a block gives a result it does not render an *empty* source rather
582
+ * than a live one (`blocks/product-carousel/Block.vue` is the worked example: three results, one
583
+ * variant, two empty sources), and anything genuinely browser-local
584
+ * (`history.recentlyViewed`) is only ever read by the variant that shows it.
585
+ */
586
+ export interface StorefrontResult<T> {
587
+ data: Ref<T | null>;
588
+ pending: Ref<boolean>;
589
+ error: Ref<string | null>;
590
+ /**
591
+ * True for the whole of *any* load — the first one, a reload because the sources changed, a
592
+ * manual `refresh()` — and false the rest of the time. The three flags answer three different
593
+ * questions and a block reads all of them: `pending` is "there is nothing to show yet" (draw the
594
+ * skeleton), `loading` is "a read is in flight" (draw a small spinner beside the value that is
595
+ * already on screen — `loading && data !== null`, never a skeleton over it), and `revalidating`
596
+ * is the narrower "only these fields are being refreshed" (below).
597
+ */
598
+ loading: Readonly<Ref<boolean>>;
599
+ /** Empty = nothing refreshing. Written by the storefront implementation, read by a block. */
600
+ revalidating: Readonly<Ref<ReadonlySet<VolatileKey>>>;
601
+ refresh: () => Promise<void>;
602
+ }
603
+
604
+ /** A `reactive()` object: a block reads it, only the app layer writes it. */
605
+ export interface StorefrontRoute {
606
+ productHandle: string | null;
607
+ collectionHandle: string | null;
608
+ /**
609
+ * The **category page**'s own category, when this route is one: the leaf's slug, and the
610
+ * canonical path it is addressed by (`billinn/bilstolar` — the ancestors' slugs, root first, then
611
+ * its own). `null` on every other route, and always both or neither.
612
+ *
613
+ * Two fields because the page needs both halves and neither derives the other cheaply: a surface
614
+ * naming one category wants the slug, and a link back to this page — or a scope sent to the
615
+ * storefront — wants the path, which is the only thing the route resolves.
616
+ */
617
+ categorySlug: string | null;
618
+ categoryPath: string | null;
619
+ orderToken: string | null;
620
+ query: string | null;
621
+ page: number;
622
+ /**
623
+ * The current `?sort=` value, or `null` when absent — read back the same generic way `page`
624
+ * already is, so `collection-grid` can seed its own sort choice from a shared URL instead of
625
+ * always starting from its field's default.
626
+ */
627
+ sort: string | null;
628
+ /** The current `?columns=` value, or `null` when absent — `collection-grid`'s column count. */
629
+ columns: string | null;
630
+ /**
631
+ * Every other query key — not `q`, `page`, `token`, `sort` or `columns`, which already have
632
+ * their own typed field above — as flat string arrays, keyed by query key. A block owns its own
633
+ * filter vocabulary (`collection-grid`'s `category`/`size`/`colour`/`availability`/`minPrice`/
634
+ * `maxPrice`), so `StorefrontRoute` only hands back the raw bag rather than declaring every
635
+ * block's filter keys itself; a value is always an array (even a single-valued one like
636
+ * `minPrice`) so a block never has to branch on whether the URL repeated a key.
637
+ */
638
+ filters: Record<string, string[]>;
639
+ /** The one writer a block may call — the plugin routes it through `useRouter()`. */
640
+ setQuery(patch: Record<string, string | string[] | null>): void;
641
+ }
642
+
643
+ /**
644
+ * How a block names the collection it wants products from. `{ slug }` is the
645
+ * storefront handle — a route segment, or a CMS field an author typed. `{ id }`
646
+ * is a catalog collection id, which is what a `reference` field stores: the
647
+ * public read resolves it to an object carrying the `slug` as well, but the
648
+ * depth-0 stub and the page builder's draft overlay carry only the id, and a
649
+ * block must still be able to ask for its products. A storefront implementation
650
+ * that cannot resolve an id answers `null`, like any other unknown collection —
651
+ * never an error.
652
+ */
653
+ export type StorefrontCollectionSelector = { slug: string } | { id: string };
654
+
655
+ export interface StorefrontCatalog {
656
+ product(handle: Ref<string | null>): StorefrontResult<StorefrontProduct>;
657
+ /**
658
+ * **The whole catalogue**, filtered, sorted, paged and counted the same way one collection's
659
+ * products are — the read behind the `/products` page, where the scope is the store rather than a
660
+ * curated list.
661
+ *
662
+ * Deliberately the same `StorefrontCollectionProducts` answer as `collectionProducts`, so
663
+ * `collection-grid` renders one shape and the filter panel reads one `facets` object whichever scope
664
+ * it is in. One difference, and it is the interesting one: **nothing is `unfilterable` here**. A
665
+ * collection's own product list has no `collectionId` parameter — the scope already *is* one
666
+ * collection and the parameter is an OR, so a second id would widen rather than intersect — while
667
+ * the catalogue-wide list does take it, so the `collection` group filters for real.
668
+ */
669
+ products(
670
+ opts: Ref<{
671
+ page: number;
672
+ pageSize: number;
673
+ sort?: string;
674
+ filters?: Record<string, string[]>;
675
+ /**
676
+ * **A category page's scope**: the current category's canonical path, which narrows the read
677
+ * to that category's whole **subtree** — what the platform's own `categoryId` parameter
678
+ * matches. Absent is the whole catalogue, which is what `/products` sends.
679
+ *
680
+ * The shopper's own `category` filter still applies and is intersected with the subtree
681
+ * rather than OR-ed beside it (`categoryId` is an OR over a list, so a value outside the
682
+ * subtree would widen the page past its own category); with nothing ticked the scope's own id
683
+ * is the filter. A path **no category occupies** is answered `null` — the same answer
684
+ * `collectionProducts` gives an unknown collection, which the grid draws as its empty state —
685
+ * never the unscoped catalogue.
686
+ */
687
+ categoryPath?: string;
688
+ }>
689
+ ): StorefrontResult<StorefrontCollectionProducts>;
690
+ collection(handle: Ref<string | null>): StorefrontResult<StorefrontCollectionInfo>;
691
+ /**
692
+ * One category by its **canonical path** — the category page's own read: its title, its ancestors
693
+ * and its direct children, all of them the storefront's walk over the store's category tree
694
+ * rather than anything one catalog response carries.
695
+ *
696
+ * `null` for a path no category occupies, exactly as `collection` answers an unknown handle, and
697
+ * for a `null` source — which makes no request at all, so a page that is not a category page pays
698
+ * nothing.
699
+ */
700
+ category(path: Ref<string | null>): StorefrontResult<StorefrontCategory>;
701
+ collectionProducts(
702
+ collection: Ref<StorefrontCollectionSelector | null>,
703
+ opts: Ref<{ page: number; pageSize: number; sort?: string; filters?: Record<string, string[]> }>
704
+ ): StorefrontResult<StorefrontCollectionProducts>;
705
+ related(handle: Ref<string | null>, limit: number): StorefrontResult<StorefrontProductListItem[]>;
706
+ byHandles(handles: Ref<string[]>): StorefrontResult<StorefrontProductListItem[]>;
707
+ /**
708
+ * The live values for a page's products, in one batched read (chunked past the gateway's own
709
+ * comfortable filter size — see `volatile.ts`'s `chunkIds`). An id nothing matches is simply
710
+ * absent from the answer, never an error; an empty `ids` makes no request at all.
711
+ *
712
+ * Deliberately *not* a `StorefrontResult`: this is a one-shot read a caller folds into data it
713
+ * already has (`applyVolatileSnapshots`), not a piece of page state with its own
714
+ * pending/error/refresh life cycle.
715
+ */
716
+ volatileByIds(ids: string[]): Promise<VolatileSnapshot[]>;
717
+ notifyBackInStock(input: { email: string; variantId: string }): Promise<StorefrontAck>;
718
+ }
719
+
720
+ export interface StorefrontForms {
721
+ subscribe(i: { email: string; list: string }): Promise<StorefrontAck>;
722
+ sendMessage(i: Record<string, string>): Promise<StorefrontAck>;
723
+ }
724
+
725
+ export interface StorefrontSearch {
726
+ run(query: Ref<string>): StorefrontResult<StorefrontSearchResponse>;
727
+ }
728
+
729
+ export interface StorefrontOrders {
730
+ current(token: Ref<string | null>): StorefrontResult<StorefrontOrder>;
731
+ }
732
+
733
+ /**
734
+ * The products a shopper saved for later, by storefront handle. Local to their browser and nothing
735
+ * more: there is no account behind it (see `docs/starter-kit.md`, "Wishlist"), so the whole store is
736
+ * `localStorage` — `createWishlistStore()` in `app/storefront/history.ts` is the one implementation,
737
+ * shared by the gateway and demo sources alike, because there is no gateway half to differ about.
738
+ *
739
+ * **Read it through `useWishlist()`** (`app/composables/useWishlist.ts`), never straight off
740
+ * `useStorefront()`: `items` is empty until `hydrate()` runs in `onMounted`, which is what keeps a
741
+ * visitor's saved list out of prerendered HTML and makes the browser's first render equal the file
742
+ * it hydrates. The gate is written up on `createWishlistStore()` itself.
743
+ */
744
+ export interface WishlistStore {
745
+ /** Saved handles, newest first. `[]` before `hydrate()` — see above. */
746
+ items: Ref<string[]>;
747
+ /** `items.value.length`, as a ref so a header can bind a count without reading the array. */
748
+ count: Readonly<Ref<number>>;
749
+ has(handle: string): boolean;
750
+ /** Saves the handle if it is not saved, removes it if it is. Returns the state it is now in:
751
+ * `true` saved, `false` removed — which is the sentence a caller's toast picks from. */
752
+ toggle(handle: string): boolean;
753
+ /** Removes it, or does nothing when it was not saved. */
754
+ remove(handle: string): void;
755
+ /**
756
+ * Empties the list. No surface calls it yet — it is here because a wishlist that cannot be
757
+ * emptied in one gesture is a wishlist whose only way out is pressing twenty hearts, and the two
758
+ * places that will want it (a "Clear wishlist" control beside the list, and a sign-out that must
759
+ * not leave one shopper's saved products in front of the next) are the same two
760
+ * `HistoryStore.clearViews` already exists for. Writing it with the rest is what keeps it on the
761
+ * same `ensureRead`-then-write path as `toggle` and `remove` rather than bolted on later.
762
+ */
763
+ clear(): void;
764
+ /**
765
+ * Reads `localStorage` into `items` and starts following the `storage` event for other tabs —
766
+ * **the gate the whole feature turns on**: nothing of a shopper's saved list is readable until
767
+ * this has run, so a prerendered page cannot carry it and the browser's first render of that page
768
+ * matches the file it is hydrating. Called from `onMounted` by `useWishlist()`, which is the only
769
+ * caller; idempotent, and inert on the server beyond the storage read. A mutation reads storage
770
+ * for itself first, so nothing can write an empty list over a saved one even unhydrated.
771
+ *
772
+ * Paired with `release()`: each call counts one live consumer.
773
+ */
774
+ hydrate(): void;
775
+ /**
776
+ * Gives up one consumer's interest, from `useWishlist()`'s `onUnmounted`. The last one to leave
777
+ * drops the shared `storage` listener; `items` is left alone, so a later `hydrate()` picks up
778
+ * where this left off. It exists because `useStorefront()` builds a fallback storefront per
779
+ * calling component when nothing is provided (every Storybook story, every block mount), and a
780
+ * listener per store with no way to undo it leaks one for each.
781
+ */
782
+ release(): void;
783
+ }
784
+
785
+ export interface HistoryStore {
786
+ recentlyViewed: Ref<string[]>;
787
+ recordView(handle: string): void;
788
+ clearViews(): void;
789
+ isAnnouncementDismissed(message: string): boolean;
790
+ dismissAnnouncement(message: string): void;
791
+ }
792
+
793
+ export interface StorefrontSource {
794
+ ready: Ref<boolean>;
795
+ /** See `StorefrontCommerce`: what the store sells in, or `null` when the platform publishes
796
+ * nothing. Not reactive — it is a build-time fact about the store, not page state. */
797
+ commerce: StorefrontCommerce | null;
798
+ route: StorefrontRoute;
799
+ catalog: StorefrontCatalog;
800
+ cart: CartStore;
801
+ search: StorefrontSearch;
802
+ orders: StorefrontOrders;
803
+ forms: StorefrontForms;
804
+ wishlist: WishlistStore;
805
+ history: HistoryStore;
806
+ }
807
+
808
+ export const STOREFRONT_KEY: InjectionKey<StorefrontSource> = Symbol.for(
809
+ 'eldra.starter.storefront'
810
+ );
811
+
812
+ // Re-exported so a consumer only needs `EldraClient` for `createGatewayStorefront` — `gateway.ts`
813
+ // re-exports it too, but importing it from here keeps a caller who only touched `types.ts` honest
814
+ // about where the dependency comes from.
815
+ export type { EldraClient };