@krizaka/ui 4.4.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/README.md +1 -0
  2. package/dist/account-menu.d.ts +1 -1
  3. package/dist/account-menu.js +1 -1
  4. package/dist/account-menu.js.map +1 -1
  5. package/dist/account-settings.d.ts +1 -1
  6. package/dist/account-settings.js +13 -6
  7. package/dist/account-settings.js.map +1 -1
  8. package/dist/agenda.d.ts +1 -1
  9. package/dist/agenda.js +2 -1
  10. package/dist/agenda.js.map +1 -1
  11. package/dist/analysis-report.js +19 -11
  12. package/dist/analysis-report.js.map +1 -1
  13. package/dist/app-frame.d.ts +1 -1
  14. package/dist/app-frame.js.map +1 -1
  15. package/dist/app-header/search.js +2 -2
  16. package/dist/app-header/search.js.map +1 -1
  17. package/dist/avatar/defaults.js +3 -1
  18. package/dist/avatar/defaults.js.map +1 -1
  19. package/dist/avatar.js +3 -1
  20. package/dist/avatar.js.map +1 -1
  21. package/dist/bird-plate.js +8 -2
  22. package/dist/bird-plate.js.map +1 -1
  23. package/dist/chapter.js +7 -4
  24. package/dist/chapter.js.map +1 -1
  25. package/dist/chat.js +1 -1
  26. package/dist/chip.d.ts +1 -1
  27. package/dist/chip.js +1 -1
  28. package/dist/{chunk-SNSQLGGS.js → chunk-5VZ37TY3.js} +1 -1
  29. package/dist/{chunk-XWJDBQU7.js.map → chunk-5VZ37TY3.js.map} +1 -1
  30. package/dist/{chunk-MTVX4RRF.js → chunk-HP7BDMVK.js} +11 -3
  31. package/dist/chunk-HP7BDMVK.js.map +1 -0
  32. package/dist/{chunk-PK3L6WQT.js → chunk-LNAAWT4Y.js} +4 -2
  33. package/dist/{chunk-PK3L6WQT.js.map → chunk-LNAAWT4Y.js.map} +1 -1
  34. package/dist/{chunk-UIP3WX5O.js → chunk-MDSP7DJR.js} +2 -2
  35. package/dist/chunk-MDSP7DJR.js.map +1 -0
  36. package/dist/{chunk-IEGTRCDI.js → chunk-NQENOT6L.js} +2 -2
  37. package/dist/{chunk-IEGTRCDI.js.map → chunk-NQENOT6L.js.map} +1 -1
  38. package/dist/{chunk-FM42KOAU.js → chunk-P7AFIKWG.js} +5 -3
  39. package/dist/chunk-P7AFIKWG.js.map +1 -0
  40. package/dist/{chunk-BCD2CRFG.js → chunk-PJNR4NTS.js} +2 -2
  41. package/dist/chunk-PJNR4NTS.js.map +1 -0
  42. package/dist/{chunk-ZFR6ZNXD.js → chunk-PVQ2KKPZ.js} +1 -1
  43. package/dist/chunk-PVQ2KKPZ.js.map +1 -0
  44. package/dist/{chunk-U4XTZMB7.js → chunk-QA3WETWT.js} +1 -1
  45. package/dist/{chunk-U4XTZMB7.js.map → chunk-QA3WETWT.js.map} +1 -1
  46. package/dist/{chunk-YXETEQQJ.js → chunk-SG2RKUVJ.js} +2 -2
  47. package/dist/{chunk-EOWV6BNQ.js → chunk-TXFX4PMN.js} +4 -2
  48. package/dist/{chunk-EOWV6BNQ.js.map → chunk-TXFX4PMN.js.map} +1 -1
  49. package/dist/{chunk-XWJDBQU7.js → chunk-V5RO6JYI.js} +1 -1
  50. package/dist/{chunk-SNSQLGGS.js.map → chunk-V5RO6JYI.js.map} +1 -1
  51. package/dist/{chunk-VUD4IEVJ.js → chunk-VZ6ZALIJ.js} +1 -1
  52. package/dist/chunk-VZ6ZALIJ.js.map +1 -0
  53. package/dist/{chunk-2DHL7NJW.js → chunk-XVRKKYWU.js} +5 -3
  54. package/dist/{chunk-2DHL7NJW.js.map → chunk-XVRKKYWU.js.map} +1 -1
  55. package/dist/{chunk-CDNOT2KR.js → chunk-YTYNKMNS.js} +1 -1
  56. package/dist/chunk-YTYNKMNS.js.map +1 -0
  57. package/dist/code-block.js.map +1 -1
  58. package/dist/columns.d.ts +132 -0
  59. package/dist/columns.js +89 -0
  60. package/dist/columns.js.map +1 -0
  61. package/dist/combobox.js +2 -2
  62. package/dist/copy-button.js +2 -2
  63. package/dist/copy-button.js.map +1 -1
  64. package/dist/data-table.js +3 -3
  65. package/dist/desktop-window.d.ts +1 -1
  66. package/dist/desktop-window.js +3 -1
  67. package/dist/desktop-window.js.map +1 -1
  68. package/dist/drop-overlay.js +8 -8
  69. package/dist/drop-overlay.js.map +1 -1
  70. package/dist/elephant.d.ts +1 -1
  71. package/dist/elephant.js.map +1 -1
  72. package/dist/embed-facade.d.ts +1 -1
  73. package/dist/embed-facade.js +3 -1
  74. package/dist/embed-facade.js.map +1 -1
  75. package/dist/engine-flow.js +7 -2
  76. package/dist/engine-flow.js.map +1 -1
  77. package/dist/entity-header.js +9 -3
  78. package/dist/entity-header.js.map +1 -1
  79. package/dist/file-upload.d.ts +1 -1
  80. package/dist/file-upload.js.map +1 -1
  81. package/dist/filter-bar.d.ts +4 -4
  82. package/dist/filter-bar.js +2 -2
  83. package/dist/flock.js +9 -6
  84. package/dist/flock.js.map +1 -1
  85. package/dist/form.d.ts +3 -3
  86. package/dist/form.js.map +1 -1
  87. package/dist/genui.js +3 -3
  88. package/dist/glossary-term.d.ts +1 -1
  89. package/dist/glossary-term.js.map +1 -1
  90. package/dist/glossary.d.ts +1 -1
  91. package/dist/glossary.js.map +1 -1
  92. package/dist/identity-card.js +1 -1
  93. package/dist/index.js +1 -1
  94. package/dist/kind-config-editor.d.ts +2 -2
  95. package/dist/kind-config-editor.js +1 -1
  96. package/dist/kind-config-editor.js.map +1 -1
  97. package/dist/kpi-explained.d.ts +1 -1
  98. package/dist/kpi-explained.js +4 -4
  99. package/dist/kpi-explained.js.map +1 -1
  100. package/dist/landing-page.js +1 -1
  101. package/dist/{lightbox-Q45BZ3HW.js → lightbox-MRB2YZEP.js} +1 -1
  102. package/dist/lightbox-MRB2YZEP.js.map +1 -0
  103. package/dist/map/cards.js +4 -2
  104. package/dist/map/cards.js.map +1 -1
  105. package/dist/map/pin.js +2 -1
  106. package/dist/map/pin.js.map +1 -1
  107. package/dist/map.d.ts +1 -1
  108. package/dist/map.js.map +1 -1
  109. package/dist/mascot-quote.js +1 -1
  110. package/dist/mascot-state.js +1 -1
  111. package/dist/mascots.js +1 -1
  112. package/dist/match-dialog.js +1 -1
  113. package/dist/motion.d.ts +1 -1
  114. package/dist/motion.js.map +1 -1
  115. package/dist/native/form.d.ts +3 -3
  116. package/dist/native/form.js.map +1 -1
  117. package/dist/native/markdown.d.ts +1 -1
  118. package/dist/native/markdown.js.map +1 -1
  119. package/dist/native/vertical-video.js.map +1 -1
  120. package/dist/native.d.ts +12 -12
  121. package/dist/native.js +12 -7
  122. package/dist/native.js.map +1 -1
  123. package/dist/nav-bar.d.ts +2 -2
  124. package/dist/nav-bar.js +1 -1
  125. package/dist/nav-bar.js.map +1 -1
  126. package/dist/next-actions.d.ts +1 -1
  127. package/dist/next-actions.js.map +1 -1
  128. package/dist/notification-preferences.d.ts +1 -1
  129. package/dist/notification-preferences.js +5 -2
  130. package/dist/notification-preferences.js.map +1 -1
  131. package/dist/page-index.js +2 -2
  132. package/dist/page-index.js.map +1 -1
  133. package/dist/product-page.js +1 -1
  134. package/dist/promo-code-field.d.ts +1 -1
  135. package/dist/promo-code-field.js.map +1 -1
  136. package/dist/qr-code.d.ts +1 -1
  137. package/dist/qr-code.js +1 -1
  138. package/dist/rail-nav.js +3 -3
  139. package/dist/rail-nav.js.map +1 -1
  140. package/dist/retro-tv.d.ts +1 -1
  141. package/dist/retro-tv.js.map +1 -1
  142. package/dist/reviews.d.ts +2 -2
  143. package/dist/reviews.js.map +1 -1
  144. package/dist/router.d.ts +1 -1
  145. package/dist/router.js +8 -8
  146. package/dist/router.js.map +1 -1
  147. package/dist/{schema-CL7t7xqb.d.ts → schema-Dd05m48Q.d.ts} +9 -9
  148. package/dist/service-card.js +22 -13
  149. package/dist/service-card.js.map +1 -1
  150. package/dist/settings-layout.js +1 -1
  151. package/dist/shop/booking.js.map +1 -1
  152. package/dist/shop/gallery.js +7 -6
  153. package/dist/shop/gallery.js.map +1 -1
  154. package/dist/shop/hero.js.map +1 -1
  155. package/dist/shop/look.d.ts +2 -2
  156. package/dist/shop/look.js +1 -1
  157. package/dist/shop/look.js.map +1 -1
  158. package/dist/shop/map-gate.d.ts +1 -1
  159. package/dist/shop/map-gate.js +2 -2
  160. package/dist/shop/map-gate.js.map +1 -1
  161. package/dist/shop/services.js.map +1 -1
  162. package/dist/shop-composer.d.ts +10 -10
  163. package/dist/shop-composer.js +27 -14
  164. package/dist/shop-composer.js.map +1 -1
  165. package/dist/shop-gallery.js +1 -1
  166. package/dist/shop.d.ts +2 -2
  167. package/dist/shop.js +2 -2
  168. package/dist/shop.js.map +1 -1
  169. package/dist/signature.js +2 -1
  170. package/dist/signature.js.map +1 -1
  171. package/dist/site-cahier.js +7 -3
  172. package/dist/site-cahier.js.map +1 -1
  173. package/dist/site-footer.js +6 -2
  174. package/dist/site-footer.js.map +1 -1
  175. package/dist/slot-picker.js +5 -2
  176. package/dist/slot-picker.js.map +1 -1
  177. package/dist/stat.js +1 -1
  178. package/dist/status-chip.d.ts +1 -1
  179. package/dist/status-chip.js.map +1 -1
  180. package/dist/tabs.js.map +1 -1
  181. package/dist/tag-input.js +2 -2
  182. package/dist/tag-selector.js +1 -1
  183. package/dist/text-style.js +4 -3
  184. package/dist/text-style.js.map +1 -1
  185. package/dist/usage.js +8 -3
  186. package/dist/usage.js.map +1 -1
  187. package/dist/versus-card.js +1 -1
  188. package/dist/versus-card.js.map +1 -1
  189. package/dist/vertical-video.js +1 -1
  190. package/dist/vertical-video.js.map +1 -1
  191. package/dist/virtual.d.ts +3 -3
  192. package/dist/wall.d.ts +4 -4
  193. package/dist/wall.js +1 -1
  194. package/dist/wall.js.map +1 -1
  195. package/package.json +20 -6
  196. package/registry/account-menu.json +2 -2
  197. package/registry/account-settings.json +3 -3
  198. package/registry/achievement.json +1 -1
  199. package/registry/action-bar.json +1 -1
  200. package/registry/activity-feed.json +1 -1
  201. package/registry/agenda.json +2 -2
  202. package/registry/alert.json +1 -1
  203. package/registry/analysis-report.json +3 -3
  204. package/registry/anatomy-plate.json +1 -1
  205. package/registry/app-frame.json +4 -4
  206. package/registry/app-header.json +2 -2
  207. package/registry/app-shell.json +1 -1
  208. package/registry/argument-card.json +1 -1
  209. package/registry/auth-layout.json +1 -1
  210. package/registry/avatar.json +2 -2
  211. package/registry/badge.json +3 -3
  212. package/registry/bird-plate.json +2 -2
  213. package/registry/button.json +1 -1
  214. package/registry/captcha.json +1 -1
  215. package/registry/card-grid.json +1 -1
  216. package/registry/card.json +1 -1
  217. package/registry/catalogue-page.json +1 -1
  218. package/registry/changelog-page.json +1 -1
  219. package/registry/chapter.json +2 -2
  220. package/registry/chat.json +1 -1
  221. package/registry/checkbox.json +1 -1
  222. package/registry/chip-link.json +1 -1
  223. package/registry/chip-row.json +1 -1
  224. package/registry/chip.json +2 -2
  225. package/registry/choice-grid.json +1 -1
  226. package/registry/code-block.json +1 -1
  227. package/registry/collection-switcher.json +1 -1
  228. package/registry/columns.json +319 -0
  229. package/registry/combobox.json +1 -1
  230. package/registry/command.json +1 -1
  231. package/registry/comparison-table.json +1 -1
  232. package/registry/component-page.json +1 -1
  233. package/registry/confirm-button.json +1 -1
  234. package/registry/contact-page.json +1 -1
  235. package/registry/continue-prompt.json +1 -1
  236. package/registry/copy-button.json +2 -2
  237. package/registry/countdown.json +1 -1
  238. package/registry/cover-hero.json +1 -1
  239. package/registry/cta-panel.json +1 -1
  240. package/registry/dashboard-layout.json +1 -1
  241. package/registry/data-table.json +2 -2
  242. package/registry/date-picker.json +1 -1
  243. package/registry/decision-list.json +1 -1
  244. package/registry/description-list.json +1 -1
  245. package/registry/desktop-window.json +2 -2
  246. package/registry/detail-layout.json +1 -1
  247. package/registry/dialog.json +1 -1
  248. package/registry/docs-article-page.json +1 -1
  249. package/registry/docs-hub-page.json +1 -1
  250. package/registry/docs-layout.json +1 -1
  251. package/registry/docs-nav.json +1 -1
  252. package/registry/document-viewer.json +1 -1
  253. package/registry/doodle.json +1 -1
  254. package/registry/drop-overlay.json +2 -2
  255. package/registry/dropdown-menu.json +1 -1
  256. package/registry/elephant.json +2 -2
  257. package/registry/embed-facade.json +3 -3
  258. package/registry/empty-state.json +1 -1
  259. package/registry/engine-flow.json +3 -3
  260. package/registry/entity-header.json +2 -2
  261. package/registry/environment-notice.json +1 -1
  262. package/registry/error-page.json +1 -1
  263. package/registry/examples/columns/columns.d.ts +4 -0
  264. package/registry/examples/columns/columns.js +21 -0
  265. package/registry/examples/columns/columns.tsx +18 -0
  266. package/registry/examples/columns/photos.d.ts +4 -0
  267. package/registry/examples/columns/photos.js +12 -0
  268. package/registry/examples/columns/photos.tsx +16 -0
  269. package/registry/examples/columns/stats.d.ts +4 -0
  270. package/registry/examples/columns/stats.js +20 -0
  271. package/registry/examples/columns/stats.tsx +22 -0
  272. package/registry/field.json +1 -1
  273. package/registry/file-upload.json +2 -2
  274. package/registry/filter-bar.json +2 -2
  275. package/registry/flock.json +3 -3
  276. package/registry/footnote.json +1 -1
  277. package/registry/force-update-screen.json +1 -1
  278. package/registry/form.json +8 -8
  279. package/registry/gallery-page.json +1 -1
  280. package/registry/genui.json +1 -1
  281. package/registry/glossary-term.json +2 -2
  282. package/registry/glossary.json +2 -2
  283. package/registry/glow-card.json +1 -1
  284. package/registry/goal-gauge.json +1 -1
  285. package/registry/grade-stamp.json +1 -1
  286. package/registry/grid.json +4 -3
  287. package/registry/identity-card.json +1 -1
  288. package/registry/image-cropper.json +1 -1
  289. package/registry/index.json +40 -9
  290. package/registry/kanban.json +1 -1
  291. package/registry/kbd.json +1 -1
  292. package/registry/kind-config-editor.json +2 -2
  293. package/registry/kpi-explained.json +2 -2
  294. package/registry/landing-page.json +1 -1
  295. package/registry/landscape.json +1 -1
  296. package/registry/language-switch.json +1 -1
  297. package/registry/legal-page.json +1 -1
  298. package/registry/link-card.json +1 -1
  299. package/registry/list.json +1 -1
  300. package/registry/loader.json +1 -1
  301. package/registry/longform-page.json +1 -1
  302. package/registry/maintenance-screen.json +1 -1
  303. package/registry/map.json +5 -5
  304. package/registry/margin-layout.json +1 -1
  305. package/registry/markdown.json +1 -1
  306. package/registry/marketing-layout.json +1 -1
  307. package/registry/mascot-quote.json +1 -1
  308. package/registry/mascot-state.json +2 -2
  309. package/registry/mascots.json +3 -3
  310. package/registry/match-dialog.json +1 -1
  311. package/registry/media-capture.json +1 -1
  312. package/registry/media-gallery.json +1 -1
  313. package/registry/meter.json +1 -1
  314. package/registry/money-input.json +1 -1
  315. package/registry/nav-bar.json +5 -5
  316. package/registry/next-actions.json +2 -2
  317. package/registry/notification-preferences.json +2 -2
  318. package/registry/number-ticker.json +1 -1
  319. package/registry/opening-hours.json +1 -1
  320. package/registry/page-header.json +1 -1
  321. package/registry/page-hero.json +1 -1
  322. package/registry/page-index.json +2 -2
  323. package/registry/page.json +2 -2
  324. package/registry/pagination.json +1 -1
  325. package/registry/pointer-light.json +1 -1
  326. package/registry/popover.json +1 -1
  327. package/registry/price-catalogue-editor.json +1 -1
  328. package/registry/pricing-page.json +1 -1
  329. package/registry/product-page.json +1 -1
  330. package/registry/profile-card.json +1 -1
  331. package/registry/progress.json +1 -1
  332. package/registry/promise-card.json +1 -1
  333. package/registry/promo-code-field.json +2 -2
  334. package/registry/proposal.json +1 -1
  335. package/registry/qr-code.json +3 -3
  336. package/registry/quota-meter.json +1 -1
  337. package/registry/radio-group.json +1 -1
  338. package/registry/rail-nav.json +4 -4
  339. package/registry/recipes.json +1 -1
  340. package/registry/retro-tv.json +2 -2
  341. package/registry/reviews.json +2 -2
  342. package/registry/router.json +2 -2
  343. package/registry/schema-form.json +1 -1
  344. package/registry/scroll-stage.json +1 -1
  345. package/registry/search-field.json +1 -1
  346. package/registry/section-backdrop.json +1 -1
  347. package/registry/separator.json +1 -1
  348. package/registry/service-card.json +2 -2
  349. package/registry/settings-layout.json +2 -2
  350. package/registry/shop-composer.json +8 -8
  351. package/registry/shop-gallery.json +2 -2
  352. package/registry/shop.json +12 -12
  353. package/registry/showcase.json +1 -1
  354. package/registry/signature.json +2 -2
  355. package/registry/site-cahier.json +2 -2
  356. package/registry/site-footer.json +4 -4
  357. package/registry/sites.json +1 -1
  358. package/registry/skeleton.json +1 -1
  359. package/registry/skip-link.json +1 -1
  360. package/registry/slider.json +1 -1
  361. package/registry/slot-picker.json +2 -2
  362. package/registry/slot.json +1 -1
  363. package/registry/specimen-tag.json +1 -1
  364. package/registry/speed-lines.json +1 -1
  365. package/registry/spinner.json +1 -1
  366. package/registry/split-view.json +1 -1
  367. package/registry/stage-banner.json +1 -1
  368. package/registry/stat.json +2 -2
  369. package/registry/status-chip.json +2 -2
  370. package/registry/status-page.json +1 -1
  371. package/registry/step-progress.json +1 -1
  372. package/registry/step-showcase.json +1 -1
  373. package/registry/stepper.json +1 -1
  374. package/registry/sticky-action.json +1 -1
  375. package/registry/stuck.json +1 -1
  376. package/registry/swipe-deck.json +1 -1
  377. package/registry/switch.json +1 -1
  378. package/registry/tabs.json +2 -2
  379. package/registry/tag-input.json +1 -1
  380. package/registry/tag-selector.json +1 -1
  381. package/registry/taped-photo.json +1 -1
  382. package/registry/terminal-replay.json +1 -1
  383. package/registry/text-style.json +2 -2
  384. package/registry/theme.json +1 -1
  385. package/registry/toast.json +1 -1
  386. package/registry/toc.json +1 -1
  387. package/registry/tooltip.json +1 -1
  388. package/registry/tree-view.json +1 -1
  389. package/registry/update-prompt.json +1 -1
  390. package/registry/upload-queue.json +1 -1
  391. package/registry/usage.json +3 -3
  392. package/registry/verified-badge.json +1 -1
  393. package/registry/versus-card.json +2 -2
  394. package/registry/vertical-video.json +2 -2
  395. package/registry/video-player.json +1 -1
  396. package/registry/video-trimmer.json +1 -1
  397. package/registry/virtual.json +1 -1
  398. package/registry/wall.json +6 -6
  399. package/registry/waveform.json +3 -3
  400. package/dist/chunk-BCD2CRFG.js.map +0 -1
  401. package/dist/chunk-CDNOT2KR.js.map +0 -1
  402. package/dist/chunk-FM42KOAU.js.map +0 -1
  403. package/dist/chunk-MTVX4RRF.js.map +0 -1
  404. package/dist/chunk-UIP3WX5O.js.map +0 -1
  405. package/dist/chunk-VUD4IEVJ.js.map +0 -1
  406. package/dist/chunk-ZFR6ZNXD.js.map +0 -1
  407. package/dist/lightbox-Q45BZ3HW.js.map +0 -1
  408. /package/dist/{chunk-YXETEQQJ.js.map → chunk-SG2RKUVJ.js.map} +0 -0
@@ -222,15 +222,15 @@
222
222
  "files": [
223
223
  {
224
224
  "path": "meta.ts",
225
- "content": "// The documentation of a component, carried by its code: each primitive has a `meta.ts` beside its source\n// (`src/<name>/meta.ts`; a component that exists only in React Native: `src/native/meta/<name>.ts`). Never built into\n// the package: `scripts/build-registry.mjs` reads them into `registry/<name>.json`, which ui.krizaka.com (apps/site) renders as\n// ui.krizaka.com/components/<name>, and `scripts/registry.test.mjs` fails when one is missing or incomplete.\n//\n// Why a typed module and not JSDoc tags: the fields are lists and links (`related`, `whenNotToUse[].use`, examples),\n// which a type checks and a comment does not; the file is plain data (erasable TypeScript), so Node reads it without a\n// compiler, and an editor completes it.\n\n/** Every documented component: the web primitives (one entry of the package each) and the native-only ones. */\nexport type ComponentName =\n | \"notification-preferences\"\n | \"quota-meter\"\n | \"environment-notice\"\n | \"embed-facade\"\n | \"reviews\"\n | \"margin-layout\"\n | \"analysis-report\"\n | \"status-chip\"\n | \"kind-config-editor\"\n | \"agenda\"\n | \"account-settings\"\n | \"drop-overlay\"\n | \"upload-queue\"\n | \"achievement\"\n | \"anatomy-plate\"\n | \"bird-plate\"\n | \"taped-photo\"\n | \"stuck\"\n | \"doodle\"\n | \"signature\"\n | \"grade-stamp\"\n | \"versus-card\"\n | \"speed-lines\"\n | \"site-cahier\"\n | \"text-style\"\n | \"flock\"\n | \"elephant\"\n | \"footnote\"\n | \"page-index\"\n | \"chapter\"\n | \"specimen-tag\"\n | \"action-bar\"\n | \"action-sheet\"\n | \"activity-feed\"\n | \"alert\"\n | \"app-frame\"\n | \"desktop-window\"\n | \"form-flow\"\n | \"grid\"\n | \"list-detail\"\n | \"state-screen\"\n | \"app-header\"\n | \"app-shell\"\n | \"argument-card\"\n | \"auth-layout\"\n | \"avatar\"\n | \"badge\"\n | \"button\"\n | \"captcha\"\n | \"card\"\n | \"card-grid\"\n | \"catalogue-page\"\n | \"changelog-page\"\n | \"chat\"\n | \"checkbox\"\n | \"chip\"\n | \"chip-link\"\n | \"chip-row\"\n | \"choice-grid\"\n | \"cn\"\n | \"code-block\"\n | \"combobox\"\n | \"comparison-table\"\n | \"command\"\n | \"component-page\"\n | \"confirm-button\"\n | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\n | \"contact-page\"\n | \"continue-prompt\"\n | \"countdown\"\n | \"cover-hero\"\n | \"cta-panel\"\n | \"dashboard-layout\"\n | \"data-table\"\n | \"date-picker\"\n | \"decision-list\"\n | \"description-list\"\n | \"detail-layout\"\n | \"dialog\"\n | \"docs-article-page\"\n | \"docs-hub-page\"\n | \"docs-layout\"\n | \"docs-nav\"\n | \"document-viewer\"\n | \"dropdown-menu\"\n | \"empty-state\"\n | \"engine-flow\"\n | \"error-page\"\n | \"fab\"\n | \"field\"\n | \"file-upload\"\n | \"filter-bar\"\n | \"force-update-screen\"\n | \"form\"\n | \"gallery-page\"\n | \"genui\"\n | \"glossary\"\n | \"glossary-term\"\n | \"glow-card\"\n | \"goal-gauge\"\n | \"header\"\n | \"image-cropper\"\n | \"image-viewer\"\n | \"kanban\"\n | \"kbd\"\n | \"kpi-explained\"\n | \"landing-page\"\n | \"landscape\"\n | \"legal-page\"\n | \"link-card\"\n | \"list\"\n | \"loader\"\n | \"longform-page\"\n | \"maintenance-screen\"\n | \"map\"\n | \"markdown\"\n | \"waveform\"\n | \"proposal\"\n | \"qr-code\"\n | \"identity-card\"\n | \"entity-header\"\n | \"collection-switcher\"\n | \"marketing-layout\"\n | \"mascot-quote\"\n | \"mascot-state\"\n | \"mascots\"\n | \"match-dialog\"\n | \"media-capture\"\n | \"language-switch\"\n | \"media-gallery\"\n | \"media-picker\"\n | \"meter\"\n | \"nav-bar\"\n | \"number-ticker\"\n | \"onboarding\"\n | \"opening-hours\"\n | \"otp-input\"\n | \"page\"\n | \"page-header\"\n | \"page-hero\"\n | \"pagination\"\n | \"permission-prompt\"\n | \"pointer-light\"\n | \"popover\"\n | \"pricing-page\"\n | \"product-page\"\n | \"profile-card\"\n | \"progress\"\n | \"promise-card\"\n | \"pull-to-refresh\"\n | \"retro-tv\"\n | \"shop-gallery\"\n | \"radio-group\"\n | \"router\"\n | \"rail-nav\"\n | \"recipes\"\n | \"screen\"\n | \"scroll-stage\"\n | \"search-field\"\n | \"section-backdrop\"\n | \"segmented\"\n | \"separator\"\n | \"service-card\"\n | \"shop\"\n | \"shop-composer\"\n | \"schema-form\"\n | \"settings-layout\"\n | \"account-menu\"\n | \"showcase\"\n | \"step-showcase\"\n | \"site-footer\"\n | \"sites\"\n | \"skeleton\"\n | \"skip-link\"\n | \"slider\"\n | \"slot-picker\"\n | \"slot\"\n | \"spinner\"\n | \"sticky-action\"\n | \"splash-handoff\"\n | \"split-view\"\n | \"stage-banner\"\n | \"stat\"\n | \"usage\"\n | \"status-page\"\n | \"step-progress\"\n | \"stepper\"\n | \"swipe-deck\"\n | \"swipeable-row\"\n | \"switch\"\n | \"tab-bar\"\n | \"tabs\"\n | \"tag-input\"\n | \"tag-selector\"\n | \"terminal-replay\"\n | \"theme\"\n | \"toast\"\n | \"toc\"\n | \"tooltip\"\n | \"tree-view\"\n | \"txt\"\n | \"update-prompt\"\n | \"verified-badge\"\n | \"vertical-video\"\n | \"video-player\"\n | \"video-trimmer\"\n | \"virtual\"\n | \"wall\";\n\n/** Where a component exists: `@krizaka/ui/<name>` (web), `@krizaka/ui/native` (React Native), or both. */\nexport type Platform = \"web\" | \"native\" | \"both\";\n\n/**\n * Why a component is not on a platform — a decision, never a silence (the parity matrix of ui.krizaka.com/platforms):\n * - `gap` (✗): it belongs there and is not built yet; `issue` is the issue that tracks it (`krizaka/krizaka-ui#275`);\n * - `n/a`: it is not meant for that platform (a site's page block on a phone, a swipe on a desktop); `use` names the\n * component that answers there, when one does.\n */\nexport type Absence =\n | { readonly status: \"gap\"; readonly issue: string; readonly reason: string; readonly use?: undefined }\n | { readonly status: \"n/a\"; readonly reason: string; readonly use?: ComponentName; readonly issue?: undefined };\n\n/**\n * Desktop is the Sovkora Mac app (Tauri 2: the system WebView renders the web components — ADR-002). `web`: the web\n * component runs there as it is; `desktop`: it also has a desktop form (a window's title bar, a denser layout…), said in\n * its documentation; otherwise the absence and why.\n */\nexport type DesktopSupport = \"web\" | \"desktop\" | Absence;\n\n/**\n * The three platforms of Krizaka UI — web · native (React Native, Expo) · desktop — for one component. The side a\n * component has is `platforms`; the side it lacks says why here: `native` is required for (and only for) a web-only\n * component, `web` for a native-only one; `desktop` always. `scripts/registry.test.mjs` fails on a missing decision.\n */\nexport interface Parity {\n readonly web?: Absence;\n readonly native?: Absence;\n readonly desktop: DesktopSupport;\n}\n\n/**\n * `experimental`: created for a filed need (ADR-008 §4), it may change or go in any minor until its first consumer imports it; `adoption`\n * names that consumer's issue. `stable`: its API only changes in a major. `beta`: it may still change in a minor. `deprecated`: no product uses it and\n * no work plans to — it still works, says what replaces it, and goes in the major named by `deprecated.removedIn`.\n */\nexport type Status = \"experimental\" | \"stable\" | \"beta\" | \"deprecated\";\n\n/**\n * What a component is for (ADR-008 §3): the thirteen domains the documentation, the size budgets and the guards are\n * organised by. The domain is metadata: the entries stay flat (`@krizaka/ui/<name>`). `cahier` is the sites' register\n * (ADR-004): a product never imports it.\n */\nexport type Domain =\n | \"foundations\"\n | \"forms\"\n | \"data-display\"\n | \"navigation-shell\"\n | \"feedback\"\n | \"maps\"\n | \"media\"\n | \"commerce\"\n | \"identity\"\n | \"abuse\"\n | \"conversation\"\n | \"page-blocks\"\n | \"cahier\";\n\n/** What a deprecated component says (required when `status` is `deprecated`, absent otherwise). */\nexport interface Deprecation {\n /** The version that deprecated it (`3.6.0`). */\n readonly since: string;\n /** The major that removes it (`4.0.0`). */\n readonly removedIn: string;\n /** What replaces it, when a component does. */\n readonly use?: ComponentName;\n /** Why it goes: no product uses it, no planned work needs it. */\n readonly reason: string;\n}\n\n/**\n * The group of the catalogue. `media`: video, sound, camera, files, cropping. `blocks`: the page blocks — the frame,\n * the hero, sections, cards that lead or argue, decisions, code, calls to act — that every page of a site is made of.\n * `layouts`: the shells of whole screens — an application, a dashboard, settings, sign-in, an object, a list and its\n * item, a site's page, a documentation page — each with its screens. `templates`: the page templates — whole pages of a\n * site (a landing, a product, a docs hub, a long read, a changelog, pricing, status, an error…), each a distinct\n * composition of the blocks, words and content as props.\n */\nexport type Category = \"actions\" | \"forms\" | \"navigation\" | \"overlays\" | \"feedback\" | \"data-display\" | \"media\" | \"blocks\" | \"layouts\" | \"templates\" | \"layout\" | \"foundations\";\n\n/** Why a reader needs a template: the seven intents the templates are grouped by (sidebar sub-headings, catalogue filter). */\nexport type TemplatePurpose = \"convince\" | \"explain\" | \"show\" | \"act\" | \"operate\" | \"converse\" | \"recover\";\n\n/** The groups of templates, in reading order: the title, and the one line that says when to come to that group. */\nexport const templatePurposes = {\n convince: { title: \"Convince\", useWhen: \"You come here when a visitor must decide: a landing, a product, a price, a comparison, a proof.\" },\n explain: { title: \"Explain\", useWhen: \"You come here when a reader must understand: how it works, a documentation hub or article, a changelog, a FAQ, a policy.\" },\n show: { title: \"Show\", useWhen: \"You come here when the work itself is the argument: a gallery, a story, a case study, an object and its details.\" },\n act: { title: \"Act\", useWhen: \"You come here when a person must do something once: reach the team, sign in or up, set up, pay.\" },\n operate: { title: \"Operate\", useWhen: \"You come here when a person works every day: a dashboard, a console with a table, settings, an app shell.\" },\n converse: { title: \"Converse\", useWhen: \"You come here when people talk: an inbox, a chat, comments, a notifications centre.\" },\n recover: { title: \"Recover\", useWhen: \"You come here when the way is blocked: an empty list, an error, a missing page, maintenance, a product still being built.\" },\n} as const satisfies Record<TemplatePurpose, { readonly title: string; readonly useWhen: string }>;\n\n/**\n * A named example: the file `registry/examples/<component>/<name>.tsx` (web) or\n * `registry/examples/<component>/native/<name>.tsx` (React Native) — at most 40 lines, imported by the stories and\n * shown (live, with its code) by the documentation.\n */\ninterface ExampleBase {\n /** The file name, kebab-case (`primary`, `icon-button`). */\n readonly name: string;\n /** A short title (`Primary`, `Icon button`). */\n readonly title: string;\n /** One or two sentences: when this variant is the right one. */\n readonly description: string;\n}\n\n/** A plain example, or a template: a whole screen with its intent (`purpose`) and the user goal its layout serves (`why`). */\nexport type Example =\n | (ExampleBase & { readonly template?: false; readonly purpose?: undefined; readonly why?: undefined })\n | (ExampleBase & {\n /**\n * A template: a whole screen of a product composed from the platform (a layout and its blocks, real words, its\n * phone version thought out), copied as a starting point — at most 160 lines, listed on ui.krizaka.com/templates.\n */\n readonly template: true;\n /** The intent that groups it: why you need this block. */\n readonly purpose: TemplatePurpose;\n /** Why this layout: the user goal it serves, in one sentence. */\n readonly why: string;\n });\n\n/** One platform's side of a component. */\nexport interface PlatformDocs {\n /** The names to import (`[\"Button\", \"IconButton\"]`): from `@krizaka/ui/<name>` on the web, `@krizaka/ui/native` in React Native. */\n readonly imports: readonly string[];\n /** The examples, in reading order; the first one is the component's preview. */\n readonly examples: readonly Example[];\n}\n\n/** The React Native side: the same concept, and what differs from the web API. */\nexport interface NativeDocs extends PlatformDocs {\n /**\n * The entry to import from when it is not `@krizaka/ui/native`: a component that needs an Expo module (an optional\n * peer) has its own, `@krizaka/ui/native/<name>`, so an app that does not use it never installs the module.\n */\n readonly entry?: string;\n /** What differs from the web API (`label` instead of children…); empty for a native-only component. */\n readonly differences: readonly string[];\n /** The React Native entry alone is deprecated while the web one stays (ADR-006 §7); a deprecated component says it once, above. */\n readonly deprecated?: Deprecation;\n}\n\nexport interface KeyboardInteraction {\n /** The keys, as written on a keyboard: `Space`, `Enter`, `Arrow keys`, `Esc`, `Tab`. */\n readonly keys: string;\n /** What they do. */\n readonly action: string;\n}\n\nexport interface ComponentMeta {\n /** The display name: `Button`, `Dropdown menu`. */\n readonly title: string;\n /** One sentence: what it is. */\n readonly summary: string;\n readonly status: Status;\n /** Required for, and only for, a `deprecated` component. */\n readonly deprecated?: Deprecation;\n readonly category: Category;\n /** What it is for: one of the twelve domains (ADR-008 §3). */\n readonly domain: Domain;\n /** The `<repo>#<n>` issue of its first consumer: required for, and only for, an `experimental` component. */\n readonly adoption?: string;\n /** Must match the sides below: `both` ⇔ `web` and `native`. */\n readonly platforms: Platform;\n /** The platforms it is not on, and why; and its desktop form (see `Parity`). */\n readonly parity: Parity;\n /** When to reach for it: concrete situations, one per item. */\n readonly whenToUse: readonly string[];\n /** When not to — and what to use instead (`use`), when another component is the answer. */\n readonly whenNotToUse: readonly { readonly when: string; readonly use?: ComponentName }[];\n /** How to use it well: wording, placement, composition. */\n readonly bestPractices: readonly string[];\n readonly accessibility: {\n /** The keyboard, when it does more than Tab and Enter. */\n readonly keyboard: readonly KeyboardInteraction[];\n /** Roles, names and announcements: what the component does, what the app must provide. */\n readonly notes: readonly string[];\n };\n /** The components a reader of this page should know about. */\n readonly related: readonly ComponentName[];\n readonly web?: PlatformDocs;\n readonly native?: NativeDocs;\n}\n"
225
+ "content": "// The documentation of a component, carried by its code: each primitive has a `meta.ts` beside its source\n// (`src/<name>/meta.ts`; a component that exists only in React Native: `src/native/meta/<name>.ts`). Never built into\n// the package: `scripts/build-registry.mjs` reads them into `registry/<name>.json`, which ui.krizaka.com (apps/site) renders as\n// ui.krizaka.com/components/<name>, and `scripts/registry.test.mjs` fails when one is missing or incomplete.\n//\n// Why a typed module and not JSDoc tags: the fields are lists and links (`related`, `whenNotToUse[].use`, examples),\n// which a type checks and a comment does not; the file is plain data (erasable TypeScript), so Node reads it without a\n// compiler, and an editor completes it.\n\n/** Every documented component: the web primitives (one entry of the package each) and the native-only ones. */\nexport type ComponentName =\n | \"notification-preferences\"\n | \"quota-meter\"\n | \"environment-notice\"\n | \"embed-facade\"\n | \"reviews\"\n | \"margin-layout\"\n | \"analysis-report\"\n | \"status-chip\"\n | \"kind-config-editor\"\n | \"agenda\"\n | \"account-settings\"\n | \"drop-overlay\"\n | \"upload-queue\"\n | \"achievement\"\n | \"anatomy-plate\"\n | \"bird-plate\"\n | \"taped-photo\"\n | \"stuck\"\n | \"doodle\"\n | \"signature\"\n | \"grade-stamp\"\n | \"versus-card\"\n | \"speed-lines\"\n | \"site-cahier\"\n | \"text-style\"\n | \"flock\"\n | \"elephant\"\n | \"footnote\"\n | \"page-index\"\n | \"chapter\"\n | \"specimen-tag\"\n | \"action-bar\"\n | \"action-sheet\"\n | \"activity-feed\"\n | \"alert\"\n | \"app-frame\"\n | \"desktop-window\"\n | \"form-flow\"\n | \"grid\"\n | \"list-detail\"\n | \"state-screen\"\n | \"app-header\"\n | \"app-shell\"\n | \"argument-card\"\n | \"auth-layout\"\n | \"avatar\"\n | \"badge\"\n | \"button\"\n | \"captcha\"\n | \"card\"\n | \"card-grid\"\n | \"catalogue-page\"\n | \"changelog-page\"\n | \"chat\"\n | \"checkbox\"\n | \"chip\"\n | \"chip-link\"\n | \"chip-row\"\n | \"columns\"\n | \"choice-grid\"\n | \"cn\"\n | \"code-block\"\n | \"combobox\"\n | \"comparison-table\"\n | \"command\"\n | \"component-page\"\n | \"confirm-button\"\n | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\n | \"contact-page\"\n | \"continue-prompt\"\n | \"countdown\"\n | \"cover-hero\"\n | \"cta-panel\"\n | \"dashboard-layout\"\n | \"data-table\"\n | \"date-picker\"\n | \"decision-list\"\n | \"description-list\"\n | \"detail-layout\"\n | \"dialog\"\n | \"docs-article-page\"\n | \"docs-hub-page\"\n | \"docs-layout\"\n | \"docs-nav\"\n | \"document-viewer\"\n | \"dropdown-menu\"\n | \"empty-state\"\n | \"engine-flow\"\n | \"error-page\"\n | \"fab\"\n | \"field\"\n | \"file-upload\"\n | \"filter-bar\"\n | \"force-update-screen\"\n | \"form\"\n | \"gallery-page\"\n | \"genui\"\n | \"glossary\"\n | \"glossary-term\"\n | \"glow-card\"\n | \"goal-gauge\"\n | \"header\"\n | \"image-cropper\"\n | \"image-viewer\"\n | \"kanban\"\n | \"kbd\"\n | \"kpi-explained\"\n | \"landing-page\"\n | \"landscape\"\n | \"legal-page\"\n | \"link-card\"\n | \"list\"\n | \"loader\"\n | \"longform-page\"\n | \"maintenance-screen\"\n | \"map\"\n | \"markdown\"\n | \"waveform\"\n | \"proposal\"\n | \"qr-code\"\n | \"identity-card\"\n | \"entity-header\"\n | \"collection-switcher\"\n | \"marketing-layout\"\n | \"mascot-quote\"\n | \"mascot-state\"\n | \"mascots\"\n | \"match-dialog\"\n | \"media-capture\"\n | \"language-switch\"\n | \"media-gallery\"\n | \"media-picker\"\n | \"meter\"\n | \"nav-bar\"\n | \"number-ticker\"\n | \"onboarding\"\n | \"opening-hours\"\n | \"otp-input\"\n | \"page\"\n | \"page-header\"\n | \"page-hero\"\n | \"pagination\"\n | \"permission-prompt\"\n | \"pointer-light\"\n | \"popover\"\n | \"pricing-page\"\n | \"product-page\"\n | \"profile-card\"\n | \"progress\"\n | \"promise-card\"\n | \"pull-to-refresh\"\n | \"retro-tv\"\n | \"shop-gallery\"\n | \"radio-group\"\n | \"router\"\n | \"rail-nav\"\n | \"recipes\"\n | \"screen\"\n | \"scroll-stage\"\n | \"search-field\"\n | \"section-backdrop\"\n | \"segmented\"\n | \"separator\"\n | \"service-card\"\n | \"shop\"\n | \"shop-composer\"\n | \"schema-form\"\n | \"settings-layout\"\n | \"account-menu\"\n | \"showcase\"\n | \"step-showcase\"\n | \"site-footer\"\n | \"sites\"\n | \"skeleton\"\n | \"skip-link\"\n | \"slider\"\n | \"slot-picker\"\n | \"slot\"\n | \"spinner\"\n | \"sticky-action\"\n | \"splash-handoff\"\n | \"split-view\"\n | \"stage-banner\"\n | \"stat\"\n | \"usage\"\n | \"status-page\"\n | \"step-progress\"\n | \"stepper\"\n | \"swipe-deck\"\n | \"swipeable-row\"\n | \"switch\"\n | \"tab-bar\"\n | \"tabs\"\n | \"tag-input\"\n | \"tag-selector\"\n | \"terminal-replay\"\n | \"theme\"\n | \"toast\"\n | \"toc\"\n | \"tooltip\"\n | \"tree-view\"\n | \"txt\"\n | \"update-prompt\"\n | \"verified-badge\"\n | \"vertical-video\"\n | \"video-player\"\n | \"video-trimmer\"\n | \"virtual\"\n | \"wall\";\n\n/** Where a component exists: `@krizaka/ui/<name>` (web), `@krizaka/ui/native` (React Native), or both. */\nexport type Platform = \"web\" | \"native\" | \"both\";\n\n/**\n * Why a component is not on a platform — a decision, never a silence (the parity matrix of ui.krizaka.com/platforms):\n * - `gap` (✗): it belongs there and is not built yet; `issue` is the issue that tracks it (`krizaka/krizaka-ui#275`);\n * - `n/a`: it is not meant for that platform (a site's page block on a phone, a swipe on a desktop); `use` names the\n * component that answers there, when one does.\n */\nexport type Absence =\n | { readonly status: \"gap\"; readonly issue: string; readonly reason: string; readonly use?: undefined }\n | { readonly status: \"n/a\"; readonly reason: string; readonly use?: ComponentName; readonly issue?: undefined };\n\n/**\n * Desktop is the Sovkora Mac app (Tauri 2: the system WebView renders the web components — ADR-002). `web`: the web\n * component runs there as it is; `desktop`: it also has a desktop form (a window's title bar, a denser layout…), said in\n * its documentation; otherwise the absence and why.\n */\nexport type DesktopSupport = \"web\" | \"desktop\" | Absence;\n\n/**\n * The three platforms of Krizaka UI — web · native (React Native, Expo) · desktop — for one component. The side a\n * component has is `platforms`; the side it lacks says why here: `native` is required for (and only for) a web-only\n * component, `web` for a native-only one; `desktop` always. `scripts/registry.test.mjs` fails on a missing decision.\n */\nexport interface Parity {\n readonly web?: Absence;\n readonly native?: Absence;\n readonly desktop: DesktopSupport;\n}\n\n/**\n * `experimental`: created for a filed need (ADR-008 §4), it may change or go in any minor until its first consumer imports it; `adoption`\n * names that consumer's issue. `stable`: its API only changes in a major. `beta`: it may still change in a minor. `deprecated`: no product uses it and\n * no work plans to — it still works, says what replaces it, and goes in the major named by `deprecated.removedIn`.\n */\nexport type Status = \"experimental\" | \"stable\" | \"beta\" | \"deprecated\";\n\n/**\n * What a component is for (ADR-008 §3): the thirteen domains the documentation, the size budgets and the guards are\n * organised by. The domain is metadata: the entries stay flat (`@krizaka/ui/<name>`). `cahier` is the sites' register\n * (ADR-004): a product never imports it.\n */\nexport type Domain =\n | \"foundations\"\n | \"forms\"\n | \"data-display\"\n | \"navigation-shell\"\n | \"feedback\"\n | \"maps\"\n | \"media\"\n | \"commerce\"\n | \"identity\"\n | \"abuse\"\n | \"conversation\"\n | \"page-blocks\"\n | \"cahier\";\n\n/** What a deprecated component says (required when `status` is `deprecated`, absent otherwise). */\nexport interface Deprecation {\n /** The version that deprecated it (`3.6.0`). */\n readonly since: string;\n /** The major that removes it (`4.0.0`). */\n readonly removedIn: string;\n /** What replaces it, when a component does. */\n readonly use?: ComponentName;\n /** Why it goes: no product uses it, no planned work needs it. */\n readonly reason: string;\n}\n\n/**\n * The group of the catalogue. `media`: video, sound, camera, files, cropping. `blocks`: the page blocks — the frame,\n * the hero, sections, cards that lead or argue, decisions, code, calls to act — that every page of a site is made of.\n * `layouts`: the shells of whole screens — an application, a dashboard, settings, sign-in, an object, a list and its\n * item, a site's page, a documentation page — each with its screens. `templates`: the page templates — whole pages of a\n * site (a landing, a product, a docs hub, a long read, a changelog, pricing, status, an error…), each a distinct\n * composition of the blocks, words and content as props.\n */\nexport type Category = \"actions\" | \"forms\" | \"navigation\" | \"overlays\" | \"feedback\" | \"data-display\" | \"media\" | \"blocks\" | \"layouts\" | \"templates\" | \"layout\" | \"foundations\";\n\n/** Why a reader needs a template: the seven intents the templates are grouped by (sidebar sub-headings, catalogue filter). */\nexport type TemplatePurpose = \"convince\" | \"explain\" | \"show\" | \"act\" | \"operate\" | \"converse\" | \"recover\";\n\n/** The groups of templates, in reading order: the title, and the one line that says when to come to that group. */\nexport const templatePurposes = {\n convince: { title: \"Convince\", useWhen: \"You come here when a visitor must decide: a landing, a product, a price, a comparison, a proof.\" },\n explain: { title: \"Explain\", useWhen: \"You come here when a reader must understand: how it works, a documentation hub or article, a changelog, a FAQ, a policy.\" },\n show: { title: \"Show\", useWhen: \"You come here when the work itself is the argument: a gallery, a story, a case study, an object and its details.\" },\n act: { title: \"Act\", useWhen: \"You come here when a person must do something once: reach the team, sign in or up, set up, pay.\" },\n operate: { title: \"Operate\", useWhen: \"You come here when a person works every day: a dashboard, a console with a table, settings, an app shell.\" },\n converse: { title: \"Converse\", useWhen: \"You come here when people talk: an inbox, a chat, comments, a notifications centre.\" },\n recover: { title: \"Recover\", useWhen: \"You come here when the way is blocked: an empty list, an error, a missing page, maintenance, a product still being built.\" },\n} as const satisfies Record<TemplatePurpose, { readonly title: string; readonly useWhen: string }>;\n\n/**\n * A named example: the file `registry/examples/<component>/<name>.tsx` (web) or\n * `registry/examples/<component>/native/<name>.tsx` (React Native) — at most 40 lines, imported by the stories and\n * shown (live, with its code) by the documentation.\n */\ninterface ExampleBase {\n /** The file name, kebab-case (`primary`, `icon-button`). */\n readonly name: string;\n /** A short title (`Primary`, `Icon button`). */\n readonly title: string;\n /** One or two sentences: when this variant is the right one. */\n readonly description: string;\n}\n\n/** A plain example, or a template: a whole screen with its intent (`purpose`) and the user goal its layout serves (`why`). */\nexport type Example =\n | (ExampleBase & { readonly template?: false; readonly purpose?: undefined; readonly why?: undefined })\n | (ExampleBase & {\n /**\n * A template: a whole screen of a product composed from the platform (a layout and its blocks, real words, its\n * phone version thought out), copied as a starting point — at most 160 lines, listed on ui.krizaka.com/templates.\n */\n readonly template: true;\n /** The intent that groups it: why you need this block. */\n readonly purpose: TemplatePurpose;\n /** Why this layout: the user goal it serves, in one sentence. */\n readonly why: string;\n });\n\n/** One platform's side of a component. */\nexport interface PlatformDocs {\n /** The names to import (`[\"Button\", \"IconButton\"]`): from `@krizaka/ui/<name>` on the web, `@krizaka/ui/native` in React Native. */\n readonly imports: readonly string[];\n /** The examples, in reading order; the first one is the component's preview. */\n readonly examples: readonly Example[];\n}\n\n/** The React Native side: the same concept, and what differs from the web API. */\nexport interface NativeDocs extends PlatformDocs {\n /**\n * The entry to import from when it is not `@krizaka/ui/native`: a component that needs an Expo module (an optional\n * peer) has its own, `@krizaka/ui/native/<name>`, so an app that does not use it never installs the module.\n */\n readonly entry?: string;\n /** What differs from the web API (`label` instead of children…); empty for a native-only component. */\n readonly differences: readonly string[];\n /** The React Native entry alone is deprecated while the web one stays (ADR-006 §7); a deprecated component says it once, above. */\n readonly deprecated?: Deprecation;\n}\n\nexport interface KeyboardInteraction {\n /** The keys, as written on a keyboard: `Space`, `Enter`, `Arrow keys`, `Esc`, `Tab`. */\n readonly keys: string;\n /** What they do. */\n readonly action: string;\n}\n\nexport interface ComponentMeta {\n /** The display name: `Button`, `Dropdown menu`. */\n readonly title: string;\n /** One sentence: what it is. */\n readonly summary: string;\n readonly status: Status;\n /** Required for, and only for, a `deprecated` component. */\n readonly deprecated?: Deprecation;\n readonly category: Category;\n /** What it is for: one of the twelve domains (ADR-008 §3). */\n readonly domain: Domain;\n /** The `<repo>#<n>` issue of its first consumer: required for, and only for, an `experimental` component. */\n readonly adoption?: string;\n /** Must match the sides below: `both` ⇔ `web` and `native`. */\n readonly platforms: Platform;\n /** The platforms it is not on, and why; and its desktop form (see `Parity`). */\n readonly parity: Parity;\n /** When to reach for it: concrete situations, one per item. */\n readonly whenToUse: readonly string[];\n /** When not to — and what to use instead (`use`), when another component is the answer. */\n readonly whenNotToUse: readonly { readonly when: string; readonly use?: ComponentName }[];\n /** How to use it well: wording, placement, composition. */\n readonly bestPractices: readonly string[];\n readonly accessibility: {\n /** The keyboard, when it does more than Tab and Enter. */\n readonly keyboard: readonly KeyboardInteraction[];\n /** Roles, names and announcements: what the component does, what the app must provide. */\n readonly notes: readonly string[];\n };\n /** The components a reader of this page should know about. */\n readonly related: readonly ComponentName[];\n readonly web?: PlatformDocs;\n readonly native?: NativeDocs;\n}\n"
226
226
  },
227
227
  {
228
228
  "path": "shop-composer/commands.ts",
229
- "content": "// The composer's commands (ADR-007 §5): every change of the document is a pure command on a reducer — never a mutation —\n// so undo / redo restore the exact document, and the rules of the document (a hero first, 16 sections, 24 blocks, the variants\n// of a type) hold after every step. A command that would break a rule is a no-op: the page stays valid, always.\nimport { SECTION_DEFINITIONS, sectionDefinition,type SectionType } from \"../shop/catalogue\";\nimport { SHOP_LIMITS } from \"../shop/limits\";\nimport { applyLook, type ShopLookLike } from \"../shop/look/apply-look\";\nimport type { Section, ShopPage } from \"../shop/schema\";\nimport type { LocalizedText } from \"../shop/text\";\n\ntype Rec = Record<string, unknown>;\n\nexport type Command =\n /** Adds a section (its type's default settings, the given or the default variant) at an index; a hero goes first. */\n | { type: \"addSection\"; sectionType: SectionType; key: string; variant?: string; at?: number; settings?: Rec }\n | { type: \"removeSection\"; key: string }\n /** Moves a section to an absolute index (the hero stays first: nothing goes above it). */\n | { type: \"moveSection\"; key: string; to: number }\n | { type: \"setVariant\"; key: string; variant: string }\n /** Merges into the settings. */\n | { type: \"patchSettings\"; key: string; patch: Rec }\n | { type: \"setText\"; key: string; field: \"title\" | \"lead\"; value: LocalizedText | undefined }\n | { type: \"toggleDisabled\"; key: string }\n | { type: \"setPreset\"; preset: { id: string; version: number }; density?: \"compact\" | \"airy\" | null }\n | { type: \"setDensity\"; density: \"compact\" | \"airy\" | undefined }\n /** A whole look (`look-*`): the variants of the sections, nothing of their content (`applyLook`). */\n | { type: \"applyLook\"; look: ShopLookLike }\n /** The accent within the look's tested list. */\n | { type: \"setAccent\"; accent: string | undefined }\n | { type: \"addBlock\"; key: string; blockKey: string; blockType: string; settings?: Rec; at?: number }\n | { type: \"removeBlock\"; key: string; blockKey: string }\n | { type: \"moveBlock\"; key: string; blockKey: string; to: number }\n | { type: \"patchBlock\"; key: string; blockKey: string; patch: Rec };\n\nconst clamp = (n: number, lo: number, hi: number) => Math.min(Math.max(n, lo), hi);\nconst indexOfKey = (page: ShopPage, key: string) => page.sections.findIndex((s) => s.key === key);\n\n/** The array with an item moved to an index. */\nexport function moved<T>(list: readonly T[], from: number, to: number): T[] {\n const next = [...list];\n const [item] = next.splice(from, 1);\n next.splice(clamp(to, 0, next.length), 0, item as T);\n return next;\n}\n\nfunction withSection(page: ShopPage, key: string, change: (s: Section) => Section): ShopPage {\n const i = indexOfKey(page, key);\n if (i < 0) return page;\n const next = change(page.sections[i]!);\n if (next === page.sections[i]) return page;\n const sections = [...page.sections];\n sections[i] = next;\n return { ...page, sections };\n}\n\ntype Handler<T extends Command[\"type\"]> = (page: ShopPage, cmd: Extract<Command, { type: T }>) => ShopPage;\n\nconst addSection: Handler<\"addSection\"> = (page, cmd) => {\n const def = SECTION_DEFINITIONS.find((d) => d.type === cmd.sectionType);\n if (!def || page.sections.length >= SHOP_LIMITS.sections || page.sections.some((s) => s.key === cmd.key)) return page;\n const variant = cmd.variant ?? def.defaultVariant;\n if (!(def.variants as readonly string[]).includes(variant)) return page;\n const isHero = def.type === \"hero\";\n if (isHero && page.sections.some((s) => s.type === \"hero\")) return page;\n const heroFirst = page.sections[0]?.type === \"hero\";\n const at = isHero ? 0 : clamp(cmd.at ?? page.sections.length, heroFirst ? 1 : 0, page.sections.length);\n const section = { key: cmd.key, type: def.type, variant, settings: { ...(def.settingsDefault as Rec), ...cmd.settings } } as unknown as Section;\n const sections = [...page.sections];\n sections.splice(at, 0, section);\n return { ...page, sections };\n};\n\nconst removeSection: Handler<\"removeSection\"> = (page, cmd) => {\n if (indexOfKey(page, cmd.key) < 0 || page.sections.length <= 1) return page;\n return { ...page, sections: page.sections.filter((s) => s.key !== cmd.key) };\n};\n\nconst moveSection: Handler<\"moveSection\"> = (page, cmd) => {\n const from = indexOfKey(page, cmd.key);\n if (from < 0 || page.sections[from]!.type === \"hero\") return page;\n const lo = page.sections[0]?.type === \"hero\" ? 1 : 0;\n const to = clamp(cmd.to, lo, page.sections.length - 1);\n return to === from ? page : { ...page, sections: moved(page.sections, from, to) };\n};\n\nconst setVariant: Handler<\"setVariant\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const def = sectionDefinition(s.type);\n if (s.variant === cmd.variant || !(def.variants as readonly string[]).includes(cmd.variant)) return s;\n return { ...s, variant: cmd.variant } as Section;\n });\n\n/** Whether every value of a patch is already the one the object holds. */\nconst saysNothingNew = (current: Rec, patch: Rec) => Object.entries(patch).every(([k, v]) => JSON.stringify(current[k]) === JSON.stringify(v));\n\nconst patchSettings: Handler<\"patchSettings\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const current = s.settings as Rec;\n // Nothing to say when every value is already the document's (a form that reports its first values after an undo).\n return saysNothingNew(current, cmd.patch) ? s : ({ ...s, settings: { ...current, ...cmd.patch } } as Section);\n });\n\nconst setText: Handler<\"setText\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const text = { ...(s.text ?? {}) } as Rec;\n if (cmd.value === undefined) delete text[cmd.field];\n else text[cmd.field] = cmd.value;\n const next = { ...s } as Rec;\n if (Object.keys(text).length === 0) delete next.text;\n else next.text = text;\n return next as unknown as Section;\n });\n\nconst toggleDisabled: Handler<\"toggleDisabled\"> = (page, cmd) => withSection(page, cmd.key, (s) => ({ ...s, disabled: s.disabled ? undefined : true }) as Section);\n\nconst setPreset: Handler<\"setPreset\"> = (page, cmd) => {\n if (page.preset.id === cmd.preset.id && page.preset.version === cmd.preset.version && cmd.density === undefined) return page;\n let density: Partial<Pick<ShopPage, \"density\">> = {};\n if (cmd.density === null) density = { density: undefined };\n else if (cmd.density) density = { density: cmd.density };\n return { ...page, preset: { ...cmd.preset }, ...density };\n};\n\nconst setDensity: Handler<\"setDensity\"> = (page, cmd) => (page.density === cmd.density ? page : { ...page, density: cmd.density });\n\nconst applyLookCmd: Handler<\"applyLook\"> = (page, cmd) => applyLook(page, cmd.look);\n\nconst setAccent: Handler<\"setAccent\"> = (page, cmd) => (page.accent === cmd.accent ? page : { ...page, accent: cmd.accent });\n\ntype Keyed = { key: string; type?: string; settings?: Rec };\n\nconst addBlock: Handler<\"addBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const def = sectionDefinition(s.type);\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n if (!(def.blockTypes as readonly string[]).includes(cmd.blockType) || blocks.length >= SHOP_LIMITS.blocks || blocks.some((b) => b.key === cmd.blockKey)) return s;\n const next = [...blocks];\n next.splice(clamp(cmd.at ?? blocks.length, 0, blocks.length), 0, { key: cmd.blockKey, type: cmd.blockType, settings: { ...cmd.settings } });\n return { ...s, blocks: next } as unknown as Section;\n });\n\nconst removeBlock: Handler<\"removeBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n if (!blocks.some((b) => b.key === cmd.blockKey)) return s;\n const next = blocks.filter((b) => b.key !== cmd.blockKey);\n return { ...s, blocks: next.length > 0 ? next : undefined } as unknown as Section;\n });\n\nconst moveBlock: Handler<\"moveBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n const from = blocks.findIndex((b) => b.key === cmd.blockKey);\n const to = clamp(cmd.to, 0, blocks.length - 1);\n return from < 0 || from === to ? s : ({ ...s, blocks: moved(blocks, from, to) } as unknown as Section);\n });\n\nconst patchBlock: Handler<\"patchBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n const block = blocks.find((b) => b.key === cmd.blockKey);\n if (!block || saysNothingNew(block.settings ?? {}, cmd.patch)) return s;\n return { ...s, blocks: blocks.map((b) => (b === block ? { ...b, settings: { ...b.settings, ...cmd.patch } } : b)) } as unknown as Section;\n });\n\nconst handlers: { [T in Command[\"type\"]]: Handler<T> } = {\n addSection, removeSection, moveSection, setVariant, patchSettings, setText, toggleDisabled, setPreset, setDensity, applyLook: applyLookCmd, setAccent, addBlock, removeBlock, moveBlock, patchBlock,\n};\n\n/** Applies a command to a document; returns the same object when nothing changes. */\nexport function applyCommand(page: ShopPage, cmd: Command): ShopPage {\n return (handlers[cmd.type] as (page: ShopPage, cmd: Command) => ShopPage)(page, cmd);\n}\n"
229
+ "content": "// The composer's commands (ADR-007 §5): every change of the document is a pure command on a reducer — never a mutation —\n// so undo / redo restore the exact document, and the rules of the document (a hero first, 16 sections, 24 blocks, the variants\n// of a type) hold after every step. A command that would break a rule is a no-op: the page stays valid, always.\nimport { SECTION_DEFINITIONS, sectionDefinition,type SectionType } from \"../shop/catalogue\";\nimport { SHOP_LIMITS } from \"../shop/limits\";\nimport { applyLook, type ShopLookLike } from \"../shop/look/apply-look\";\nimport type { Section, ShopPage } from \"../shop/schema\";\nimport type { LocalizedText } from \"../shop/text\";\n\ntype Rec = Record<string, unknown>;\n\nexport type Command =\n /** Adds a section (its type's default settings, the given or the default variant) at an index; a hero goes first. */\n | { type: \"addSection\"; sectionType: SectionType; key: string; variant?: string; at?: number; settings?: Rec }\n | { type: \"removeSection\"; key: string }\n /** Moves a section to an absolute index (the hero stays first: nothing goes above it). */\n | { type: \"moveSection\"; key: string; to: number }\n | { type: \"setVariant\"; key: string; variant: string }\n /** Merges into the settings. */\n | { type: \"patchSettings\"; key: string; patch: Rec }\n | { type: \"setText\"; key: string; field: \"title\" | \"lead\"; value: LocalizedText | undefined }\n | { type: \"toggleDisabled\"; key: string }\n | { type: \"setPreset\"; preset: { id: string; version: number }; density?: \"compact\" | \"airy\" | null }\n | { type: \"setDensity\"; density: \"compact\" | \"airy\" | undefined }\n /** A whole look (`look-*`): the variants of the sections, nothing of their content (`applyLook`). */\n | { type: \"applyLook\"; look: ShopLookLike }\n /** The accent within the look's tested list. */\n | { type: \"setAccent\"; accent: string | undefined }\n | { type: \"addBlock\"; key: string; blockKey: string; blockType: string; settings?: Rec; at?: number }\n | { type: \"removeBlock\"; key: string; blockKey: string }\n | { type: \"moveBlock\"; key: string; blockKey: string; to: number }\n | { type: \"patchBlock\"; key: string; blockKey: string; patch: Rec };\n\nconst clamp = (n: number, lo: number, hi: number) => Math.min(Math.max(n, lo), hi);\nconst indexOfKey = (page: ShopPage, key: string) => page.sections.findIndex((s) => s.key === key);\n\n/** The array with an item moved to an index. */\nexport function moved<T>(list: readonly T[], from: number, to: number): T[] {\n const next = [...list];\n const [item] = next.splice(from, 1);\n next.splice(clamp(to, 0, next.length), 0, item as T);\n return next;\n}\n\nfunction withSection(page: ShopPage, key: string, change: (s: Section) => Section): ShopPage {\n const i = indexOfKey(page, key);\n if (i < 0) return page;\n const next = change(page.sections[i]!);\n if (next === page.sections[i]) return page;\n const sections = [...page.sections];\n sections[i] = next;\n return { ...page, sections };\n}\n\ntype Handler<T extends Command[\"type\"]> = (page: ShopPage, cmd: Extract<Command, { type: T }>) => ShopPage;\n\nconst addSection: Handler<\"addSection\"> = (page, cmd) => {\n const def = SECTION_DEFINITIONS.find((d) => d.type === cmd.sectionType);\n if (!def || page.sections.length >= SHOP_LIMITS.sections || page.sections.some((s) => s.key === cmd.key)) return page;\n const variant = cmd.variant ?? def.defaultVariant;\n if (!(def.variants as readonly string[]).includes(variant)) return page;\n const isHero = def.type === \"hero\";\n if (isHero && page.sections.some((s) => s.type === \"hero\")) return page;\n const heroFirst = page.sections[0]?.type === \"hero\";\n const minAt = heroFirst ? 1 : 0;\n const at = isHero ? 0 : clamp(cmd.at ?? page.sections.length, minAt, page.sections.length);\n const section = { key: cmd.key, type: def.type, variant, settings: { ...(def.settingsDefault as Rec), ...cmd.settings } } as unknown as Section;\n const sections = [...page.sections];\n sections.splice(at, 0, section);\n return { ...page, sections };\n};\n\nconst removeSection: Handler<\"removeSection\"> = (page, cmd) => {\n if (indexOfKey(page, cmd.key) < 0 || page.sections.length <= 1) return page;\n return { ...page, sections: page.sections.filter((s) => s.key !== cmd.key) };\n};\n\nconst moveSection: Handler<\"moveSection\"> = (page, cmd) => {\n const from = indexOfKey(page, cmd.key);\n if (from < 0 || page.sections[from]!.type === \"hero\") return page;\n const lo = page.sections[0]?.type === \"hero\" ? 1 : 0;\n const to = clamp(cmd.to, lo, page.sections.length - 1);\n return to === from ? page : { ...page, sections: moved(page.sections, from, to) };\n};\n\nconst setVariant: Handler<\"setVariant\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const def = sectionDefinition(s.type);\n if (s.variant === cmd.variant || !(def.variants as readonly string[]).includes(cmd.variant)) return s;\n return { ...s, variant: cmd.variant } as Section;\n });\n\n/** Whether every value of a patch is already the one the object holds. */\nconst saysNothingNew = (current: Rec, patch: Rec) => Object.entries(patch).every(([k, v]) => JSON.stringify(current[k]) === JSON.stringify(v));\n\nconst patchSettings: Handler<\"patchSettings\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const current = s.settings as Rec;\n // Nothing to say when every value is already the document's (a form that reports its first values after an undo).\n return saysNothingNew(current, cmd.patch) ? s : ({ ...s, settings: { ...current, ...cmd.patch } } as Section);\n });\n\nconst setText: Handler<\"setText\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const text = { ...(s.text ?? {}) } as Rec;\n if (cmd.value === undefined) delete text[cmd.field];\n else text[cmd.field] = cmd.value;\n const next = { ...s } as Rec;\n if (Object.keys(text).length === 0) delete next.text;\n else next.text = text;\n return next as unknown as Section;\n });\n\nconst toggleDisabled: Handler<\"toggleDisabled\"> = (page, cmd) => withSection(page, cmd.key, (s) => ({ ...s, disabled: s.disabled ? undefined : true }) as Section);\n\nconst setPreset: Handler<\"setPreset\"> = (page, cmd) => {\n if (page.preset.id === cmd.preset.id && page.preset.version === cmd.preset.version && cmd.density === undefined) return page;\n let density: Partial<Pick<ShopPage, \"density\">> = {};\n if (cmd.density === null) density = { density: undefined };\n else if (cmd.density) density = { density: cmd.density };\n return { ...page, preset: { ...cmd.preset }, ...density };\n};\n\nconst setDensity: Handler<\"setDensity\"> = (page, cmd) => (page.density === cmd.density ? page : { ...page, density: cmd.density });\n\nconst applyLookCmd: Handler<\"applyLook\"> = (page, cmd) => applyLook(page, cmd.look);\n\nconst setAccent: Handler<\"setAccent\"> = (page, cmd) => (page.accent === cmd.accent ? page : { ...page, accent: cmd.accent });\n\ntype Keyed = { key: string; type?: string; settings?: Rec };\n\nconst addBlock: Handler<\"addBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const def = sectionDefinition(s.type);\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n if (!(def.blockTypes as readonly string[]).includes(cmd.blockType) || blocks.length >= SHOP_LIMITS.blocks || blocks.some((b) => b.key === cmd.blockKey)) return s;\n const next = [...blocks];\n next.splice(clamp(cmd.at ?? blocks.length, 0, blocks.length), 0, { key: cmd.blockKey, type: cmd.blockType, settings: { ...cmd.settings } });\n return { ...s, blocks: next } as unknown as Section;\n });\n\nconst removeBlock: Handler<\"removeBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n if (!blocks.some((b) => b.key === cmd.blockKey)) return s;\n const next = blocks.filter((b) => b.key !== cmd.blockKey);\n return { ...s, blocks: next.length > 0 ? next : undefined } as unknown as Section;\n });\n\nconst moveBlock: Handler<\"moveBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n const from = blocks.findIndex((b) => b.key === cmd.blockKey);\n const to = clamp(cmd.to, 0, blocks.length - 1);\n return from < 0 || from === to ? s : ({ ...s, blocks: moved(blocks, from, to) } as unknown as Section);\n });\n\nconst patchBlock: Handler<\"patchBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n const block = blocks.find((b) => b.key === cmd.blockKey);\n if (!block || saysNothingNew(block.settings ?? {}, cmd.patch)) return s;\n return { ...s, blocks: blocks.map((b) => (b === block ? { ...b, settings: { ...b.settings, ...cmd.patch } } : b)) } as unknown as Section;\n });\n\nconst handlers: { [T in Command[\"type\"]]: Handler<T> } = {\n addSection, removeSection, moveSection, setVariant, patchSettings, setText, toggleDisabled, setPreset, setDensity, applyLook: applyLookCmd, setAccent, addBlock, removeBlock, moveBlock, patchBlock,\n};\n\n/** Applies a command to a document; returns the same object when nothing changes. */\nexport function applyCommand(page: ShopPage, cmd: Command): ShopPage {\n return (handlers[cmd.type] as (page: ShopPage, cmd: Command) => ShopPage)(page, cmd);\n}\n"
230
230
  },
231
231
  {
232
232
  "path": "shop-composer/composer.tsx",
233
- "content": "\"use client\";\n\n// Our own shop composer (ADR-007 §5): three panes on a laptop — the outline of the sections, the live preview of the product's own\n// public page, the inspector of the selected section — and two steps on a phone (the list, then the section; the preview behind a\n// « View » button). Every change is a command on a reducer (⌘Z / ⇧⌘Z, 100 steps), saved to the draft after 800 ms of calm; « Publish »\n// shows what changes and refuses while a setting is invalid. Every action has a keyboard path. No third-party editor: Puck was weighed\n// and not adopted (the model is a list, not a canvas).\nimport { Button } from \"@krizaka/ui/button\";\nimport { Dialog } from \"@krizaka/ui/dialog\";\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { SECTION_DEFINITIONS, type SectionType } from \"../shop/catalogue\";\nimport { postToPreview } from \"../shop/preview\";\nimport { parseShopPage, type ShopPage } from \"../shop/schema\";\nimport { type Command } from \"./commands\";\nimport { type DiffEntry, diffPages } from \"./diff\";\nimport { canRedo, canUndo, createHistory, type History, redo, run, undo } from \"./history\";\nimport { Inspector } from \"./inspector\";\nimport { newKey } from \"./keys\";\nimport { LookPicker } from \"./look-picker\";\nimport { defaultShopComposerMessages, fill, type ShopComposerMessages } from \"./messages\";\nimport { Outline, sectionLabel } from \"./outline\";\n\n/** How long the draft waits for calm before it is saved. */\n// @fixed: ADR-007 §5 — the autosave debounce of the editor, 800 ms; not a shop setting.\nexport const AUTOSAVE_MS = 800;\n\nexport type ShopComposerPreset = {\n id: string;\n version: number;\n name: string;\n density: \"compact\" | \"airy\";\n variants: Readonly<Record<string, string>>;\n /** A look's (`look-*`): the accent it starts with and the tested list the owner chooses from. Presets without a list are trade presets (the « Style » select). */\n accent?: string;\n accents?: readonly string[];\n};\n\nexport type ShopComposerProps = {\n /** The draft to edit. The composer keeps its own history from it. */\n value: ShopPage;\n /** Change it to load another document (another draft): the history and the selection start again. */\n resetKey?: string | number;\n /** Called with a valid draft after 800 ms without a change: save it. A rejection says « Not saved ». */\n onChange?: (page: ShopPage) => void | Promise<void>;\n /** Called with the draft once the person confirmed the diff. */\n onPublish: (page: ShopPage) => void | Promise<void>;\n /** The discard of the draft (the product asks first, in its own dialog). Absent: no such button. */\n onDiscard?: () => void;\n /** What is live now, for the diff of « Publish ». Absent: the document the composer was opened with. */\n published?: ShopPage;\n /** The page of the product, in an iframe: its own route with `?draft=<id>`. Its origin is the bridge's. */\n previewUrl: string;\n /** The look presets of the shop's trade. */\n presets: readonly ShopComposerPreset[];\n /** The section types the trade does not use: folded under « … » in the catalogue. */\n foldedTypes?: readonly SectionType[];\n /** The words, translated. Default: English. */\n messages?: ShopComposerMessages;\n /** Classes merged on the root (its height: `h-[100dvh]`). */\n className?: string;\n};\n\ntype State = { history: History; epoch: number };\ntype Action = { type: \"run\"; cmd: Command; merge?: string } | { type: \"undo\" } | { type: \"redo\" } | { type: \"reset\"; page: ShopPage };\n\nfunction reducer(state: State, a: Action): State {\n switch (a.type) {\n case \"run\": {\n const history = run(state.history, a.cmd, a.merge);\n return history === state.history ? state : { ...state, history };\n }\n case \"undo\": {\n const history = undo(state.history);\n return history === state.history ? state : { history, epoch: state.epoch + 1 };\n }\n case \"redo\": {\n const history = redo(state.history);\n return history === state.history ? state : { history, epoch: state.epoch + 1 };\n }\n case \"reset\":\n return { history: createHistory(a.page), epoch: state.epoch + 1 };\n }\n}\n\nfunction PreviewFrame({ src, title, phone, frame }: { src: string; title: string; phone: boolean; frame: React.Ref<HTMLIFrameElement> }) {\n return (\n <div className=\"flex h-full min-h-0 justify-center overflow-auto bg-surface-2 p-3\">\n <iframe ref={frame} src={src || undefined} title={title} data-device={phone ? \"phone\" : \"desktop\"} className={phone ? \"h-full min-h-[34rem] w-[390px] max-w-full rounded-xl border border-border-default bg-surface-0\" : \"h-full min-h-[34rem] w-full rounded-xl border border-border-default bg-surface-0\"} />\n </div>\n );\n}\n\n/** The shop composer. */\nexport function ShopComposer({ value, resetKey, onChange, onPublish, onDiscard, published, previewUrl, presets, foldedTypes = [], messages = defaultShopComposerMessages, className }: ShopComposerProps) {\n const m = messages;\n const [{ history, epoch }, dispatch] = React.useReducer(reducer, value, (v): State => ({ history: createHistory(v), epoch: 0 }));\n const page = history.present;\n const [baseline, setBaseline] = React.useState(published ?? value);\n const [selected, setSelected] = React.useState<string | null>(page.sections[0]?.key ?? null);\n const [step, setStep] = React.useState<\"list\" | \"section\">(\"list\");\n const [live, setLive] = React.useState(\"\");\n const [status, setStatus] = React.useState<\"idle\" | \"saving\" | \"saved\" | \"error\">(\"idle\");\n const [adding, setAdding] = React.useState(false);\n const [publishing, setPublishing] = React.useState(false);\n const [device, setDevice] = React.useState<\"phone\" | \"desktop\">(\"desktop\");\n const [previewOpen, setPreviewOpen] = React.useState(false);\n const [invalid, setInvalid] = React.useState<ReadonlySet<string>>(new Set());\n const [focusRequest, setFocusRequest] = React.useState<{ key: string } | null>(null);\n const frame = React.useRef<HTMLIFrameElement | null>(null);\n const origin = React.useMemo(() => {\n try {\n return new URL(previewUrl, typeof location === \"undefined\" ? undefined : location.href).origin;\n } catch {\n return \"\";\n }\n }, [previewUrl]);\n\n // A `data:` or `about:` preview has an opaque origin (« null »): nothing can be addressed to it.\n const hasOrigin = origin !== \"\" && origin !== \"null\";\n\n // A new document from outside (another draft): history and selection start again.\n const first = React.useRef(true);\n const saved = React.useRef(page);\n React.useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n saved.current = value;\n dispatch({ type: \"reset\", page: value });\n setInvalid(new Set());\n setBaseline(published ?? value);\n setSelected(value.sections[0]?.key ?? null);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only a new `resetKey` reloads the document\n }, [resetKey]);\n\n const parsed = React.useMemo(() => parseShopPage(page), [page]);\n const looks = React.useMemo(() => presets.filter((p) => p.id.startsWith(\"look-\")), [presets]);\n const styles = React.useMemo(() => presets.filter((p) => !p.id.startsWith(\"look-\")), [presets]);\n const announce = React.useCallback((message: string) => setLive((prev) => (prev === message ? message + String.fromCodePoint(0x200b) : message)), []);\n const exec = React.useCallback((cmd: Command, merge?: string) => dispatch({ type: \"run\", cmd, merge }), []);\n const selectedSection = page.sections.find((s) => s.key === selected) ?? null;\n const selectedIndex = selectedSection ? page.sections.indexOf(selectedSection) : -1;\n\n // Autosave to the draft: a valid document, after a calm of 800 ms; the preview refreshes once it is saved.\n React.useEffect(() => {\n if (page === saved.current || !parsed.ok || !onChange) return;\n const timer = setTimeout(async () => {\n setStatus(\"saving\");\n try {\n await onChange(page);\n saved.current = page;\n setStatus(\"saved\");\n if (hasOrigin) postToPreview(frame.current?.contentWindow, origin, { source: \"krizaka-shop-composer\", type: \"refresh\" });\n } catch {\n setStatus(\"error\");\n }\n }, AUTOSAVE_MS);\n return () => clearTimeout(timer);\n }, [page, parsed.ok, onChange, origin, hasOrigin]);\n\n // The preview follows the selection: outline and scroll.\n React.useEffect(() => {\n if (selected && hasOrigin) postToPreview(frame.current?.contentWindow, origin, { source: \"krizaka-shop-composer\", type: \"scroll\", key: selected });\n }, [selected, origin, hasOrigin]);\n\n const select = (key: string) => {\n setSelected(key);\n setStep(\"section\");\n };\n\n const addSection = (type: SectionType) => {\n const def = SECTION_DEFINITIONS.find((d) => d.type === type)!;\n const preferred = presets.find((p) => p.id === page.preset.id)?.variants[type];\n const variant = preferred && (def.variants as readonly string[]).includes(preferred) ? preferred : undefined;\n const key = newKey(\"s\");\n const at = type === \"hero\" ? 0 : page.sections.length;\n exec({ type: \"addSection\", sectionType: type, key, variant, at });\n setAdding(false);\n setSelected(key);\n setFocusRequest({ key });\n announce(fill(m.announceAdded, { name: m.sectionNames[type], n: at + 1 }));\n };\n\n // Undo and redo hand the form a document it did not write: what it said was invalid is no longer true.\n const step_ = (direction: \"undo\" | \"redo\") => {\n dispatch({ type: direction });\n setInvalid(new Set());\n announce(direction === \"undo\" ? m.announceUndone : m.announceRedone);\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (!(e.metaKey || e.ctrlKey) || e.key.toLowerCase() !== \"z\") return;\n const el = e.target as HTMLElement;\n if (el.closest(\"input, textarea, select, [contenteditable=true]\")) return;\n e.preventDefault();\n step_(e.shiftKey ? \"redo\" : \"undo\");\n };\n\n const changes: DiffEntry[] = publishing ? diffPages(baseline, page) : [];\n const nameOfKey = (key: string) => {\n const i = page.sections.findIndex((s) => s.key === key);\n if (i >= 0) return sectionLabel(page.sections, i, m);\n const was = baseline.sections.findIndex((s) => s.key === key);\n return was >= 0 ? sectionLabel(baseline.sections, was, m) : key;\n };\n const problems = [\n ...[...invalid].filter((key) => page.sections.some((s) => s.key === key)).map((key) => ({ key, text: fill(m.problemIn, { name: nameOfKey(key) }) })),\n ...(!parsed.ok ? parsed.issues.map((i) => ({ key: i.path, text: `${i.path}: ${i.message}` })) : []),\n ];\n const describe = (d: DiffEntry): string => {\n const name = \"key\" in d ? nameOfKey(d.key) : \"\";\n const t = m.diff[d.kind];\n switch (d.kind) {\n case \"moved\": return fill(t, { name, from: d.from + 1, to: d.to + 1 });\n case \"variant\": return fill(t, { name, from: m.variantNames[`${d.type}.${d.from}`] ?? d.from, to: m.variantNames[`${d.type}.${d.to}`] ?? d.to });\n case \"preset\": return fill(t, { from: presets.find((p) => p.id === d.from)?.name ?? d.from, to: presets.find((p) => p.id === d.to)?.name ?? d.to });\n case \"density\": return fill(t, { from: d.from ?? \"—\", to: d.to ?? \"—\" });\n default: return fill(t, { name });\n }\n };\n\n const status_ = status === \"saving\" ? m.saving : status === \"saved\" ? m.saved : status === \"error\" ? m.saveFailed : \"\";\n\n return (\n <div className={cn(\"kz-composer flex min-h-0 flex-col gap-3\", className)} onKeyDown={onKeyDown} data-step={step}>\n <header className=\"flex flex-wrap items-center gap-2 border-b border-border-subtle pb-2\">\n <h2 className=\"m-0 me-auto text-base font-semibold text-fg\">{m.title}</h2>\n <span role=\"status\" aria-live=\"polite\" className=\"text-xs text-fg-secondary\">{status_}</span>\n <Button variant=\"ghost\" size=\"sm\" disabled={!canUndo(history)} onClick={() => step_(\"undo\")} aria-keyshortcuts=\"Control+Z Meta+Z\">{m.undo}</Button>\n <Button variant=\"ghost\" size=\"sm\" disabled={!canRedo(history)} onClick={() => step_(\"redo\")} aria-keyshortcuts=\"Control+Shift+Z Meta+Shift+Z\">{m.redo}</Button>\n {onDiscard && <Button variant=\"ghost\" size=\"sm\" onClick={onDiscard}>{m.discard}</Button>}\n <Button variant=\"secondary\" size=\"sm\" className=\"lg:hidden\" onClick={() => setPreviewOpen(true)}>{m.viewPreview}</Button>\n <Button variant=\"primary\" size=\"sm\" onClick={() => setPublishing(true)}>{m.publish}</Button>\n </header>\n {/* One polite live region says every move, add, remove, undo. */}\n <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">{live}</p>\n\n <div className=\"grid min-h-0 flex-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)_24rem]\">\n <aside aria-label={m.sections} className={cn(\"flex min-h-0 flex-col gap-4 overflow-y-auto\", step === \"section\" && \"hidden lg:flex\")}>\n <Outline sections={page.sections} selected={selected} onSelect={select} run={exec} messages={m} announce={announce} onAdd={() => setAdding(true)} focusRequest={focusRequest} />\n <details className=\"rounded-lg border border-border-default p-3\" open>\n <summary className=\"min-h-9 cursor-pointer text-sm font-semibold text-fg\">{m.look}</summary>\n <div className=\"mt-2 grid gap-3\">\n {looks.length > 0 && <LookPicker looks={looks} page={page} messages={m} run={exec} announce={announce} />}\n {styles.length > 0 && <label className=\"grid gap-1 text-xs font-semibold text-fg-secondary\">\n {m.preset}\n <select\n className=\"min-h-10 rounded-md border border-border-control bg-surface-1 px-2 text-sm font-normal text-fg\"\n value={page.preset.id}\n onChange={(e) => {\n const p = presets.find((x) => x.id === e.target.value);\n if (p) exec({ type: \"setPreset\", preset: { id: p.id, version: p.version }, density: null });\n }}\n >\n {styles.map((p) => <option key={p.id} value={p.id}>{p.name}</option>)}\n </select>\n </label>}\n <RadioGroup.Root label={m.density} variant=\"segmented\" value={page.density ?? presets.find((p) => p.id === page.preset.id)?.density ?? \"compact\"} onValueChange={(d) => exec({ type: \"setDensity\", density: d as \"compact\" | \"airy\" })}>\n <RadioGroup.Segment value=\"compact\">{m.densityCompact}</RadioGroup.Segment>\n <RadioGroup.Segment value=\"airy\">{m.densityAiry}</RadioGroup.Segment>\n </RadioGroup.Root>\n </div>\n </details>\n </aside>\n\n <section aria-label={m.preview} className=\"hidden min-h-0 flex-col gap-2 lg:flex\">\n <RadioGroup.Root label={m.preview} variant=\"segmented\" value={device} onValueChange={(d) => setDevice(d as \"phone\" | \"desktop\")} className=\"self-start\">\n <RadioGroup.Segment value=\"desktop\">{m.desktop}</RadioGroup.Segment>\n <RadioGroup.Segment value=\"phone\">{m.phone}</RadioGroup.Segment>\n </RadioGroup.Root>\n <PreviewFrame src={previewUrl} title={m.previewTitle} phone={device === \"phone\"} frame={frame} />\n </section>\n\n <aside aria-label={m.inspector} className={cn(\"flex min-h-0 flex-col gap-4 overflow-y-auto\", step === \"list\" && \"hidden lg:flex\")}>\n <Button variant=\"ghost\" size=\"sm\" className=\"self-start lg:hidden\" onClick={() => setStep(\"list\")}>← {m.backToSections}</Button>\n {selectedSection ? (\n <Inspector\n section={selectedSection}\n name={sectionLabel(page.sections, selectedIndex, m)}\n messages={m}\n run={exec}\n epoch={epoch}\n announce={announce}\n onInvalid={(key, bad) => setInvalid((prev) => { const next = new Set(prev); if (bad) next.add(key); else next.delete(key); return next.size === prev.size && next.has(key) === prev.has(key) ? prev : next; })}\n preset={page.preset.id}\n density={page.density}\n />\n ) : (\n <p className=\"m-0 text-sm text-fg-secondary\">{m.noSelection}</p>\n )}\n </aside>\n </div>\n\n <Dialog.Root open={adding} onOpenChange={setAdding}>\n <Dialog.Content closeLabel={m.cancel}>\n <Dialog.Header>\n <Dialog.Title>{m.addSection}</Dialog.Title>\n <Dialog.Description>{m.addSectionHint}</Dialog.Description>\n </Dialog.Header>\n <Dialog.Body>\n {[SECTION_DEFINITIONS.filter((d) => !foldedTypes.includes(d.type)), SECTION_DEFINITIONS.filter((d) => foldedTypes.includes(d.type))].map((group, g) => {\n const list = (\n <ul className=\"m-0 grid list-none gap-1 p-0\">\n {group.map((d) => (\n <li key={d.type}>\n <Button variant=\"ghost\" className=\"w-full justify-start\" disabled={d.type === \"hero\" && page.sections.some((s) => s.type === \"hero\")} onClick={() => addSection(d.type)}>\n {m.sectionNames[d.type]}\n </Button>\n </li>\n ))}\n </ul>\n );\n return group.length === 0 ? null : g === 0 ? <React.Fragment key={g}>{list}</React.Fragment> : <details key={g} className=\"mt-3\"><summary className=\"min-h-9 cursor-pointer text-sm text-fg-secondary\">…</summary>{list}</details>;\n })}\n </Dialog.Body>\n </Dialog.Content>\n </Dialog.Root>\n\n <Dialog.Root open={publishing} onOpenChange={setPublishing}>\n <Dialog.Content closeLabel={m.cancel}>\n <Dialog.Header>\n <Dialog.Title>{m.publishTitle}</Dialog.Title>\n <Dialog.Description>{m.publishWhat}</Dialog.Description>\n </Dialog.Header>\n <Dialog.Body>\n {problems.length > 0 && (\n <div role=\"alert\" className=\"mb-3 rounded-md border border-border-control bg-surface-2 p-3\">\n <p className=\"m-0 text-sm font-semibold text-fg\">{fill(m.problemsTitle, { n: problems.length })}</p>\n <ul className=\"m-0 mt-1 list-disc ps-5 text-sm text-fg-secondary\">{problems.map((p) => <li key={p.key}>{p.text}</li>)}</ul>\n </div>\n )}\n {changes.length === 0 ? (\n <p className=\"m-0 text-sm text-fg-secondary\">{m.publishNothing}</p>\n ) : (\n <ul className=\"m-0 list-disc ps-5 text-sm text-fg\">{changes.map((d, i) => <li key={i}>{describe(d)}</li>)}</ul>\n )}\n </Dialog.Body>\n <Dialog.Footer>\n <Dialog.Close asChild><Button variant=\"ghost\">{m.cancel}</Button></Dialog.Close>\n <Button variant=\"primary\" disabled={problems.length > 0 || !parsed.ok} onClick={async () => { await onPublish(page); setBaseline(page); setPublishing(false); }}>{m.publishConfirm}</Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog.Root>\n\n <Dialog.Root open={previewOpen} onOpenChange={setPreviewOpen}>\n <Dialog.Content closeLabel={m.closePreview} size=\"lg\">\n <Dialog.Header><Dialog.Title>{m.preview}</Dialog.Title></Dialog.Header>\n <Dialog.Body className=\"p-0\">\n {previewOpen && <PreviewFrame src={previewUrl} title={m.previewTitle} phone frame={frame} />}\n </Dialog.Body>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n );\n}\n"
233
+ "content": "\"use client\";\n\n// Our own shop composer (ADR-007 §5): three panes on a laptop — the outline of the sections, the live preview of the product's own\n// public page, the inspector of the selected section — and two steps on a phone (the list, then the section; the preview behind a\n// « View » button). Every change is a command on a reducer (⌘Z / ⇧⌘Z, 100 steps), saved to the draft after 800 ms of calm; « Publish »\n// shows what changes and refuses while a setting is invalid. Every action has a keyboard path. No third-party editor: Puck was weighed\n// and not adopted (the model is a list, not a canvas).\nimport { Button } from \"@krizaka/ui/button\";\nimport { Dialog } from \"@krizaka/ui/dialog\";\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { SECTION_DEFINITIONS, type SectionType } from \"../shop/catalogue\";\nimport { postToPreview } from \"../shop/preview\";\nimport { parseShopPage, type ShopPage } from \"../shop/schema\";\nimport { type Command } from \"./commands\";\nimport { type DiffEntry, diffPages } from \"./diff\";\nimport { canRedo, canUndo, createHistory, type History, redo, run, undo } from \"./history\";\nimport { Inspector } from \"./inspector\";\nimport { newKey } from \"./keys\";\nimport { LookPicker } from \"./look-picker\";\nimport { defaultShopComposerMessages, fill, type ShopComposerMessages } from \"./messages\";\nimport { Outline, sectionLabel } from \"./outline\";\n\n/** How long the draft waits for calm before it is saved. */\n// @fixed: ADR-007 §5 — the autosave debounce of the editor, 800 ms; not a shop setting.\nexport const AUTOSAVE_MS = 800;\n\nexport type ShopComposerPreset = {\n id: string;\n version: number;\n name: string;\n density: \"compact\" | \"airy\";\n variants: Readonly<Record<string, string>>;\n /** A look's (`look-*`): the accent it starts with and the tested list the owner chooses from. Presets without a list are trade presets (the « Style » select). */\n accent?: string;\n accents?: readonly string[];\n};\n\nexport type ShopComposerProps = {\n /** The draft to edit. The composer keeps its own history from it. */\n value: ShopPage;\n /** Change it to load another document (another draft): the history and the selection start again. */\n resetKey?: string | number;\n /** Called with a valid draft after 800 ms without a change: save it. A rejection says « Not saved ». */\n onChange?: (page: ShopPage) => void | Promise<void>;\n /** Called with the draft once the person confirmed the diff. */\n onPublish: (page: ShopPage) => void | Promise<void>;\n /** The discard of the draft (the product asks first, in its own dialog). Absent: no such button. */\n onDiscard?: () => void;\n /** What is live now, for the diff of « Publish ». Absent: the document the composer was opened with. */\n published?: ShopPage;\n /** The page of the product, in an iframe: its own route with `?draft=<id>`. Its origin is the bridge's. */\n previewUrl: string;\n /** The look presets of the shop's trade. */\n presets: readonly ShopComposerPreset[];\n /** The section types the trade does not use: folded under « … » in the catalogue. */\n foldedTypes?: readonly SectionType[];\n /** The words, translated. Default: English. */\n messages?: ShopComposerMessages;\n /** Classes merged on the root (its height: `h-[100dvh]`). */\n className?: string;\n};\n\ntype State = { history: History; epoch: number };\ntype Action = { type: \"run\"; cmd: Command; merge?: string } | { type: \"undo\" } | { type: \"redo\" } | { type: \"reset\"; page: ShopPage };\n\nfunction reducer(state: State, a: Action): State {\n switch (a.type) {\n case \"run\": {\n const history = run(state.history, a.cmd, a.merge);\n return history === state.history ? state : { ...state, history };\n }\n case \"undo\": {\n const history = undo(state.history);\n return history === state.history ? state : { history, epoch: state.epoch + 1 };\n }\n case \"redo\": {\n const history = redo(state.history);\n return history === state.history ? state : { history, epoch: state.epoch + 1 };\n }\n case \"reset\":\n return { history: createHistory(a.page), epoch: state.epoch + 1 };\n }\n}\n\nfunction PreviewFrame({ src, title, phone, frame }: Readonly<{ src: string; title: string; phone: boolean; frame: React.Ref<HTMLIFrameElement> }>) {\n return (\n <div className=\"flex h-full min-h-0 justify-center overflow-auto bg-surface-2 p-3\">\n <iframe ref={frame} src={src || undefined} title={title} data-device={phone ? \"phone\" : \"desktop\"} className={phone ? \"h-full min-h-[34rem] w-[390px] max-w-full rounded-xl border border-border-default bg-surface-0\" : \"h-full min-h-[34rem] w-full rounded-xl border border-border-default bg-surface-0\"} />\n </div>\n );\n}\n\n/** The shop composer. */\nexport function ShopComposer({ value, resetKey, onChange, onPublish, onDiscard, published, previewUrl, presets, foldedTypes = [], messages = defaultShopComposerMessages, className }: Readonly<ShopComposerProps>) {\n const m = messages;\n const [{ history, epoch }, dispatch] = React.useReducer(reducer, value, (v): State => ({ history: createHistory(v), epoch: 0 }));\n const page = history.present;\n const [baseline, setBaseline] = React.useState(published ?? value);\n const [selected, setSelected] = React.useState<string | null>(page.sections[0]?.key ?? null);\n const [step, setStep] = React.useState<\"list\" | \"section\">(\"list\");\n const [live, setLive] = React.useState(\"\");\n const [status, setStatus] = React.useState<\"idle\" | \"saving\" | \"saved\" | \"error\">(\"idle\");\n const [adding, setAdding] = React.useState(false);\n const [publishing, setPublishing] = React.useState(false);\n const [device, setDevice] = React.useState<\"phone\" | \"desktop\">(\"desktop\");\n const [previewOpen, setPreviewOpen] = React.useState(false);\n const [invalid, setInvalid] = React.useState<ReadonlySet<string>>(new Set());\n const [focusRequest, setFocusRequest] = React.useState<{ key: string } | null>(null);\n const frame = React.useRef<HTMLIFrameElement | null>(null);\n const origin = React.useMemo(() => {\n try {\n return new URL(previewUrl, typeof location === \"undefined\" ? undefined : location.href).origin;\n } catch {\n return \"\";\n }\n }, [previewUrl]);\n\n // A `data:` or `about:` preview has an opaque origin (« null »): nothing can be addressed to it.\n const hasOrigin = origin !== \"\" && origin !== \"null\";\n\n // A new document from outside (another draft): history and selection start again.\n const first = React.useRef(true);\n const saved = React.useRef(page);\n React.useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n saved.current = value;\n dispatch({ type: \"reset\", page: value });\n setInvalid(new Set());\n setBaseline(published ?? value);\n setSelected(value.sections[0]?.key ?? null);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only a new `resetKey` reloads the document\n }, [resetKey]);\n\n const parsed = React.useMemo(() => parseShopPage(page), [page]);\n const looks = React.useMemo(() => presets.filter((p) => p.id.startsWith(\"look-\")), [presets]);\n const styles = React.useMemo(() => presets.filter((p) => !p.id.startsWith(\"look-\")), [presets]);\n const announce = React.useCallback((message: string) => setLive((prev) => (prev === message ? message + String.fromCodePoint(0x200b) : message)), []);\n const exec = React.useCallback((cmd: Command, merge?: string) => dispatch({ type: \"run\", cmd, merge }), []);\n const selectedSection = page.sections.find((s) => s.key === selected) ?? null;\n const selectedIndex = selectedSection ? page.sections.indexOf(selectedSection) : -1;\n\n // Autosave to the draft: a valid document, after a calm of 800 ms; the preview refreshes once it is saved.\n React.useEffect(() => {\n if (page === saved.current || !parsed.ok || !onChange) return;\n const timer = setTimeout(async () => {\n setStatus(\"saving\");\n try {\n await onChange(page);\n saved.current = page;\n setStatus(\"saved\");\n if (hasOrigin) postToPreview(frame.current?.contentWindow, origin, { source: \"krizaka-shop-composer\", type: \"refresh\" });\n } catch {\n setStatus(\"error\");\n }\n }, AUTOSAVE_MS);\n return () => clearTimeout(timer);\n }, [page, parsed.ok, onChange, origin, hasOrigin]);\n\n // The preview follows the selection: outline and scroll.\n React.useEffect(() => {\n if (selected && hasOrigin) postToPreview(frame.current?.contentWindow, origin, { source: \"krizaka-shop-composer\", type: \"scroll\", key: selected });\n }, [selected, origin, hasOrigin]);\n\n const select = (key: string) => {\n setSelected(key);\n setStep(\"section\");\n };\n\n const addSection = (type: SectionType) => {\n const def = SECTION_DEFINITIONS.find((d) => d.type === type)!;\n const preferred = presets.find((p) => p.id === page.preset.id)?.variants[type];\n const variant = preferred && (def.variants as readonly string[]).includes(preferred) ? preferred : undefined;\n const key = newKey(\"s\");\n const at = type === \"hero\" ? 0 : page.sections.length;\n exec({ type: \"addSection\", sectionType: type, key, variant, at });\n setAdding(false);\n setSelected(key);\n setFocusRequest({ key });\n announce(fill(m.announceAdded, { name: m.sectionNames[type], n: at + 1 }));\n };\n\n // Undo and redo hand the form a document it did not write: what it said was invalid is no longer true.\n const step_ = (direction: \"undo\" | \"redo\") => {\n dispatch({ type: direction });\n setInvalid(new Set());\n announce(direction === \"undo\" ? m.announceUndone : m.announceRedone);\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (!(e.metaKey || e.ctrlKey) || e.key.toLowerCase() !== \"z\") return;\n const el = e.target as HTMLElement;\n if (el.closest(\"input, textarea, select, [contenteditable=true]\")) return;\n e.preventDefault();\n step_(e.shiftKey ? \"redo\" : \"undo\");\n };\n\n const changes: DiffEntry[] = publishing ? diffPages(baseline, page) : [];\n const nameOfKey = (key: string) => {\n const i = page.sections.findIndex((s) => s.key === key);\n if (i >= 0) return sectionLabel(page.sections, i, m);\n const was = baseline.sections.findIndex((s) => s.key === key);\n return was >= 0 ? sectionLabel(baseline.sections, was, m) : key;\n };\n const problems = [\n ...[...invalid].filter((key) => page.sections.some((s) => s.key === key)).map((key) => ({ key, text: fill(m.problemIn, { name: nameOfKey(key) }) })),\n ...(!parsed.ok ? parsed.issues.map((i) => ({ key: i.path, text: `${i.path}: ${i.message}` })) : []),\n ];\n const describe = (d: DiffEntry): string => {\n const name = \"key\" in d ? nameOfKey(d.key) : \"\";\n const t = m.diff[d.kind];\n switch (d.kind) {\n case \"moved\": return fill(t, { name, from: d.from + 1, to: d.to + 1 });\n case \"variant\": return fill(t, { name, from: m.variantNames[`${d.type}.${d.from}`] ?? d.from, to: m.variantNames[`${d.type}.${d.to}`] ?? d.to });\n case \"preset\": return fill(t, { from: presets.find((p) => p.id === d.from)?.name ?? d.from, to: presets.find((p) => p.id === d.to)?.name ?? d.to });\n case \"density\": return fill(t, { from: d.from ?? \"—\", to: d.to ?? \"—\" });\n default: return fill(t, { name });\n }\n };\n\n let status_ = \"\";\n if (status === \"saving\") status_ = m.saving;\n else if (status === \"saved\") status_ = m.saved;\n else if (status === \"error\") status_ = m.saveFailed;\n\n return (\n <div className={cn(\"kz-composer flex min-h-0 flex-col gap-3\", className)} onKeyDown={onKeyDown} data-step={step}>\n <header className=\"flex flex-wrap items-center gap-2 border-b border-border-subtle pb-2\">\n <h2 className=\"m-0 me-auto text-base font-semibold text-fg\">{m.title}</h2>\n <span role=\"status\" aria-live=\"polite\" className=\"text-xs text-fg-secondary\">{status_}</span>\n <Button variant=\"ghost\" size=\"sm\" disabled={!canUndo(history)} onClick={() => step_(\"undo\")} aria-keyshortcuts=\"Control+Z Meta+Z\">{m.undo}</Button>\n <Button variant=\"ghost\" size=\"sm\" disabled={!canRedo(history)} onClick={() => step_(\"redo\")} aria-keyshortcuts=\"Control+Shift+Z Meta+Shift+Z\">{m.redo}</Button>\n {onDiscard && <Button variant=\"ghost\" size=\"sm\" onClick={onDiscard}>{m.discard}</Button>}\n <Button variant=\"secondary\" size=\"sm\" className=\"lg:hidden\" onClick={() => setPreviewOpen(true)}>{m.viewPreview}</Button>\n <Button variant=\"primary\" size=\"sm\" onClick={() => setPublishing(true)}>{m.publish}</Button>\n </header>\n {/* One polite live region says every move, add, remove, undo. */}\n <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">{live}</p>\n\n <div className=\"grid min-h-0 flex-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)_24rem]\">\n <aside aria-label={m.sections} className={cn(\"flex min-h-0 flex-col gap-4 overflow-y-auto\", step === \"section\" && \"hidden lg:flex\")}>\n <Outline sections={page.sections} selected={selected} onSelect={select} run={exec} messages={m} announce={announce} onAdd={() => setAdding(true)} focusRequest={focusRequest} />\n <details className=\"rounded-lg border border-border-default p-3\" open>\n <summary className=\"min-h-9 cursor-pointer text-sm font-semibold text-fg\">{m.look}</summary>\n <div className=\"mt-2 grid gap-3\">\n {looks.length > 0 && <LookPicker looks={looks} page={page} messages={m} run={exec} announce={announce} />}\n {styles.length > 0 && <label className=\"grid gap-1 text-xs font-semibold text-fg-secondary\">\n {m.preset}\n <select\n className=\"min-h-10 rounded-md border border-border-control bg-surface-1 px-2 text-sm font-normal text-fg\"\n value={page.preset.id}\n onChange={(e) => {\n const p = presets.find((x) => x.id === e.target.value);\n if (p) exec({ type: \"setPreset\", preset: { id: p.id, version: p.version }, density: null });\n }}\n >\n {styles.map((p) => <option key={p.id} value={p.id}>{p.name}</option>)}\n </select>\n </label>}\n <RadioGroup.Root label={m.density} variant=\"segmented\" value={page.density ?? presets.find((p) => p.id === page.preset.id)?.density ?? \"compact\"} onValueChange={(d) => exec({ type: \"setDensity\", density: d as \"compact\" | \"airy\" })}>\n <RadioGroup.Segment value=\"compact\">{m.densityCompact}</RadioGroup.Segment>\n <RadioGroup.Segment value=\"airy\">{m.densityAiry}</RadioGroup.Segment>\n </RadioGroup.Root>\n </div>\n </details>\n </aside>\n\n <section aria-label={m.preview} className=\"hidden min-h-0 flex-col gap-2 lg:flex\">\n <RadioGroup.Root label={m.preview} variant=\"segmented\" value={device} onValueChange={(d) => setDevice(d as \"phone\" | \"desktop\")} className=\"self-start\">\n <RadioGroup.Segment value=\"desktop\">{m.desktop}</RadioGroup.Segment>\n <RadioGroup.Segment value=\"phone\">{m.phone}</RadioGroup.Segment>\n </RadioGroup.Root>\n <PreviewFrame src={previewUrl} title={m.previewTitle} phone={device === \"phone\"} frame={frame} />\n </section>\n\n <aside aria-label={m.inspector} className={cn(\"flex min-h-0 flex-col gap-4 overflow-y-auto\", step === \"list\" && \"hidden lg:flex\")}>\n <Button variant=\"ghost\" size=\"sm\" className=\"self-start lg:hidden\" onClick={() => setStep(\"list\")}>← {m.backToSections}</Button>\n {selectedSection ? (\n <Inspector\n section={selectedSection}\n name={sectionLabel(page.sections, selectedIndex, m)}\n messages={m}\n run={exec}\n epoch={epoch}\n announce={announce}\n onInvalid={(key, bad) =>\n setInvalid((prev) => {\n const next = new Set(prev);\n if (bad) {\n next.add(key);\n } else {\n next.delete(key);\n }\n return next.size === prev.size && next.has(key) === prev.has(key) ? prev : next;\n })\n }\n preset={page.preset.id}\n density={page.density}\n />\n ) : (\n <p className=\"m-0 text-sm text-fg-secondary\">{m.noSelection}</p>\n )}\n </aside>\n </div>\n\n <Dialog.Root open={adding} onOpenChange={setAdding}>\n <Dialog.Content closeLabel={m.cancel}>\n <Dialog.Header>\n <Dialog.Title>{m.addSection}</Dialog.Title>\n <Dialog.Description>{m.addSectionHint}</Dialog.Description>\n </Dialog.Header>\n <Dialog.Body>\n {[\n { key: \"open\", group: SECTION_DEFINITIONS.filter((d) => !foldedTypes.includes(d.type)) },\n { key: \"folded\", group: SECTION_DEFINITIONS.filter((d) => foldedTypes.includes(d.type)) },\n ].map(({ key: groupKey, group }) => {\n const list = (\n <ul className=\"m-0 grid list-none gap-1 p-0\">\n {group.map((d) => (\n <li key={d.type}>\n <Button variant=\"ghost\" className=\"w-full justify-start\" disabled={d.type === \"hero\" && page.sections.some((s) => s.type === \"hero\")} onClick={() => addSection(d.type)}>\n {m.sectionNames[d.type]}\n </Button>\n </li>\n ))}\n </ul>\n );\n if (group.length === 0) return null;\n if (groupKey === \"open\") return <React.Fragment key={groupKey}>{list}</React.Fragment>;\n return <details key={groupKey} className=\"mt-3\"><summary className=\"min-h-9 cursor-pointer text-sm text-fg-secondary\">…</summary>{list}</details>;\n })}\n </Dialog.Body>\n </Dialog.Content>\n </Dialog.Root>\n\n <Dialog.Root open={publishing} onOpenChange={setPublishing}>\n <Dialog.Content closeLabel={m.cancel}>\n <Dialog.Header>\n <Dialog.Title>{m.publishTitle}</Dialog.Title>\n <Dialog.Description>{m.publishWhat}</Dialog.Description>\n </Dialog.Header>\n <Dialog.Body>\n {problems.length > 0 && (\n <div role=\"alert\" className=\"mb-3 rounded-md border border-border-control bg-surface-2 p-3\">\n <p className=\"m-0 text-sm font-semibold text-fg\">{fill(m.problemsTitle, { n: problems.length })}</p>\n <ul className=\"m-0 mt-1 list-disc ps-5 text-sm text-fg-secondary\">{problems.map((p) => <li key={p.key}>{p.text}</li>)}</ul>\n </div>\n )}\n {changes.length === 0 ? (\n <p className=\"m-0 text-sm text-fg-secondary\">{m.publishNothing}</p>\n ) : (\n <ul className=\"m-0 list-disc ps-5 text-sm text-fg\">{changes.map((d) => <li key={\"key\" in d ? `${d.kind}:${d.key}` : d.kind}>{describe(d)}</li>)}</ul>\n )}\n </Dialog.Body>\n <Dialog.Footer>\n <Dialog.Close asChild><Button variant=\"ghost\">{m.cancel}</Button></Dialog.Close>\n <Button variant=\"primary\" disabled={problems.length > 0 || !parsed.ok} onClick={async () => { await onPublish(page); setBaseline(page); setPublishing(false); }}>{m.publishConfirm}</Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog.Root>\n\n <Dialog.Root open={previewOpen} onOpenChange={setPreviewOpen}>\n <Dialog.Content closeLabel={m.closePreview} size=\"lg\">\n <Dialog.Header><Dialog.Title>{m.preview}</Dialog.Title></Dialog.Header>\n <Dialog.Body className=\"p-0\">\n {previewOpen && <PreviewFrame src={previewUrl} title={m.previewTitle} phone frame={frame} />}\n </Dialog.Body>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n );\n}\n"
234
234
  },
235
235
  {
236
236
  "path": "shop-composer/diff.ts",
@@ -250,7 +250,7 @@
250
250
  },
251
251
  {
252
252
  "path": "shop-composer/inspector.tsx",
253
- "content": "\"use client\";\n\n// The inspector (ADR-007 §5): for the selected section, the variant as a radio group of live thumbnails, the settings as a form\n// generated from the zod schema of its type, the owner's own words (title and line, in each language), and the blocks as a\n// sortable list (Move up / Move down, no drag needed). The look of the whole page is the first tab's concern: see `LookPanel`.\nimport { Button } from \"@krizaka/ui/button\";\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\nimport * as React from \"react\";\n\nimport { sectionDefinition } from \"../shop/catalogue\";\nimport type { Section } from \"../shop/schema\";\nimport type { Command } from \"./commands\";\nimport { newKey } from \"./keys\";\nimport { fill, type ShopComposerMessages } from \"./messages\";\nimport { SettingsForm } from \"./settings-form\";\nimport { SectionThumbnail } from \"./thumbnails\";\n\nexport type InspectorProps = {\n section: Section;\n name: string;\n messages: ShopComposerMessages;\n run: (cmd: Command, merge?: string) => void;\n /** Bumped when the document changes from outside the form (undo, redo): the settings form remounts. */\n epoch: number;\n announce: (message: string) => void;\n onInvalid: (key: string, invalid: boolean) => void;\n /** The page's look, so a thumbnail wears it. */\n preset?: string;\n density?: \"compact\" | \"airy\";\n};\n\nfunction Words({ section, m, run }: Pick<InspectorProps, \"section\" | \"run\"> & { m: ShopComposerMessages }) {\n const id = React.useId();\n const text = section.text ?? {};\n const field = (name: \"title\" | \"lead\", label: string) => (\n <fieldset className=\"m-0 grid gap-1.5 border-0 p-0\">\n <legend className=\"mb-1 text-xs font-semibold text-fg-secondary\">{label}</legend>\n {([\"fr\", \"en\"] as const).map((lang) => (\n <div key={lang} className=\"flex flex-col gap-1\">\n <label htmlFor={`${id}-${name}-${lang}`} className=\"text-xs text-fg-secondary\">{lang === \"fr\" ? m.french : m.english}</label>\n <input\n id={`${id}-${name}-${lang}`}\n className=\"min-h-10 rounded-md border border-border-control bg-surface-1 px-3 text-sm text-fg focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring\"\n maxLength={600}\n value={text[name]?.[lang] ?? \"\"}\n onChange={(e) => {\n const next = { ...(text[name] ?? {}), [lang]: e.target.value || undefined };\n const empty = !next.fr && !next.en;\n run({ type: \"setText\", key: section.key, field: name, value: empty ? undefined : next }, `text:${section.key}:${name}:${lang}`);\n }}\n />\n </div>\n ))}\n </fieldset>\n );\n return (\n <section aria-label={m.words} className=\"grid gap-3\">\n <h3 className=\"m-0 text-sm font-semibold text-fg\">{m.words}</h3>\n {field(\"title\", m.titleField)}\n {field(\"lead\", m.leadField)}\n </section>\n );\n}\n\nfunction Blocks({ section, m, run, announce }: Pick<InspectorProps, \"section\" | \"run\" | \"announce\"> & { m: ShopComposerMessages }) {\n const def = sectionDefinition(section.type);\n const blocks = ((section.blocks ?? []) as { key: string; type: string }[]);\n if (def.blockTypes.length === 0) return null;\n const label = (b: { type: string }, i: number) => `${m.blockNames[b.type] ?? b.type} ${i + 1}`;\n const move = (i: number, to: number) => {\n const b = blocks[i]!;\n if (to < 0 || to >= blocks.length) return;\n run({ type: \"moveBlock\", key: section.key, blockKey: b.key, to });\n announce(fill(m.announceMoved, { name: label(b, i), n: to + 1, total: blocks.length }));\n };\n return (\n <section aria-label={m.blocks} className=\"grid gap-2\">\n <h3 className=\"m-0 text-sm font-semibold text-fg\">{m.blocks}</h3>\n {blocks.length > 0 && (\n <ol className=\"m-0 grid list-none gap-1 p-0\">\n {blocks.map((b, i) => (\n <li key={b.key} className=\"flex items-center gap-1 rounded-md border border-border-default bg-surface-1 ps-3\">\n <span className=\"min-w-0 flex-1 truncate text-sm text-fg\">{label(b, i)}</span>\n <Button size=\"sm\" variant=\"ghost\" disabled={i === 0} aria-label={`${m.moveUp}: ${label(b, i)}`} onClick={() => move(i, i - 1)}>↑</Button>\n <Button size=\"sm\" variant=\"ghost\" disabled={i === blocks.length - 1} aria-label={`${m.moveDown}: ${label(b, i)}`} onClick={() => move(i, i + 1)}>↓</Button>\n <Button size=\"sm\" variant=\"ghost\" aria-label={fill(m.removeBlock, { name: label(b, i) })} onClick={() => run({ type: \"removeBlock\", key: section.key, blockKey: b.key })}>×</Button>\n </li>\n ))}\n </ol>\n )}\n <div className=\"flex flex-wrap gap-2\">\n {def.blockTypes.map((type) => (\n <Button key={type} size=\"sm\" variant=\"outline\" onClick={() => run({ type: \"addBlock\", key: section.key, blockKey: newKey(\"b\"), blockType: type, settings: defaultBlockSettings(type) })}>\n {m.addBlock} · {m.blockNames[type] ?? type}\n </Button>\n ))}\n </div>\n </section>\n );\n}\n\n/** The first settings of a new block: what its schema needs to be valid (a product then fills the references). */\nfunction defaultBlockSettings(type: string): Record<string, unknown> {\n switch (type) {\n case \"fact\": return { kind: \"open-now\" };\n case \"note\": return { text: \"…\" };\n case \"flyer\": return { text: \"…\" };\n case \"photo\": return { mediaId: \"\" };\n case \"service\": return { serviceId: \"\" };\n case \"member\": return { memberId: \"\" };\n case \"reel\": return { platform: \"tiktok\", url: \"https://\" };\n case \"link\": return { platform: \"instagram\", url: \"https://\" };\n case \"question\": return { question: {}, answer: {} };\n default: return {};\n }\n}\n\nexport function Inspector({ section, name, messages: m, run, epoch, announce, onInvalid, preset, density }: InspectorProps) {\n const def = sectionDefinition(section.type);\n const label = React.useId();\n return (\n <div className=\"flex min-w-0 flex-col gap-6\">\n <section aria-labelledby={label} className=\"grid gap-2\">\n <h3 id={label} className=\"m-0 text-sm font-semibold text-fg\">{m.variant}</h3>\n {/* The thumbnail is a section: it holds links and buttons, so it sits beside the radio, never inside it. */}\n <RadioGroup.Root label={`${name}: ${m.variant}`} value={section.variant} onValueChange={(variant) => run({ type: \"setVariant\", key: section.key, variant })} className=\"grid grid-cols-1 gap-2 sm:grid-cols-2\">\n {def.variants.map((variant) => (\n <div\n key={variant}\n role=\"presentation\"\n data-checked={section.variant === variant ? \"\" : undefined}\n onClick={() => run({ type: \"setVariant\", key: section.key, variant })}\n className=\"grid cursor-pointer gap-2 rounded-lg border border-border-default bg-surface-1 p-2 data-[checked]:border-accent data-[checked]:bg-accent-soft\"\n >\n <SectionThumbnail type={section.type} variant={variant} preset={preset} density={density} />\n <RadioGroup.Item value={variant}>{m.variantNames[`${section.type}.${variant}`] ?? variant}</RadioGroup.Item>\n </div>\n ))}\n </RadioGroup.Root>\n </section>\n <SettingsForm\n key={`${section.key}:${epoch}`}\n section={section}\n messages={m}\n onValid={(settings) => run({ type: \"patchSettings\", key: section.key, patch: settings }, `settings:${section.key}`)}\n onInvalid={(invalid) => onInvalid(section.key, invalid)}\n />\n <Blocks section={section} m={m} run={run} announce={announce} />\n <Words section={section} m={m} run={run} />\n </div>\n );\n}\n"
253
+ "content": "\"use client\";\n\n// The inspector (ADR-007 §5): for the selected section, the variant as a radio group of live thumbnails, the settings as a form\n// generated from the zod schema of its type, the owner's own words (title and line, in each language), and the blocks as a\n// sortable list (Move up / Move down, no drag needed). The look of the whole page is the first tab's concern: see `LookPanel`.\nimport { Button } from \"@krizaka/ui/button\";\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\nimport * as React from \"react\";\n\nimport { sectionDefinition } from \"../shop/catalogue\";\nimport type { Section } from \"../shop/schema\";\nimport type { Command } from \"./commands\";\nimport { newKey } from \"./keys\";\nimport { fill, type ShopComposerMessages } from \"./messages\";\nimport { SettingsForm } from \"./settings-form\";\nimport { SectionThumbnail } from \"./thumbnails\";\n\nexport type InspectorProps = {\n section: Section;\n name: string;\n messages: ShopComposerMessages;\n run: (cmd: Command, merge?: string) => void;\n /** Bumped when the document changes from outside the form (undo, redo): the settings form remounts. */\n epoch: number;\n announce: (message: string) => void;\n onInvalid: (key: string, invalid: boolean) => void;\n /** The page's look, so a thumbnail wears it. */\n preset?: string;\n density?: \"compact\" | \"airy\";\n};\n\nfunction Words({ section, m, run }: Pick<InspectorProps, \"section\" | \"run\"> & { m: ShopComposerMessages }) {\n const id = React.useId();\n const text = section.text ?? {};\n const field = (name: \"title\" | \"lead\", label: string) => (\n <fieldset className=\"m-0 grid gap-1.5 border-0 p-0\">\n <legend className=\"mb-1 text-xs font-semibold text-fg-secondary\">{label}</legend>\n {([\"fr\", \"en\"] as const).map((lang) => (\n <div key={lang} className=\"flex flex-col gap-1\">\n <label htmlFor={`${id}-${name}-${lang}`} className=\"text-xs text-fg-secondary\">{lang === \"fr\" ? m.french : m.english}</label>\n <input\n id={`${id}-${name}-${lang}`}\n className=\"min-h-10 rounded-md border border-border-control bg-surface-1 px-3 text-sm text-fg focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring\"\n maxLength={600}\n value={text[name]?.[lang] ?? \"\"}\n onChange={(e) => {\n const next = { ...(text[name] ?? {}), [lang]: e.target.value || undefined };\n const empty = !next.fr && !next.en;\n run({ type: \"setText\", key: section.key, field: name, value: empty ? undefined : next }, `text:${section.key}:${name}:${lang}`);\n }}\n />\n </div>\n ))}\n </fieldset>\n );\n return (\n <section aria-label={m.words} className=\"grid gap-3\">\n <h3 className=\"m-0 text-sm font-semibold text-fg\">{m.words}</h3>\n {field(\"title\", m.titleField)}\n {field(\"lead\", m.leadField)}\n </section>\n );\n}\n\nfunction Blocks({ section, m, run, announce }: Pick<InspectorProps, \"section\" | \"run\" | \"announce\"> & { m: ShopComposerMessages }) {\n const def = sectionDefinition(section.type);\n const blocks = ((section.blocks ?? []) as { key: string; type: string }[]);\n if (def.blockTypes.length === 0) return null;\n const label = (b: { type: string }, i: number) => `${m.blockNames[b.type] ?? b.type} ${i + 1}`;\n const move = (i: number, to: number) => {\n const b = blocks[i]!;\n if (to < 0 || to >= blocks.length) return;\n run({ type: \"moveBlock\", key: section.key, blockKey: b.key, to });\n announce(fill(m.announceMoved, { name: label(b, i), n: to + 1, total: blocks.length }));\n };\n return (\n <section aria-label={m.blocks} className=\"grid gap-2\">\n <h3 className=\"m-0 text-sm font-semibold text-fg\">{m.blocks}</h3>\n {blocks.length > 0 && (\n <ol className=\"m-0 grid list-none gap-1 p-0\">\n {blocks.map((b, i) => (\n <li key={b.key} className=\"flex items-center gap-1 rounded-md border border-border-default bg-surface-1 ps-3\">\n <span className=\"min-w-0 flex-1 truncate text-sm text-fg\">{label(b, i)}</span>\n <Button size=\"sm\" variant=\"ghost\" disabled={i === 0} aria-label={`${m.moveUp}: ${label(b, i)}`} onClick={() => move(i, i - 1)}>↑</Button>\n <Button size=\"sm\" variant=\"ghost\" disabled={i === blocks.length - 1} aria-label={`${m.moveDown}: ${label(b, i)}`} onClick={() => move(i, i + 1)}>↓</Button>\n <Button size=\"sm\" variant=\"ghost\" aria-label={fill(m.removeBlock, { name: label(b, i) })} onClick={() => run({ type: \"removeBlock\", key: section.key, blockKey: b.key })}>×</Button>\n </li>\n ))}\n </ol>\n )}\n <div className=\"flex flex-wrap gap-2\">\n {def.blockTypes.map((type) => (\n <Button key={type} size=\"sm\" variant=\"outline\" onClick={() => run({ type: \"addBlock\", key: section.key, blockKey: newKey(\"b\"), blockType: type, settings: defaultBlockSettings(type) })}>\n {m.addBlock} · {m.blockNames[type] ?? type}\n </Button>\n ))}\n </div>\n </section>\n );\n}\n\n/** The first settings of a new block: what its schema needs to be valid (a product then fills the references). */\nfunction defaultBlockSettings(type: string): Record<string, unknown> {\n switch (type) {\n case \"fact\": return { kind: \"open-now\" };\n case \"note\": return { text: \"…\" };\n case \"flyer\": return { text: \"…\" };\n case \"photo\": return { mediaId: \"\" };\n case \"service\": return { serviceId: \"\" };\n case \"member\": return { memberId: \"\" };\n case \"reel\": return { platform: \"tiktok\", url: \"https://\" };\n case \"link\": return { platform: \"instagram\", url: \"https://\" };\n case \"question\": return { question: {}, answer: {} };\n default: return {};\n }\n}\n\nexport function Inspector({ section, name, messages: m, run, epoch, announce, onInvalid, preset, density }: Readonly<InspectorProps>) {\n const def = sectionDefinition(section.type);\n const label = React.useId();\n return (\n <div className=\"flex min-w-0 flex-col gap-6\">\n <section aria-labelledby={label} className=\"grid gap-2\">\n <h3 id={label} className=\"m-0 text-sm font-semibold text-fg\">{m.variant}</h3>\n {/* The thumbnail is a section: it holds links and buttons, so it sits beside the radio, never inside it. */}\n <RadioGroup.Root label={`${name}: ${m.variant}`} value={section.variant} onValueChange={(variant) => run({ type: \"setVariant\", key: section.key, variant })} className=\"grid grid-cols-1 gap-2 sm:grid-cols-2\">\n {def.variants.map((variant) => (\n <div\n key={variant}\n role=\"presentation\"\n data-checked={section.variant === variant ? \"\" : undefined}\n onClick={() => run({ type: \"setVariant\", key: section.key, variant })}\n className=\"grid cursor-pointer gap-2 rounded-lg border border-border-default bg-surface-1 p-2 data-[checked]:border-accent data-[checked]:bg-accent-soft\"\n >\n <SectionThumbnail type={section.type} variant={variant} preset={preset} density={density} />\n <RadioGroup.Item value={variant}>{m.variantNames[`${section.type}.${variant}`] ?? variant}</RadioGroup.Item>\n </div>\n ))}\n </RadioGroup.Root>\n </section>\n <SettingsForm\n key={`${section.key}:${epoch}`}\n section={section}\n messages={m}\n onValid={(settings) => run({ type: \"patchSettings\", key: section.key, patch: settings }, `settings:${section.key}`)}\n onInvalid={(invalid) => onInvalid(section.key, invalid)}\n />\n <Blocks section={section} m={m} run={run} announce={announce} />\n <Words section={section} m={m} run={run} />\n </div>\n );\n}\n"
254
254
  },
255
255
  {
256
256
  "path": "shop-composer/keys.ts",
@@ -258,7 +258,7 @@
258
258
  },
259
259
  {
260
260
  "path": "shop-composer/look-picker.tsx",
261
- "content": "// The look of the page (folioviv#478): a radio group of the six looks as swatches (name, the look's own surface and its accent\n// chips), then the accent within the chosen look's tested list. It applies to the draft only; publishing goes through the diff.\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\n\nimport { cn } from \"../cn\";\nimport type { ShopPage } from \"../shop/schema\";\nimport type { Command } from \"./commands\";\nimport type { ShopComposerPreset } from \"./composer\";\nimport { fill, type ShopComposerMessages } from \"./messages\";\n\nexport type LookPickerProps = {\n looks: readonly ShopComposerPreset[];\n page: ShopPage;\n messages: ShopComposerMessages;\n run: (cmd: Command) => void;\n announce: (message: string) => void;\n};\n\n/** The accent chips of a look, drawn by its own tokens. */\nfunction Chips({ look }: { look: ShopComposerPreset }) {\n return (\n <span aria-hidden className=\"inline-flex gap-1\">\n {(look.accents ?? [look.accent ?? \"krizaka\"]).map((a) => (\n <span key={a} data-shop-preset={look.id} data-shop-accent={a} className=\"kz-look-chip\">\n <i />\n </span>\n ))}\n </span>\n );\n}\n\nexport function LookPicker({ looks, page, messages: m, run, announce }: LookPickerProps) {\n const current = looks.find((l) => l.id === page.preset.id);\n const accents = current?.accents ?? [];\n return (\n <div className=\"grid gap-3\">\n <RadioGroup.Root\n label={m.lookChoice}\n variant=\"cards\"\n value={current?.id ?? \"\"}\n onValueChange={(id) => {\n const look = looks.find((l) => l.id === id);\n if (!look) return;\n run({ type: \"applyLook\", look });\n announce(fill(m.lookApplied, { name: look.name }));\n }}\n className=\"grid-cols-2\"\n >\n {looks.map((l) => (\n <RadioGroup.Card key={l.id} value={l.id}>\n <span data-shop-preset={l.id} className={cn(\"kz-look-swatch\", \"w-full justify-between\")}>\n <span className=\"text-sm font-semibold\">{l.name}</span>\n <Chips look={l} />\n </span>\n </RadioGroup.Card>\n ))}\n </RadioGroup.Root>\n {accents.length > 1 && (\n <RadioGroup.Root label={m.accentChoice} variant=\"buttons\" value={page.accent ?? current?.accent ?? accents[0]} onValueChange={(a) => run({ type: \"setAccent\", accent: a === current?.accent ? undefined : a })}>\n {accents.map((a) => (\n <RadioGroup.Button key={a} value={a}>\n {m.accentNames[a] ?? a}\n </RadioGroup.Button>\n ))}\n </RadioGroup.Root>\n )}\n </div>\n );\n}\n"
261
+ "content": "// The look of the page (folioviv#478): a radio group of the six looks as swatches (name, the look's own surface and its accent\n// chips), then the accent within the chosen look's tested list. It applies to the draft only; publishing goes through the diff.\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\n\nimport { cn } from \"../cn\";\nimport type { ShopPage } from \"../shop/schema\";\nimport type { Command } from \"./commands\";\nimport type { ShopComposerPreset } from \"./composer\";\nimport { fill, type ShopComposerMessages } from \"./messages\";\n\nexport type LookPickerProps = {\n looks: readonly ShopComposerPreset[];\n page: ShopPage;\n messages: ShopComposerMessages;\n run: (cmd: Command) => void;\n announce: (message: string) => void;\n};\n\n/** The accent chips of a look, drawn by its own tokens. */\nfunction Chips({ look }: Readonly<{ look: ShopComposerPreset }>) {\n return (\n <span aria-hidden className=\"inline-flex gap-1\">\n {(look.accents ?? [look.accent ?? \"krizaka\"]).map((a) => (\n <span key={a} data-shop-preset={look.id} data-shop-accent={a} className=\"kz-look-chip\">\n <i />\n </span>\n ))}\n </span>\n );\n}\n\nexport function LookPicker({ looks, page, messages: m, run, announce }: Readonly<LookPickerProps>) {\n const current = looks.find((l) => l.id === page.preset.id);\n const accents = current?.accents ?? [];\n return (\n <div className=\"grid gap-3\">\n <RadioGroup.Root\n label={m.lookChoice}\n variant=\"cards\"\n value={current?.id ?? \"\"}\n onValueChange={(id) => {\n const look = looks.find((l) => l.id === id);\n if (!look) return;\n run({ type: \"applyLook\", look });\n announce(fill(m.lookApplied, { name: look.name }));\n }}\n className=\"grid-cols-2\"\n >\n {looks.map((l) => (\n <RadioGroup.Card key={l.id} value={l.id}>\n <span data-shop-preset={l.id} className={cn(\"kz-look-swatch\", \"w-full justify-between\")}>\n <span className=\"text-sm font-semibold\">{l.name}</span>\n <Chips look={l} />\n </span>\n </RadioGroup.Card>\n ))}\n </RadioGroup.Root>\n {accents.length > 1 && (\n <RadioGroup.Root label={m.accentChoice} variant=\"buttons\" value={page.accent ?? current?.accent ?? accents[0]} onValueChange={(a) => run({ type: \"setAccent\", accent: a === current?.accent ? undefined : a })}>\n {accents.map((a) => (\n <RadioGroup.Button key={a} value={a}>\n {m.accentNames[a] ?? a}\n </RadioGroup.Button>\n ))}\n </RadioGroup.Root>\n )}\n </div>\n );\n}\n"
262
262
  },
263
263
  {
264
264
  "path": "shop-composer/messages.ts",
@@ -270,15 +270,15 @@
270
270
  },
271
271
  {
272
272
  "path": "shop-composer/outline.tsx",
273
- "content": "\"use client\";\n\n// The outline (ADR-007 §5): the sections in order — name, the variant as a mono note, a visibility switch, a menu. Drag is an\n// extra the page does not need: the path is the keyboard — focus a row, `Alt+↑` / `Alt+↓` (or the row's menu: Move up, Move\n// down, Move to top). Every move is announced (« Reviews moved to position 3 of 8 ») and focus stays on the moved row.\nimport { Button } from \"@krizaka/ui/button\";\nimport { DropdownMenu } from \"@krizaka/ui/dropdown-menu\";\nimport { Switch } from \"@krizaka/ui/switch\";\nimport * as React from \"react\";\n\nimport type { Section } from \"../shop/schema\";\nimport type { Command } from \"./commands\";\nimport { fill, type ShopComposerMessages } from \"./messages\";\n\nexport type OutlineProps = {\n sections: readonly Section[];\n selected: string | null;\n onSelect: (key: string) => void;\n run: (cmd: Command, merge?: string) => void;\n messages: ShopComposerMessages;\n announce: (message: string) => void;\n onAdd: () => void;\n /** A request to focus a row (a new section): a new object each time; consumed once, after the render that drew the row. */\n focusRequest?: { key: string } | null;\n};\n\n/** « Photos », « Photos 2 » when a type appears twice. */\nexport function sectionLabel(sections: readonly Section[], index: number, messages: ShopComposerMessages): string {\n const s = sections[index]!;\n const same = sections.filter((x) => x.type === s.type);\n const base = messages.sectionNames[s.type];\n return same.length > 1 ? `${base} ${same.indexOf(s) + 1}` : base;\n}\n\nconst ICON = \"h-4 w-4\";\n\nexport function Outline({ sections, selected, onSelect, run, messages: m, announce, onAdd, focusRequest }: OutlineProps) {\n const rows = React.useRef(new Map<string, HTMLButtonElement>());\n // After a move (or a menu action) the moved row keeps the focus: the DOM may have reordered under it. A request is consumed once —\n // never on the next change of the document, which may be typing somewhere else.\n const wanted = React.useRef<string | null>(null);\n const [tick, setTick] = React.useState(0);\n const want = (key: string) => {\n wanted.current = key;\n setTick((t) => t + 1);\n };\n React.useLayoutEffect(() => {\n if (focusRequest) wanted.current = focusRequest.key;\n }, [focusRequest]);\n React.useLayoutEffect(() => {\n const key = wanted.current;\n wanted.current = null;\n if (key) rows.current.get(key)?.focus();\n }, [tick, focusRequest]);\n\n const move = (index: number, to: number) => {\n const s = sections[index]!;\n const name = sectionLabel(sections, index, m);\n const lo = sections[0]?.type === \"hero\" ? 1 : 0;\n const clamped = Math.min(Math.max(to, lo), sections.length - 1);\n if (s.type === \"hero\" || clamped === index) {\n announce(fill(m.announceCannotMove, { name }));\n return;\n }\n run({ type: \"moveSection\", key: s.key, to: clamped });\n want(s.key);\n announce(fill(m.announceMoved, { name, n: clamped + 1, total: sections.length }));\n };\n\n const onKeyDown = (e: React.KeyboardEvent, index: number) => {\n if (e.altKey && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\")) {\n e.preventDefault();\n move(index, index + (e.key === \"ArrowUp\" ? -1 : 1));\n } else if (!e.altKey && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\")) {\n const next = sections[index + (e.key === \"ArrowUp\" ? -1 : 1)];\n if (next) {\n e.preventDefault();\n rows.current.get(next.key)?.focus();\n }\n }\n };\n\n return (\n <nav aria-label={m.sections} className=\"flex min-h-0 flex-col gap-3\">\n <ol className=\"m-0 flex list-none flex-col gap-1 p-0\">\n {sections.map((s, i) => {\n const name = sectionLabel(sections, i, m);\n const isHero = s.type === \"hero\";\n const lo = sections[0]?.type === \"hero\" ? 1 : 0;\n return (\n <li key={s.key} data-selected={selected === s.key ? \"\" : undefined} data-disabled={s.disabled ? \"\" : undefined} className=\"flex items-center gap-1 rounded-lg border border-transparent data-[selected]:border-accent data-[selected]:bg-accent-soft\">\n <button\n type=\"button\"\n ref={(el) => {\n if (el) rows.current.set(s.key, el);\n else rows.current.delete(s.key);\n }}\n aria-current={selected === s.key ? \"true\" : undefined}\n aria-keyshortcuts=\"Alt+ArrowUp Alt+ArrowDown\"\n onClick={() => onSelect(s.key)}\n onKeyDown={(e) => onKeyDown(e, i)}\n className=\"flex min-h-11 min-w-0 flex-1 flex-col items-start justify-center rounded-lg px-3 py-1.5 text-start focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring\"\n >\n <span className=\"flex w-full items-baseline gap-2\">\n <span className={s.disabled ? \"truncate text-sm font-semibold text-fg-secondary line-through decoration-1\" : \"truncate text-sm font-semibold text-fg\"}>{name}</span>\n {s.disabled && <span className=\"font-mono text-[11px] text-fg-secondary\">{m.hiddenNote}</span>}\n </span>\n <span className=\"font-mono text-xs text-fg-secondary\">{m.variantNames[`${s.type}.${s.variant}`] ?? s.variant}</span>\n </button>\n <Switch\n size=\"sm\"\n label={fill(m.toggleVisible, { name })}\n checked={!s.disabled}\n onCheckedChange={(on) => {\n run({ type: \"toggleDisabled\", key: s.key });\n announce(fill(on ? m.announceShown : m.announceHidden, { name }));\n }}\n />\n <DropdownMenu.Root>\n <DropdownMenu.Trigger asChild>\n <Button variant=\"ghost\" size=\"icon\" aria-label={fill(m.sectionMenu, { name })}>\n <svg viewBox=\"0 0 16 16\" className={ICON} fill=\"currentColor\" aria-hidden>\n <circle cx=\"8\" cy=\"3\" r=\"1.4\" />\n <circle cx=\"8\" cy=\"8\" r=\"1.4\" />\n <circle cx=\"8\" cy=\"13\" r=\"1.4\" />\n </svg>\n </Button>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n onCloseAutoFocus={(e) => {\n e.preventDefault();\n rows.current.get(s.key)?.focus();\n }}\n >\n <DropdownMenu.Item disabled={isHero || i <= lo} onSelect={() => move(i, i - 1)}>{m.moveUp}</DropdownMenu.Item>\n <DropdownMenu.Item disabled={isHero || i >= sections.length - 1} onSelect={() => move(i, i + 1)}>{m.moveDown}</DropdownMenu.Item>\n <DropdownMenu.Item disabled={isHero || i <= lo} onSelect={() => move(i, lo)}>{m.moveTop}</DropdownMenu.Item>\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n tone=\"danger\"\n disabled={sections.length <= 1}\n onSelect={() => {\n run({ type: \"removeSection\", key: s.key });\n announce(fill(m.announceRemoved, { name }));\n const next = sections[i + 1] ?? sections[i - 1];\n if (next) want(next.key);\n }}\n >\n {m.remove}\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </li>\n );\n })}\n </ol>\n <Button variant=\"outline\" onClick={onAdd}>{m.addSection}</Button>\n </nav>\n );\n}\n"
273
+ "content": "\"use client\";\n\n// The outline (ADR-007 §5): the sections in order — name, the variant as a mono note, a visibility switch, a menu. Drag is an\n// extra the page does not need: the path is the keyboard — focus a row, `Alt+↑` / `Alt+↓` (or the row's menu: Move up, Move\n// down, Move to top). Every move is announced (« Reviews moved to position 3 of 8 ») and focus stays on the moved row.\nimport { Button } from \"@krizaka/ui/button\";\nimport { DropdownMenu } from \"@krizaka/ui/dropdown-menu\";\nimport { Switch } from \"@krizaka/ui/switch\";\nimport * as React from \"react\";\n\nimport type { Section } from \"../shop/schema\";\nimport type { Command } from \"./commands\";\nimport { fill, type ShopComposerMessages } from \"./messages\";\n\nexport type OutlineProps = {\n sections: readonly Section[];\n selected: string | null;\n onSelect: (key: string) => void;\n run: (cmd: Command, merge?: string) => void;\n messages: ShopComposerMessages;\n announce: (message: string) => void;\n onAdd: () => void;\n /** A request to focus a row (a new section): a new object each time; consumed once, after the render that drew the row. */\n focusRequest?: { key: string } | null;\n};\n\n/** « Photos », « Photos 2 » when a type appears twice. */\nexport function sectionLabel(sections: readonly Section[], index: number, messages: ShopComposerMessages): string {\n const s = sections[index]!;\n const same = sections.filter((x) => x.type === s.type);\n const base = messages.sectionNames[s.type];\n return same.length > 1 ? `${base} ${same.indexOf(s) + 1}` : base;\n}\n\nconst ICON = \"h-4 w-4\";\n\nexport function Outline({ sections, selected, onSelect, run, messages: m, announce, onAdd, focusRequest }: Readonly<OutlineProps>) {\n const rows = React.useRef(new Map<string, HTMLButtonElement>());\n // After a move (or a menu action) the moved row keeps the focus: the DOM may have reordered under it. A request is consumed once —\n // never on the next change of the document, which may be typing somewhere else.\n const wanted = React.useRef<string | null>(null);\n const [tick, setTick] = React.useState(0);\n const want = (key: string) => {\n wanted.current = key;\n setTick((t) => t + 1);\n };\n React.useLayoutEffect(() => {\n if (focusRequest) wanted.current = focusRequest.key;\n }, [focusRequest]);\n React.useLayoutEffect(() => {\n const key = wanted.current;\n wanted.current = null;\n if (key) rows.current.get(key)?.focus();\n }, [tick, focusRequest]);\n\n const move = (index: number, to: number) => {\n const s = sections[index]!;\n const name = sectionLabel(sections, index, m);\n const lo = sections[0]?.type === \"hero\" ? 1 : 0;\n const clamped = Math.min(Math.max(to, lo), sections.length - 1);\n if (s.type === \"hero\" || clamped === index) {\n announce(fill(m.announceCannotMove, { name }));\n return;\n }\n run({ type: \"moveSection\", key: s.key, to: clamped });\n want(s.key);\n announce(fill(m.announceMoved, { name, n: clamped + 1, total: sections.length }));\n };\n\n const onKeyDown = (e: React.KeyboardEvent, index: number) => {\n if (e.altKey && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\")) {\n e.preventDefault();\n move(index, index + (e.key === \"ArrowUp\" ? -1 : 1));\n } else if (!e.altKey && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\")) {\n const next = sections[index + (e.key === \"ArrowUp\" ? -1 : 1)];\n if (next) {\n e.preventDefault();\n rows.current.get(next.key)?.focus();\n }\n }\n };\n\n return (\n <nav aria-label={m.sections} className=\"flex min-h-0 flex-col gap-3\">\n <ol className=\"m-0 flex list-none flex-col gap-1 p-0\">\n {sections.map((s, i) => {\n const name = sectionLabel(sections, i, m);\n const isHero = s.type === \"hero\";\n const lo = sections[0]?.type === \"hero\" ? 1 : 0;\n return (\n <li key={s.key} data-selected={selected === s.key ? \"\" : undefined} data-disabled={s.disabled ? \"\" : undefined} className=\"flex items-center gap-1 rounded-lg border border-transparent data-[selected]:border-accent data-[selected]:bg-accent-soft\">\n <button\n type=\"button\"\n ref={(el) => {\n if (el) rows.current.set(s.key, el);\n else rows.current.delete(s.key);\n }}\n aria-current={selected === s.key ? \"true\" : undefined}\n aria-keyshortcuts=\"Alt+ArrowUp Alt+ArrowDown\"\n onClick={() => onSelect(s.key)}\n onKeyDown={(e) => onKeyDown(e, i)}\n className=\"flex min-h-11 min-w-0 flex-1 flex-col items-start justify-center rounded-lg px-3 py-1.5 text-start focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring\"\n >\n <span className=\"flex w-full items-baseline gap-2\">\n <span className={s.disabled ? \"truncate text-sm font-semibold text-fg-secondary line-through decoration-1\" : \"truncate text-sm font-semibold text-fg\"}>{name}</span>\n {s.disabled && <span className=\"font-mono text-[11px] text-fg-secondary\">{m.hiddenNote}</span>}\n </span>\n <span className=\"font-mono text-xs text-fg-secondary\">{m.variantNames[`${s.type}.${s.variant}`] ?? s.variant}</span>\n </button>\n <Switch\n size=\"sm\"\n label={fill(m.toggleVisible, { name })}\n checked={!s.disabled}\n onCheckedChange={(on) => {\n run({ type: \"toggleDisabled\", key: s.key });\n announce(fill(on ? m.announceShown : m.announceHidden, { name }));\n }}\n />\n <DropdownMenu.Root>\n <DropdownMenu.Trigger asChild>\n <Button variant=\"ghost\" size=\"icon\" aria-label={fill(m.sectionMenu, { name })}>\n <svg viewBox=\"0 0 16 16\" className={ICON} fill=\"currentColor\" aria-hidden>\n <circle cx=\"8\" cy=\"3\" r=\"1.4\" />\n <circle cx=\"8\" cy=\"8\" r=\"1.4\" />\n <circle cx=\"8\" cy=\"13\" r=\"1.4\" />\n </svg>\n </Button>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n onCloseAutoFocus={(e) => {\n e.preventDefault();\n rows.current.get(s.key)?.focus();\n }}\n >\n <DropdownMenu.Item disabled={isHero || i <= lo} onSelect={() => move(i, i - 1)}>{m.moveUp}</DropdownMenu.Item>\n <DropdownMenu.Item disabled={isHero || i >= sections.length - 1} onSelect={() => move(i, i + 1)}>{m.moveDown}</DropdownMenu.Item>\n <DropdownMenu.Item disabled={isHero || i <= lo} onSelect={() => move(i, lo)}>{m.moveTop}</DropdownMenu.Item>\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n tone=\"danger\"\n disabled={sections.length <= 1}\n onSelect={() => {\n run({ type: \"removeSection\", key: s.key });\n announce(fill(m.announceRemoved, { name }));\n const next = sections[i + 1] ?? sections[i - 1];\n if (next) want(next.key);\n }}\n >\n {m.remove}\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </li>\n );\n })}\n </ol>\n <Button variant=\"outline\" onClick={onAdd}>{m.addSection}</Button>\n </nav>\n );\n}\n"
274
274
  },
275
275
  {
276
276
  "path": "shop-composer/settings-form.tsx",
277
- "content": "\"use client\";\n\n// The settings of a section, as a form generated from the zod schema of its type (ADR-007 §5): the form is `@krizaka/ui/form`\n// (TanStack Form behind the facade), the fields are the ones the schema describes (`fields.ts`). Every valid change is committed to\n// the document at once (so undo and the preview follow); an invalid value is said next to its field, stays in the field, and is\n// reported to the composer, which refuses to publish until it is fixed.\nimport { createKrizakaForm, FormField, Switch, TextArea, TextField, useFormContext } from \"@krizaka/ui/form\";\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\nimport * as React from \"react\";\n\nimport { type SectionDefinition, sectionDefinition } from \"../shop/catalogue\";\nimport type { Section } from \"../shop/schema\";\nimport { describeSettings, type FieldSpec } from \"./fields\";\nimport type { ShopComposerMessages } from \"./messages\";\n\ntype Factory = ReturnType<typeof createKrizakaForm>;\n// One form per section type, defined once (schema + defaults), as the facade asks.\nconst factories = new Map<string, Factory>();\nfunction factoryFor(def: SectionDefinition): Factory {\n let f = factories.get(def.type);\n if (!f) {\n f = createKrizakaForm({ schema: def.settings as never, defaultValues: def.settingsDefault as never }) as unknown as Factory;\n factories.set(def.type, f);\n }\n return f;\n}\n\nconst nameOf = (m: ShopComposerMessages, key: string) => m.settingNames[key] ?? key;\nconst optionName = (m: ShopComposerMessages, o: string | number) => m.optionNames[String(o)] ?? String(o);\n\nfunction Choice({ spec, m }: { spec: Extract<FieldSpec, { kind: \"choice\" }>; m: ShopComposerMessages }) {\n return (\n <FormField name={spec.name}>\n {(f) => (\n <div className=\"grid gap-1.5\">\n <span aria-hidden className=\"text-xs font-semibold text-fg-secondary\">{nameOf(m, spec.name)}</span>\n <RadioGroup.Root label={nameOf(m, spec.name)} variant=\"segmented\" value={String(f.value)} onValueChange={(v) => f.setValue(spec.options.find((o) => String(o) === v))} onBlur={f.onBlur}>\n {spec.options.map((o) => (\n <RadioGroup.Segment key={String(o)} value={String(o)}>{optionName(m, o)}</RadioGroup.Segment>\n ))}\n </RadioGroup.Root>\n </div>\n )}\n </FormField>\n );\n}\n\nfunction Multi({ spec, m }: { spec: Extract<FieldSpec, { kind: \"multi\" }>; m: ShopComposerMessages }) {\n return (\n <FormField name={spec.name}>\n {(f) => {\n const value = (f.value as string[] | undefined) ?? [];\n return (\n <fieldset className=\"m-0 flex flex-col gap-1.5 border-0 p-0\">\n <legend className=\"mb-1 text-xs font-semibold text-fg-secondary\">{nameOf(m, spec.name)}</legend>\n {spec.options.map((o) => (\n <label key={o} className=\"flex min-h-9 items-center gap-2 text-sm text-fg\">\n <input\n type=\"checkbox\"\n className=\"h-4 w-4 accent-accent\"\n checked={value.includes(o)}\n onChange={(e) => f.setValue(e.target.checked ? [...value, o] : value.filter((x) => x !== o))}\n />\n {optionName(m, o)}\n </label>\n ))}\n </fieldset>\n );\n }}\n </FormField>\n );\n}\n\nfunction Field({ spec, m }: { spec: FieldSpec; m: ShopComposerMessages }) {\n switch (spec.kind) {\n case \"choice\":\n return <Choice spec={spec} m={m} />;\n case \"multi\":\n return <Multi spec={spec} m={m} />;\n case \"toggle\":\n return <Switch name={spec.name} label={nameOf(m, spec.name)} />;\n case \"text\":\n return <TextField name={spec.name} label={nameOf(m, spec.name)} />;\n case \"localized\":\n return (\n <div className=\"flex flex-col gap-2\">\n <TextArea name={`${spec.name}.fr`} label={`${nameOf(m, spec.name)} — ${m.french}`} rows={3} maxLength={600} />\n <TextArea name={`${spec.name}.en`} label={`${nameOf(m, spec.name)} — ${m.english}`} rows={3} maxLength={600} />\n </div>\n );\n }\n}\n\n/** What the schema is asked: an emptied text is an absent setting (an optional id), an emptied language an absent language. */\nfunction normalise(values: unknown): unknown {\n if (Array.isArray(values)) return values;\n if (typeof values !== \"object\" || values === null) return values;\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(values)) {\n if (v === \"\") continue;\n const inner = typeof v === \"object\" && v !== null && !Array.isArray(v) ? normalise(v) : v;\n out[k] = inner;\n }\n return out;\n}\n\n/** Reports the form's values: a valid set goes to `onValid`, an invalid one to `onInvalid` (and never reaches the document). */\nfunction Commit({ def, onValid, onInvalid }: { def: SectionDefinition; onValid: (settings: Record<string, unknown>) => void; onInvalid: (invalid: boolean) => void }) {\n const { api } = useFormContext();\n const latest = React.useRef({ onValid, onInvalid });\n React.useEffect(() => {\n latest.current = { onValid, onInvalid };\n });\n React.useEffect(() => {\n const sub = (api.store as { subscribe: (cb: () => void) => unknown }).subscribe(() => {\n const result = def.settings.safeParse(normalise(api.state.values));\n latest.current.onInvalid(!result.success);\n if (result.success) latest.current.onValid(result.data as Record<string, unknown>);\n });\n return () => {\n const s = sub as { unsubscribe?: () => void } | (() => void);\n if (typeof s === \"function\") s();\n else s?.unsubscribe?.();\n };\n }, [api, def]);\n return null;\n}\n\nexport type SettingsFormProps = {\n section: Section;\n messages: ShopComposerMessages;\n /** A valid set of settings: the composer commits it. */\n onValid: (settings: Record<string, unknown>) => void;\n /** Whether the form holds a value the schema refuses (publish waits). */\n onInvalid: (invalid: boolean) => void;\n};\n\n/** The form of a section's settings: remount it (a `key`) when the document is changed from outside (undo, redo). */\nexport function SettingsForm({ section, messages: m, onValid, onInvalid }: SettingsFormProps) {\n const def = sectionDefinition(section.type);\n const factory = factoryFor(def);\n const form = factory.useForm({ defaultValues: section.settings as never }) as unknown as { Form: (p: { \"aria-label\": string; className?: string; children: React.ReactNode }) => React.ReactElement };\n const specs = describeSettings(def.settings);\n if (specs.length === 0) return null;\n return (\n <form.Form aria-label={m.settings} className=\"flex flex-col gap-4\">\n {specs.map((spec) => (\n <Field key={spec.name} spec={spec} m={m} />\n ))}\n <Commit def={def} onValid={onValid} onInvalid={onInvalid} />\n </form.Form>\n );\n}\n"
277
+ "content": "\"use client\";\n\n// The settings of a section, as a form generated from the zod schema of its type (ADR-007 §5): the form is `@krizaka/ui/form`\n// (TanStack Form behind the facade), the fields are the ones the schema describes (`fields.ts`). Every valid change is committed to\n// the document at once (so undo and the preview follow); an invalid value is said next to its field, stays in the field, and is\n// reported to the composer, which refuses to publish until it is fixed.\nimport { createKrizakaForm, FormField, Switch, TextArea, TextField, useFormContext } from \"@krizaka/ui/form\";\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\nimport * as React from \"react\";\n\nimport { type SectionDefinition, sectionDefinition } from \"../shop/catalogue\";\nimport type { Section } from \"../shop/schema\";\nimport { describeSettings, type FieldSpec } from \"./fields\";\nimport type { ShopComposerMessages } from \"./messages\";\n\ntype Factory = ReturnType<typeof createKrizakaForm>;\n// One form per section type, defined once (schema + defaults), as the facade asks.\nconst factories = new Map<string, Factory>();\nfunction factoryFor(def: SectionDefinition): Factory {\n let f = factories.get(def.type);\n if (!f) {\n f = createKrizakaForm({ schema: def.settings as never, defaultValues: def.settingsDefault as never }) as unknown as Factory;\n factories.set(def.type, f);\n }\n return f;\n}\n\nconst nameOf = (m: ShopComposerMessages, key: string) => m.settingNames[key] ?? key;\nconst optionName = (m: ShopComposerMessages, o: string | number) => m.optionNames[String(o)] ?? String(o);\n\nfunction Choice({ spec, m }: Readonly<{ spec: Extract<FieldSpec, { kind: \"choice\" }>; m: ShopComposerMessages }>) {\n return (\n <FormField name={spec.name}>\n {(f) => (\n <div className=\"grid gap-1.5\">\n <span aria-hidden className=\"text-xs font-semibold text-fg-secondary\">{nameOf(m, spec.name)}</span>\n <RadioGroup.Root label={nameOf(m, spec.name)} variant=\"segmented\" value={String(f.value)} onValueChange={(v) => f.setValue(spec.options.find((o) => String(o) === v))} onBlur={f.onBlur}>\n {spec.options.map((o) => (\n <RadioGroup.Segment key={String(o)} value={String(o)}>{optionName(m, o)}</RadioGroup.Segment>\n ))}\n </RadioGroup.Root>\n </div>\n )}\n </FormField>\n );\n}\n\nfunction Multi({ spec, m }: Readonly<{ spec: Extract<FieldSpec, { kind: \"multi\" }>; m: ShopComposerMessages }>) {\n return (\n <FormField name={spec.name}>\n {(f) => {\n const value = (f.value as string[] | undefined) ?? [];\n return (\n <fieldset className=\"m-0 flex flex-col gap-1.5 border-0 p-0\">\n <legend className=\"mb-1 text-xs font-semibold text-fg-secondary\">{nameOf(m, spec.name)}</legend>\n {spec.options.map((o) => (\n <label key={o} className=\"flex min-h-9 items-center gap-2 text-sm text-fg\">\n <input\n type=\"checkbox\"\n className=\"h-4 w-4 accent-accent\"\n checked={value.includes(o)}\n onChange={(e) => f.setValue(e.target.checked ? [...value, o] : value.filter((x) => x !== o))}\n />\n {optionName(m, o)}\n </label>\n ))}\n </fieldset>\n );\n }}\n </FormField>\n );\n}\n\nfunction Field({ spec, m }: Readonly<{ spec: FieldSpec; m: ShopComposerMessages }>) {\n switch (spec.kind) {\n case \"choice\":\n return <Choice spec={spec} m={m} />;\n case \"multi\":\n return <Multi spec={spec} m={m} />;\n case \"toggle\":\n return <Switch name={spec.name} label={nameOf(m, spec.name)} />;\n case \"text\":\n return <TextField name={spec.name} label={nameOf(m, spec.name)} />;\n case \"localized\":\n return (\n <div className=\"flex flex-col gap-2\">\n <TextArea name={`${spec.name}.fr`} label={`${nameOf(m, spec.name)} — ${m.french}`} rows={3} maxLength={600} />\n <TextArea name={`${spec.name}.en`} label={`${nameOf(m, spec.name)} — ${m.english}`} rows={3} maxLength={600} />\n </div>\n );\n }\n}\n\n/** What the schema is asked: an emptied text is an absent setting (an optional id), an emptied language an absent language. */\nfunction normalise(values: unknown): unknown {\n if (Array.isArray(values)) return values;\n if (typeof values !== \"object\" || values === null) return values;\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(values)) {\n if (v === \"\") continue;\n const inner = typeof v === \"object\" && v !== null && !Array.isArray(v) ? normalise(v) : v;\n out[k] = inner;\n }\n return out;\n}\n\n/** Reports the form's values: a valid set goes to `onValid`, an invalid one to `onInvalid` (and never reaches the document). */\nfunction Commit({ def, onValid, onInvalid }: { def: SectionDefinition; onValid: (settings: Record<string, unknown>) => void; onInvalid: (invalid: boolean) => void }) {\n const { api } = useFormContext();\n const latest = React.useRef({ onValid, onInvalid });\n React.useEffect(() => {\n latest.current = { onValid, onInvalid };\n });\n React.useEffect(() => {\n const sub = (api.store as { subscribe: (cb: () => void) => unknown }).subscribe(() => {\n const result = def.settings.safeParse(normalise(api.state.values));\n latest.current.onInvalid(!result.success);\n if (result.success) latest.current.onValid(result.data as Record<string, unknown>);\n });\n return () => {\n const s = sub as { unsubscribe?: () => void } | (() => void);\n if (typeof s === \"function\") s();\n else s?.unsubscribe?.();\n };\n }, [api, def]);\n return null;\n}\n\nexport type SettingsFormProps = {\n section: Section;\n messages: ShopComposerMessages;\n /** A valid set of settings: the composer commits it. */\n onValid: (settings: Record<string, unknown>) => void;\n /** Whether the form holds a value the schema refuses (publish waits). */\n onInvalid: (invalid: boolean) => void;\n};\n\n/** The form of a section's settings: remount it (a `key`) when the document is changed from outside (undo, redo). */\nexport function SettingsForm({ section, messages: m, onValid, onInvalid }: Readonly<SettingsFormProps>) {\n const def = sectionDefinition(section.type);\n const factory = factoryFor(def);\n const form = factory.useForm({ defaultValues: section.settings as never }) as unknown as { Form: (p: { \"aria-label\": string; className?: string; children: React.ReactNode }) => React.ReactElement };\n const specs = describeSettings(def.settings);\n if (specs.length === 0) return null;\n return (\n <form.Form aria-label={m.settings} className=\"flex flex-col gap-4\">\n {specs.map((spec) => (\n <Field key={spec.name} spec={spec} m={m} />\n ))}\n <Commit def={def} onValid={onValid} onInvalid={onInvalid} />\n </form.Form>\n );\n}\n"
278
278
  },
279
279
  {
280
280
  "path": "shop-composer/thumbnails.tsx",
281
- "content": "\"use client\";\n\n// The variant picker's thumbnails (ADR-007 §5): the section itself, drawn with demo data at the scale of a card — not a screenshot,\n// so a new variant or a new preset needs no new picture, and each thumbnail wears the page's look (the preset applies around it).\nimport * as React from \"react\";\n\nimport { Button } from \"../button/button\";\nimport { BookingSection } from \"../shop/booking/booking\";\nimport { BulletinSection } from \"../shop/bulletin/bulletin\";\nimport type { SectionType } from \"../shop/catalogue\";\nimport { demoSalon } from \"../shop/demo\";\nimport { FaqSection } from \"../shop/faq/faq\";\nimport { ShopFrame } from \"../shop/frame\";\nimport { GallerySection } from \"../shop/gallery/gallery\";\nimport { HeroSection } from \"../shop/hero/hero\";\nimport { PoliciesSection } from \"../shop/policies/policies\";\nimport { ReviewsSection } from \"../shop/reviews/reviews\";\nimport { ServicesSection } from \"../shop/services/services\";\nimport { SocialSection } from \"../shop/social/social\";\nimport { StorySection } from \"../shop/story/story\";\nimport { TeamSection } from \"../shop/team/team\";\nimport { VideoSection } from \"../shop/video/video\";\nimport { VisitSection } from \"../shop/visit/visit\";\n\nconst shop = demoSalon;\nconst play = { tiktok: \"Play\", \"youtube-shorts\": \"Play\", instagram: \"Play\" } as const;\nconst reel = { id: \"r\", platform: \"tiktok\" as const, url: \"https://www.tiktok.com/@salon/video/7000000000000000000\", title: \"Reel\" };\nconst summary = {\n score: 4.7, count: 38, distribution: [0, 1, 2, 7, 28] as [number, number, number, number, number],\n scoreText: \"4.7 / 5\", countText: \"38 reviews\", summaryText: \"4.7 out of 5, 38 reviews\", starText: (s: number, n: number) => `${s} stars: ${n}`,\n};\nconst review = { id: \"a\", author: \"Nadia F.\", date: \"October 2026\", dateTime: \"2026-10\", service: \"Cut and blow-dry\", rating: 5, ratingText: \"5 out of 5\", text: \"The best blow-dry in the neighbourhood, simply.\" };\n\n/** The section as it looks with demo data, in the variant asked. */\nfunction Demo({ type, variant }: { type: SectionType; variant: string }): React.ReactNode {\n const v = variant as never;\n switch (type) {\n case \"hero\":\n return <HeroSection variant={v} title={shop.name} eyebrow={shop.eyebrow} lead={shop.promise} cover={shop.cover} actions={<Button variant=\"primary\">Book</Button>} tv={{ poster: shop.cover.src, title: \"Latest video\" } as never} />;\n case \"services\":\n return <ServicesSection variant={v} title=\"Services\" services={shop.services} chooseLabel=\"Choose\" popularLabel=\"Popular\" />;\n case \"booking\":\n return variant === \"sticky\" ? <div className=\"flex items-center justify-center border-t border-border-default bg-surface-1 p-4\"><Button variant=\"primary\" size=\"lg\">Book</Button></div> : <BookingSection variant={v} label=\"Next free times\" times={shop.times} href=\"#\" actionLabel=\"Book\" title=\"Ready when you are\" body=\"A few taps.\" />;\n case \"gallery\":\n return <GallerySection variant={v} title=\"Photos\" label=\"Photos\" photos={shop.photos} sign={shop.name} />;\n case \"video\":\n return <VideoSection variant={v} title=\"Latest\" reels={[reel, { ...reel, id: \"r2\" }]} playLabels={play} />;\n case \"reviews\":\n return <ReviewsSection variant={v} title=\"Reviews\" summary={summary} reviews={[review, { ...review, id: \"b\", author: \"Léo P.\" }]} />;\n case \"bulletin\":\n return <BulletinSection variant={v} title=\"News\" today=\"2026-10-27\" flyers={[{ id: \"f\", text: \"Closed on Monday the 3rd: see you on Tuesday!\", signature: \"Jade\" }]} />;\n case \"team\":\n return <TeamSection variant={v} title=\"Team\" members={shop.team.map((t) => ({ id: t.id, name: t.name, role: \"Stylist\" }))} />;\n case \"visit\":\n return <VisitSection variant={v} title=\"Visit\" hours={shop.hours} status={shop.status} hoursLabel=\"Hours\" address={shop.address} phone={{ href: \"tel:5145550110\", label: shop.phone }} map={{ label: \"Map\", center: [-73.58, 45.48], showLabel: \"Show the map\" }} />;\n case \"story\":\n return <StorySection variant={v} title=\"Our story\" quote=\"Cuts that last, advice that is honest.\" body=\"Three friends opened the salon in 2019, on the corner where the old bakery stood.\" owner={{ name: \"Jade\" }} />;\n case \"social\":\n return <SocialSection variant={v} title=\"Follow us\" links={[{ id: \"a\", platform: \"instagram\", url: \"https://instagram.com/salon\" }, { id: \"b\", platform: \"tiktok\", url: \"https://tiktok.com/@salon\" }]} playLabels={play} />;\n case \"faq\":\n return <FaqSection title=\"Questions\" questions={[{ id: \"q\", question: \"Do I need to book?\", answer: \"Yes, pick a time online.\" }, { id: \"q2\", question: \"Can I cancel?\", answer: \"Up to 24 hours before.\" }]} />;\n case \"policies\":\n return <PoliciesSection title=\"Policies\" items={[{ id: \"p\", term: \"Cancellation\", details: \"Free up to 24 h before\" }, { id: \"p2\", term: \"Prices\", details: \"Before taxes\" }]} />;\n }\n}\n\nexport type SectionThumbnailProps = {\n /** The section type. */\n type: SectionType;\n /** Its variant: one of the type's. */\n variant: string;\n /** The look preset the page wears (`salon-vitrine`): the thumbnail wears it too. */\n preset?: string;\n /** The page's spacing. @default \"compact\" */\n density?: \"compact\" | \"airy\";\n};\n\n/** A picture of a section: 160 × 96 px of a 960 px page, inert and hidden from assistive technology. */\nexport function SectionThumbnail({ type, variant, preset, density }: SectionThumbnailProps) {\n return (\n <div aria-hidden inert className=\"kz-shop-thumb\" data-thumb={`${type}.${variant}`}>\n <div className=\"kz-shop-thumb-inner\">\n <ShopFrame preset={preset} density={density ?? \"compact\"}>\n <Demo type={type} variant={variant} />\n </ShopFrame>\n </div>\n </div>\n );\n}\n"
281
+ "content": "\"use client\";\n\n// The variant picker's thumbnails (ADR-007 §5): the section itself, drawn with demo data at the scale of a card — not a screenshot,\n// so a new variant or a new preset needs no new picture, and each thumbnail wears the page's look (the preset applies around it).\nimport * as React from \"react\";\n\nimport { Button } from \"../button/button\";\nimport { BookingSection } from \"../shop/booking/booking\";\nimport { BulletinSection } from \"../shop/bulletin/bulletin\";\nimport type { SectionType } from \"../shop/catalogue\";\nimport { demoSalon } from \"../shop/demo\";\nimport { FaqSection } from \"../shop/faq/faq\";\nimport { ShopFrame } from \"../shop/frame\";\nimport { GallerySection } from \"../shop/gallery/gallery\";\nimport { HeroSection } from \"../shop/hero/hero\";\nimport { PoliciesSection } from \"../shop/policies/policies\";\nimport { ReviewsSection } from \"../shop/reviews/reviews\";\nimport { ServicesSection } from \"../shop/services/services\";\nimport { SocialSection } from \"../shop/social/social\";\nimport { StorySection } from \"../shop/story/story\";\nimport { TeamSection } from \"../shop/team/team\";\nimport { VideoSection } from \"../shop/video/video\";\nimport { VisitSection } from \"../shop/visit/visit\";\n\nconst shop = demoSalon;\nconst play = { tiktok: \"Play\", \"youtube-shorts\": \"Play\", instagram: \"Play\" } as const;\nconst reel = { id: \"r\", platform: \"tiktok\" as const, url: \"https://www.tiktok.com/@salon/video/7000000000000000000\", title: \"Reel\" };\nconst summary = {\n score: 4.7, count: 38, distribution: [0, 1, 2, 7, 28] as [number, number, number, number, number],\n scoreText: \"4.7 / 5\", countText: \"38 reviews\", summaryText: \"4.7 out of 5, 38 reviews\", starText: (s: number, n: number) => `${s} stars: ${n}`,\n};\nconst review = { id: \"a\", author: \"Nadia F.\", date: \"October 2026\", dateTime: \"2026-10\", service: \"Cut and blow-dry\", rating: 5, ratingText: \"5 out of 5\", text: \"The best blow-dry in the neighbourhood, simply.\" };\n\n/** The section as it looks with demo data, in the variant asked. */\nfunction Demo({ type, variant }: Readonly<{ type: SectionType; variant: string }>): React.ReactNode {\n const v = variant as never;\n switch (type) {\n case \"hero\":\n return <HeroSection variant={v} title={shop.name} eyebrow={shop.eyebrow} lead={shop.promise} cover={shop.cover} actions={<Button variant=\"primary\">Book</Button>} tv={{ poster: shop.cover.src, title: \"Latest video\" } as never} />;\n case \"services\":\n return <ServicesSection variant={v} title=\"Services\" services={shop.services} chooseLabel=\"Choose\" popularLabel=\"Popular\" />;\n case \"booking\":\n return variant === \"sticky\" ? <div className=\"flex items-center justify-center border-t border-border-default bg-surface-1 p-4\"><Button variant=\"primary\" size=\"lg\">Book</Button></div> : <BookingSection variant={v} label=\"Next free times\" times={shop.times} href=\"#\" actionLabel=\"Book\" title=\"Ready when you are\" body=\"A few taps.\" />;\n case \"gallery\":\n return <GallerySection variant={v} title=\"Photos\" label=\"Photos\" photos={shop.photos} sign={shop.name} />;\n case \"video\":\n return <VideoSection variant={v} title=\"Latest\" reels={[reel, { ...reel, id: \"r2\" }]} playLabels={play} />;\n case \"reviews\":\n return <ReviewsSection variant={v} title=\"Reviews\" summary={summary} reviews={[review, { ...review, id: \"b\", author: \"Léo P.\" }]} />;\n case \"bulletin\":\n return <BulletinSection variant={v} title=\"News\" today=\"2026-10-27\" flyers={[{ id: \"f\", text: \"Closed on Monday the 3rd: see you on Tuesday!\", signature: \"Jade\" }]} />;\n case \"team\":\n return <TeamSection variant={v} title=\"Team\" members={shop.team.map((t) => ({ id: t.id, name: t.name, role: \"Stylist\" }))} />;\n case \"visit\":\n return <VisitSection variant={v} title=\"Visit\" hours={shop.hours} status={shop.status} hoursLabel=\"Hours\" address={shop.address} phone={{ href: \"tel:5145550110\", label: shop.phone }} map={{ label: \"Map\", center: [-73.58, 45.48], showLabel: \"Show the map\" }} />;\n case \"story\":\n return <StorySection variant={v} title=\"Our story\" quote=\"Cuts that last, advice that is honest.\" body=\"Three friends opened the salon in 2019, on the corner where the old bakery stood.\" owner={{ name: \"Jade\" }} />;\n case \"social\":\n return <SocialSection variant={v} title=\"Follow us\" links={[{ id: \"a\", platform: \"instagram\", url: \"https://instagram.com/salon\" }, { id: \"b\", platform: \"tiktok\", url: \"https://tiktok.com/@salon\" }]} playLabels={play} />;\n case \"faq\":\n return <FaqSection title=\"Questions\" questions={[{ id: \"q\", question: \"Do I need to book?\", answer: \"Yes, pick a time online.\" }, { id: \"q2\", question: \"Can I cancel?\", answer: \"Up to 24 hours before.\" }]} />;\n case \"policies\":\n return <PoliciesSection title=\"Policies\" items={[{ id: \"p\", term: \"Cancellation\", details: \"Free up to 24 h before\" }, { id: \"p2\", term: \"Prices\", details: \"Before taxes\" }]} />;\n }\n}\n\nexport type SectionThumbnailProps = {\n /** The section type. */\n type: SectionType;\n /** Its variant: one of the type's. */\n variant: string;\n /** The look preset the page wears (`salon-vitrine`): the thumbnail wears it too. */\n preset?: string;\n /** The page's spacing. @default \"compact\" */\n density?: \"compact\" | \"airy\";\n};\n\n/** A picture of a section: 160 × 96 px of a 960 px page, inert and hidden from assistive technology. */\nexport function SectionThumbnail({ type, variant, preset, density }: Readonly<SectionThumbnailProps>) {\n return (\n <div aria-hidden inert className=\"kz-shop-thumb\" data-thumb={`${type}.${variant}`}>\n <div className=\"kz-shop-thumb-inner\">\n <ShopFrame preset={preset} density={density ?? \"compact\"}>\n <Demo type={type} variant={variant} />\n </ShopFrame>\n </div>\n </div>\n );\n}\n"
282
282
  }
283
283
  ],
284
284
  "dependencies": [
@@ -134,7 +134,7 @@
134
134
  "files": [
135
135
  {
136
136
  "path": "meta.ts",
137
- "content": "// The documentation of a component, carried by its code: each primitive has a `meta.ts` beside its source\n// (`src/<name>/meta.ts`; a component that exists only in React Native: `src/native/meta/<name>.ts`). Never built into\n// the package: `scripts/build-registry.mjs` reads them into `registry/<name>.json`, which ui.krizaka.com (apps/site) renders as\n// ui.krizaka.com/components/<name>, and `scripts/registry.test.mjs` fails when one is missing or incomplete.\n//\n// Why a typed module and not JSDoc tags: the fields are lists and links (`related`, `whenNotToUse[].use`, examples),\n// which a type checks and a comment does not; the file is plain data (erasable TypeScript), so Node reads it without a\n// compiler, and an editor completes it.\n\n/** Every documented component: the web primitives (one entry of the package each) and the native-only ones. */\nexport type ComponentName =\n | \"notification-preferences\"\n | \"quota-meter\"\n | \"environment-notice\"\n | \"embed-facade\"\n | \"reviews\"\n | \"margin-layout\"\n | \"analysis-report\"\n | \"status-chip\"\n | \"kind-config-editor\"\n | \"agenda\"\n | \"account-settings\"\n | \"drop-overlay\"\n | \"upload-queue\"\n | \"achievement\"\n | \"anatomy-plate\"\n | \"bird-plate\"\n | \"taped-photo\"\n | \"stuck\"\n | \"doodle\"\n | \"signature\"\n | \"grade-stamp\"\n | \"versus-card\"\n | \"speed-lines\"\n | \"site-cahier\"\n | \"text-style\"\n | \"flock\"\n | \"elephant\"\n | \"footnote\"\n | \"page-index\"\n | \"chapter\"\n | \"specimen-tag\"\n | \"action-bar\"\n | \"action-sheet\"\n | \"activity-feed\"\n | \"alert\"\n | \"app-frame\"\n | \"desktop-window\"\n | \"form-flow\"\n | \"grid\"\n | \"list-detail\"\n | \"state-screen\"\n | \"app-header\"\n | \"app-shell\"\n | \"argument-card\"\n | \"auth-layout\"\n | \"avatar\"\n | \"badge\"\n | \"button\"\n | \"captcha\"\n | \"card\"\n | \"card-grid\"\n | \"catalogue-page\"\n | \"changelog-page\"\n | \"chat\"\n | \"checkbox\"\n | \"chip\"\n | \"chip-link\"\n | \"chip-row\"\n | \"choice-grid\"\n | \"cn\"\n | \"code-block\"\n | \"combobox\"\n | \"comparison-table\"\n | \"command\"\n | \"component-page\"\n | \"confirm-button\"\n | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\n | \"contact-page\"\n | \"continue-prompt\"\n | \"countdown\"\n | \"cover-hero\"\n | \"cta-panel\"\n | \"dashboard-layout\"\n | \"data-table\"\n | \"date-picker\"\n | \"decision-list\"\n | \"description-list\"\n | \"detail-layout\"\n | \"dialog\"\n | \"docs-article-page\"\n | \"docs-hub-page\"\n | \"docs-layout\"\n | \"docs-nav\"\n | \"document-viewer\"\n | \"dropdown-menu\"\n | \"empty-state\"\n | \"engine-flow\"\n | \"error-page\"\n | \"fab\"\n | \"field\"\n | \"file-upload\"\n | \"filter-bar\"\n | \"force-update-screen\"\n | \"form\"\n | \"gallery-page\"\n | \"genui\"\n | \"glossary\"\n | \"glossary-term\"\n | \"glow-card\"\n | \"goal-gauge\"\n | \"header\"\n | \"image-cropper\"\n | \"image-viewer\"\n | \"kanban\"\n | \"kbd\"\n | \"kpi-explained\"\n | \"landing-page\"\n | \"landscape\"\n | \"legal-page\"\n | \"link-card\"\n | \"list\"\n | \"loader\"\n | \"longform-page\"\n | \"maintenance-screen\"\n | \"map\"\n | \"markdown\"\n | \"waveform\"\n | \"proposal\"\n | \"qr-code\"\n | \"identity-card\"\n | \"entity-header\"\n | \"collection-switcher\"\n | \"marketing-layout\"\n | \"mascot-quote\"\n | \"mascot-state\"\n | \"mascots\"\n | \"match-dialog\"\n | \"media-capture\"\n | \"language-switch\"\n | \"media-gallery\"\n | \"media-picker\"\n | \"meter\"\n | \"nav-bar\"\n | \"number-ticker\"\n | \"onboarding\"\n | \"opening-hours\"\n | \"otp-input\"\n | \"page\"\n | \"page-header\"\n | \"page-hero\"\n | \"pagination\"\n | \"permission-prompt\"\n | \"pointer-light\"\n | \"popover\"\n | \"pricing-page\"\n | \"product-page\"\n | \"profile-card\"\n | \"progress\"\n | \"promise-card\"\n | \"pull-to-refresh\"\n | \"retro-tv\"\n | \"shop-gallery\"\n | \"radio-group\"\n | \"router\"\n | \"rail-nav\"\n | \"recipes\"\n | \"screen\"\n | \"scroll-stage\"\n | \"search-field\"\n | \"section-backdrop\"\n | \"segmented\"\n | \"separator\"\n | \"service-card\"\n | \"shop\"\n | \"shop-composer\"\n | \"schema-form\"\n | \"settings-layout\"\n | \"account-menu\"\n | \"showcase\"\n | \"step-showcase\"\n | \"site-footer\"\n | \"sites\"\n | \"skeleton\"\n | \"skip-link\"\n | \"slider\"\n | \"slot-picker\"\n | \"slot\"\n | \"spinner\"\n | \"sticky-action\"\n | \"splash-handoff\"\n | \"split-view\"\n | \"stage-banner\"\n | \"stat\"\n | \"usage\"\n | \"status-page\"\n | \"step-progress\"\n | \"stepper\"\n | \"swipe-deck\"\n | \"swipeable-row\"\n | \"switch\"\n | \"tab-bar\"\n | \"tabs\"\n | \"tag-input\"\n | \"tag-selector\"\n | \"terminal-replay\"\n | \"theme\"\n | \"toast\"\n | \"toc\"\n | \"tooltip\"\n | \"tree-view\"\n | \"txt\"\n | \"update-prompt\"\n | \"verified-badge\"\n | \"vertical-video\"\n | \"video-player\"\n | \"video-trimmer\"\n | \"virtual\"\n | \"wall\";\n\n/** Where a component exists: `@krizaka/ui/<name>` (web), `@krizaka/ui/native` (React Native), or both. */\nexport type Platform = \"web\" | \"native\" | \"both\";\n\n/**\n * Why a component is not on a platform — a decision, never a silence (the parity matrix of ui.krizaka.com/platforms):\n * - `gap` (✗): it belongs there and is not built yet; `issue` is the issue that tracks it (`krizaka/krizaka-ui#275`);\n * - `n/a`: it is not meant for that platform (a site's page block on a phone, a swipe on a desktop); `use` names the\n * component that answers there, when one does.\n */\nexport type Absence =\n | { readonly status: \"gap\"; readonly issue: string; readonly reason: string; readonly use?: undefined }\n | { readonly status: \"n/a\"; readonly reason: string; readonly use?: ComponentName; readonly issue?: undefined };\n\n/**\n * Desktop is the Sovkora Mac app (Tauri 2: the system WebView renders the web components — ADR-002). `web`: the web\n * component runs there as it is; `desktop`: it also has a desktop form (a window's title bar, a denser layout…), said in\n * its documentation; otherwise the absence and why.\n */\nexport type DesktopSupport = \"web\" | \"desktop\" | Absence;\n\n/**\n * The three platforms of Krizaka UI — web · native (React Native, Expo) · desktop — for one component. The side a\n * component has is `platforms`; the side it lacks says why here: `native` is required for (and only for) a web-only\n * component, `web` for a native-only one; `desktop` always. `scripts/registry.test.mjs` fails on a missing decision.\n */\nexport interface Parity {\n readonly web?: Absence;\n readonly native?: Absence;\n readonly desktop: DesktopSupport;\n}\n\n/**\n * `experimental`: created for a filed need (ADR-008 §4), it may change or go in any minor until its first consumer imports it; `adoption`\n * names that consumer's issue. `stable`: its API only changes in a major. `beta`: it may still change in a minor. `deprecated`: no product uses it and\n * no work plans to — it still works, says what replaces it, and goes in the major named by `deprecated.removedIn`.\n */\nexport type Status = \"experimental\" | \"stable\" | \"beta\" | \"deprecated\";\n\n/**\n * What a component is for (ADR-008 §3): the thirteen domains the documentation, the size budgets and the guards are\n * organised by. The domain is metadata: the entries stay flat (`@krizaka/ui/<name>`). `cahier` is the sites' register\n * (ADR-004): a product never imports it.\n */\nexport type Domain =\n | \"foundations\"\n | \"forms\"\n | \"data-display\"\n | \"navigation-shell\"\n | \"feedback\"\n | \"maps\"\n | \"media\"\n | \"commerce\"\n | \"identity\"\n | \"abuse\"\n | \"conversation\"\n | \"page-blocks\"\n | \"cahier\";\n\n/** What a deprecated component says (required when `status` is `deprecated`, absent otherwise). */\nexport interface Deprecation {\n /** The version that deprecated it (`3.6.0`). */\n readonly since: string;\n /** The major that removes it (`4.0.0`). */\n readonly removedIn: string;\n /** What replaces it, when a component does. */\n readonly use?: ComponentName;\n /** Why it goes: no product uses it, no planned work needs it. */\n readonly reason: string;\n}\n\n/**\n * The group of the catalogue. `media`: video, sound, camera, files, cropping. `blocks`: the page blocks — the frame,\n * the hero, sections, cards that lead or argue, decisions, code, calls to act — that every page of a site is made of.\n * `layouts`: the shells of whole screens — an application, a dashboard, settings, sign-in, an object, a list and its\n * item, a site's page, a documentation page — each with its screens. `templates`: the page templates — whole pages of a\n * site (a landing, a product, a docs hub, a long read, a changelog, pricing, status, an error…), each a distinct\n * composition of the blocks, words and content as props.\n */\nexport type Category = \"actions\" | \"forms\" | \"navigation\" | \"overlays\" | \"feedback\" | \"data-display\" | \"media\" | \"blocks\" | \"layouts\" | \"templates\" | \"layout\" | \"foundations\";\n\n/** Why a reader needs a template: the seven intents the templates are grouped by (sidebar sub-headings, catalogue filter). */\nexport type TemplatePurpose = \"convince\" | \"explain\" | \"show\" | \"act\" | \"operate\" | \"converse\" | \"recover\";\n\n/** The groups of templates, in reading order: the title, and the one line that says when to come to that group. */\nexport const templatePurposes = {\n convince: { title: \"Convince\", useWhen: \"You come here when a visitor must decide: a landing, a product, a price, a comparison, a proof.\" },\n explain: { title: \"Explain\", useWhen: \"You come here when a reader must understand: how it works, a documentation hub or article, a changelog, a FAQ, a policy.\" },\n show: { title: \"Show\", useWhen: \"You come here when the work itself is the argument: a gallery, a story, a case study, an object and its details.\" },\n act: { title: \"Act\", useWhen: \"You come here when a person must do something once: reach the team, sign in or up, set up, pay.\" },\n operate: { title: \"Operate\", useWhen: \"You come here when a person works every day: a dashboard, a console with a table, settings, an app shell.\" },\n converse: { title: \"Converse\", useWhen: \"You come here when people talk: an inbox, a chat, comments, a notifications centre.\" },\n recover: { title: \"Recover\", useWhen: \"You come here when the way is blocked: an empty list, an error, a missing page, maintenance, a product still being built.\" },\n} as const satisfies Record<TemplatePurpose, { readonly title: string; readonly useWhen: string }>;\n\n/**\n * A named example: the file `registry/examples/<component>/<name>.tsx` (web) or\n * `registry/examples/<component>/native/<name>.tsx` (React Native) — at most 40 lines, imported by the stories and\n * shown (live, with its code) by the documentation.\n */\ninterface ExampleBase {\n /** The file name, kebab-case (`primary`, `icon-button`). */\n readonly name: string;\n /** A short title (`Primary`, `Icon button`). */\n readonly title: string;\n /** One or two sentences: when this variant is the right one. */\n readonly description: string;\n}\n\n/** A plain example, or a template: a whole screen with its intent (`purpose`) and the user goal its layout serves (`why`). */\nexport type Example =\n | (ExampleBase & { readonly template?: false; readonly purpose?: undefined; readonly why?: undefined })\n | (ExampleBase & {\n /**\n * A template: a whole screen of a product composed from the platform (a layout and its blocks, real words, its\n * phone version thought out), copied as a starting point — at most 160 lines, listed on ui.krizaka.com/templates.\n */\n readonly template: true;\n /** The intent that groups it: why you need this block. */\n readonly purpose: TemplatePurpose;\n /** Why this layout: the user goal it serves, in one sentence. */\n readonly why: string;\n });\n\n/** One platform's side of a component. */\nexport interface PlatformDocs {\n /** The names to import (`[\"Button\", \"IconButton\"]`): from `@krizaka/ui/<name>` on the web, `@krizaka/ui/native` in React Native. */\n readonly imports: readonly string[];\n /** The examples, in reading order; the first one is the component's preview. */\n readonly examples: readonly Example[];\n}\n\n/** The React Native side: the same concept, and what differs from the web API. */\nexport interface NativeDocs extends PlatformDocs {\n /**\n * The entry to import from when it is not `@krizaka/ui/native`: a component that needs an Expo module (an optional\n * peer) has its own, `@krizaka/ui/native/<name>`, so an app that does not use it never installs the module.\n */\n readonly entry?: string;\n /** What differs from the web API (`label` instead of children…); empty for a native-only component. */\n readonly differences: readonly string[];\n /** The React Native entry alone is deprecated while the web one stays (ADR-006 §7); a deprecated component says it once, above. */\n readonly deprecated?: Deprecation;\n}\n\nexport interface KeyboardInteraction {\n /** The keys, as written on a keyboard: `Space`, `Enter`, `Arrow keys`, `Esc`, `Tab`. */\n readonly keys: string;\n /** What they do. */\n readonly action: string;\n}\n\nexport interface ComponentMeta {\n /** The display name: `Button`, `Dropdown menu`. */\n readonly title: string;\n /** One sentence: what it is. */\n readonly summary: string;\n readonly status: Status;\n /** Required for, and only for, a `deprecated` component. */\n readonly deprecated?: Deprecation;\n readonly category: Category;\n /** What it is for: one of the twelve domains (ADR-008 §3). */\n readonly domain: Domain;\n /** The `<repo>#<n>` issue of its first consumer: required for, and only for, an `experimental` component. */\n readonly adoption?: string;\n /** Must match the sides below: `both` ⇔ `web` and `native`. */\n readonly platforms: Platform;\n /** The platforms it is not on, and why; and its desktop form (see `Parity`). */\n readonly parity: Parity;\n /** When to reach for it: concrete situations, one per item. */\n readonly whenToUse: readonly string[];\n /** When not to — and what to use instead (`use`), when another component is the answer. */\n readonly whenNotToUse: readonly { readonly when: string; readonly use?: ComponentName }[];\n /** How to use it well: wording, placement, composition. */\n readonly bestPractices: readonly string[];\n readonly accessibility: {\n /** The keyboard, when it does more than Tab and Enter. */\n readonly keyboard: readonly KeyboardInteraction[];\n /** Roles, names and announcements: what the component does, what the app must provide. */\n readonly notes: readonly string[];\n };\n /** The components a reader of this page should know about. */\n readonly related: readonly ComponentName[];\n readonly web?: PlatformDocs;\n readonly native?: NativeDocs;\n}\n"
137
+ "content": "// The documentation of a component, carried by its code: each primitive has a `meta.ts` beside its source\n// (`src/<name>/meta.ts`; a component that exists only in React Native: `src/native/meta/<name>.ts`). Never built into\n// the package: `scripts/build-registry.mjs` reads them into `registry/<name>.json`, which ui.krizaka.com (apps/site) renders as\n// ui.krizaka.com/components/<name>, and `scripts/registry.test.mjs` fails when one is missing or incomplete.\n//\n// Why a typed module and not JSDoc tags: the fields are lists and links (`related`, `whenNotToUse[].use`, examples),\n// which a type checks and a comment does not; the file is plain data (erasable TypeScript), so Node reads it without a\n// compiler, and an editor completes it.\n\n/** Every documented component: the web primitives (one entry of the package each) and the native-only ones. */\nexport type ComponentName =\n | \"notification-preferences\"\n | \"quota-meter\"\n | \"environment-notice\"\n | \"embed-facade\"\n | \"reviews\"\n | \"margin-layout\"\n | \"analysis-report\"\n | \"status-chip\"\n | \"kind-config-editor\"\n | \"agenda\"\n | \"account-settings\"\n | \"drop-overlay\"\n | \"upload-queue\"\n | \"achievement\"\n | \"anatomy-plate\"\n | \"bird-plate\"\n | \"taped-photo\"\n | \"stuck\"\n | \"doodle\"\n | \"signature\"\n | \"grade-stamp\"\n | \"versus-card\"\n | \"speed-lines\"\n | \"site-cahier\"\n | \"text-style\"\n | \"flock\"\n | \"elephant\"\n | \"footnote\"\n | \"page-index\"\n | \"chapter\"\n | \"specimen-tag\"\n | \"action-bar\"\n | \"action-sheet\"\n | \"activity-feed\"\n | \"alert\"\n | \"app-frame\"\n | \"desktop-window\"\n | \"form-flow\"\n | \"grid\"\n | \"list-detail\"\n | \"state-screen\"\n | \"app-header\"\n | \"app-shell\"\n | \"argument-card\"\n | \"auth-layout\"\n | \"avatar\"\n | \"badge\"\n | \"button\"\n | \"captcha\"\n | \"card\"\n | \"card-grid\"\n | \"catalogue-page\"\n | \"changelog-page\"\n | \"chat\"\n | \"checkbox\"\n | \"chip\"\n | \"chip-link\"\n | \"chip-row\"\n | \"columns\"\n | \"choice-grid\"\n | \"cn\"\n | \"code-block\"\n | \"combobox\"\n | \"comparison-table\"\n | \"command\"\n | \"component-page\"\n | \"confirm-button\"\n | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\n | \"contact-page\"\n | \"continue-prompt\"\n | \"countdown\"\n | \"cover-hero\"\n | \"cta-panel\"\n | \"dashboard-layout\"\n | \"data-table\"\n | \"date-picker\"\n | \"decision-list\"\n | \"description-list\"\n | \"detail-layout\"\n | \"dialog\"\n | \"docs-article-page\"\n | \"docs-hub-page\"\n | \"docs-layout\"\n | \"docs-nav\"\n | \"document-viewer\"\n | \"dropdown-menu\"\n | \"empty-state\"\n | \"engine-flow\"\n | \"error-page\"\n | \"fab\"\n | \"field\"\n | \"file-upload\"\n | \"filter-bar\"\n | \"force-update-screen\"\n | \"form\"\n | \"gallery-page\"\n | \"genui\"\n | \"glossary\"\n | \"glossary-term\"\n | \"glow-card\"\n | \"goal-gauge\"\n | \"header\"\n | \"image-cropper\"\n | \"image-viewer\"\n | \"kanban\"\n | \"kbd\"\n | \"kpi-explained\"\n | \"landing-page\"\n | \"landscape\"\n | \"legal-page\"\n | \"link-card\"\n | \"list\"\n | \"loader\"\n | \"longform-page\"\n | \"maintenance-screen\"\n | \"map\"\n | \"markdown\"\n | \"waveform\"\n | \"proposal\"\n | \"qr-code\"\n | \"identity-card\"\n | \"entity-header\"\n | \"collection-switcher\"\n | \"marketing-layout\"\n | \"mascot-quote\"\n | \"mascot-state\"\n | \"mascots\"\n | \"match-dialog\"\n | \"media-capture\"\n | \"language-switch\"\n | \"media-gallery\"\n | \"media-picker\"\n | \"meter\"\n | \"nav-bar\"\n | \"number-ticker\"\n | \"onboarding\"\n | \"opening-hours\"\n | \"otp-input\"\n | \"page\"\n | \"page-header\"\n | \"page-hero\"\n | \"pagination\"\n | \"permission-prompt\"\n | \"pointer-light\"\n | \"popover\"\n | \"pricing-page\"\n | \"product-page\"\n | \"profile-card\"\n | \"progress\"\n | \"promise-card\"\n | \"pull-to-refresh\"\n | \"retro-tv\"\n | \"shop-gallery\"\n | \"radio-group\"\n | \"router\"\n | \"rail-nav\"\n | \"recipes\"\n | \"screen\"\n | \"scroll-stage\"\n | \"search-field\"\n | \"section-backdrop\"\n | \"segmented\"\n | \"separator\"\n | \"service-card\"\n | \"shop\"\n | \"shop-composer\"\n | \"schema-form\"\n | \"settings-layout\"\n | \"account-menu\"\n | \"showcase\"\n | \"step-showcase\"\n | \"site-footer\"\n | \"sites\"\n | \"skeleton\"\n | \"skip-link\"\n | \"slider\"\n | \"slot-picker\"\n | \"slot\"\n | \"spinner\"\n | \"sticky-action\"\n | \"splash-handoff\"\n | \"split-view\"\n | \"stage-banner\"\n | \"stat\"\n | \"usage\"\n | \"status-page\"\n | \"step-progress\"\n | \"stepper\"\n | \"swipe-deck\"\n | \"swipeable-row\"\n | \"switch\"\n | \"tab-bar\"\n | \"tabs\"\n | \"tag-input\"\n | \"tag-selector\"\n | \"terminal-replay\"\n | \"theme\"\n | \"toast\"\n | \"toc\"\n | \"tooltip\"\n | \"tree-view\"\n | \"txt\"\n | \"update-prompt\"\n | \"verified-badge\"\n | \"vertical-video\"\n | \"video-player\"\n | \"video-trimmer\"\n | \"virtual\"\n | \"wall\";\n\n/** Where a component exists: `@krizaka/ui/<name>` (web), `@krizaka/ui/native` (React Native), or both. */\nexport type Platform = \"web\" | \"native\" | \"both\";\n\n/**\n * Why a component is not on a platform — a decision, never a silence (the parity matrix of ui.krizaka.com/platforms):\n * - `gap` (✗): it belongs there and is not built yet; `issue` is the issue that tracks it (`krizaka/krizaka-ui#275`);\n * - `n/a`: it is not meant for that platform (a site's page block on a phone, a swipe on a desktop); `use` names the\n * component that answers there, when one does.\n */\nexport type Absence =\n | { readonly status: \"gap\"; readonly issue: string; readonly reason: string; readonly use?: undefined }\n | { readonly status: \"n/a\"; readonly reason: string; readonly use?: ComponentName; readonly issue?: undefined };\n\n/**\n * Desktop is the Sovkora Mac app (Tauri 2: the system WebView renders the web components — ADR-002). `web`: the web\n * component runs there as it is; `desktop`: it also has a desktop form (a window's title bar, a denser layout…), said in\n * its documentation; otherwise the absence and why.\n */\nexport type DesktopSupport = \"web\" | \"desktop\" | Absence;\n\n/**\n * The three platforms of Krizaka UI — web · native (React Native, Expo) · desktop — for one component. The side a\n * component has is `platforms`; the side it lacks says why here: `native` is required for (and only for) a web-only\n * component, `web` for a native-only one; `desktop` always. `scripts/registry.test.mjs` fails on a missing decision.\n */\nexport interface Parity {\n readonly web?: Absence;\n readonly native?: Absence;\n readonly desktop: DesktopSupport;\n}\n\n/**\n * `experimental`: created for a filed need (ADR-008 §4), it may change or go in any minor until its first consumer imports it; `adoption`\n * names that consumer's issue. `stable`: its API only changes in a major. `beta`: it may still change in a minor. `deprecated`: no product uses it and\n * no work plans to — it still works, says what replaces it, and goes in the major named by `deprecated.removedIn`.\n */\nexport type Status = \"experimental\" | \"stable\" | \"beta\" | \"deprecated\";\n\n/**\n * What a component is for (ADR-008 §3): the thirteen domains the documentation, the size budgets and the guards are\n * organised by. The domain is metadata: the entries stay flat (`@krizaka/ui/<name>`). `cahier` is the sites' register\n * (ADR-004): a product never imports it.\n */\nexport type Domain =\n | \"foundations\"\n | \"forms\"\n | \"data-display\"\n | \"navigation-shell\"\n | \"feedback\"\n | \"maps\"\n | \"media\"\n | \"commerce\"\n | \"identity\"\n | \"abuse\"\n | \"conversation\"\n | \"page-blocks\"\n | \"cahier\";\n\n/** What a deprecated component says (required when `status` is `deprecated`, absent otherwise). */\nexport interface Deprecation {\n /** The version that deprecated it (`3.6.0`). */\n readonly since: string;\n /** The major that removes it (`4.0.0`). */\n readonly removedIn: string;\n /** What replaces it, when a component does. */\n readonly use?: ComponentName;\n /** Why it goes: no product uses it, no planned work needs it. */\n readonly reason: string;\n}\n\n/**\n * The group of the catalogue. `media`: video, sound, camera, files, cropping. `blocks`: the page blocks — the frame,\n * the hero, sections, cards that lead or argue, decisions, code, calls to act — that every page of a site is made of.\n * `layouts`: the shells of whole screens — an application, a dashboard, settings, sign-in, an object, a list and its\n * item, a site's page, a documentation page — each with its screens. `templates`: the page templates — whole pages of a\n * site (a landing, a product, a docs hub, a long read, a changelog, pricing, status, an error…), each a distinct\n * composition of the blocks, words and content as props.\n */\nexport type Category = \"actions\" | \"forms\" | \"navigation\" | \"overlays\" | \"feedback\" | \"data-display\" | \"media\" | \"blocks\" | \"layouts\" | \"templates\" | \"layout\" | \"foundations\";\n\n/** Why a reader needs a template: the seven intents the templates are grouped by (sidebar sub-headings, catalogue filter). */\nexport type TemplatePurpose = \"convince\" | \"explain\" | \"show\" | \"act\" | \"operate\" | \"converse\" | \"recover\";\n\n/** The groups of templates, in reading order: the title, and the one line that says when to come to that group. */\nexport const templatePurposes = {\n convince: { title: \"Convince\", useWhen: \"You come here when a visitor must decide: a landing, a product, a price, a comparison, a proof.\" },\n explain: { title: \"Explain\", useWhen: \"You come here when a reader must understand: how it works, a documentation hub or article, a changelog, a FAQ, a policy.\" },\n show: { title: \"Show\", useWhen: \"You come here when the work itself is the argument: a gallery, a story, a case study, an object and its details.\" },\n act: { title: \"Act\", useWhen: \"You come here when a person must do something once: reach the team, sign in or up, set up, pay.\" },\n operate: { title: \"Operate\", useWhen: \"You come here when a person works every day: a dashboard, a console with a table, settings, an app shell.\" },\n converse: { title: \"Converse\", useWhen: \"You come here when people talk: an inbox, a chat, comments, a notifications centre.\" },\n recover: { title: \"Recover\", useWhen: \"You come here when the way is blocked: an empty list, an error, a missing page, maintenance, a product still being built.\" },\n} as const satisfies Record<TemplatePurpose, { readonly title: string; readonly useWhen: string }>;\n\n/**\n * A named example: the file `registry/examples/<component>/<name>.tsx` (web) or\n * `registry/examples/<component>/native/<name>.tsx` (React Native) — at most 40 lines, imported by the stories and\n * shown (live, with its code) by the documentation.\n */\ninterface ExampleBase {\n /** The file name, kebab-case (`primary`, `icon-button`). */\n readonly name: string;\n /** A short title (`Primary`, `Icon button`). */\n readonly title: string;\n /** One or two sentences: when this variant is the right one. */\n readonly description: string;\n}\n\n/** A plain example, or a template: a whole screen with its intent (`purpose`) and the user goal its layout serves (`why`). */\nexport type Example =\n | (ExampleBase & { readonly template?: false; readonly purpose?: undefined; readonly why?: undefined })\n | (ExampleBase & {\n /**\n * A template: a whole screen of a product composed from the platform (a layout and its blocks, real words, its\n * phone version thought out), copied as a starting point — at most 160 lines, listed on ui.krizaka.com/templates.\n */\n readonly template: true;\n /** The intent that groups it: why you need this block. */\n readonly purpose: TemplatePurpose;\n /** Why this layout: the user goal it serves, in one sentence. */\n readonly why: string;\n });\n\n/** One platform's side of a component. */\nexport interface PlatformDocs {\n /** The names to import (`[\"Button\", \"IconButton\"]`): from `@krizaka/ui/<name>` on the web, `@krizaka/ui/native` in React Native. */\n readonly imports: readonly string[];\n /** The examples, in reading order; the first one is the component's preview. */\n readonly examples: readonly Example[];\n}\n\n/** The React Native side: the same concept, and what differs from the web API. */\nexport interface NativeDocs extends PlatformDocs {\n /**\n * The entry to import from when it is not `@krizaka/ui/native`: a component that needs an Expo module (an optional\n * peer) has its own, `@krizaka/ui/native/<name>`, so an app that does not use it never installs the module.\n */\n readonly entry?: string;\n /** What differs from the web API (`label` instead of children…); empty for a native-only component. */\n readonly differences: readonly string[];\n /** The React Native entry alone is deprecated while the web one stays (ADR-006 §7); a deprecated component says it once, above. */\n readonly deprecated?: Deprecation;\n}\n\nexport interface KeyboardInteraction {\n /** The keys, as written on a keyboard: `Space`, `Enter`, `Arrow keys`, `Esc`, `Tab`. */\n readonly keys: string;\n /** What they do. */\n readonly action: string;\n}\n\nexport interface ComponentMeta {\n /** The display name: `Button`, `Dropdown menu`. */\n readonly title: string;\n /** One sentence: what it is. */\n readonly summary: string;\n readonly status: Status;\n /** Required for, and only for, a `deprecated` component. */\n readonly deprecated?: Deprecation;\n readonly category: Category;\n /** What it is for: one of the twelve domains (ADR-008 §3). */\n readonly domain: Domain;\n /** The `<repo>#<n>` issue of its first consumer: required for, and only for, an `experimental` component. */\n readonly adoption?: string;\n /** Must match the sides below: `both` ⇔ `web` and `native`. */\n readonly platforms: Platform;\n /** The platforms it is not on, and why; and its desktop form (see `Parity`). */\n readonly parity: Parity;\n /** When to reach for it: concrete situations, one per item. */\n readonly whenToUse: readonly string[];\n /** When not to — and what to use instead (`use`), when another component is the answer. */\n readonly whenNotToUse: readonly { readonly when: string; readonly use?: ComponentName }[];\n /** How to use it well: wording, placement, composition. */\n readonly bestPractices: readonly string[];\n readonly accessibility: {\n /** The keyboard, when it does more than Tab and Enter. */\n readonly keyboard: readonly KeyboardInteraction[];\n /** Roles, names and announcements: what the component does, what the app must provide. */\n readonly notes: readonly string[];\n };\n /** The components a reader of this page should know about. */\n readonly related: readonly ComponentName[];\n readonly web?: PlatformDocs;\n readonly native?: NativeDocs;\n}\n"
138
138
  },
139
139
  {
140
140
  "path": "shop-gallery/index.ts",
@@ -146,7 +146,7 @@
146
146
  },
147
147
  {
148
148
  "path": "shop-gallery/lightbox.tsx",
149
- "content": "\"use client\";\n\n// The lightbox: loaded as a lazy chunk, only once a photo is opened. A Dialog (focus trapped, Escape, scroll lock), arrow\n// keys and a horizontal swipe, the photo at full resolution and its alt text as the caption.\nimport * as React from \"react\";\n\nimport { IconButton } from \"../button/button\";\nimport { Dialog } from \"../dialog\";\nimport type { ShopGalleryLabels } from \"./labels\";\nimport type { ShopGalleryPhoto } from \"./shop-gallery\";\n\nconst SWIPE = 50;\n\nfunction Arrow({ dir }: { dir: \"left\" | \"right\" }) {\n return (\n <svg viewBox=\"0 0 24 24\" className=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d={dir === \"left\" ? \"m15 6-6 6 6 6\" : \"m9 6 6 6-6 6\"} />\n </svg>\n );\n}\n\nexport type ShopGalleryLightboxProps = {\n photos: readonly ShopGalleryPhoto[];\n index: number;\n onIndexChange: (index: number) => void;\n onClose: () => void;\n label: string;\n labels: ShopGalleryLabels;\n /** Where focus goes back to when it closes. */\n returnFocus: () => HTMLElement | null;\n};\n\nexport default function ShopGalleryLightbox({ photos, index, onIndexChange, onClose, label, labels, returnFocus }: ShopGalleryLightboxProps) {\n const total = photos.length;\n const photo = photos[index];\n const startX = React.useRef<number | null>(null);\n const go = (to: number) => onIndexChange(((to % total) + total) % total);\n if (!photo) return null;\n const preload = [photos[(index + 1) % total], photos[(index - 1 + total) % total]];\n return (\n <Dialog.Root open onOpenChange={(open) => !open && onClose()}>\n <Dialog.Content\n closeLabel={labels.close}\n size=\"lg\"\n className=\"kz-sg-lightbox sm:max-w-5xl\"\n onCloseAutoFocus={(event) => {\n const target = returnFocus();\n if (target) {\n event.preventDefault();\n target.focus();\n }\n }}\n onKeyDown={(event) => {\n if (event.key === \"ArrowLeft\") go(index - 1);\n else if (event.key === \"ArrowRight\") go(index + 1);\n }}\n >\n <style>{`.kz-sg-stage{touch-action:pan-y}.kz-sg-lightbox img{user-select:none;-webkit-user-drag:none}@media (prefers-reduced-motion:no-preference){.kz-sg-photo{animation:kz-sg-in .22s ease-out}}@keyframes kz-sg-in{from{opacity:.4}to{opacity:1}}`}</style>\n <Dialog.Header>\n <Dialog.Title className=\"sr-only\">{labels.title(label)}</Dialog.Title>\n <p className=\"m-0 text-sm text-fg-secondary\" aria-live=\"polite\">{labels.position(index + 1, total)}</p>\n </Dialog.Header>\n <Dialog.Body className=\"flex flex-col gap-3\">\n <div\n className=\"kz-sg-stage relative flex items-center justify-center\"\n onTouchStart={(event) => {\n startX.current = event.touches[0]?.clientX ?? null;\n }}\n onTouchEnd={(event) => {\n const from = startX.current;\n const to = event.changedTouches[0]?.clientX;\n startX.current = null;\n if (from === null || to === undefined) return;\n if (to - from <= -SWIPE) go(index + 1);\n else if (to - from >= SWIPE) go(index - 1);\n }}\n >\n <img\n key={photo.id}\n src={photo.fullSrc ?? photo.src}\n srcSet={photo.fullSrcSet ?? photo.srcSet}\n sizes={photo.fullSrcSet ?? photo.srcSet ? \"(min-width: 64rem) 64rem, 100vw\" : undefined}\n alt={photo.alt}\n decoding=\"async\"\n className=\"kz-sg-photo max-h-[68dvh] w-full rounded-lg object-contain\"\n />\n {total > 1 && (\n <>\n <IconButton label={labels.previous} variant=\"secondary\" shape=\"pill\" className=\"absolute left-2 top-1/2 -translate-y-1/2\" onClick={() => go(index - 1)}>\n <Arrow dir=\"left\" />\n </IconButton>\n <IconButton label={labels.next} variant=\"secondary\" shape=\"pill\" className=\"absolute right-2 top-1/2 -translate-y-1/2\" onClick={() => go(index + 1)}>\n <Arrow dir=\"right\" />\n </IconButton>\n </>\n )}\n </div>\n <Dialog.Description className=\"m-0 min-h-5 text-center\">{photo.alt}</Dialog.Description>\n <div hidden aria-hidden>\n {preload.map((p) => p && p.id !== photo.id && <img key={p.id} src={p.fullSrc ?? p.src} alt=\"\" />)}\n </div>\n </Dialog.Body>\n </Dialog.Content>\n </Dialog.Root>\n );\n}\n"
149
+ "content": "\"use client\";\n\n// The lightbox: loaded as a lazy chunk, only once a photo is opened. A Dialog (focus trapped, Escape, scroll lock), arrow\n// keys and a horizontal swipe, the photo at full resolution and its alt text as the caption.\nimport * as React from \"react\";\n\nimport { IconButton } from \"../button/button\";\nimport { Dialog } from \"../dialog\";\nimport type { ShopGalleryLabels } from \"./labels\";\nimport type { ShopGalleryPhoto } from \"./shop-gallery\";\n\nconst SWIPE = 50;\n\nfunction Arrow({ dir }: Readonly<{ dir: \"left\" | \"right\" }>) {\n return (\n <svg viewBox=\"0 0 24 24\" className=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d={dir === \"left\" ? \"m15 6-6 6 6 6\" : \"m9 6 6 6-6 6\"} />\n </svg>\n );\n}\n\nexport type ShopGalleryLightboxProps = {\n photos: readonly ShopGalleryPhoto[];\n index: number;\n onIndexChange: (index: number) => void;\n onClose: () => void;\n label: string;\n labels: ShopGalleryLabels;\n /** Where focus goes back to when it closes. */\n returnFocus: () => HTMLElement | null;\n};\n\nexport default function ShopGalleryLightbox({ photos, index, onIndexChange, onClose, label, labels, returnFocus }: Readonly<ShopGalleryLightboxProps>) {\n const total = photos.length;\n const photo = photos[index];\n const startX = React.useRef<number | null>(null);\n const go = (to: number) => onIndexChange(((to % total) + total) % total);\n if (!photo) return null;\n const preload = [photos[(index + 1) % total], photos[(index - 1 + total) % total]];\n return (\n <Dialog.Root open onOpenChange={(open) => !open && onClose()}>\n <Dialog.Content\n closeLabel={labels.close}\n size=\"lg\"\n className=\"kz-sg-lightbox sm:max-w-5xl\"\n onCloseAutoFocus={(event) => {\n const target = returnFocus();\n if (target) {\n event.preventDefault();\n target.focus();\n }\n }}\n onKeyDown={(event) => {\n if (event.key === \"ArrowLeft\") go(index - 1);\n else if (event.key === \"ArrowRight\") go(index + 1);\n }}\n >\n <style>{`.kz-sg-stage{touch-action:pan-y}.kz-sg-lightbox img{user-select:none;-webkit-user-drag:none}@media (prefers-reduced-motion:no-preference){.kz-sg-photo{animation:kz-sg-in .22s ease-out}}@keyframes kz-sg-in{from{opacity:.4}to{opacity:1}}`}</style>\n <Dialog.Header>\n <Dialog.Title className=\"sr-only\">{labels.title(label)}</Dialog.Title>\n <p className=\"m-0 text-sm text-fg-secondary\" aria-live=\"polite\">{labels.position(index + 1, total)}</p>\n </Dialog.Header>\n <Dialog.Body className=\"flex flex-col gap-3\">\n <div\n className=\"kz-sg-stage relative flex items-center justify-center\"\n onTouchStart={(event) => {\n startX.current = event.touches[0]?.clientX ?? null;\n }}\n onTouchEnd={(event) => {\n const from = startX.current;\n const to = event.changedTouches[0]?.clientX;\n startX.current = null;\n if (from === null || to === undefined) return;\n if (to - from <= -SWIPE) go(index + 1);\n else if (to - from >= SWIPE) go(index - 1);\n }}\n >\n <img\n key={photo.id}\n src={photo.fullSrc ?? photo.src}\n srcSet={photo.fullSrcSet ?? photo.srcSet}\n sizes={photo.fullSrcSet ?? photo.srcSet ? \"(min-width: 64rem) 64rem, 100vw\" : undefined}\n alt={photo.alt}\n decoding=\"async\"\n className=\"kz-sg-photo max-h-[68dvh] w-full rounded-lg object-contain\"\n />\n {total > 1 && (\n <>\n <IconButton label={labels.previous} variant=\"secondary\" shape=\"pill\" className=\"absolute left-2 top-1/2 -translate-y-1/2\" onClick={() => go(index - 1)}>\n <Arrow dir=\"left\" />\n </IconButton>\n <IconButton label={labels.next} variant=\"secondary\" shape=\"pill\" className=\"absolute right-2 top-1/2 -translate-y-1/2\" onClick={() => go(index + 1)}>\n <Arrow dir=\"right\" />\n </IconButton>\n </>\n )}\n </div>\n <Dialog.Description className=\"m-0 min-h-5 text-center\">{photo.alt}</Dialog.Description>\n <div hidden aria-hidden>\n {preload.map((p) => p && p.id !== photo.id && <img key={p.id} src={p.fullSrc ?? p.src} alt=\"\" />)}\n </div>\n </Dialog.Body>\n </Dialog.Content>\n </Dialog.Root>\n );\n}\n"
150
150
  },
151
151
  {
152
152
  "path": "shop-gallery/meta.ts",