@krizaka/ui 4.7.0 → 4.7.1

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 (933) hide show
  1. package/dist/{RotatingWord-D3tpDLE4.d.ts → RotatingWord-CkDcPH9x.d.ts} +2 -2
  2. package/dist/account-menu.js +2 -2
  3. package/dist/account-menu.js.map +1 -1
  4. package/dist/account-settings.d.ts +9 -9
  5. package/dist/account-settings.js +4 -4
  6. package/dist/account-settings.js.map +1 -1
  7. package/dist/achievement.d.ts +3 -3
  8. package/dist/achievement.js +1 -1
  9. package/dist/achievement.js.map +1 -1
  10. package/dist/action-bar.d.ts +1 -1
  11. package/dist/action-bar.js +5 -5
  12. package/dist/action-bar.js.map +1 -1
  13. package/dist/activity-feed.d.ts +2 -2
  14. package/dist/activity-feed.js +1 -1
  15. package/dist/activity-feed.js.map +1 -1
  16. package/dist/alert.d.ts +1 -1
  17. package/dist/alert.js.map +1 -1
  18. package/dist/analysis-report.d.ts +1 -1
  19. package/dist/analysis-report.js +4 -4
  20. package/dist/analysis-report.js.map +1 -1
  21. package/dist/anatomy-plate.d.ts +1 -1
  22. package/dist/anatomy-plate.js +1 -1
  23. package/dist/anatomy-plate.js.map +1 -1
  24. package/dist/app-header/search.d.ts +1 -1
  25. package/dist/app-header/search.js +2 -2
  26. package/dist/app-header/search.js.map +1 -1
  27. package/dist/app-header.d.ts +2 -2
  28. package/dist/app-header.js.map +1 -1
  29. package/dist/app-shell.d.ts +8 -8
  30. package/dist/app-shell.js +4 -4
  31. package/dist/app-shell.js.map +1 -1
  32. package/dist/architecture-diagram.d.ts +1 -1
  33. package/dist/architecture-diagram.js.map +1 -1
  34. package/dist/argument-card.d.ts +2 -2
  35. package/dist/argument-card.js +6 -6
  36. package/dist/argument-card.js.map +1 -1
  37. package/dist/auth-layout.d.ts +1 -1
  38. package/dist/auth-layout.js.map +1 -1
  39. package/dist/avatar.d.ts +2 -2
  40. package/dist/avatar.js.map +1 -1
  41. package/dist/badge.d.ts +1 -1
  42. package/dist/badge.js +1 -1
  43. package/dist/bird-plate.d.ts +1 -1
  44. package/dist/bird-plate.js +2 -2
  45. package/dist/bird-plate.js.map +1 -1
  46. package/dist/button.d.ts +2 -2
  47. package/dist/button.js +3 -3
  48. package/dist/captcha.d.ts +2 -2
  49. package/dist/captcha.js +3 -3
  50. package/dist/captcha.js.map +1 -1
  51. package/dist/card-grid.d.ts +1 -1
  52. package/dist/card-grid.js +1 -1
  53. package/dist/card-grid.js.map +1 -1
  54. package/dist/card.d.ts +9 -9
  55. package/dist/card.js +1 -1
  56. package/dist/card.js.map +1 -1
  57. package/dist/catalogue-page.d.ts +2 -2
  58. package/dist/catalogue-page.js.map +1 -1
  59. package/dist/changelog-page.d.ts +1 -1
  60. package/dist/changelog-page.js +2 -2
  61. package/dist/changelog-page.js.map +1 -1
  62. package/dist/chapter.d.ts +3 -3
  63. package/dist/chapter.js +2 -2
  64. package/dist/chapter.js.map +1 -1
  65. package/dist/chat.d.ts +3 -3
  66. package/dist/chat.js +1 -1
  67. package/dist/chat.js.map +1 -1
  68. package/dist/checkbox.d.ts +1 -1
  69. package/dist/checkbox.js.map +1 -1
  70. package/dist/chip-link.d.ts +1 -1
  71. package/dist/chip-link.js +1 -1
  72. package/dist/chip-row.d.ts +2 -2
  73. package/dist/chip-row.js +1 -1
  74. package/dist/chip-row.js.map +1 -1
  75. package/dist/chip.d.ts +4 -5
  76. package/dist/chip.js +2 -2
  77. package/dist/choice-grid.d.ts +1 -1
  78. package/dist/choice-grid.js +2 -2
  79. package/dist/choice-grid.js.map +1 -1
  80. package/dist/{chunk-S6NYGOJT.js → chunk-22IORLB5.js} +1 -1
  81. package/dist/chunk-22IORLB5.js.map +1 -0
  82. package/dist/{chunk-QA3WETWT.js → chunk-2P7Y3LNN.js} +1 -1
  83. package/dist/chunk-2P7Y3LNN.js.map +1 -0
  84. package/dist/{chunk-OGWB76BR.js → chunk-3CEMOJBL.js} +2 -2
  85. package/dist/chunk-3CEMOJBL.js.map +1 -0
  86. package/dist/{chunk-WC3SO4CE.js → chunk-3SWWUJJL.js} +2 -2
  87. package/dist/chunk-3SWWUJJL.js.map +1 -0
  88. package/dist/{chunk-S2O4NSN5.js → chunk-3TCHVNNB.js} +1 -1
  89. package/dist/chunk-3TCHVNNB.js.map +1 -0
  90. package/dist/{chunk-7P7I5OQV.js → chunk-5KBYZLU4.js} +2 -2
  91. package/dist/chunk-5KBYZLU4.js.map +1 -0
  92. package/dist/{chunk-WKQ5CB3I.js → chunk-6ARAO3TR.js} +1 -1
  93. package/dist/{chunk-WKQ5CB3I.js.map → chunk-6ARAO3TR.js.map} +1 -1
  94. package/dist/{chunk-QHVV2JGF.js → chunk-6LF6IZZM.js} +2 -2
  95. package/dist/chunk-6LF6IZZM.js.map +1 -0
  96. package/dist/{chunk-HP7BDMVK.js → chunk-7B5Q76JR.js} +2 -2
  97. package/dist/chunk-7B5Q76JR.js.map +1 -0
  98. package/dist/{chunk-F2UZ2WWL.js → chunk-7KIIAOQH.js} +1 -1
  99. package/dist/{chunk-F2UZ2WWL.js.map → chunk-7KIIAOQH.js.map} +1 -1
  100. package/dist/{chunk-ADRUEPYC.js → chunk-7MA3UODW.js} +2 -2
  101. package/dist/{chunk-ADRUEPYC.js.map → chunk-7MA3UODW.js.map} +1 -1
  102. package/dist/{chunk-KH3JOEPY.js → chunk-7PVLEALV.js} +1 -1
  103. package/dist/chunk-7PVLEALV.js.map +1 -0
  104. package/dist/{chunk-QVHSV6RA.js → chunk-7UBLUGNW.js} +1 -1
  105. package/dist/chunk-7UBLUGNW.js.map +1 -0
  106. package/dist/{chunk-YTYNKMNS.js → chunk-BKMHN4UA.js} +5 -5
  107. package/dist/chunk-BKMHN4UA.js.map +1 -0
  108. package/dist/{chunk-4QH6CP2Y.js → chunk-BRYRZWLV.js} +1 -1
  109. package/dist/{chunk-4QH6CP2Y.js.map → chunk-BRYRZWLV.js.map} +1 -1
  110. package/dist/{chunk-43PTCDTL.js → chunk-BVN7JFOP.js} +1 -1
  111. package/dist/chunk-BVN7JFOP.js.map +1 -0
  112. package/dist/{chunk-5RWHDX5J.js → chunk-BYKA3FHX.js} +2 -2
  113. package/dist/chunk-BYKA3FHX.js.map +1 -0
  114. package/dist/{chunk-5PFCELGW.js → chunk-DIOAQOR5.js} +1 -1
  115. package/dist/chunk-DIOAQOR5.js.map +1 -0
  116. package/dist/{chunk-HJFRHYCI.js → chunk-DTGRZXYO.js} +2 -2
  117. package/dist/{chunk-P7AFIKWG.js → chunk-DVC4YQI2.js} +2 -2
  118. package/dist/chunk-DVC4YQI2.js.map +1 -0
  119. package/dist/{chunk-V5RO6JYI.js → chunk-E3LFHTUV.js} +2 -2
  120. package/dist/chunk-E3LFHTUV.js.map +1 -0
  121. package/dist/{chunk-WEVYKZIF.js → chunk-EAXIDRMB.js} +1 -1
  122. package/dist/chunk-EAXIDRMB.js.map +1 -0
  123. package/dist/{chunk-WU4VLSEA.js → chunk-EYMS6VRF.js} +1 -1
  124. package/dist/chunk-EYMS6VRF.js.map +1 -0
  125. package/dist/{chunk-LH5J3VLZ.js → chunk-F7EJZV53.js} +1 -1
  126. package/dist/chunk-F7EJZV53.js.map +1 -0
  127. package/dist/{chunk-VPO27AFS.js → chunk-G3L7AKZJ.js} +1 -1
  128. package/dist/chunk-G3L7AKZJ.js.map +1 -0
  129. package/dist/{chunk-EB45EVPJ.js → chunk-G5NROYGK.js} +3 -3
  130. package/dist/chunk-G5NROYGK.js.map +1 -0
  131. package/dist/{chunk-HKEAYSFS.js → chunk-GQMINKT3.js} +1 -1
  132. package/dist/{chunk-ENOS6ETI.js.map → chunk-GQMINKT3.js.map} +1 -1
  133. package/dist/{chunk-3X3OF4TI.js → chunk-H4NXYAL7.js} +1 -1
  134. package/dist/{chunk-3X3OF4TI.js.map → chunk-H4NXYAL7.js.map} +1 -1
  135. package/dist/{chunk-KR2W4ONJ.js → chunk-H7I6YLI6.js} +1 -1
  136. package/dist/chunk-H7I6YLI6.js.map +1 -0
  137. package/dist/{chunk-PJNR4NTS.js → chunk-HC2TY45B.js} +4 -4
  138. package/dist/{chunk-NSLXEDIS.js → chunk-HHBTM4AU.js} +1 -1
  139. package/dist/chunk-HHBTM4AU.js.map +1 -0
  140. package/dist/{chunk-XVRKKYWU.js → chunk-HVUR3UNK.js} +2 -2
  141. package/dist/{chunk-XVRKKYWU.js.map → chunk-HVUR3UNK.js.map} +1 -1
  142. package/dist/{chunk-V7W4RLRW.js → chunk-HWIDTLLO.js} +3 -3
  143. package/dist/chunk-HWIDTLLO.js.map +1 -0
  144. package/dist/{chunk-W675RFOA.js → chunk-ISC2QBXJ.js} +1 -1
  145. package/dist/chunk-ISC2QBXJ.js.map +1 -0
  146. package/dist/{chunk-7DYZTEE3.js → chunk-IWPB6SSW.js} +1 -1
  147. package/dist/chunk-IWPB6SSW.js.map +1 -0
  148. package/dist/{chunk-TVLRE7S3.js → chunk-JDVWUF5W.js} +2 -2
  149. package/dist/{chunk-TVLRE7S3.js.map → chunk-JDVWUF5W.js.map} +1 -1
  150. package/dist/{chunk-757ZTGU5.js → chunk-JE2NY4XE.js} +4 -4
  151. package/dist/chunk-JE2NY4XE.js.map +1 -0
  152. package/dist/{chunk-HLEBSAGC.js → chunk-KBSZ6JRF.js} +2 -2
  153. package/dist/chunk-KBSZ6JRF.js.map +1 -0
  154. package/dist/{chunk-Y3P5B4XS.js → chunk-KCU45KQ3.js} +3 -3
  155. package/dist/chunk-KCU45KQ3.js.map +1 -0
  156. package/dist/{chunk-ST5P5HNI.js → chunk-L4YBG5US.js} +4 -4
  157. package/dist/{chunk-ST5P5HNI.js.map → chunk-L4YBG5US.js.map} +1 -1
  158. package/dist/{chunk-NG6G6V5E.js → chunk-LFH3LEWR.js} +1 -1
  159. package/dist/chunk-LFH3LEWR.js.map +1 -0
  160. package/dist/{chunk-YATTFMDV.js → chunk-LSQQSJ6J.js} +2 -2
  161. package/dist/{chunk-YATTFMDV.js.map → chunk-LSQQSJ6J.js.map} +1 -1
  162. package/dist/{chunk-LNAAWT4Y.js → chunk-MJWOZ3JI.js} +1 -1
  163. package/dist/chunk-MJWOZ3JI.js.map +1 -0
  164. package/dist/{chunk-KID32IRJ.js → chunk-MXHJMTZ5.js} +1 -1
  165. package/dist/{chunk-KID32IRJ.js.map → chunk-MXHJMTZ5.js.map} +1 -1
  166. package/dist/{chunk-GHAN7OOE.js → chunk-N6LAWI4F.js} +2 -2
  167. package/dist/chunk-N6LAWI4F.js.map +1 -0
  168. package/dist/{chunk-5VZ37TY3.js → chunk-NFJWD5BT.js} +2 -2
  169. package/dist/chunk-NFJWD5BT.js.map +1 -0
  170. package/dist/{chunk-ZPOVOEO3.js → chunk-NJLIHGU4.js} +2 -2
  171. package/dist/chunk-NJLIHGU4.js.map +1 -0
  172. package/dist/{chunk-PRD7JRQX.js → chunk-ONCQWOTH.js} +4 -4
  173. package/dist/{chunk-PRD7JRQX.js.map → chunk-ONCQWOTH.js.map} +1 -1
  174. package/dist/{chunk-ENOS6ETI.js → chunk-OZC6CDZF.js} +1 -1
  175. package/dist/{chunk-HKEAYSFS.js.map → chunk-OZC6CDZF.js.map} +1 -1
  176. package/dist/{chunk-TXFX4PMN.js → chunk-OZY4C4W5.js} +1 -1
  177. package/dist/{chunk-TXFX4PMN.js.map → chunk-OZY4C4W5.js.map} +1 -1
  178. package/dist/{chunk-NPMGYLJV.js → chunk-PIRYDEX2.js} +3 -3
  179. package/dist/chunk-PIRYDEX2.js.map +1 -0
  180. package/dist/{chunk-C57KK5VB.js → chunk-PM23USOC.js} +1 -1
  181. package/dist/chunk-PM23USOC.js.map +1 -0
  182. package/dist/{chunk-PGBF3UBX.js → chunk-QKL5TECH.js} +1 -1
  183. package/dist/chunk-QKL5TECH.js.map +1 -0
  184. package/dist/{chunk-Z47KIPCT.js → chunk-QY5JEUJT.js} +1 -1
  185. package/dist/chunk-QY5JEUJT.js.map +1 -0
  186. package/dist/{chunk-FVGFPB73.js → chunk-RPVKF4RR.js} +1 -1
  187. package/dist/{chunk-FVGFPB73.js.map → chunk-RPVKF4RR.js.map} +1 -1
  188. package/dist/{chunk-NM2DEHFZ.js → chunk-RXYKJIC4.js} +1 -1
  189. package/dist/chunk-RXYKJIC4.js.map +1 -0
  190. package/dist/{chunk-W64RAX4N.js → chunk-TKYNYIJS.js} +5 -5
  191. package/dist/chunk-TKYNYIJS.js.map +1 -0
  192. package/dist/{chunk-S4TLZRGZ.js → chunk-UMXWOA3I.js} +1 -1
  193. package/dist/chunk-UMXWOA3I.js.map +1 -0
  194. package/dist/{chunk-VA4NPCUQ.js → chunk-VD7QFUAP.js} +3 -3
  195. package/dist/chunk-VD7QFUAP.js.map +1 -0
  196. package/dist/{chunk-MDSP7DJR.js → chunk-VQELCPQJ.js} +5 -5
  197. package/dist/chunk-VQELCPQJ.js.map +1 -0
  198. package/dist/{chunk-2FCQCWIK.js → chunk-VXNBXW3P.js} +5 -5
  199. package/dist/chunk-VXNBXW3P.js.map +1 -0
  200. package/dist/{chunk-B47WSPMP.js → chunk-WPUDPH2Q.js} +1 -1
  201. package/dist/chunk-WPUDPH2Q.js.map +1 -0
  202. package/dist/{chunk-SG2RKUVJ.js → chunk-WTZUMVJI.js} +5 -5
  203. package/dist/chunk-WTZUMVJI.js.map +1 -0
  204. package/dist/{chunk-EDQLPCM4.js → chunk-WVZF6WK3.js} +2 -2
  205. package/dist/chunk-WVZF6WK3.js.map +1 -0
  206. package/dist/{chunk-5D7NMUF6.js → chunk-XDAETKWM.js} +2 -2
  207. package/dist/chunk-XDAETKWM.js.map +1 -0
  208. package/dist/{chunk-QD6SNXF5.js → chunk-XDWSGNL4.js} +3 -3
  209. package/dist/chunk-XDWSGNL4.js.map +1 -0
  210. package/dist/{chunk-SB5WSVPI.js → chunk-ZFH2BYXW.js} +2 -2
  211. package/dist/chunk-ZFH2BYXW.js.map +1 -0
  212. package/dist/{chunk-XVLWVTQA.js → chunk-ZI7K742O.js} +1 -1
  213. package/dist/{chunk-XVLWVTQA.js.map → chunk-ZI7K742O.js.map} +1 -1
  214. package/dist/{chunk-NQENOT6L.js → chunk-ZRRWSKV3.js} +8 -8
  215. package/dist/chunk-ZRRWSKV3.js.map +1 -0
  216. package/dist/cn.js +1 -1
  217. package/dist/code-block.d.ts +2 -2
  218. package/dist/code-block.js +2 -2
  219. package/dist/code-block.js.map +1 -1
  220. package/dist/collection-switcher.d.ts +1 -1
  221. package/dist/collection-switcher.js +1 -1
  222. package/dist/collection-switcher.js.map +1 -1
  223. package/dist/columns.d.ts +2 -2
  224. package/dist/columns.js.map +1 -1
  225. package/dist/combobox.js +4 -4
  226. package/dist/command.d.ts +10 -10
  227. package/dist/command.js +4 -4
  228. package/dist/command.js.map +1 -1
  229. package/dist/comparison-table.d.ts +1 -1
  230. package/dist/comparison-table.js +1 -1
  231. package/dist/comparison-table.js.map +1 -1
  232. package/dist/component-page.d.ts +1 -1
  233. package/dist/component-page.js.map +1 -1
  234. package/dist/confirm-button.d.ts +1 -1
  235. package/dist/confirm-button.js +4 -4
  236. package/dist/contact-page.d.ts +1 -1
  237. package/dist/contact-page.js.map +1 -1
  238. package/dist/continue-prompt.d.ts +1 -1
  239. package/dist/continue-prompt.js +1 -1
  240. package/dist/continue-prompt.js.map +1 -1
  241. package/dist/copy-button.d.ts +1 -1
  242. package/dist/copy-button.js +4 -4
  243. package/dist/copy-button.js.map +1 -1
  244. package/dist/countdown.d.ts +1 -1
  245. package/dist/countdown.js.map +1 -1
  246. package/dist/cover-hero.d.ts +1 -1
  247. package/dist/cover-hero.js +5 -5
  248. package/dist/cover-hero.js.map +1 -1
  249. package/dist/cta-panel.d.ts +1 -1
  250. package/dist/cta-panel.js +1 -1
  251. package/dist/cta-panel.js.map +1 -1
  252. package/dist/dashboard-layout.d.ts +2 -2
  253. package/dist/dashboard-layout.js.map +1 -1
  254. package/dist/data-table.d.ts +5 -5
  255. package/dist/data-table.js +9 -9
  256. package/dist/date-picker.d.ts +11 -11
  257. package/dist/date-picker.js +5 -5
  258. package/dist/date-picker.js.map +1 -1
  259. package/dist/decision-list.d.ts +1 -1
  260. package/dist/decision-list.js +2 -2
  261. package/dist/decision-list.js.map +1 -1
  262. package/dist/description-list.d.ts +2 -2
  263. package/dist/description-list.js.map +1 -1
  264. package/dist/detail-layout.d.ts +5 -5
  265. package/dist/detail-layout.js +1 -1
  266. package/dist/detail-layout.js.map +1 -1
  267. package/dist/{dialog-DpUwec2g.d.ts → dialog-CFnxFGyn.d.ts} +7 -7
  268. package/dist/dialog.d.ts +2 -2
  269. package/dist/dialog.js +4 -4
  270. package/dist/dialog.js.map +1 -1
  271. package/dist/docs-article-page.d.ts +1 -1
  272. package/dist/docs-article-page.js.map +1 -1
  273. package/dist/docs-hub-page.d.ts +1 -1
  274. package/dist/docs-hub-page.js.map +1 -1
  275. package/dist/docs-layout.d.ts +1 -1
  276. package/dist/docs-layout.js +1 -1
  277. package/dist/docs-layout.js.map +1 -1
  278. package/dist/docs-nav.d.ts +1 -1
  279. package/dist/docs-nav.js +1 -1
  280. package/dist/docs-nav.js.map +1 -1
  281. package/dist/document-viewer.d.ts +2 -2
  282. package/dist/document-viewer.js +3 -3
  283. package/dist/document-viewer.js.map +1 -1
  284. package/dist/doodle.d.ts +1 -1
  285. package/dist/doodle.js +1 -1
  286. package/dist/doodle.js.map +1 -1
  287. package/dist/drop-overlay.d.ts +1 -1
  288. package/dist/drop-overlay.js +1 -1
  289. package/dist/drop-overlay.js.map +1 -1
  290. package/dist/dropdown-menu.d.ts +8 -8
  291. package/dist/dropdown-menu.js +2 -2
  292. package/dist/embed-facade.js +1 -1
  293. package/dist/empty-state.d.ts +1 -1
  294. package/dist/empty-state.js.map +1 -1
  295. package/dist/engine-flow.d.ts +1 -1
  296. package/dist/engine-flow.js +1 -1
  297. package/dist/engine-flow.js.map +1 -1
  298. package/dist/entity-header.d.ts +1 -1
  299. package/dist/entity-header.js +1 -1
  300. package/dist/entity-header.js.map +1 -1
  301. package/dist/environment-notice.d.ts +1 -1
  302. package/dist/environment-notice.js.map +1 -1
  303. package/dist/error-page.d.ts +1 -1
  304. package/dist/error-page.js +1 -1
  305. package/dist/error-page.js.map +1 -1
  306. package/dist/field.d.ts +3 -3
  307. package/dist/field.js +1 -1
  308. package/dist/field.js.map +1 -1
  309. package/dist/file-upload.d.ts +1 -1
  310. package/dist/file-upload.js +1 -1
  311. package/dist/file-upload.js.map +1 -1
  312. package/dist/filter-bar.d.ts +2 -2
  313. package/dist/filter-bar.js +4 -4
  314. package/dist/flock.d.ts +1 -1
  315. package/dist/flock.js +2 -2
  316. package/dist/flock.js.map +1 -1
  317. package/dist/footnote.d.ts +3 -3
  318. package/dist/footnote.js +1 -1
  319. package/dist/footnote.js.map +1 -1
  320. package/dist/force-update-screen.d.ts +1 -1
  321. package/dist/force-update-screen.js +3 -3
  322. package/dist/force-update-screen.js.map +1 -1
  323. package/dist/form/server.js.map +1 -1
  324. package/dist/form.d.ts +12 -12
  325. package/dist/form.js +4 -4
  326. package/dist/form.js.map +1 -1
  327. package/dist/{frame-CmDztC_y.d.ts → frame-D5HU_cG8.d.ts} +2 -2
  328. package/dist/gallery-page.d.ts +1 -1
  329. package/dist/gallery-page.js +1 -1
  330. package/dist/gallery-page.js.map +1 -1
  331. package/dist/genui.d.ts +2 -2
  332. package/dist/genui.js +9 -9
  333. package/dist/genui.js.map +1 -1
  334. package/dist/glossary-term.js +2 -2
  335. package/dist/glow-card.d.ts +1 -1
  336. package/dist/glow-card.js +1 -1
  337. package/dist/glow-card.js.map +1 -1
  338. package/dist/goal-gauge.d.ts +1 -1
  339. package/dist/goal-gauge.js +1 -1
  340. package/dist/goal-gauge.js.map +1 -1
  341. package/dist/grade-stamp.d.ts +1 -1
  342. package/dist/grade-stamp.js +2 -2
  343. package/dist/grade-stamp.js.map +1 -1
  344. package/dist/identity-card.d.ts +1 -1
  345. package/dist/identity-card.js +5 -5
  346. package/dist/identity-card.js.map +1 -1
  347. package/dist/image-cropper.d.ts +1 -1
  348. package/dist/image-cropper.js +3 -3
  349. package/dist/image-cropper.js.map +1 -1
  350. package/dist/index.d.ts +5 -5
  351. package/dist/index.js +2 -2
  352. package/dist/index.js.map +1 -1
  353. package/dist/kanban.d.ts +1 -1
  354. package/dist/kanban.js.map +1 -1
  355. package/dist/kbd.d.ts +1 -1
  356. package/dist/kbd.js.map +1 -1
  357. package/dist/kind-config-editor.js +8 -8
  358. package/dist/kind-config-editor.js.map +1 -1
  359. package/dist/kpi-explained.js +1 -1
  360. package/dist/kpi-explained.js.map +1 -1
  361. package/dist/landing-page.d.ts +1 -1
  362. package/dist/landing-page.js.map +1 -1
  363. package/dist/landscape.d.ts +1 -1
  364. package/dist/landscape.js +2 -2
  365. package/dist/landscape.js.map +1 -1
  366. package/dist/language-switch.d.ts +10 -10
  367. package/dist/language-switch.js +1 -1
  368. package/dist/legal-page.d.ts +1 -1
  369. package/dist/legal-page.js.map +1 -1
  370. package/dist/{lightbox-MRB2YZEP.js → lightbox-JLWASIJC.js} +4 -4
  371. package/dist/link-card.d.ts +1 -1
  372. package/dist/link-card.js +4 -4
  373. package/dist/list.d.ts +1 -1
  374. package/dist/list.js +2 -2
  375. package/dist/list.js.map +1 -1
  376. package/dist/loader.d.ts +2 -2
  377. package/dist/loader.js +1 -1
  378. package/dist/loader.js.map +1 -1
  379. package/dist/longform-page.d.ts +1 -1
  380. package/dist/longform-page.js +1 -1
  381. package/dist/longform-page.js.map +1 -1
  382. package/dist/maintenance-screen.d.ts +1 -1
  383. package/dist/maintenance-screen.js +3 -3
  384. package/dist/maintenance-screen.js.map +1 -1
  385. package/dist/map/cards.d.ts +2 -2
  386. package/dist/map/cards.js +1 -1
  387. package/dist/map/cards.js.map +1 -1
  388. package/dist/map/pin.js +1 -1
  389. package/dist/map/sheet.d.ts +1 -1
  390. package/dist/map/sheet.js +1 -1
  391. package/dist/map/sheet.js.map +1 -1
  392. package/dist/map.d.ts +11 -11
  393. package/dist/map.js +4 -4
  394. package/dist/map.js.map +1 -1
  395. package/dist/margin-layout.d.ts +2 -2
  396. package/dist/margin-layout.js.map +1 -1
  397. package/dist/markdown.d.ts +1 -1
  398. package/dist/markdown.js.map +1 -1
  399. package/dist/marketing-layout.d.ts +1 -1
  400. package/dist/marketing-layout.js.map +1 -1
  401. package/dist/mascot-quote.d.ts +1 -1
  402. package/dist/mascot-quote.js +2 -2
  403. package/dist/mascot-quote.js.map +1 -1
  404. package/dist/mascot-state.d.ts +5 -5
  405. package/dist/mascot-state.js +1 -1
  406. package/dist/mascot-state.js.map +1 -1
  407. package/dist/mascots.d.ts +2 -2
  408. package/dist/mascots.js +2 -2
  409. package/dist/mascots.js.map +1 -1
  410. package/dist/match-dialog.d.ts +1 -1
  411. package/dist/match-dialog.js +4 -4
  412. package/dist/match-dialog.js.map +1 -1
  413. package/dist/media-capture.d.ts +1 -1
  414. package/dist/media-capture.js +1 -1
  415. package/dist/media-capture.js.map +1 -1
  416. package/dist/media-carousel.js +5 -5
  417. package/dist/media-carousel.js.map +1 -1
  418. package/dist/media-gallery.d.ts +1 -1
  419. package/dist/media-gallery.js +1 -1
  420. package/dist/media-gallery.js.map +1 -1
  421. package/dist/media-player.d.ts +1 -1
  422. package/dist/media-player.js +4 -4
  423. package/dist/meter.d.ts +2 -2
  424. package/dist/meter.js +1 -1
  425. package/dist/money-input.d.ts +1 -1
  426. package/dist/money-input.js +3 -3
  427. package/dist/motion.d.ts +1 -1
  428. package/dist/motion.js +1 -1
  429. package/dist/native/form.d.ts +12 -12
  430. package/dist/native/form.js +4 -4
  431. package/dist/native/form.js.map +1 -1
  432. package/dist/native/list.d.ts +1 -1
  433. package/dist/native/list.js.map +1 -1
  434. package/dist/native/map.d.ts +4 -4
  435. package/dist/native/map.js +2 -2
  436. package/dist/native/map.js.map +1 -1
  437. package/dist/native/markdown.js.map +1 -1
  438. package/dist/native/media-capture.d.ts +1 -1
  439. package/dist/native/media-capture.js.map +1 -1
  440. package/dist/native/media-picker.d.ts +1 -1
  441. package/dist/native/media-picker.js.map +1 -1
  442. package/dist/native/vertical-video.d.ts +2 -2
  443. package/dist/native/vertical-video.js.map +1 -1
  444. package/dist/native/video-player.d.ts +1 -1
  445. package/dist/native/video-player.js.map +1 -1
  446. package/dist/native.d.ts +95 -95
  447. package/dist/native.js +13 -13
  448. package/dist/native.js.map +1 -1
  449. package/dist/nav-bar.d.ts +13 -13
  450. package/dist/nav-bar.js +5 -5
  451. package/dist/nav-bar.js.map +1 -1
  452. package/dist/notification-preferences.js +3 -3
  453. package/dist/number-ticker.d.ts +1 -1
  454. package/dist/number-ticker.js +1 -1
  455. package/dist/number-ticker.js.map +1 -1
  456. package/dist/opening-hours.d.ts +1 -1
  457. package/dist/opening-hours.js +1 -1
  458. package/dist/opening-hours.js.map +1 -1
  459. package/dist/{page-DPHDmDAQ.d.ts → page-Ufnb5TrQ.d.ts} +5 -5
  460. package/dist/page-header.d.ts +1 -1
  461. package/dist/page-header.js.map +1 -1
  462. package/dist/page-hero.d.ts +1 -1
  463. package/dist/page-hero.js +5 -5
  464. package/dist/page-hero.js.map +1 -1
  465. package/dist/page-index.d.ts +1 -1
  466. package/dist/page-index.js +2 -2
  467. package/dist/page-index.js.map +1 -1
  468. package/dist/page.d.ts +1 -1
  469. package/dist/page.js +3 -3
  470. package/dist/pagination.d.ts +1 -1
  471. package/dist/pagination.js +1 -1
  472. package/dist/pagination.js.map +1 -1
  473. package/dist/pausable-loop.js +2 -2
  474. package/dist/{player-lightbox-BYQ57OXT.js → player-lightbox-SJR3GB7U.js} +5 -5
  475. package/dist/player-lightbox-SJR3GB7U.js.map +1 -0
  476. package/dist/pointer-light.d.ts +1 -1
  477. package/dist/pointer-light.js.map +1 -1
  478. package/dist/popover.d.ts +1 -1
  479. package/dist/popover.js +1 -1
  480. package/dist/popover.js.map +1 -1
  481. package/dist/price-catalogue-editor.js +8 -8
  482. package/dist/price-catalogue-editor.js.map +1 -1
  483. package/dist/pricing-page.d.ts +1 -1
  484. package/dist/pricing-page.js +1 -1
  485. package/dist/pricing-page.js.map +1 -1
  486. package/dist/product-page.d.ts +1 -1
  487. package/dist/product-page.js +1 -1
  488. package/dist/product-page.js.map +1 -1
  489. package/dist/profile-card.d.ts +3 -3
  490. package/dist/profile-card.js +1 -1
  491. package/dist/profile-card.js.map +1 -1
  492. package/dist/progress.d.ts +1 -1
  493. package/dist/progress.js.map +1 -1
  494. package/dist/promise-card.d.ts +1 -1
  495. package/dist/promise-card.js +1 -1
  496. package/dist/promise-card.js.map +1 -1
  497. package/dist/promo-code-field.js +4 -4
  498. package/dist/proposal.js +5 -5
  499. package/dist/qr-code.js +6 -6
  500. package/dist/qr-code.js.map +1 -1
  501. package/dist/quota-meter.d.ts +1 -1
  502. package/dist/quota-meter.js +1 -1
  503. package/dist/quota-meter.js.map +1 -1
  504. package/dist/radio-group.d.ts +5 -5
  505. package/dist/radio-group.js +3 -3
  506. package/dist/radio-group.js.map +1 -1
  507. package/dist/rail-nav.d.ts +4 -4
  508. package/dist/rail-nav.js +3 -3
  509. package/dist/rail-nav.js.map +1 -1
  510. package/dist/recipes.js +1 -1
  511. package/dist/recipes.js.map +1 -1
  512. package/dist/retro-tv-playlist.d.ts +1 -1
  513. package/dist/retro-tv-playlist.js.map +1 -1
  514. package/dist/retro-tv.js +6 -6
  515. package/dist/retro-tv.js.map +1 -1
  516. package/dist/reviews.js +3 -3
  517. package/dist/{schema-Dkn0uX72.d.ts → schema-Dd05m48Q.d.ts} +1 -1
  518. package/dist/schema-form.js +7 -7
  519. package/dist/schema-form.js.map +1 -1
  520. package/dist/scroll-stage.d.ts +2 -2
  521. package/dist/scroll-stage.js +2 -2
  522. package/dist/scroll-stage.js.map +1 -1
  523. package/dist/search-field.d.ts +1 -1
  524. package/dist/search-field.js +2 -2
  525. package/dist/section-backdrop.d.ts +1 -1
  526. package/dist/section-backdrop.js +1 -1
  527. package/dist/separator.d.ts +1 -1
  528. package/dist/separator.js.map +1 -1
  529. package/dist/service-card.d.ts +1 -1
  530. package/dist/service-card.js +6 -6
  531. package/dist/service-card.js.map +1 -1
  532. package/dist/settings-layout.d.ts +3 -3
  533. package/dist/settings-layout.js +2 -2
  534. package/dist/shop/booking.d.ts +1 -1
  535. package/dist/shop/booking.js +4 -4
  536. package/dist/shop/booking.js.map +1 -1
  537. package/dist/shop/bulletin.d.ts +1 -1
  538. package/dist/shop/bulletin.js +2 -2
  539. package/dist/shop/bulletin.js.map +1 -1
  540. package/dist/shop/faq.d.ts +1 -1
  541. package/dist/shop/faq.js +3 -3
  542. package/dist/shop/faq.js.map +1 -1
  543. package/dist/shop/gallery.d.ts +1 -1
  544. package/dist/shop/gallery.js +3 -3
  545. package/dist/shop/gallery.js.map +1 -1
  546. package/dist/shop/hero.d.ts +1 -1
  547. package/dist/shop/hero.js +2 -2
  548. package/dist/shop/hero.js.map +1 -1
  549. package/dist/shop/policies.d.ts +1 -1
  550. package/dist/shop/policies.js +2 -2
  551. package/dist/shop/policies.js.map +1 -1
  552. package/dist/shop/reviews.d.ts +1 -1
  553. package/dist/shop/reviews.js +2 -2
  554. package/dist/shop/reviews.js.map +1 -1
  555. package/dist/shop/services.d.ts +1 -1
  556. package/dist/shop/services.js +4 -4
  557. package/dist/shop/services.js.map +1 -1
  558. package/dist/shop/social.d.ts +1 -1
  559. package/dist/shop/social.js +2 -2
  560. package/dist/shop/social.js.map +1 -1
  561. package/dist/shop/story.d.ts +1 -1
  562. package/dist/shop/story.js +2 -2
  563. package/dist/shop/story.js.map +1 -1
  564. package/dist/shop/team.d.ts +1 -1
  565. package/dist/shop/team.js +2 -2
  566. package/dist/shop/team.js.map +1 -1
  567. package/dist/shop/video.d.ts +1 -1
  568. package/dist/shop/video.js +2 -2
  569. package/dist/shop/video.js.map +1 -1
  570. package/dist/shop/visit.d.ts +1 -1
  571. package/dist/shop/visit.js +2 -2
  572. package/dist/shop/visit.js.map +1 -1
  573. package/dist/shop-composer.js +2 -2
  574. package/dist/shop-composer.js.map +1 -1
  575. package/dist/shop-gallery.d.ts +1 -1
  576. package/dist/shop-gallery.js +2 -2
  577. package/dist/shop-gallery.js.map +1 -1
  578. package/dist/shop.d.ts +3 -3
  579. package/dist/shop.js +2 -2
  580. package/dist/showcase.d.ts +1 -1
  581. package/dist/showcase.js +6 -6
  582. package/dist/showcase.js.map +1 -1
  583. package/dist/signature.d.ts +1 -1
  584. package/dist/signature.js +2 -2
  585. package/dist/signature.js.map +1 -1
  586. package/dist/site-cahier.d.ts +3 -3
  587. package/dist/site-cahier.js +10 -10
  588. package/dist/site-cahier.js.map +1 -1
  589. package/dist/site-footer.d.ts +4 -4
  590. package/dist/site-footer.js +1 -1
  591. package/dist/site-footer.js.map +1 -1
  592. package/dist/skeleton.d.ts +3 -3
  593. package/dist/skeleton.js.map +1 -1
  594. package/dist/skip-link.d.ts +1 -1
  595. package/dist/skip-link.js +1 -1
  596. package/dist/slider.d.ts +1 -1
  597. package/dist/slider.js +2 -2
  598. package/dist/slider.js.map +1 -1
  599. package/dist/slot-picker.d.ts +1 -1
  600. package/dist/slot-picker.js +1 -1
  601. package/dist/slot-picker.js.map +1 -1
  602. package/dist/specimen-tag.d.ts +2 -2
  603. package/dist/specimen-tag.js +2 -2
  604. package/dist/speed-lines.d.ts +1 -1
  605. package/dist/speed-lines.js +1 -1
  606. package/dist/speed-lines.js.map +1 -1
  607. package/dist/spinner.d.ts +2 -2
  608. package/dist/spinner.js +1 -1
  609. package/dist/spinner.js.map +1 -1
  610. package/dist/split-view.d.ts +1 -1
  611. package/dist/split-view.js.map +1 -1
  612. package/dist/stage-banner.d.ts +1 -1
  613. package/dist/stage-banner.js +1 -1
  614. package/dist/stage-banner.js.map +1 -1
  615. package/dist/stat.d.ts +2 -2
  616. package/dist/stat.js +1 -1
  617. package/dist/status-chip.js +4 -4
  618. package/dist/status-chip.js.map +1 -1
  619. package/dist/status-page.d.ts +1 -1
  620. package/dist/status-page.js.map +1 -1
  621. package/dist/step-progress.d.ts +1 -1
  622. package/dist/step-progress.js.map +1 -1
  623. package/dist/step-showcase.d.ts +2 -2
  624. package/dist/step-showcase.js +3 -3
  625. package/dist/step-showcase.js.map +1 -1
  626. package/dist/stepper.d.ts +1 -1
  627. package/dist/stepper.js +1 -1
  628. package/dist/stepper.js.map +1 -1
  629. package/dist/sticky-action.d.ts +1 -1
  630. package/dist/sticky-action.js.map +1 -1
  631. package/dist/stuck.d.ts +1 -1
  632. package/dist/stuck.js +1 -1
  633. package/dist/stuck.js.map +1 -1
  634. package/dist/swipe-deck.d.ts +2 -2
  635. package/dist/swipe-deck.js.map +1 -1
  636. package/dist/switch.d.ts +1 -1
  637. package/dist/switch.js +1 -1
  638. package/dist/tabs.d.ts +6 -6
  639. package/dist/tabs.js +1 -1
  640. package/dist/tabs.js.map +1 -1
  641. package/dist/tag-input.d.ts +1 -1
  642. package/dist/tag-input.js +4 -4
  643. package/dist/tag-input.js.map +1 -1
  644. package/dist/tag-selector.d.ts +1 -1
  645. package/dist/tag-selector.js +3 -3
  646. package/dist/tag-selector.js.map +1 -1
  647. package/dist/taped-photo.d.ts +1 -1
  648. package/dist/taped-photo.js +2 -2
  649. package/dist/terminal-replay.d.ts +1 -1
  650. package/dist/terminal-replay.js +3 -3
  651. package/dist/terminal-replay.js.map +1 -1
  652. package/dist/text-style/server.d.ts +1 -1
  653. package/dist/text-style/server.js.map +1 -1
  654. package/dist/text-style.d.ts +2 -2
  655. package/dist/text-style.js.map +1 -1
  656. package/dist/theme.d.ts +3 -3
  657. package/dist/theme.js +3 -3
  658. package/dist/theme.js.map +1 -1
  659. package/dist/toast.d.ts +1 -1
  660. package/dist/toast.js +2 -2
  661. package/dist/toast.js.map +1 -1
  662. package/dist/toc.d.ts +2 -2
  663. package/dist/toc.js +1 -1
  664. package/dist/toc.js.map +1 -1
  665. package/dist/tooltip.d.ts +1 -1
  666. package/dist/tooltip.js +2 -2
  667. package/dist/tree-view.d.ts +1 -1
  668. package/dist/tree-view.js +2 -2
  669. package/dist/tree-view.js.map +1 -1
  670. package/dist/update-prompt.d.ts +1 -1
  671. package/dist/update-prompt.js +3 -3
  672. package/dist/update-prompt.js.map +1 -1
  673. package/dist/upload-queue.d.ts +2 -2
  674. package/dist/upload-queue.js +1 -1
  675. package/dist/upload-queue.js.map +1 -1
  676. package/dist/usage.d.ts +4 -4
  677. package/dist/usage.js +3 -3
  678. package/dist/usage.js.map +1 -1
  679. package/dist/verified-badge.d.ts +1 -1
  680. package/dist/verified-badge.js.map +1 -1
  681. package/dist/versus-card.d.ts +1 -1
  682. package/dist/versus-card.js +2 -2
  683. package/dist/versus-card.js.map +1 -1
  684. package/dist/vertical-video.d.ts +2 -2
  685. package/dist/vertical-video.js +6 -6
  686. package/dist/vertical-video.js.map +1 -1
  687. package/dist/video-player.d.ts +1 -1
  688. package/dist/video-player.js +5 -5
  689. package/dist/video-trimmer.d.ts +1 -1
  690. package/dist/video-trimmer.js.map +1 -1
  691. package/dist/virtual.d.ts +2 -2
  692. package/dist/virtual.js +1 -1
  693. package/dist/wall.js +2 -2
  694. package/dist/wall.js.map +1 -1
  695. package/dist/waveform.d.ts +1 -1
  696. package/dist/waveform.js.map +1 -1
  697. package/package.json +7 -7
  698. package/registry/account-settings.json +17 -17
  699. package/registry/achievement.json +1 -1
  700. package/registry/action-bar.json +3 -3
  701. package/registry/activity-feed.json +2 -2
  702. package/registry/alert.json +1 -1
  703. package/registry/analysis-report.json +1 -1
  704. package/registry/anatomy-plate.json +1 -1
  705. package/registry/app-frame.json +6 -6
  706. package/registry/app-header.json +4 -4
  707. package/registry/app-shell.json +2 -2
  708. package/registry/architecture-diagram.json +1 -1
  709. package/registry/argument-card.json +3 -3
  710. package/registry/auth-layout.json +1 -1
  711. package/registry/avatar.json +3 -3
  712. package/registry/badge.json +1 -1
  713. package/registry/bird-plate.json +1 -1
  714. package/registry/button.json +1 -1
  715. package/registry/captcha.json +1 -1
  716. package/registry/card-grid.json +1 -1
  717. package/registry/card.json +1 -1
  718. package/registry/catalogue-page.json +1 -1
  719. package/registry/changelog-page.json +2 -2
  720. package/registry/chapter.json +2 -2
  721. package/registry/chat.json +1 -1
  722. package/registry/checkbox.json +1 -1
  723. package/registry/chip-link.json +1 -1
  724. package/registry/chip-row.json +1 -1
  725. package/registry/chip.json +2 -2
  726. package/registry/choice-grid.json +2 -2
  727. package/registry/cn.json +1 -1
  728. package/registry/code-block.json +2 -2
  729. package/registry/collection-switcher.json +2 -2
  730. package/registry/columns.json +1 -1
  731. package/registry/combobox.json +2 -2
  732. package/registry/command.json +1 -1
  733. package/registry/comparison-table.json +1 -1
  734. package/registry/component-page.json +1 -1
  735. package/registry/confirm-button.json +1 -1
  736. package/registry/contact-page.json +1 -1
  737. package/registry/continue-prompt.json +1 -1
  738. package/registry/copy-button.json +2 -2
  739. package/registry/countdown.json +1 -1
  740. package/registry/cover-hero.json +3 -3
  741. package/registry/cta-panel.json +1 -1
  742. package/registry/dashboard-layout.json +2 -2
  743. package/registry/data-table.json +4 -4
  744. package/registry/date-picker.json +8 -8
  745. package/registry/decision-list.json +2 -2
  746. package/registry/description-list.json +1 -1
  747. package/registry/detail-layout.json +1 -1
  748. package/registry/dialog.json +2 -2
  749. package/registry/docs-article-page.json +1 -1
  750. package/registry/docs-hub-page.json +1 -1
  751. package/registry/docs-layout.json +2 -2
  752. package/registry/docs-nav.json +1 -1
  753. package/registry/document-viewer.json +2 -2
  754. package/registry/doodle.json +1 -1
  755. package/registry/drop-overlay.json +1 -1
  756. package/registry/dropdown-menu.json +1 -1
  757. package/registry/empty-state.json +1 -1
  758. package/registry/engine-flow.json +1 -1
  759. package/registry/entity-header.json +2 -2
  760. package/registry/environment-notice.json +1 -1
  761. package/registry/error-page.json +1 -1
  762. package/registry/field.json +1 -1
  763. package/registry/file-upload.json +2 -2
  764. package/registry/filter-bar.json +4 -4
  765. package/registry/flock.json +1 -1
  766. package/registry/footnote.json +1 -1
  767. package/registry/force-update-screen.json +1 -1
  768. package/registry/form.json +64 -64
  769. package/registry/gallery-page.json +1 -1
  770. package/registry/genui.json +2 -2
  771. package/registry/glow-card.json +1 -1
  772. package/registry/goal-gauge.json +1 -1
  773. package/registry/grade-stamp.json +1 -1
  774. package/registry/identity-card.json +1 -1
  775. package/registry/image-cropper.json +1 -1
  776. package/registry/index.json +8 -8
  777. package/registry/kanban.json +1 -1
  778. package/registry/kbd.json +1 -1
  779. package/registry/kind-config-editor.json +2 -2
  780. package/registry/kpi-explained.json +1 -1
  781. package/registry/landing-page.json +1 -1
  782. package/registry/landscape.json +1 -1
  783. package/registry/language-switch.json +1 -1
  784. package/registry/legal-page.json +1 -1
  785. package/registry/link-card.json +3 -3
  786. package/registry/list.json +2 -2
  787. package/registry/loader.json +1 -1
  788. package/registry/longform-page.json +1 -1
  789. package/registry/maintenance-screen.json +1 -1
  790. package/registry/map.json +7 -7
  791. package/registry/margin-layout.json +1 -1
  792. package/registry/markdown.json +1 -1
  793. package/registry/marketing-layout.json +1 -1
  794. package/registry/mascot-quote.json +1 -1
  795. package/registry/mascot-state.json +2 -2
  796. package/registry/mascots.json +3 -3
  797. package/registry/match-dialog.json +1 -1
  798. package/registry/media-capture.json +2 -2
  799. package/registry/media-gallery.json +4 -4
  800. package/registry/meter.json +1 -1
  801. package/registry/money-input.json +1 -1
  802. package/registry/nav-bar.json +8 -8
  803. package/registry/number-ticker.json +1 -1
  804. package/registry/opening-hours.json +2 -2
  805. package/registry/page-header.json +1 -1
  806. package/registry/page-hero.json +3 -3
  807. package/registry/page-index.json +2 -2
  808. package/registry/page.json +1 -1
  809. package/registry/pagination.json +2 -2
  810. package/registry/pointer-light.json +1 -1
  811. package/registry/popover.json +1 -1
  812. package/registry/price-catalogue-editor.json +1 -1
  813. package/registry/pricing-page.json +2 -2
  814. package/registry/product-page.json +1 -1
  815. package/registry/profile-card.json +3 -3
  816. package/registry/progress.json +1 -1
  817. package/registry/promise-card.json +1 -1
  818. package/registry/qr-code.json +2 -2
  819. package/registry/quota-meter.json +1 -1
  820. package/registry/radio-group.json +14 -14
  821. package/registry/rail-nav.json +8 -8
  822. package/registry/recipes.json +1 -1
  823. package/registry/retro-tv.json +3 -3
  824. package/registry/schema-form.json +1 -1
  825. package/registry/scroll-stage.json +1 -1
  826. package/registry/search-field.json +2 -2
  827. package/registry/section-backdrop.json +1 -1
  828. package/registry/separator.json +1 -1
  829. package/registry/service-card.json +3 -3
  830. package/registry/settings-layout.json +1 -1
  831. package/registry/shop-composer.json +3 -3
  832. package/registry/shop-gallery.json +1 -1
  833. package/registry/shop.json +17 -17
  834. package/registry/showcase.json +1 -1
  835. package/registry/signature.json +1 -1
  836. package/registry/site-cahier.json +2 -2
  837. package/registry/site-footer.json +10 -10
  838. package/registry/skeleton.json +1 -1
  839. package/registry/skip-link.json +1 -1
  840. package/registry/slider.json +1 -1
  841. package/registry/slot-picker.json +2 -2
  842. package/registry/specimen-tag.json +1 -1
  843. package/registry/speed-lines.json +1 -1
  844. package/registry/spinner.json +2 -2
  845. package/registry/split-view.json +1 -1
  846. package/registry/stage-banner.json +1 -1
  847. package/registry/stat.json +1 -1
  848. package/registry/status-chip.json +2 -2
  849. package/registry/status-page.json +1 -1
  850. package/registry/step-progress.json +1 -1
  851. package/registry/step-showcase.json +2 -2
  852. package/registry/stepper.json +1 -1
  853. package/registry/sticky-action.json +1 -1
  854. package/registry/stuck.json +1 -1
  855. package/registry/swipe-deck.json +1 -1
  856. package/registry/switch.json +1 -1
  857. package/registry/tabs.json +1 -1
  858. package/registry/tag-input.json +1 -1
  859. package/registry/tag-selector.json +1 -1
  860. package/registry/taped-photo.json +1 -1
  861. package/registry/terminal-replay.json +2 -2
  862. package/registry/text-style.json +8 -8
  863. package/registry/theme.json +1 -1
  864. package/registry/toast.json +1 -1
  865. package/registry/toc.json +1 -1
  866. package/registry/tooltip.json +1 -1
  867. package/registry/tree-view.json +2 -2
  868. package/registry/update-prompt.json +1 -1
  869. package/registry/upload-queue.json +1 -1
  870. package/registry/usage.json +2 -2
  871. package/registry/verified-badge.json +1 -1
  872. package/registry/versus-card.json +1 -1
  873. package/registry/vertical-video.json +2 -2
  874. package/registry/video-player.json +2 -2
  875. package/registry/video-trimmer.json +1 -1
  876. package/registry/virtual.json +3 -3
  877. package/registry/wall.json +1 -1
  878. package/registry/waveform.json +1 -1
  879. package/dist/chunk-2FCQCWIK.js.map +0 -1
  880. package/dist/chunk-43PTCDTL.js.map +0 -1
  881. package/dist/chunk-5D7NMUF6.js.map +0 -1
  882. package/dist/chunk-5PFCELGW.js.map +0 -1
  883. package/dist/chunk-5RWHDX5J.js.map +0 -1
  884. package/dist/chunk-5VZ37TY3.js.map +0 -1
  885. package/dist/chunk-757ZTGU5.js.map +0 -1
  886. package/dist/chunk-7DYZTEE3.js.map +0 -1
  887. package/dist/chunk-7P7I5OQV.js.map +0 -1
  888. package/dist/chunk-B47WSPMP.js.map +0 -1
  889. package/dist/chunk-C57KK5VB.js.map +0 -1
  890. package/dist/chunk-EB45EVPJ.js.map +0 -1
  891. package/dist/chunk-EDQLPCM4.js.map +0 -1
  892. package/dist/chunk-GHAN7OOE.js.map +0 -1
  893. package/dist/chunk-HLEBSAGC.js.map +0 -1
  894. package/dist/chunk-HP7BDMVK.js.map +0 -1
  895. package/dist/chunk-KH3JOEPY.js.map +0 -1
  896. package/dist/chunk-KR2W4ONJ.js.map +0 -1
  897. package/dist/chunk-LH5J3VLZ.js.map +0 -1
  898. package/dist/chunk-LNAAWT4Y.js.map +0 -1
  899. package/dist/chunk-MDSP7DJR.js.map +0 -1
  900. package/dist/chunk-NG6G6V5E.js.map +0 -1
  901. package/dist/chunk-NM2DEHFZ.js.map +0 -1
  902. package/dist/chunk-NPMGYLJV.js.map +0 -1
  903. package/dist/chunk-NQENOT6L.js.map +0 -1
  904. package/dist/chunk-NSLXEDIS.js.map +0 -1
  905. package/dist/chunk-OGWB76BR.js.map +0 -1
  906. package/dist/chunk-P7AFIKWG.js.map +0 -1
  907. package/dist/chunk-PGBF3UBX.js.map +0 -1
  908. package/dist/chunk-QA3WETWT.js.map +0 -1
  909. package/dist/chunk-QD6SNXF5.js.map +0 -1
  910. package/dist/chunk-QHVV2JGF.js.map +0 -1
  911. package/dist/chunk-QVHSV6RA.js.map +0 -1
  912. package/dist/chunk-S2O4NSN5.js.map +0 -1
  913. package/dist/chunk-S4TLZRGZ.js.map +0 -1
  914. package/dist/chunk-S6NYGOJT.js.map +0 -1
  915. package/dist/chunk-SB5WSVPI.js.map +0 -1
  916. package/dist/chunk-SG2RKUVJ.js.map +0 -1
  917. package/dist/chunk-V5RO6JYI.js.map +0 -1
  918. package/dist/chunk-V7W4RLRW.js.map +0 -1
  919. package/dist/chunk-VA4NPCUQ.js.map +0 -1
  920. package/dist/chunk-VPO27AFS.js.map +0 -1
  921. package/dist/chunk-W64RAX4N.js.map +0 -1
  922. package/dist/chunk-W675RFOA.js.map +0 -1
  923. package/dist/chunk-WC3SO4CE.js.map +0 -1
  924. package/dist/chunk-WEVYKZIF.js.map +0 -1
  925. package/dist/chunk-WU4VLSEA.js.map +0 -1
  926. package/dist/chunk-Y3P5B4XS.js.map +0 -1
  927. package/dist/chunk-YTYNKMNS.js.map +0 -1
  928. package/dist/chunk-Z47KIPCT.js.map +0 -1
  929. package/dist/chunk-ZPOVOEO3.js.map +0 -1
  930. package/dist/player-lightbox-BYQ57OXT.js.map +0 -1
  931. /package/dist/{chunk-HJFRHYCI.js.map → chunk-DTGRZXYO.js.map} +0 -0
  932. /package/dist/{chunk-PJNR4NTS.js.map → chunk-HC2TY45B.js.map} +0 -0
  933. /package/dist/{lightbox-MRB2YZEP.js.map → lightbox-JLWASIJC.js.map} +0 -0
@@ -1859,6 +1859,66 @@
1859
1859
  }
1860
1860
  ]
1861
1861
  },
1862
+ {
1863
+ "component": "FieldCheck",
1864
+ "description": "A value checked on the server as it is typed: an error (or its key), or nothing when the value is fine.",
1865
+ "props": []
1866
+ },
1867
+ {
1868
+ "component": "KrizakaField",
1869
+ "description": "A field as its component draws it: the value, its setter, its error in words, its state.",
1870
+ "props": []
1871
+ },
1872
+ {
1873
+ "component": "KrizakaFieldArray",
1874
+ "description": "The array of a field array, with its operations (`form.FieldArray`).",
1875
+ "props": []
1876
+ },
1877
+ {
1878
+ "component": "FormActionResult",
1879
+ "description": "What a Server Action (or any submit) answers: done, or a refusal the form shows.",
1880
+ "props": []
1881
+ },
1882
+ {
1883
+ "component": "FormOutput",
1884
+ "description": "The values a form sends: the schema's output (zod transforms applied).",
1885
+ "props": []
1886
+ },
1887
+ {
1888
+ "component": "FormSchema",
1889
+ "description": "A schema the form validates with: any Standard Schema — zod 4 (`z.object`), valibot, arktype.",
1890
+ "props": []
1891
+ },
1892
+ {
1893
+ "component": "FormValues",
1894
+ "description": "The values a form holds: the schema's input.",
1895
+ "props": []
1896
+ },
1897
+ {
1898
+ "component": "KrizakaFormFactory",
1899
+ "description": "A form defined once (schema + defaults), used in components: `signUp.useForm({ onSubmit })`.",
1900
+ "props": []
1901
+ },
1902
+ {
1903
+ "component": "KrizakaFormInstance",
1904
+ "description": "A form in a component: its fields (typed by the schema), its submit and its state.",
1905
+ "props": []
1906
+ },
1907
+ {
1908
+ "component": "FormFieldError",
1909
+ "description": "An error of a field or of the whole form: the key of its words in the app's catalogue, and what fills them in.",
1910
+ "props": []
1911
+ },
1912
+ {
1913
+ "component": "FormI18n",
1914
+ "description": "How a form finds its words: the app's translate function, and the prefixes of its keys.",
1915
+ "props": []
1916
+ },
1917
+ {
1918
+ "component": "FormProblem",
1919
+ "description": "A refusal the form shows, serialisable (a Server Action returns it): the shape of `KrizakaApiError` of",
1920
+ "props": []
1921
+ },
1862
1922
  {
1863
1923
  "component": "FieldArray",
1864
1924
  "description": "A list of fields that grows and shrinks (links, tiers, guests): each item's fields named `links[0].url`.",
@@ -1932,66 +1992,6 @@
1932
1992
  "required": true
1933
1993
  }
1934
1994
  ]
1935
- },
1936
- {
1937
- "component": "FieldCheck",
1938
- "description": "A value checked on the server as it is typed: an error (or its key), or nothing when the value is fine.",
1939
- "props": []
1940
- },
1941
- {
1942
- "component": "KrizakaField",
1943
- "description": "A field as its component draws it: the value, its setter, its error in words, its state.",
1944
- "props": []
1945
- },
1946
- {
1947
- "component": "KrizakaFieldArray",
1948
- "description": "The array of a field array, with its operations (`form.FieldArray`).",
1949
- "props": []
1950
- },
1951
- {
1952
- "component": "FormActionResult",
1953
- "description": "What a Server Action (or any submit) answers: done, or a refusal the form shows.",
1954
- "props": []
1955
- },
1956
- {
1957
- "component": "FormOutput",
1958
- "description": "The values a form sends: the schema's output (zod transforms applied).",
1959
- "props": []
1960
- },
1961
- {
1962
- "component": "FormSchema",
1963
- "description": "A schema the form validates with: any Standard Schema — zod 4 (`z.object`), valibot, arktype.",
1964
- "props": []
1965
- },
1966
- {
1967
- "component": "FormValues",
1968
- "description": "The values a form holds: the schema's input.",
1969
- "props": []
1970
- },
1971
- {
1972
- "component": "KrizakaFormFactory",
1973
- "description": "A form defined once (schema + defaults), used in components: `signUp.useForm({ onSubmit })`.",
1974
- "props": []
1975
- },
1976
- {
1977
- "component": "KrizakaFormInstance",
1978
- "description": "A form in a component: its fields (typed by the schema), its submit and its state.",
1979
- "props": []
1980
- },
1981
- {
1982
- "component": "FormFieldError",
1983
- "description": "An error of a field or of the whole form: the key of its words in the app's catalogue, and what fills them in.",
1984
- "props": []
1985
- },
1986
- {
1987
- "component": "FormI18n",
1988
- "description": "How a form finds its words: the app's translate function, and the prefixes of its keys.",
1989
- "props": []
1990
- },
1991
- {
1992
- "component": "FormProblem",
1993
- "description": "A refusal the form shows, serialisable (a Server Action returns it): the shape of `KrizakaApiError` of",
1994
- "props": []
1995
1995
  }
1996
1996
  ],
1997
1997
  "examples": [
@@ -2072,11 +2072,11 @@
2072
2072
  "files": [
2073
2073
  {
2074
2074
  "path": "form/core.tsx",
2075
- "content": "// Platform-neutral React (web and React Native): the engine of a Krizaka form, TanStack Form v1 behind the facade\n// (ADR-001: a product never imports @tanstack/*). A form = a Standard Schema (zod 4) + its default values; the schema\n// validates every change, an error shows once the person leaves the field or tries to send (and goes as soon as it is\n// fixed), a field may check a value on the server (debounced, aborted when the value changes), and a refusal of the\n// server (Problem Details `fields`) lands under its fields. The fields themselves are the platform's (web.tsx, native).\nimport { type AnyFieldApi, type AnyFormApi, type DeepKeys, type StandardSchemaV1, useField, useForm, useStore } from \"@tanstack/react-form\";\nimport * as React from \"react\";\n\nimport { type FormFieldError, type FormI18n, formMessage, type FormProblem, isFormProblem, issuesToFields, problemToErrors, type SchemaIssue } from \"./errors\";\n\n/** A schema the form validates with: any Standard Schema — zod 4 (`z.object`), valibot, arktype. */\nexport type FormSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>;\n/** The values a form holds: the schema's input. */\nexport type FormValues<S> = S extends { readonly \"~standard\": { readonly types?: { readonly input: infer I } } } ? I : never;\n/** The values a form sends: the schema's output (zod transforms applied). */\nexport type FormOutput<S> = S extends { readonly \"~standard\": { readonly types?: { readonly output: infer O } } } ? O : never;\n/** A field's name: `email`, `address.city`, `links[0].url`. */\nexport type FieldName<V> = DeepKeys<V> & string;\n\n/** What a Server Action (or any submit) answers: done, or a refusal the form shows. */\nexport type FormActionResult<T = unknown> = { ok: true; data?: T } | { ok: false; problem: FormProblem };\n\n/** A value checked on the server as it is typed: an error (or its key), or nothing when the value is fine. */\nexport type FieldCheck<T = unknown> = (value: T, signal: AbortSignal) => Promise<FormFieldError | string | null | undefined> | FormFieldError | string | null | undefined;\n\nexport interface KrizakaFormDefinition<S extends FormSchema> {\n /** The schema of the values (zod 4): the same one the server parses with. */\n schema: S;\n /** The values at first: every field of the schema. */\n defaultValues: FormValues<S>;\n /** The words: the app's translate function, the key prefixes, the locale. */\n i18n?: FormI18n;\n}\n\nexport interface UseKrizakaFormOptions<S extends FormSchema, R = unknown> {\n /** Sends the values (the schema's output): a mutation of @krizaka/query, a Server Action. Throw a `KrizakaApiError` or\n * return `{ ok: false, problem }` to refuse: its `fields` go under their fields, the rest above the button. */\n onSubmit?: (values: FormOutput<S>) => R | Promise<R>;\n /** Called after a successful submit with what `onSubmit` returned (`data` of a `{ ok: true, data }`). */\n onSuccess?: (result: R extends FormActionResult<infer T> ? T | undefined : R) => void;\n /** Values that replace the definition's (a profile loaded from the server). */\n defaultValues?: FormValues<S>;\n /** Overrides the definition's words (the translate function of a hook). */\n i18n?: FormI18n;\n /** The server's codes that belong to a field (`{ UNDERAGE: \"dateOfBirth\", USERNAME_RESERVED: \"username\" }`): a refusal\n * with that code shows under the field, as `form.errors.<CODE>`, instead of above the button. */\n codeFields?: Readonly<Record<string, string>>;\n}\n\n/** The state of a form, for its fields and its button. */\nexport interface FormContextValue {\n /** TanStack's form, through the facade: never import @tanstack/* in a product. */\n readonly api: AnyFormApi;\n readonly i18n: FormI18n;\n /** The whole form's error (a refusal without a field), or null. */\n readonly error: FormFieldError | null;\n /** Sends the form: validates, focuses (web) or announces (native) the first error, else calls `onSubmit`. */\n readonly submit: () => Promise<boolean>;\n}\n\nexport const FormContext = React.createContext<FormContextValue | null>(null);\n\n/** The form around a field: inside `form.Form`. */\nexport function useFormContext(): FormContextValue {\n const ctx = React.useContext(FormContext);\n if (!ctx) throw new Error(\"A Krizaka form field must be inside its form's `form.Form`.\");\n return ctx;\n}\n\ntype StandardResult = { readonly value?: unknown; readonly issues?: readonly SchemaIssue[] };\n\nconst run = (schema: FormSchema, value: unknown) => schema[\"~standard\"].validate(value) as StandardResult | Promise<StandardResult>;\n\n/** The engine of a form: TanStack's form wired to the schema, the server's refusals and the submit. */\nexport function useKrizakaFormCore<S extends FormSchema, R>(definition: KrizakaFormDefinition<S>, options: UseKrizakaFormOptions<S, R> = {}): FormContextValue {\n const i18n = { ...definition.i18n, ...options.i18n };\n const latest = React.useRef({ options, i18n });\n // The latest options for the engine's callbacks (a submit, a change), which outlive the render that made them.\n React.useLayoutEffect(() => {\n latest.current = { options, i18n };\n });\n const [error, setError] = React.useState<FormFieldError | null>(null);\n const refused = React.useRef(false);\n\n const api = useForm({\n defaultValues: options.defaultValues ?? definition.defaultValues,\n validators: {\n // Every change: the schema, synchronously (an async refinement waits for the submit). Errors are computed for\n // every field; each field shows its own once the person left it or tried to send.\n onChange: ({ value }: { value: unknown }) => {\n const result = run(definition.schema, value);\n if (result instanceof Promise || !result.issues?.length) return undefined;\n const fields = issuesToFields(result.issues, latest.current.i18n.prefix);\n delete fields[\"\"];\n return { fields };\n },\n },\n onSubmit: async ({ value }: { value: unknown }) => {\n const parsed = await run(definition.schema, value);\n if (parsed.issues?.length) {\n apply({ fields: issuesToFields(parsed.issues, latest.current.i18n.prefix) as FormProblem[\"fields\"] });\n return;\n }\n let result: unknown;\n try {\n result = await latest.current.options.onSubmit?.(parsed.value as FormOutput<S>);\n } catch (thrown) {\n apply(isFormProblem(thrown) ? thrown : { code: \"server\" });\n return;\n }\n if (result && typeof result === \"object\" && \"ok\" in result && (result as FormActionResult).ok === false) {\n apply((result as unknown as { problem: FormProblem }).problem);\n return;\n }\n const data = result && typeof result === \"object\" && \"ok\" in result ? (result as { data?: unknown }).data : result;\n latest.current.options.onSuccess?.(data as never);\n },\n });\n\n const known = (name: string) => name in api.fieldInfo;\n function apply(problem: FormProblem) {\n refused.current = true;\n const { fields, form } = problemToErrors(problem, latest.current.i18n, known, latest.current.options.codeFields);\n for (const [name, fieldError] of Object.entries(fields)) {\n api.setFieldMeta(name as never, (meta) => ({ ...meta, isBlurred: true, errorMap: { ...meta.errorMap, onServer: fieldError } }));\n }\n setError(form);\n }\n\n const submit = React.useCallback(async () => {\n setError(null);\n refused.current = false;\n for (const name of Object.keys(api.fieldInfo)) {\n if ((api.getFieldMeta(name as never) as { errorMap?: Record<string, unknown> } | undefined)?.errorMap?.onServer) api.setFieldMeta(name as never, (meta) => ({ ...meta, errorMap: { ...meta.errorMap, onServer: undefined } }));\n }\n await api.handleSubmit();\n const state = api.state;\n return !refused.current && state.isSubmitSuccessful && state.isValid && !(Object.values(state.fieldMeta) as { errorMap?: Record<string, unknown> }[]).some((meta) => meta?.errorMap?.onServer);\n }, [api]);\n\n return React.useMemo(() => ({ api, i18n, error, submit }), [api, error, submit, i18n.t, i18n.prefix, i18n.apiPrefix, i18n.locale]); // eslint-disable-line react-hooks/exhaustive-deps\n}\n\nconst UNCHECKED = Symbol(\"unchecked\");\n\nexport interface FieldOptions<T> {\n /** Checks the value on the server as it is typed (a username's availability): debounced, aborted when it changes. */\n validateAsync?: FieldCheck<T>;\n /** The wait, in ms, between the last change and `validateAsync`. Default 350. */\n asyncDebounceMs?: number;\n}\n\n/** A field as its component draws it: the value, its setter, its error in words, its state. */\nexport interface KrizakaField<T = unknown> {\n /** The id of the control (`htmlFor` of its label). */\n readonly id: string;\n readonly name: string;\n readonly value: T;\n /** Sets the value (clears a refusal of the server on it). */\n setValue(value: T): void;\n /** Call when the control loses focus: from then on, its errors show. */\n readonly onBlur: () => void;\n /** The error to show, in words — only once it should show. */\n readonly error: string | undefined;\n /** The error itself, with its suggestion. */\n readonly errorDetail: FormFieldError | undefined;\n /** A check (`validateAsync`) is running. */\n readonly validating: boolean;\n /** The check passed for the current value. */\n readonly available: boolean;\n /** The ids of the hint and the error (`aria-describedby`). */\n readonly hintId: string;\n readonly errorId: string;\n /** The form's locale (numbers, money, dates). */\n readonly locale: string;\n /** TanStack's field, through the facade. */\n readonly api: AnyFieldApi;\n}\n\n/** Binds a field of the form around it (inside `form.Form`): what the platform's field components are made of. */\nexport function useKrizakaField<T = unknown>(name: string, options: FieldOptions<T> = {}): KrizakaField<T> {\n const ctx = useFormContext();\n const id = React.useId();\n const [checked, setChecked] = React.useState<unknown>(UNCHECKED);\n const check = options.validateAsync;\n const field = useField({\n form: ctx.api,\n name: name as never,\n ...(check\n ? {\n asyncDebounceMs: options.asyncDebounceMs ?? 350,\n validators: {\n onChangeAsyncDebounceMs: options.asyncDebounceMs ?? 350,\n onChangeAsync: async ({ value, signal }: { value: T; signal: AbortSignal }) => {\n const answer = await check(value, signal);\n if (signal.aborted) return undefined;\n if (!answer) {\n setChecked(value);\n return undefined;\n }\n setChecked(UNCHECKED);\n const error = typeof answer === \"string\" ? { key: answer } : answer;\n return { ...error, immediate: true, source: \"check\" } satisfies FormFieldError;\n },\n },\n }\n : {}),\n } as never) as unknown as AnyFieldApi;\n const attempts = useStore(ctx.api.store, (state: { submissionAttempts: number }) => state.submissionAttempts);\n const meta = field.state.meta;\n const map = meta.errorMap as Record<string, unknown>;\n const all = [map.onServer, map.onChange, map.onBlur, map.onSubmit, map.onMount].filter(Boolean) as (FormFieldError | string)[];\n const first = all[0];\n const detail = typeof first === \"string\" ? { key: first } : first;\n const visible = detail && (detail.immediate || detail.source === \"server\" || meta.isBlurred || attempts > 0) ? detail : undefined;\n const value = field.state.value as T;\n\n return {\n id,\n name,\n value,\n setValue: (next: T) => {\n if (map.onServer) ctx.api.setFieldMeta(name as never, (m: { errorMap: Record<string, unknown> }) => ({ ...m, errorMap: { ...m.errorMap, onServer: undefined } }) as never);\n field.handleChange(next as never);\n },\n onBlur: () => field.handleBlur(),\n error: visible ? formMessage(visible, ctx.i18n) : undefined,\n errorDetail: visible,\n validating: Boolean(meta.isValidating),\n available: Boolean(check) && checked !== UNCHECKED && Object.is(checked, value) && !meta.isValidating && all.length === 0,\n hintId: `${id}-hint`,\n errorId: `${id}-error`,\n locale: ctx.i18n.locale ?? \"en\",\n api: field,\n };\n}\n\n/** The array of a field array, with its operations (`form.FieldArray`). */\nexport interface KrizakaFieldArray<T = unknown> {\n readonly name: string;\n readonly items: readonly T[];\n /** Adds an item at the end. */\n readonly push: (item: T) => void;\n /** Removes the item at `index`. */\n readonly remove: (index: number) => void;\n /** Moves an item. */\n readonly move: (from: number, to: number) => void;\n /** The name of a sub-field of an item: `name(0, \"url\")` → `links[0].url`. */\n readonly fieldName: (index: number, key?: string) => string;\n /** The error of the array itself (too few, too many), in words, once it should show. */\n readonly error: string | undefined;\n}\n\n/** Binds an array of the form (a list of links, of tiers): its items and their operations. */\nexport function useKrizakaFieldArray<T = unknown>(name: string): KrizakaFieldArray<T> {\n const ctx = useFormContext();\n const field = useField({ form: ctx.api, name: name as never, mode: \"array\" } as never) as unknown as AnyFieldApi;\n const attempts = useStore(ctx.api.store, (state: { submissionAttempts: number }) => state.submissionAttempts);\n const map = field.state.meta.errorMap as Record<string, FormFieldError | undefined>;\n const first = map.onServer ?? map.onChange ?? map.onSubmit;\n return {\n name,\n items: (field.state.value as T[] | undefined) ?? [],\n push: (item) => field.pushValue(item as never),\n remove: (index) => void field.removeValue(index),\n move: (from, to) => field.moveValue(from, to),\n fieldName: (index, key) => `${name}[${index}]${key ? `.${key}` : \"\"}`,\n error: first && (attempts > 0 || first.source === \"server\" || field.state.meta.isDirty) ? formMessage(first, ctx.i18n) : undefined,\n };\n}\n\n/** The value of a field, kept up to date (`form.Watch`): show a part of the form only when a box is ticked. */\nexport function useFormValue<T = unknown>(name: string): T {\n const ctx = useFormContext();\n return useStore(ctx.api.store, (state: { values: unknown }) => getPath(state.values, name)) as T;\n}\n\nexport type FormFieldProps<T = unknown> = {\n /** The field's name in the schema (typed by the form). */\n name: string;\n /** Checks the value on the server as it changes. */\n validateAsync?: FieldCheck<T>;\n /** The wait, in ms, before `validateAsync`. */\n asyncDebounceMs?: number;\n /** Draws the field: its value, setter, error (and the ids, on the web) (`useKrizakaField`). */\n children: (field: KrizakaField<T>) => React.ReactNode;\n};\n\n/** A field drawn by the app (a control the package does not have): the form's value and errors, any markup. */\nexport function FormField({ name, validateAsync, asyncDebounceMs, children }: Readonly<FormFieldProps>) {\n return <>{children(useKrizakaField(name, { validateAsync, asyncDebounceMs }))}</>;\n}\n\nexport type FieldArrayProps<T = unknown> = {\n /** The array's name in the schema (typed by the form). */\n name: string;\n /** Draws the items: `items`, `push`, `remove`, `move`, `fieldName(i, \"url\")` for the fields of an item. */\n children: (array: KrizakaFieldArray<T>) => React.ReactNode;\n};\n\n/** A list of fields that grows and shrinks (links, tiers, guests): each item's fields named `links[0].url`. */\nexport function FieldArray({ name, children }: Readonly<FieldArrayProps>) {\n return <>{children(useKrizakaFieldArray(name))}</>;\n}\n\nexport type WatchProps<T = unknown> = {\n /** The field to follow (typed by the form). */\n name: string;\n /** Draws from its current value: show a part of the form only when a choice is made. */\n children: (value: T) => React.ReactNode;\n};\n\n/** Renders from a field's current value (a part shown only when a choice is made, a total). */\nexport function Watch({ name, children }: Readonly<WatchProps>) {\n return <>{children(useFormValue(name))}</>;\n}\n\n/** The state of the submit, for a button: sending, and whether the last try succeeded. */\nexport function useFormStatus(): { submitting: boolean; succeeded: boolean; attempts: number } {\n const ctx = useFormContext();\n const submitting = useStore(ctx.api.store, (s: { isSubmitting: boolean }) => s.isSubmitting);\n const succeeded = useStore(ctx.api.store, (s: { isSubmitSuccessful: boolean }) => s.isSubmitSuccessful);\n const attempts = useStore(ctx.api.store, (s: { submissionAttempts: number }) => s.submissionAttempts);\n return { submitting, succeeded: succeeded && !ctx.error, attempts };\n}\n\nfunction getPath(source: unknown, path: string): unknown {\n let current = source;\n for (const part of path.replace(/\\[(\\d+)\\]/g, \".$1\").split(\".\")) {\n if (current === null || typeof current !== \"object\") return undefined;\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n}\n\n/** The first visible error of a form, in words (native: announced after a refused submit). */\nexport function firstVisibleError(ctx: FormContextValue): string | undefined {\n if (ctx.error) return formMessage(ctx.error, ctx.i18n);\n for (const meta of Object.values(ctx.api.state.fieldMeta) as { errorMap?: Record<string, FormFieldError | string | undefined> }[]) {\n const error = meta?.errorMap && Object.values(meta.errorMap).find(Boolean);\n if (error) return formMessage(error, ctx.i18n);\n }\n return undefined;\n}\n\n/** The platform's components, typed by the form's field names: `name` completes and is checked against the schema. */\nexport type BoundFields<C, N extends string> = {\n [K in keyof C]: C[K] extends (props: infer P) => infer R ? (P extends { name: string } ? (props: Omit<P, \"name\"> & { name: N }) => R : C[K]) : C[K];\n};\n\n/** A form in a component: its fields (typed by the schema), its submit and its state. */\nexport type KrizakaFormInstance<S extends FormSchema, C, RootProps> = BoundFields<C, FieldName<FormValues<S>>> & {\n /** The form element (web) or view (native): renders its fields and provides them the form. */\n Form: (props: RootProps) => React.ReactElement;\n /** Sends the form (what `Submit` does): `true` when it went through. */\n submit: () => Promise<boolean>;\n /** Back to the default values (or the given ones), errors cleared. */\n reset: (values?: FormValues<S>) => void;\n /** Sets a field's value from outside (a suggestion, a preset). */\n setValue: (name: FieldName<FormValues<S>>, value: unknown) => void;\n /** The values now. */\n getValues: () => FormValues<S>;\n /** The whole form's error (a refusal without a field), or null. */\n error: FormFieldError | null;\n /** TanStack's form, the escape hatch — never import @tanstack/* in a product. */\n api: AnyFormApi;\n};\n\n/** A form defined once (schema + defaults), used in components: `signUp.useForm({ onSubmit })`. */\nexport interface KrizakaFormFactory<S extends FormSchema, C, RootProps> {\n readonly schema: S;\n readonly defaultValues: FormValues<S>;\n /** The form in a component: `onSubmit` sends the values (a mutation), a thrown `KrizakaApiError` lands on the fields. */\n useForm<R = unknown>(options?: UseKrizakaFormOptions<S, R>): KrizakaFormInstance<S, C, RootProps>;\n /** The form sent by a Server Action: it receives the values and answers `{ ok: true, data }` or `{ ok: false, problem }`. */\n useFormWithAction<T = unknown>(action: (values: FormOutput<S>) => Promise<FormActionResult<T>>, options?: Omit<UseKrizakaFormOptions<S, FormActionResult<T>>, \"onSubmit\">): KrizakaFormInstance<S, C, RootProps>;\n}\n\n/** Builds a platform's `createKrizakaForm` from its field components and its root (web `<form>`, native `View`). */\nexport function makeCreateKrizakaForm<C extends object, RootProps extends object>(components: C, Root: (props: RootProps & { value: FormContextValue }) => React.ReactElement) {\n return function createKrizakaForm<S extends FormSchema>(definition: KrizakaFormDefinition<S>): KrizakaFormFactory<S, C, RootProps> {\n function useForm<R>(options?: UseKrizakaFormOptions<S, R>): KrizakaFormInstance<S, C, RootProps> {\n const ctx = useKrizakaFormCore(definition, options);\n // One `Form` for the life of the form (never remounted, so focus and fields stay): it reads the latest state from a\n // small store the hook updates.\n const [store] = React.useState(() => createStore(ctx));\n React.useLayoutEffect(() => store.set(ctx), [store, ctx]);\n const Form = React.useCallback((props: RootProps) => <Bound store={store} Root={Root} props={props} />, [store]);\n return React.useMemo(\n () =>\n ({\n ...components,\n Form,\n submit: ctx.submit,\n reset: (values?: FormValues<S>) => ctx.api.reset(values),\n setValue: (name: string, value: unknown) => ctx.api.setFieldValue(name as never, value as never),\n getValues: () => ctx.api.state.values as FormValues<S>,\n error: ctx.error,\n api: ctx.api,\n }) as unknown as KrizakaFormInstance<S, C, RootProps>,\n [ctx, Form],\n );\n }\n return {\n schema: definition.schema,\n defaultValues: definition.defaultValues,\n useForm,\n useFormWithAction: (action, options) => useForm({ ...options, onSubmit: action }),\n };\n };\n}\n\ntype Store<T> = { get: () => T; set: (value: T) => void; subscribe: (listener: () => void) => () => void };\n\nfunction createStore<T>(initial: T): Store<T> {\n let value = initial;\n const listeners = new Set<() => void>();\n return {\n get: () => value,\n set: (next) => {\n if (Object.is(next, value)) return;\n value = next;\n listeners.forEach((listener) => listener());\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\nfunction Bound<RootProps extends object>({ store, Root, props }: { store: Store<FormContextValue>; Root: (props: RootProps & { value: FormContextValue }) => React.ReactElement; props: RootProps }) {\n const value = React.useSyncExternalStore(store.subscribe, store.get, store.get);\n return <Root {...props} value={value} />;\n}\n"
2075
+ "content": "// Platform-neutral React (web and React Native): the engine of a Krizaka form, TanStack Form v1 behind the facade\n// (ADR-001: a product never imports @tanstack/*). A form = a Standard Schema (zod 4) + its default values; the schema\n// validates every change, an error shows once the person leaves the field or tries to send (and goes as soon as it is\n// fixed), a field may check a value on the server (debounced, aborted when the value changes), and a refusal of the\n// server (Problem Details `fields`) lands under its fields. The fields themselves are the platform's (web.tsx, native).\nimport { type AnyFieldApi, type AnyFormApi, type DeepKeys, type StandardSchemaV1, useField, useForm, useStore } from \"@tanstack/react-form\";\nimport * as React from \"react\";\n\nimport { type FormFieldError, type FormI18n, formMessage, type FormProblem, isFormProblem, issuesToFields, problemToErrors, type SchemaIssue } from \"./errors\";\n\n/** A schema the form validates with: any Standard Schema — zod 4 (`z.object`), valibot, arktype. */\nexport type FormSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>;\n/** The values a form holds: the schema's input. */\nexport type FormValues<S> = S extends { readonly \"~standard\": { readonly types?: { readonly input: infer I } } } ? I : never;\n/** The values a form sends: the schema's output (zod transforms applied). */\nexport type FormOutput<S> = S extends { readonly \"~standard\": { readonly types?: { readonly output: infer O } } } ? O : never;\n/** A field's name: `email`, `address.city`, `links[0].url`. */\nexport type FieldName<V> = DeepKeys<V> & string;\n\n/** What a Server Action (or any submit) answers: done, or a refusal the form shows. */\nexport type FormActionResult<T = unknown> = { ok: true; data?: T } | { ok: false; problem: FormProblem };\n\n/** A value checked on the server as it is typed: an error (or its key), or nothing when the value is fine. */\nexport type FieldCheck<T = unknown> = (value: T, signal: AbortSignal) => Promise<FormFieldError | string | null | undefined> | FormFieldError | string | null | undefined;\n\nexport interface KrizakaFormDefinition<S extends FormSchema> {\n /** The schema of the values (zod 4): the same one the server parses with. */\n schema: S;\n /** The values at first: every field of the schema. */\n defaultValues: FormValues<S>;\n /** The words: the app's translate function, the key prefixes, the locale. */\n i18n?: FormI18n;\n}\n\nexport interface UseKrizakaFormOptions<S extends FormSchema, R = unknown> {\n /** Sends the values (the schema's output): a mutation of @krizaka/query, a Server Action. Throw a `KrizakaApiError` or\n * return `{ ok: false, problem }` to refuse: its `fields` go under their fields, the rest above the button. */\n onSubmit?: (values: FormOutput<S>) => R | Promise<R>;\n /** Called after a successful submit with what `onSubmit` returned (`data` of a `{ ok: true, data }`). */\n onSuccess?: (result: R extends FormActionResult<infer T> ? T | undefined : R) => void;\n /** Values that replace the definition's (a profile loaded from the server). */\n defaultValues?: FormValues<S>;\n /** Overrides the definition's words (the translate function of a hook). */\n i18n?: FormI18n;\n /** The server's codes that belong to a field (`{ UNDERAGE: \"dateOfBirth\", USERNAME_RESERVED: \"username\" }`): a refusal\n * with that code shows under the field, as `form.errors.<CODE>`, instead of above the button. */\n codeFields?: Readonly<Record<string, string>>;\n}\n\n/** The state of a form, for its fields and its button. */\nexport interface FormContextValue {\n /** TanStack's form, through the facade: never import @tanstack/* in a product. */\n readonly api: AnyFormApi;\n readonly i18n: FormI18n;\n /** The whole form's error (a refusal without a field), or null. */\n readonly error: FormFieldError | null;\n /** Sends the form: validates, focuses (web) or announces (native) the first error, else calls `onSubmit`. */\n readonly submit: () => Promise<boolean>;\n}\n\nexport const FormContext = React.createContext<FormContextValue | null>(null);\n\n/** The form around a field: inside `form.Form`. */\nexport function useFormContext(): FormContextValue {\n const ctx = React.useContext(FormContext);\n if (!ctx) throw new Error(\"A Krizaka form field must be inside its form's `form.Form`.\");\n return ctx;\n}\n\ntype StandardResult = { readonly value?: unknown; readonly issues?: readonly SchemaIssue[] };\n\nconst run = (schema: FormSchema, value: unknown) => schema[\"~standard\"].validate(value) as StandardResult | Promise<StandardResult>;\n\n/** The engine of a form: TanStack's form wired to the schema, the server's refusals and the submit. */\nexport function useKrizakaFormCore<S extends FormSchema, R>(definition: KrizakaFormDefinition<S>, options: UseKrizakaFormOptions<S, R> = {}): FormContextValue {\n const i18n = { ...definition.i18n, ...options.i18n };\n const latest = React.useRef({ options, i18n });\n // The latest options for the engine's callbacks (a submit, a change), which outlive the render that made them.\n React.useLayoutEffect(() => {\n latest.current = { options, i18n };\n });\n const [error, setError] = React.useState<FormFieldError | null>(null);\n const refused = React.useRef(false);\n\n const api = useForm({\n defaultValues: options.defaultValues ?? definition.defaultValues,\n validators: {\n // Every change: the schema, synchronously (an async refinement waits for the submit). Errors are computed for\n // every field; each field shows its own once the person left it or tried to send.\n onChange: ({ value }: { value: unknown }) => {\n const result = run(definition.schema, value);\n if (result instanceof Promise || !result.issues?.length) return undefined;\n const fields = issuesToFields(result.issues, latest.current.i18n.prefix);\n delete fields[\"\"];\n return { fields };\n },\n },\n onSubmit: async ({ value }: { value: unknown }) => {\n const parsed = await run(definition.schema, value);\n if (parsed.issues?.length) {\n apply({ fields: issuesToFields(parsed.issues, latest.current.i18n.prefix) as FormProblem[\"fields\"] });\n return;\n }\n let result: unknown;\n try {\n result = await latest.current.options.onSubmit?.(parsed.value as FormOutput<S>);\n } catch (thrown) {\n apply(isFormProblem(thrown) ? thrown : { code: \"server\" });\n return;\n }\n if (result && typeof result === \"object\" && \"ok\" in result && (result as FormActionResult).ok === false) {\n apply((result as unknown as { problem: FormProblem }).problem);\n return;\n }\n const data = result && typeof result === \"object\" && \"ok\" in result ? (result as { data?: unknown }).data : result;\n latest.current.options.onSuccess?.(data as never);\n },\n });\n\n const known = (name: string) => name in api.fieldInfo;\n function apply(problem: FormProblem) {\n refused.current = true;\n const { fields, form } = problemToErrors(problem, latest.current.i18n, known, latest.current.options.codeFields);\n for (const [name, fieldError] of Object.entries(fields)) {\n api.setFieldMeta(name as never, (meta) => ({ ...meta, isBlurred: true, errorMap: { ...meta.errorMap, onServer: fieldError } }));\n }\n setError(form);\n }\n\n const submit = React.useCallback(async () => {\n setError(null);\n refused.current = false;\n for (const name of Object.keys(api.fieldInfo)) {\n if ((api.getFieldMeta(name as never) as { errorMap?: Record<string, unknown> } | undefined)?.errorMap?.onServer) api.setFieldMeta(name as never, (meta) => ({ ...meta, errorMap: { ...meta.errorMap, onServer: undefined } }));\n }\n await api.handleSubmit();\n const state = api.state;\n return !refused.current && state.isSubmitSuccessful && state.isValid && !(Object.values(state.fieldMeta) as { errorMap?: Record<string, unknown> }[]).some((meta) => meta?.errorMap?.onServer);\n }, [api]);\n\n return React.useMemo(() => ({ api, i18n, error, submit }), [api, error, submit, i18n.t, i18n.prefix, i18n.apiPrefix, i18n.locale]); // eslint-disable-line react-hooks/exhaustive-deps\n}\n\nconst UNCHECKED = Symbol(\"unchecked\");\n\nexport interface FieldOptions<T> {\n /** Checks the value on the server as it is typed (a username's availability): debounced, aborted when it changes. */\n validateAsync?: FieldCheck<T>;\n /** The wait, in ms, between the last change and `validateAsync`. Default 350. */\n asyncDebounceMs?: number;\n}\n\n/** A field as its component draws it: the value, its setter, its error in words, its state. */\nexport interface KrizakaField<T = unknown> {\n /** The id of the control (`htmlFor` of its label). */\n readonly id: string;\n readonly name: string;\n readonly value: T;\n /** Sets the value (clears a refusal of the server on it). */\n setValue(value: T): void;\n /** Call when the control loses focus: from then on, its errors show. */\n readonly onBlur: () => void;\n /** The error to show, in words — only once it should show. */\n readonly error: string | undefined;\n /** The error itself, with its suggestion. */\n readonly errorDetail: FormFieldError | undefined;\n /** A check (`validateAsync`) is running. */\n readonly validating: boolean;\n /** The check passed for the current value. */\n readonly available: boolean;\n /** The ids of the hint and the error (`aria-describedby`). */\n readonly hintId: string;\n readonly errorId: string;\n /** The form's locale (numbers, money, dates). */\n readonly locale: string;\n /** TanStack's field, through the facade. */\n readonly api: AnyFieldApi;\n}\n\n/** Binds a field of the form around it (inside `form.Form`): what the platform's field components are made of. */\nexport function useKrizakaField<T = unknown>(name: string, options: FieldOptions<T> = {}): KrizakaField<T> {\n const ctx = useFormContext();\n const id = React.useId();\n const [checked, setChecked] = React.useState<unknown>(UNCHECKED);\n const check = options.validateAsync;\n const field = useField({\n form: ctx.api,\n name: name as never,\n ...(check\n ? {\n asyncDebounceMs: options.asyncDebounceMs ?? 350,\n validators: {\n onChangeAsyncDebounceMs: options.asyncDebounceMs ?? 350,\n onChangeAsync: async ({ value, signal }: { value: T; signal: AbortSignal }) => {\n const answer = await check(value, signal);\n if (signal.aborted) return undefined;\n if (!answer) {\n setChecked(value);\n return undefined;\n }\n setChecked(UNCHECKED);\n const error = typeof answer === \"string\" ? { key: answer } : answer;\n return { ...error, immediate: true, source: \"check\" } satisfies FormFieldError;\n },\n },\n }\n : {}),\n } as never) as unknown as AnyFieldApi;\n const attempts = useStore(ctx.api.store, (state: { submissionAttempts: number }) => state.submissionAttempts);\n const meta = field.state.meta;\n const map = meta.errorMap as Record<string, unknown>;\n const all = [map.onServer, map.onChange, map.onBlur, map.onSubmit, map.onMount].filter(Boolean) as (FormFieldError | string)[];\n const first = all[0];\n const detail = typeof first === \"string\" ? { key: first } : first;\n const visible = detail && (detail.immediate || detail.source === \"server\" || meta.isBlurred || attempts > 0) ? detail : undefined;\n const value = field.state.value as T;\n\n return {\n id,\n name,\n value,\n setValue: (next: T) => {\n if (map.onServer) ctx.api.setFieldMeta(name as never, (m: { errorMap: Record<string, unknown> }) => ({ ...m, errorMap: { ...m.errorMap, onServer: undefined } }) as never);\n field.handleChange(next as never);\n },\n onBlur: () => field.handleBlur(),\n error: visible ? formMessage(visible, ctx.i18n) : undefined,\n errorDetail: visible,\n validating: Boolean(meta.isValidating),\n available: Boolean(check) && checked !== UNCHECKED && Object.is(checked, value) && !meta.isValidating && all.length === 0,\n hintId: `${id}-hint`,\n errorId: `${id}-error`,\n locale: ctx.i18n.locale ?? \"en\",\n api: field,\n };\n}\n\n/** The array of a field array, with its operations (`form.FieldArray`). */\nexport interface KrizakaFieldArray<T = unknown> {\n readonly name: string;\n readonly items: readonly T[];\n /** Adds an item at the end. */\n readonly push: (item: T) => void;\n /** Removes the item at `index`. */\n readonly remove: (index: number) => void;\n /** Moves an item. */\n readonly move: (from: number, to: number) => void;\n /** The name of a sub-field of an item: `name(0, \"url\")` → `links[0].url`. */\n readonly fieldName: (index: number, key?: string) => string;\n /** The error of the array itself (too few, too many), in words, once it should show. */\n readonly error: string | undefined;\n}\n\n/** Binds an array of the form (a list of links, of tiers): its items and their operations. */\nexport function useKrizakaFieldArray<T = unknown>(name: string): KrizakaFieldArray<T> {\n const ctx = useFormContext();\n const field = useField({ form: ctx.api, name: name as never, mode: \"array\" } as never) as unknown as AnyFieldApi;\n const attempts = useStore(ctx.api.store, (state: { submissionAttempts: number }) => state.submissionAttempts);\n const map = field.state.meta.errorMap as Record<string, FormFieldError | undefined>;\n const first = map.onServer ?? map.onChange ?? map.onSubmit;\n return {\n name,\n items: (field.state.value as T[] | undefined) ?? [],\n push: (item) => field.pushValue(item as never),\n remove: (index) => void field.removeValue(index),\n move: (from, to) => field.moveValue(from, to),\n fieldName: (index, key) => `${name}[${index}]${key ? `.${key}` : \"\"}`,\n error: first && (attempts > 0 || first.source === \"server\" || field.state.meta.isDirty) ? formMessage(first, ctx.i18n) : undefined,\n };\n}\n\n/** The value of a field, kept up to date (`form.Watch`): show a part of the form only when a box is ticked. */\nexport function useFormValue<T = unknown>(name: string): T {\n const ctx = useFormContext();\n return useStore(ctx.api.store, (state: { values: unknown }) => getPath(state.values, name)) as T;\n}\n\nexport type FormFieldProps<T = unknown> = {\n /** The field's name in the schema (typed by the form). */\n name: string;\n /** Checks the value on the server as it changes. */\n validateAsync?: FieldCheck<T>;\n /** The wait, in ms, before `validateAsync`. */\n asyncDebounceMs?: number;\n /** Draws the field: its value, setter, error (and the ids, on the web) (`useKrizakaField`). */\n children: (field: KrizakaField<T>) => React.ReactNode;\n};\n\n/** A field drawn by the app (a control the package does not have): the form's value and errors, any markup. */\nexport function FormField({ name, validateAsync, asyncDebounceMs, children }: Readonly<FormFieldProps>) {\n return <>{children(useKrizakaField(name, { validateAsync, asyncDebounceMs }))}</>;\n}\n\nexport type FieldArrayProps<T = unknown> = {\n /** The array's name in the schema (typed by the form). */\n name: string;\n /** Draws the items: `items`, `push`, `remove`, `move`, `fieldName(i, \"url\")` for the fields of an item. */\n children: (array: KrizakaFieldArray<T>) => React.ReactNode;\n};\n\n/** A list of fields that grows and shrinks (links, tiers, guests): each item's fields named `links[0].url`. */\nexport function FieldArray({ name, children }: Readonly<FieldArrayProps>) {\n return <>{children(useKrizakaFieldArray(name))}</>;\n}\n\nexport type WatchProps<T = unknown> = {\n /** The field to follow (typed by the form). */\n name: string;\n /** Draws from its current value: show a part of the form only when a choice is made. */\n children: (value: T) => React.ReactNode;\n};\n\n/** Renders from a field's current value (a part shown only when a choice is made, a total). */\nexport function Watch({ name, children }: Readonly<WatchProps>) {\n return <>{children(useFormValue(name))}</>;\n}\n\n/** The state of the submit, for a button: sending, and whether the last try succeeded. */\nexport function useFormStatus(): { submitting: boolean; succeeded: boolean; attempts: number } {\n const ctx = useFormContext();\n const submitting = useStore(ctx.api.store, (s: { isSubmitting: boolean }) => s.isSubmitting);\n const succeeded = useStore(ctx.api.store, (s: { isSubmitSuccessful: boolean }) => s.isSubmitSuccessful);\n const attempts = useStore(ctx.api.store, (s: { submissionAttempts: number }) => s.submissionAttempts);\n return { submitting, succeeded: succeeded && !ctx.error, attempts };\n}\n\nfunction getPath(source: unknown, path: string): unknown {\n let current = source;\n for (const part of path.replaceAll(/\\[(\\d+)\\]/g, \".$1\").split(\".\")) {\n if (current === null || typeof current !== \"object\") return undefined;\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n}\n\n/** The first visible error of a form, in words (native: announced after a refused submit). */\nexport function firstVisibleError(ctx: FormContextValue): string | undefined {\n if (ctx.error) return formMessage(ctx.error, ctx.i18n);\n for (const meta of Object.values(ctx.api.state.fieldMeta) as { errorMap?: Record<string, FormFieldError | string | undefined> }[]) {\n const error = meta?.errorMap && Object.values(meta.errorMap).find(Boolean);\n if (error) return formMessage(error, ctx.i18n);\n }\n return undefined;\n}\n\n/** The platform's components, typed by the form's field names: `name` completes and is checked against the schema. */\nexport type BoundFields<C, N extends string> = {\n [K in keyof C]: C[K] extends (props: infer P) => infer R ? (P extends { name: string } ? (props: Omit<P, \"name\"> & { name: N }) => R : C[K]) : C[K];\n};\n\n/** A form in a component: its fields (typed by the schema), its submit and its state. */\nexport type KrizakaFormInstance<S extends FormSchema, C, RootProps> = BoundFields<C, FieldName<FormValues<S>>> & {\n /** The form element (web) or view (native): renders its fields and provides them the form. */\n Form: (props: RootProps) => React.ReactElement;\n /** Sends the form (what `Submit` does): `true` when it went through. */\n submit: () => Promise<boolean>;\n /** Back to the default values (or the given ones), errors cleared. */\n reset: (values?: FormValues<S>) => void;\n /** Sets a field's value from outside (a suggestion, a preset). */\n setValue: (name: FieldName<FormValues<S>>, value: unknown) => void;\n /** The values now. */\n getValues: () => FormValues<S>;\n /** The whole form's error (a refusal without a field), or null. */\n error: FormFieldError | null;\n /** TanStack's form, the escape hatch — never import @tanstack/* in a product. */\n api: AnyFormApi;\n};\n\n/** A form defined once (schema + defaults), used in components: `signUp.useForm({ onSubmit })`. */\nexport interface KrizakaFormFactory<S extends FormSchema, C, RootProps> {\n readonly schema: S;\n readonly defaultValues: FormValues<S>;\n /** The form in a component: `onSubmit` sends the values (a mutation), a thrown `KrizakaApiError` lands on the fields. */\n useForm<R = unknown>(options?: UseKrizakaFormOptions<S, R>): KrizakaFormInstance<S, C, RootProps>;\n /** The form sent by a Server Action: it receives the values and answers `{ ok: true, data }` or `{ ok: false, problem }`. */\n useFormWithAction<T = unknown>(action: (values: FormOutput<S>) => Promise<FormActionResult<T>>, options?: Omit<UseKrizakaFormOptions<S, FormActionResult<T>>, \"onSubmit\">): KrizakaFormInstance<S, C, RootProps>;\n}\n\n/** Builds a platform's `createKrizakaForm` from its field components and its root (web `<form>`, native `View`). */\nexport function makeCreateKrizakaForm<C extends object, RootProps extends object>(components: C, Root: (props: RootProps & { value: FormContextValue }) => React.ReactElement) {\n return function createKrizakaForm<S extends FormSchema>(definition: KrizakaFormDefinition<S>): KrizakaFormFactory<S, C, RootProps> {\n function useForm<R>(options?: UseKrizakaFormOptions<S, R>): KrizakaFormInstance<S, C, RootProps> {\n const ctx = useKrizakaFormCore(definition, options);\n // One `Form` for the life of the form (never remounted, so focus and fields stay): it reads the latest state from a\n // small store the hook updates.\n const [store] = React.useState(() => createStore(ctx));\n React.useLayoutEffect(() => store.set(ctx), [store, ctx]);\n const Form = React.useCallback((props: RootProps) => <Bound store={store} Root={Root} props={props} />, [store]);\n return React.useMemo(\n () =>\n ({\n ...components,\n Form,\n submit: ctx.submit,\n reset: (values?: FormValues<S>) => ctx.api.reset(values),\n setValue: (name: string, value: unknown) => ctx.api.setFieldValue(name as never, value as never),\n getValues: () => ctx.api.state.values as FormValues<S>,\n error: ctx.error,\n api: ctx.api,\n }) as unknown as KrizakaFormInstance<S, C, RootProps>,\n [ctx, Form],\n );\n }\n return {\n schema: definition.schema,\n defaultValues: definition.defaultValues,\n useForm,\n useFormWithAction: (action, options) => useForm({ ...options, onSubmit: action }),\n };\n };\n}\n\ntype Store<T> = { get: () => T; set: (value: T) => void; subscribe: (listener: () => void) => () => void };\n\nfunction createStore<T>(initial: T): Store<T> {\n let value = initial;\n const listeners = new Set<() => void>();\n return {\n get: () => value,\n set: (next) => {\n if (Object.is(next, value)) return;\n value = next;\n listeners.forEach((listener) => listener());\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\nfunction Bound<RootProps extends object>({ store, Root, props }: Readonly<{ store: Store<FormContextValue>; Root: (props: RootProps & { value: FormContextValue }) => React.ReactElement; props: RootProps }>) {\n const value = React.useSyncExternalStore(store.subscribe, store.get, store.get);\n return <Root {...props} value={value} />;\n}\n"
2076
2076
  },
2077
2077
  {
2078
2078
  "path": "form/errors.ts",
2079
- "content": "// Platform-neutral and server-safe: no React, no DOM, no React Native. The errors of a Krizaka form — a schema's issues,\n// a server's Problem Details, an availability check — as one shape, `FormFieldError`, whose words come from a key of the\n// app's catalogue (`form.errors.tooShort`), never from the validation engine's English.\n\n/** A value a message placeholder takes (`{minimum}`, `{suggestion}`). */\nexport type FormMessageValue = string | number;\n\n/** An error of a field or of the whole form: the key of its words in the app's catalogue, and what fills them in. */\nexport interface FormFieldError {\n /** The i18n key: `form.errors.required`, or the key a schema names (`z.string().min(3, \"signUp.username.short\")`). */\n key: string;\n /** The placeholders of the message (`{ minimum: 3 }`). */\n values?: Readonly<Record<string, FormMessageValue>>;\n /** The server's own words, in English: shown only when the catalogue has no message for the key. */\n message?: string;\n /** A value to offer instead (a free username): a button under the error sets it. Its label is passed translated. */\n suggestion?: { readonly label: string; readonly value: unknown };\n /** Shown at once, while the person types (an availability check), not only once they leave the field. */\n immediate?: boolean;\n /** Where it comes from: the schema (default), a field's check, or the server's answer (kept until the field changes). */\n source?: \"schema\" | \"check\" | \"server\";\n}\n\n/** The English defaults of the generic errors, by code — the words a form shows when the app's catalogue has none. */\nexport const formMessages: Readonly<Record<string, string>> = {\n required: \"This field is required.\",\n tooShort: \"Use at least {minimum} characters.\",\n tooLong: \"Use at most {maximum} characters.\",\n tooSmall: \"Enter {minimum} or more.\",\n tooBig: \"Enter {maximum} or less.\",\n tooFew: \"Choose at least {minimum}.\",\n tooMany: \"Choose at most {maximum}.\",\n invalidEmail: \"Enter an e-mail address, like name@example.com.\",\n invalidUrl: \"Enter a web address, like https://example.com.\",\n invalidDate: \"Enter a real date.\",\n invalidNumber: \"Enter a number.\",\n invalidFormat: \"Check the format of this field.\",\n invalidChoice: \"Choose one of the options.\",\n invalid: \"Check this field.\",\n // The whole form (a server's answer without fields): the codes of @krizaka/query's KrizakaApiError.\n network: \"No connection. Check your network and try again.\",\n \"rate-limited\": \"Too many tries. Wait a moment and try again.\",\n unauthorized: \"Your session has ended. Sign in again.\",\n forbidden: \"You are not allowed to do this.\",\n conflict: \"This was changed meanwhile. Reload and try again.\",\n \"validation-failed\": \"Some fields need your attention.\",\n unavailable: \"The service is unavailable for a moment. Try again shortly.\",\n server: \"Something went wrong on our side. Try again.\",\n};\n\n/** How a form finds its words: the app's translate function, and the prefixes of its keys. */\nexport interface FormI18n {\n /** The app's translate function (`(key, values) => t(key, values)`): a string, or `undefined` when the key is missing. */\n t?: (key: string, values?: Readonly<Record<string, FormMessageValue>>) => string | undefined;\n /** The prefix of the generic field errors. Default `form.errors` (→ `form.errors.tooShort`). */\n prefix?: string;\n /** The prefix of the server's codes for the whole form, as `KrizakaApiError.messageKey()`. Default `apiErrors`. */\n apiPrefix?: string;\n /** The locale of numbers, money and dates. Default `en`. */\n locale?: string;\n}\n\nconst KEY = /^[\\w-]+(\\.[\\w-]+)+$/;\n\nconst fill = (text: string, values?: Readonly<Record<string, FormMessageValue>>) =>\n values ? text.replace(/\\{(\\w+)\\}/g, (all, name: string) => (values[name] === undefined ? all : String(values[name]))) : text;\n\n/** The words of an error: the app's catalogue, else the English default of its code, else the server's words, else the key. */\nexport function formMessage(error: FormFieldError | string, i18n: FormI18n = {}): string {\n const e = typeof error === \"string\" ? { key: error } : error;\n const translated = i18n.t?.(e.key, e.values);\n if (translated && translated !== e.key) return translated;\n const code = e.key.slice(e.key.lastIndexOf(\".\") + 1);\n const fallback = formMessages[code];\n // The server's words beat a generic default (a refusal without a code), never a default for its own code.\n if (e.message && (code === \"invalid\" || !fallback)) return e.message;\n if (fallback && (e.key.startsWith(`${i18n.prefix ?? \"form.errors\"}.`) || e.key.startsWith(`${i18n.apiPrefix ?? \"apiErrors\"}.`))) return fill(fallback, e.values);\n return e.message ?? (KEY.test(e.key) ? fill(fallback ?? formMessages.invalid!, e.values) : e.key);\n}\n\n/** One issue of a Standard Schema (zod 4, valibot, arktype): zod adds its `code` and limits, read when present. */\nexport interface SchemaIssue {\n readonly message: string;\n readonly path?: ReadonlyArray<PropertyKey | { readonly key: PropertyKey }>;\n readonly code?: string;\n readonly minimum?: number | bigint;\n readonly maximum?: number | bigint;\n readonly origin?: string;\n readonly format?: string;\n readonly input?: unknown;\n readonly expected?: string;\n}\n\n/** A field's name from an issue's path, as the form writes it: `links[0].url`. */\nexport function pathName(path: SchemaIssue[\"path\"]): string {\n let name = \"\";\n for (const part of path ?? []) {\n const key = typeof part === \"object\" && part !== null ? part.key : part;\n if (typeof key === \"number\") name += `[${key}]`;\n else name += name ? `.${String(key)}` : String(key);\n }\n return name;\n}\n\nconst num = (value: number | bigint | undefined) => (value === undefined ? undefined : Number(value));\n\n/** The key and values of an issue: the schema's own key when it names one, else the generic code of what failed. */\nexport function issueError(issue: SchemaIssue, prefix = \"form.errors\"): FormFieldError {\n if (KEY.test(issue.message)) return { key: issue.message };\n const key = (code: string, values?: Record<string, FormMessageValue>) => ({ key: `${prefix}.${code}`, ...(values ? { values } : {}) });\n const collection = issue.origin === \"array\" || issue.origin === \"set\";\n switch (issue.code) {\n case \"invalid_type\":\n return issue.input === undefined || issue.input === null || issue.input === \"\" ? key(\"required\") : issue.expected === \"number\" ? key(\"invalidNumber\") : issue.expected === \"date\" ? key(\"invalidDate\") : key(\"invalid\");\n case \"too_small\": {\n const minimum = num(issue.minimum)!;\n if (issue.origin === \"string\") return minimum <= 1 ? key(\"required\") : key(\"tooShort\", { minimum });\n if (collection) return minimum <= 1 ? key(\"required\") : key(\"tooFew\", { minimum });\n return key(\"tooSmall\", { minimum });\n }\n case \"too_big\": {\n const maximum = num(issue.maximum)!;\n return issue.origin === \"string\" ? key(\"tooLong\", { maximum }) : collection ? key(\"tooMany\", { maximum }) : key(\"tooBig\", { maximum });\n }\n case \"invalid_format\":\n if (issue.format === \"email\") return key(\"invalidEmail\");\n if (issue.format === \"url\") return key(\"invalidUrl\");\n if (issue.format === \"date\" || issue.format === \"datetime\") return key(\"invalidDate\");\n return key(\"invalidFormat\");\n case \"invalid_value\":\n // `z.literal(true)`: a box that must be ticked.\n return issue.input === false || issue.input === undefined ? key(\"required\") : key(\"invalidChoice\");\n case \"invalid_union\":\n case \"invalid_key\":\n case \"invalid_element\":\n return key(\"invalidChoice\");\n default:\n return key(\"invalid\");\n }\n}\n\n/** The first error of each field of a schema's issues (an issue without a path is the whole form's: `\"\"`). */\nexport function issuesToFields(issues: readonly SchemaIssue[], prefix?: string): Record<string, FormFieldError> {\n const fields: Record<string, FormFieldError> = {};\n for (const issue of issues) {\n const name = pathName(issue.path);\n if (!(name in fields)) fields[name] = { ...issueError(issue, prefix), source: \"schema\" };\n }\n return fields;\n}\n\n/**\n * A refusal the form shows, serialisable (a Server Action returns it): the shape of `KrizakaApiError` of @krizaka/query —\n * a `KrizakaApiError` *is* a `FormProblem`. `fields` go under their fields, the rest above the submit button.\n */\nexport interface FormProblem {\n /** The HTTP status (0 when no response arrived). */\n status?: number;\n /** The stable code of the refusal (`rate-limited`, `conflict`, `ACCOUNT_EXISTS`): the key of its words. */\n code?: string;\n /** The server's sentence, in English: shown only when the catalogue has no message for the code. */\n detail?: string;\n /** The refused fields, by name: a server's `{ code, message }`, or an error the form already knows (`key`). */\n fields?: Readonly<Record<string, { code?: string; message: string } | FormFieldError | string>>;\n /** Epoch ms before which the same call is refused (a 429). */\n retryAt?: number;\n}\n\n/** True for what a form can read as a problem: a `KrizakaApiError`, a `FormProblem`, an `{ ok: false, problem }` result. */\nexport function isFormProblem(value: unknown): value is FormProblem {\n return typeof value === \"object\" && value !== null && (\"fields\" in value || \"code\" in value || \"status\" in value);\n}\n\n/** A problem as field errors (by name) and the whole form's error (or `null` when every refusal has its field). */\nexport function problemToErrors(\n problem: FormProblem,\n i18n: FormI18n = {},\n known?: (name: string) => boolean,\n codeFields: Readonly<Record<string, string>> = {},\n): { fields: Record<string, FormFieldError>; form: FormFieldError | null } {\n const prefix = i18n.prefix ?? \"form.errors\";\n const fields: Record<string, FormFieldError> = {};\n let unplaced = false;\n // A refusal named by a code that belongs to a field (`UNDERAGE` → `dateOfBirth`): under that field, in its words.\n const owner = problem.code ? codeFields[problem.code] : undefined;\n if (owner && (!known || known(owner)) && !problem.fields?.[owner]) {\n fields[owner] = { key: `${prefix}.${problem.code}`, ...(problem.detail ? { message: problem.detail } : {}), source: \"server\" };\n if (!problem.fields || Object.keys(problem.fields).length === 0) return { fields, form: null };\n }\n for (const [name, refusal] of Object.entries(problem.fields ?? {})) {\n if (known && !known(name)) {\n unplaced = true;\n continue;\n }\n const error: FormFieldError =\n typeof refusal === \"string\"\n ? { key: refusal }\n : \"key\" in refusal\n ? refusal\n : { key: refusal.code ? (KEY.test(refusal.code) ? refusal.code : `${prefix}.${refusal.code}`) : `${prefix}.invalid`, message: refusal.message };\n fields[name] = { ...error, source: \"server\" };\n }\n const placed = Object.keys(fields).length > 0;\n if (placed && !unplaced) return { fields, form: null };\n const code = problem.code ?? (problem.status === 0 ? \"network\" : problem.status && problem.status >= 500 ? \"server\" : \"invalid\");\n const retryIn = problem.retryAt ? Math.max(1, Math.ceil((problem.retryAt - Date.now()) / 1000)) : undefined;\n return {\n fields,\n form: { key: KEY.test(code) ? code : `${i18n.apiPrefix ?? \"apiErrors\"}.${code}`, ...(problem.detail ? { message: problem.detail } : {}), ...(retryIn ? { values: { seconds: retryIn } } : {}), source: \"server\" },\n };\n}\n"
2079
+ "content": "// Platform-neutral and server-safe: no React, no DOM, no React Native. The errors of a Krizaka form — a schema's issues,\n// a server's Problem Details, an availability check — as one shape, `FormFieldError`, whose words come from a key of the\n// app's catalogue (`form.errors.tooShort`), never from the validation engine's English.\n\n/** A value a message placeholder takes (`{minimum}`, `{suggestion}`). */\nexport type FormMessageValue = string | number;\n\n/** An error of a field or of the whole form: the key of its words in the app's catalogue, and what fills them in. */\nexport interface FormFieldError {\n /** The i18n key: `form.errors.required`, or the key a schema names (`z.string().min(3, \"signUp.username.short\")`). */\n key: string;\n /** The placeholders of the message (`{ minimum: 3 }`). */\n values?: Readonly<Record<string, FormMessageValue>>;\n /** The server's own words, in English: shown only when the catalogue has no message for the key. */\n message?: string;\n /** A value to offer instead (a free username): a button under the error sets it. Its label is passed translated. */\n suggestion?: { readonly label: string; readonly value: unknown };\n /** Shown at once, while the person types (an availability check), not only once they leave the field. */\n immediate?: boolean;\n /** Where it comes from: the schema (default), a field's check, or the server's answer (kept until the field changes). */\n source?: \"schema\" | \"check\" | \"server\";\n}\n\n/** The English defaults of the generic errors, by code — the words a form shows when the app's catalogue has none. */\nexport const formMessages: Readonly<Record<string, string>> = {\n required: \"This field is required.\",\n tooShort: \"Use at least {minimum} characters.\",\n tooLong: \"Use at most {maximum} characters.\",\n tooSmall: \"Enter {minimum} or more.\",\n tooBig: \"Enter {maximum} or less.\",\n tooFew: \"Choose at least {minimum}.\",\n tooMany: \"Choose at most {maximum}.\",\n invalidEmail: \"Enter an e-mail address, like name@example.com.\",\n invalidUrl: \"Enter a web address, like https://example.com.\",\n invalidDate: \"Enter a real date.\",\n invalidNumber: \"Enter a number.\",\n invalidFormat: \"Check the format of this field.\",\n invalidChoice: \"Choose one of the options.\",\n invalid: \"Check this field.\",\n // The whole form (a server's answer without fields): the codes of @krizaka/query's KrizakaApiError.\n network: \"No connection. Check your network and try again.\",\n \"rate-limited\": \"Too many tries. Wait a moment and try again.\",\n unauthorized: \"Your session has ended. Sign in again.\",\n forbidden: \"You are not allowed to do this.\",\n conflict: \"This was changed meanwhile. Reload and try again.\",\n \"validation-failed\": \"Some fields need your attention.\",\n unavailable: \"The service is unavailable for a moment. Try again shortly.\",\n server: \"Something went wrong on our side. Try again.\",\n};\n\n/** How a form finds its words: the app's translate function, and the prefixes of its keys. */\nexport interface FormI18n {\n /** The app's translate function (`(key, values) => t(key, values)`): a string, or `undefined` when the key is missing. */\n t?: (key: string, values?: Readonly<Record<string, FormMessageValue>>) => string | undefined;\n /** The prefix of the generic field errors. Default `form.errors` (→ `form.errors.tooShort`). */\n prefix?: string;\n /** The prefix of the server's codes for the whole form, as `KrizakaApiError.messageKey()`. Default `apiErrors`. */\n apiPrefix?: string;\n /** The locale of numbers, money and dates. Default `en`. */\n locale?: string;\n}\n\nconst KEY = /^[\\w-]+(\\.[\\w-]+)+$/;\n\nconst fill = (text: string, values?: Readonly<Record<string, FormMessageValue>>) =>\n values ? text.replaceAll(/\\{(\\w+)\\}/g, (all, name: string) => (values[name] === undefined ? all : String(values[name]))) : text;\n\n/** The words of an error: the app's catalogue, else the English default of its code, else the server's words, else the key. */\nexport function formMessage(error: FormFieldError | string, i18n: FormI18n = {}): string {\n const e = typeof error === \"string\" ? { key: error } : error;\n const translated = i18n.t?.(e.key, e.values);\n if (translated && translated !== e.key) return translated;\n const code = e.key.slice(e.key.lastIndexOf(\".\") + 1);\n const fallback = formMessages[code];\n // The server's words beat a generic default (a refusal without a code), never a default for its own code.\n if (e.message && (code === \"invalid\" || !fallback)) return e.message;\n if (fallback && (e.key.startsWith(`${i18n.prefix ?? \"form.errors\"}.`) || e.key.startsWith(`${i18n.apiPrefix ?? \"apiErrors\"}.`))) return fill(fallback, e.values);\n return e.message ?? (KEY.test(e.key) ? fill(fallback ?? formMessages.invalid!, e.values) : e.key);\n}\n\n/** One issue of a Standard Schema (zod 4, valibot, arktype): zod adds its `code` and limits, read when present. */\nexport interface SchemaIssue {\n readonly message: string;\n readonly path?: ReadonlyArray<PropertyKey | { readonly key: PropertyKey }>;\n readonly code?: string;\n readonly minimum?: number | bigint;\n readonly maximum?: number | bigint;\n readonly origin?: string;\n readonly format?: string;\n readonly input?: unknown;\n readonly expected?: string;\n}\n\n/** A field's name from an issue's path, as the form writes it: `links[0].url`. */\nexport function pathName(path: SchemaIssue[\"path\"]): string {\n let name = \"\";\n for (const part of path ?? []) {\n const key = typeof part === \"object\" && part !== null ? part.key : part;\n if (typeof key === \"number\") name += `[${key}]`;\n else name += name ? `.${String(key)}` : String(key);\n }\n return name;\n}\n\nconst num = (value: number | bigint | undefined) => (value === undefined ? undefined : Number(value));\n\n/** The key and values of an issue: the schema's own key when it names one, else the generic code of what failed. */\nexport function issueError(issue: SchemaIssue, prefix = \"form.errors\"): FormFieldError {\n if (KEY.test(issue.message)) return { key: issue.message };\n const key = (code: string, values?: Record<string, FormMessageValue>) => ({ key: `${prefix}.${code}`, ...(values ? { values } : {}) });\n const collection = issue.origin === \"array\" || issue.origin === \"set\";\n switch (issue.code) {\n case \"invalid_type\":\n return issue.input === undefined || issue.input === null || issue.input === \"\" ? key(\"required\") : issue.expected === \"number\" ? key(\"invalidNumber\") : issue.expected === \"date\" ? key(\"invalidDate\") : key(\"invalid\");\n case \"too_small\": {\n const minimum = num(issue.minimum)!;\n if (issue.origin === \"string\") return minimum <= 1 ? key(\"required\") : key(\"tooShort\", { minimum });\n if (collection) return minimum <= 1 ? key(\"required\") : key(\"tooFew\", { minimum });\n return key(\"tooSmall\", { minimum });\n }\n case \"too_big\": {\n const maximum = num(issue.maximum)!;\n return issue.origin === \"string\" ? key(\"tooLong\", { maximum }) : collection ? key(\"tooMany\", { maximum }) : key(\"tooBig\", { maximum });\n }\n case \"invalid_format\":\n if (issue.format === \"email\") return key(\"invalidEmail\");\n if (issue.format === \"url\") return key(\"invalidUrl\");\n if (issue.format === \"date\" || issue.format === \"datetime\") return key(\"invalidDate\");\n return key(\"invalidFormat\");\n case \"invalid_value\":\n // `z.literal(true)`: a box that must be ticked.\n return issue.input === false || issue.input === undefined ? key(\"required\") : key(\"invalidChoice\");\n case \"invalid_union\":\n case \"invalid_key\":\n case \"invalid_element\":\n return key(\"invalidChoice\");\n default:\n return key(\"invalid\");\n }\n}\n\n/** The first error of each field of a schema's issues (an issue without a path is the whole form's: `\"\"`). */\nexport function issuesToFields(issues: readonly SchemaIssue[], prefix?: string): Record<string, FormFieldError> {\n const fields: Record<string, FormFieldError> = {};\n for (const issue of issues) {\n const name = pathName(issue.path);\n if (!(name in fields)) fields[name] = { ...issueError(issue, prefix), source: \"schema\" };\n }\n return fields;\n}\n\n/**\n * A refusal the form shows, serialisable (a Server Action returns it): the shape of `KrizakaApiError` of @krizaka/query —\n * a `KrizakaApiError` *is* a `FormProblem`. `fields` go under their fields, the rest above the submit button.\n */\nexport interface FormProblem {\n /** The HTTP status (0 when no response arrived). */\n status?: number;\n /** The stable code of the refusal (`rate-limited`, `conflict`, `ACCOUNT_EXISTS`): the key of its words. */\n code?: string;\n /** The server's sentence, in English: shown only when the catalogue has no message for the code. */\n detail?: string;\n /** The refused fields, by name: a server's `{ code, message }`, or an error the form already knows (`key`). */\n fields?: Readonly<Record<string, { code?: string; message: string } | FormFieldError | string>>;\n /** Epoch ms before which the same call is refused (a 429). */\n retryAt?: number;\n}\n\n/** True for what a form can read as a problem: a `KrizakaApiError`, a `FormProblem`, an `{ ok: false, problem }` result. */\nexport function isFormProblem(value: unknown): value is FormProblem {\n return typeof value === \"object\" && value !== null && (\"fields\" in value || \"code\" in value || \"status\" in value);\n}\n\n/** A problem as field errors (by name) and the whole form's error (or `null` when every refusal has its field). */\nexport function problemToErrors(\n problem: FormProblem,\n i18n: FormI18n = {},\n known?: (name: string) => boolean,\n codeFields: Readonly<Record<string, string>> = {},\n): { fields: Record<string, FormFieldError>; form: FormFieldError | null } {\n const prefix = i18n.prefix ?? \"form.errors\";\n const fields: Record<string, FormFieldError> = {};\n let unplaced = false;\n // A refusal named by a code that belongs to a field (`UNDERAGE` → `dateOfBirth`): under that field, in its words.\n const owner = problem.code ? codeFields[problem.code] : undefined;\n if (owner && (!known || known(owner)) && !problem.fields?.[owner]) {\n fields[owner] = { key: `${prefix}.${problem.code}`, ...(problem.detail ? { message: problem.detail } : {}), source: \"server\" };\n if (!problem.fields || Object.keys(problem.fields).length === 0) return { fields, form: null };\n }\n for (const [name, refusal] of Object.entries(problem.fields ?? {})) {\n if (known && !known(name)) {\n unplaced = true;\n continue;\n }\n const error: FormFieldError =\n typeof refusal === \"string\"\n ? { key: refusal }\n : \"key\" in refusal\n ? refusal\n : { key: refusal.code ? (KEY.test(refusal.code) ? refusal.code : `${prefix}.${refusal.code}`) : `${prefix}.invalid`, message: refusal.message };\n fields[name] = { ...error, source: \"server\" };\n }\n const placed = Object.keys(fields).length > 0;\n if (placed && !unplaced) return { fields, form: null };\n const code = problem.code ?? (problem.status === 0 ? \"network\" : problem.status && problem.status >= 500 ? \"server\" : \"invalid\");\n const retryIn = problem.retryAt ? Math.max(1, Math.ceil((problem.retryAt - Date.now()) / 1000)) : undefined;\n return {\n fields,\n form: { key: KEY.test(code) ? code : `${i18n.apiPrefix ?? \"apiErrors\"}.${code}`, ...(problem.detail ? { message: problem.detail } : {}), ...(retryIn ? { values: { seconds: retryIn } } : {}), source: \"server\" },\n };\n}\n"
2080
2080
  },
2081
2081
  {
2082
2082
  "path": "form/index.ts",
@@ -2088,7 +2088,7 @@
2088
2088
  },
2089
2089
  {
2090
2090
  "path": "form/money.ts",
2091
- "content": "// Platform-neutral: an amount typed in a field ↔ integer minor units (cents), never a float on the way.\nimport { currencyDigits } from \"@krizaka/intl\";\n\n/** The decimal separator of a locale (`en` → `.`, `fr` → `,`). */\nexport function decimalSeparator(locale: string): string {\n return new Intl.NumberFormat(locale).formatToParts(1.5).find((p) => p.type === \"decimal\")?.value ?? \".\";\n}\n\n/** The currency's sign in a locale (`USD`, `en-US` → `$`; `EUR`, `fr` → `€`). */\nexport function currencySymbol(currency: string, locale: string): string {\n return new Intl.NumberFormat(locale, { style: \"currency\", currency }).formatToParts(0).find((p) => p.type === \"currency\")?.value ?? currency;\n}\n\n/**\n * An amount as typed (`12.5`, `12,50`, `1,234.56`, `1 234,56`) → integer minor units (`1250`). `undefined` when empty,\n * `null` when it is not an amount (letters, more decimals than the currency has).\n */\nexport function parseMoney(text: string, currency: string, locale = \"en\"): number | null | undefined {\n const digits = currencyDigits(currency);\n const t = text.replace(/[\\s\\u00a0\\u202f']/g, \"\");\n if (!t) return undefined;\n const negative = t.startsWith(\"-\");\n const body = negative ? t.slice(1) : t;\n if (!/^[\\d.,]+$/.test(body)) return null;\n let int = body;\n let frac = \"\";\n const last = Math.max(body.lastIndexOf(\".\"), body.lastIndexOf(\",\"));\n if (last >= 0) {\n const tail = body.slice(last + 1);\n // The last separator is the decimal one when it is the locale's, or when it is not followed by a group of three.\n if (body[last] === decimalSeparator(locale) || tail.length !== 3) {\n if (tail.length > digits || !/^\\d*$/.test(tail)) return null;\n int = body.slice(0, last);\n frac = tail;\n }\n }\n // What is left before the decimals: digits, grouped by three when separated (`1,234,567`).\n if (!/^(\\d*|\\d{1,3}([.,]\\d{3})+)$/.test(int)) return null;\n int = int.replace(/[.,]/g, \"\");\n if (!int && !frac) return null;\n const units = BigInt(int || \"0\") * 10n ** BigInt(digits) + BigInt((frac || \"\").padEnd(digits, \"0\") || \"0\");\n const value = Number(negative ? -units : units);\n return Number.isSafeInteger(value) ? value : null;\n}\n\n/** Minor units as the field writes them while editing (`1250`, `USD`, `fr` → `12,50`): no symbol, no grouping. */\nexport function moneyInputText(minorUnits: number | null | undefined, currency: string, locale = \"en\"): string {\n if (minorUnits === null || minorUnits === undefined || !Number.isFinite(minorUnits)) return \"\";\n const digits = currencyDigits(currency);\n const sign = minorUnits < 0 ? \"-\" : \"\";\n const abs = String(Math.abs(Math.trunc(minorUnits))).padStart(digits + 1, \"0\");\n return digits === 0 ? sign + abs : `${sign}${abs.slice(0, -digits)}${decimalSeparator(locale)}${abs.slice(-digits)}`;\n}\n"
2091
+ "content": "// Platform-neutral: an amount typed in a field ↔ integer minor units (cents), never a float on the way.\nimport { currencyDigits } from \"@krizaka/intl\";\n\n/** The decimal separator of a locale (`en` → `.`, `fr` → `,`). */\nexport function decimalSeparator(locale: string): string {\n return new Intl.NumberFormat(locale).formatToParts(1.5).find((p) => p.type === \"decimal\")?.value ?? \".\";\n}\n\n/** The currency's sign in a locale (`USD`, `en-US` → `$`; `EUR`, `fr` → `€`). */\nexport function currencySymbol(currency: string, locale: string): string {\n return new Intl.NumberFormat(locale, { style: \"currency\", currency }).formatToParts(0).find((p) => p.type === \"currency\")?.value ?? currency;\n}\n\n/**\n * An amount as typed (`12.5`, `12,50`, `1,234.56`, `1 234,56`) → integer minor units (`1250`). `undefined` when empty,\n * `null` when it is not an amount (letters, more decimals than the currency has).\n */\nexport function parseMoney(text: string, currency: string, locale = \"en\"): number | null | undefined {\n const digits = currencyDigits(currency);\n const t = text.replaceAll(/[\\s\\u00a0\\u202f']/g, \"\");\n if (!t) return undefined;\n const negative = t.startsWith(\"-\");\n const body = negative ? t.slice(1) : t;\n if (!/^[\\d.,]+$/.test(body)) return null;\n let int = body;\n let frac = \"\";\n const last = Math.max(body.lastIndexOf(\".\"), body.lastIndexOf(\",\"));\n if (last >= 0) {\n const tail = body.slice(last + 1);\n // The last separator is the decimal one when it is the locale's, or when it is not followed by a group of three.\n if (body[last] === decimalSeparator(locale) || tail.length !== 3) {\n if (tail.length > digits || !/^\\d*$/.test(tail)) return null;\n int = body.slice(0, last);\n frac = tail;\n }\n }\n // What is left before the decimals: digits, grouped by three when separated (`1,234,567`).\n if (!/^(\\d*|\\d{1,3}([.,]\\d{3})+)$/.test(int)) return null;\n int = int.replaceAll(/[.,]/g, \"\");\n if (!int && !frac) return null;\n const units = BigInt(int || \"0\") * 10n ** BigInt(digits) + BigInt((frac || \"\").padEnd(digits, \"0\") || \"0\");\n const value = Number(negative ? -units : units);\n return Number.isSafeInteger(value) ? value : null;\n}\n\n/** Minor units as the field writes them while editing (`1250`, `USD`, `fr` → `12,50`): no symbol, no grouping. */\nexport function moneyInputText(minorUnits: number | null | undefined, currency: string, locale = \"en\"): string {\n if (minorUnits === null || minorUnits === undefined || !Number.isFinite(minorUnits)) return \"\";\n const digits = currencyDigits(currency);\n const sign = minorUnits < 0 ? \"-\" : \"\";\n const abs = String(Math.abs(Math.trunc(minorUnits))).padStart(digits + 1, \"0\");\n return digits === 0 ? sign + abs : `${sign}${abs.slice(0, -digits)}${decimalSeparator(locale)}${abs.slice(-digits)}`;\n}\n"
2092
2092
  },
2093
2093
  {
2094
2094
  "path": "form/server.ts",
@@ -2096,7 +2096,7 @@
2096
2096
  },
2097
2097
  {
2098
2098
  "path": "form/web.tsx",
2099
- "content": "// Client. The form's fields for the web: thin adapters from a form field (useKrizakaField) to the platform's current\n// primitives — Field + Input, Checkbox, Switch, RadioGroup (dots, cards, tactile keys, segments), Combobox, the date\n// pickers (calendar, typed, wheels), TagInput, Dropzone, Slider. A new look for a primitive changes an adapter here,\n// never a form.\nimport { Alert } from \"@krizaka/ui/alert\";\nimport { Button, type ButtonProps } from \"@krizaka/ui/button\";\nimport { Checkbox as CheckboxControl } from \"@krizaka/ui/checkbox\";\nimport { Combobox as ComboboxControl, type ComboboxLabels, type ComboboxOption } from \"@krizaka/ui/combobox\";\nimport { DateField as DatePartsControl, DatePicker, type DatePickerLabels, DateWheel } from \"@krizaka/ui/date-picker\";\nimport { Field, Input, Select as SelectControl, Textarea } from \"@krizaka/ui/field\";\nimport { Dropzone, formatBytes } from \"@krizaka/ui/file-upload\";\nimport { RadioGroup as RadioGroupControl } from \"@krizaka/ui/radio-group\";\nimport { Slider as SliderControl, type SliderMark, type SliderValue } from \"@krizaka/ui/slider\";\nimport { Spinner } from \"@krizaka/ui/spinner\";\nimport { Switch as SwitchControl } from \"@krizaka/ui/switch\";\nimport { TagInput as TagInputControl, type TagInputProps } from \"@krizaka/ui/tag-input\";\nimport * as React from \"react\";\n\nimport type { DatePart } from \"../date-picker/parts\";\nimport {\n FieldArray,\n type FieldCheck,\n FormContext,\n type FormContextValue,\n FormField,\n type KrizakaField,\n makeCreateKrizakaForm,\n useFormContext,\n useFormStatus,\n useKrizakaField,\n Watch,\n} from \"./core\";\nimport { formMessage } from \"./errors\";\nimport { currencySymbol, moneyInputText, parseMoney } from \"./money\";\n\nexport { FieldArray, FormField, Watch };\nexport type { FieldArrayProps, FormFieldProps, WatchProps } from \"./core\";\n\ntype Base = {\n /** The field's name in the schema: `email`, `address.city`, `links[0].url` (typed by the form). */\n name: string;\n /** The visible label, passed translated (also the control's accessible name). */\n label: string;\n /** A help text under the control, read with it; the error takes its place when there is one. */\n hint?: string;\n /** Not available. */\n disabled?: boolean;\n /** Classes merged on the field's root. */\n className?: string;\n};\n\nconst ids = (f: KrizakaField, hint?: string) => [hint && !f.error ? f.hintId : null, f.error ? f.errorId : null].filter(Boolean).join(\" \") || undefined;\n\nfunction Caption({ field, hint, ok }: { field: KrizakaField; hint?: string; ok?: string }) {\n const suggestion = field.errorDetail?.suggestion;\n if (field.error)\n return (\n <Field.Error id={field.errorId}>\n <span>\n {field.error}\n {suggestion ? (\n <>\n {\" \"}\n <button type=\"button\" className=\"font-semibold text-accent-text underline underline-offset-2\" onClick={() => field.setValue(suggestion.value)}>\n {suggestion.label}\n </button>\n </>\n ) : null}\n </span>\n </Field.Error>\n );\n const text = field.available && ok ? (hint ? `${ok} · ${hint}` : ok) : hint;\n return text ? <Field.Hint id={field.hintId}>{text}</Field.Hint> : null;\n}\n\nconst Check = () => (\n <svg viewBox=\"0 0 24 24\" className=\"h-4 w-4 text-fg-success\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n);\n\nexport type FormProps = Omit<React.ComponentProps<\"form\">, \"onSubmit\" | \"noValidate\"> & {\n /** The fields, the error and the button. */\n children?: React.ReactNode;\n};\n\n/** The `<form>` of a form (`form.Form`): `noValidate` (the schema validates), the first error focused after a refused submit. */\nfunction FormRoot({ value, className, children, ...props }: FormProps & { value: FormContextValue }) {\n const ref = React.useRef<HTMLFormElement>(null);\n return (\n <FormContext.Provider value={value}>\n <form\n ref={ref}\n noValidate\n className={className ?? \"flex flex-col gap-4\"}\n onSubmit={async (event) => {\n event.preventDefault();\n if (!(await value.submit())) requestAnimationFrame(() => ref.current?.querySelector<HTMLElement>('[aria-invalid=\"true\"], [data-invalid] input')?.focus());\n }}\n {...props}\n >\n {children}\n </form>\n </FormContext.Provider>\n );\n}\n\nexport type SubmitProps = Omit<ButtonProps, \"type\" | \"loading\"> & {\n /** The button's words, passed translated (\"Create my account\"). */\n children: React.ReactNode;\n};\n\n/** The submit button: busy while the form is sent (not pressable twice), never disabled for an invalid form. */\nexport function Submit({ variant = \"primary\", children, ...props }: SubmitProps) {\n const { submitting } = useFormStatus();\n return (\n <Button type=\"submit\" variant={variant} loading={submitting} {...props}>\n {children}\n </Button>\n );\n}\n\nexport type FormErrorProps = {\n /** A headline above the message (\"We could not create your account\"), passed translated. */\n title?: string;\n /** Classes merged on the alert. */\n className?: string;\n};\n\n/** The whole form's error — a refusal of the server that belongs to no field (a conflict, too many tries, no network). */\nexport function FormError({ title, className }: FormErrorProps) {\n const ctx = useFormContext();\n if (!ctx.error) return null;\n return (\n <Alert tone=\"danger\" title={title} className={className}>\n {formMessage(ctx.error, ctx.i18n)}\n </Alert>\n );\n}\n\nexport type TextFieldProps = Base & {\n /** `text` (default), `email`, `password`, `url`, `tel`, `search`: the right keyboard on a phone. */\n type?: \"text\" | \"email\" | \"password\" | \"url\" | \"tel\" | \"search\";\n /** The browser's autofill (`email`, `username`, `new-password`, `name`). */\n autoComplete?: string;\n /** An example of a value, passed translated — never the label. */\n placeholder?: string;\n /** The keyboard on a phone (`numeric`, `decimal`). */\n inputMode?: React.HTMLAttributes<HTMLInputElement>[\"inputMode\"];\n /** The most characters. */\n maxLength?: number;\n /** Cleans what is typed before it is stored (`(v) => v.toLowerCase().replace(/\\s+/g, \"_\")`). */\n transform?: (raw: string) => string;\n /** Checks the value on the server as it is typed (availability): an error key, or nothing when it is fine. */\n validateAsync?: FieldCheck<string>;\n /** The wait, in ms, between the last key and `validateAsync`. Default 350. */\n asyncDebounceMs?: number;\n /** The words once `validateAsync` accepted the value (\"@eric is free\"), passed translated. */\n availableHint?: string;\n /** The name of the wait while it checks (\"Checking\"), passed translated. */\n checkingLabel?: string;\n /** Something before the text (an `@`, an icon). */\n start?: React.ReactNode;\n};\n\n/** A text field of the form: label, input, hint or error, an optional check on the server. */\nexport function TextField({ name, label, hint, disabled, className, type = \"text\", transform, validateAsync, asyncDebounceMs, availableHint, checkingLabel = \"Checking\", start, ...input }: TextFieldProps) {\n const f = useKrizakaField<string>(name, { validateAsync, asyncDebounceMs });\n const end = f.validating ? <Spinner size=\"sm\" label={checkingLabel} /> : f.available ? <Check /> : null;\n return (\n <Field.Root className={className}>\n <Field.Label htmlFor={f.id}>{label}</Field.Label>\n <span className=\"relative flex items-center\">\n {start ? <span className=\"pointer-events-none absolute left-3 text-fg-muted\">{start}</span> : null}\n <Input\n id={f.id}\n name={name}\n type={type}\n value={f.value ?? \"\"}\n disabled={disabled}\n invalid={Boolean(f.error)}\n aria-describedby={ids(f, hint ?? availableHint)}\n onChange={(event) => f.setValue(transform ? transform(event.target.value) : event.target.value)}\n onBlur={f.onBlur}\n className={[start ? \"pl-9\" : \"\", end ? \"pr-10\" : \"\"].join(\" \").trim() || undefined}\n {...input}\n />\n {end ? <span className=\"absolute right-3 flex\">{end}</span> : null}\n </span>\n <Caption field={f} hint={hint} ok={availableHint} />\n </Field.Root>\n );\n}\n\nexport type TextAreaProps = Base & {\n /** An example of a value, passed translated. */\n placeholder?: string;\n /** The visible lines. Default 4. */\n rows?: number;\n /** The most characters. */\n maxLength?: number;\n};\n\n/** A longer text of the form (a bio, a description, a report). */\nexport function TextArea({ name, label, hint, disabled, className, rows = 4, ...input }: TextAreaProps) {\n const f = useKrizakaField<string>(name);\n return (\n <Field.Root className={className}>\n <Field.Label htmlFor={f.id}>{label}</Field.Label>\n <Textarea id={f.id} name={name} rows={rows} value={f.value ?? \"\"} disabled={disabled} invalid={Boolean(f.error)} aria-describedby={ids(f, hint)} onChange={(e) => f.setValue(e.target.value)} onBlur={f.onBlur} {...input} />\n <Caption field={f} hint={hint} />\n </Field.Root>\n );\n}\n\nexport type CheckboxProps = Omit<Base, \"label\"> & {\n /** The words next to the box, clickable with it — text, or a sentence with links (terms, privacy). */\n label: React.ReactNode;\n};\n\n/** A box of the form (`boolean`): terms to accept, an option. */\nexport function Checkbox({ name, label, hint, disabled, className }: CheckboxProps) {\n const f = useKrizakaField<boolean>(name);\n return (\n <div className={className ?? \"flex flex-col gap-1.5\"}>\n <CheckboxControl id={f.id} name={name} checked={f.value === true} disabled={disabled} invalid={Boolean(f.error)} aria-describedby={ids(f, hint)} onCheckedChange={(c) => f.setValue(c === true)} onBlur={f.onBlur}>\n {label}\n </CheckboxControl>\n <Caption field={f} hint={hint} />\n </div>\n );\n}\n\n/** An on/off setting of the form (`boolean`): the label and its hint beside the switch. */\nexport function Switch({ name, label, hint, disabled, className }: Base) {\n const f = useKrizakaField<boolean>(name);\n return (\n <div className={className ?? \"flex items-start justify-between gap-4\"}>\n <div className=\"flex min-w-0 flex-col gap-0.5\">\n <Field.Label htmlFor={f.id} className=\"text-sm font-medium text-fg\">\n {label}\n </Field.Label>\n <Caption field={f} hint={hint} />\n </div>\n <SwitchControl id={f.id} name={name} checked={f.value === true} disabled={disabled} invalid={Boolean(f.error)} aria-describedby={ids(f, hint)} onCheckedChange={(c) => f.setValue(c)} onBlur={f.onBlur} />\n </div>\n );\n}\n\n/** A choice of the form: the value stored, its words (passed translated), a line under them. */\nexport type FormOption = { value: string; label: string; description?: string; disabled?: boolean };\n\nexport type RadioGroupProps = Base & {\n /** The choices, all visible (two to five). */\n options: readonly FormOption[];\n /**\n * `list` (a dot and its words, default), `cards` (a whole card is the radio: an amount, a plan, an audience),\n * `buttons` (tactile keys that press in: a size, a tip; `description` is the key's second line) or `segmented`\n * (two to four short choices on one line).\n */\n variant?: \"list\" | \"cards\" | \"buttons\" | \"segmented\";\n /** `vertical` (default) or `horizontal`. */\n orientation?: \"vertical\" | \"horizontal\";\n};\n\n/** One choice among a few, all visible. */\nexport function RadioGroup({ name, label, hint, disabled, className, options, variant = \"list\", orientation = \"vertical\" }: RadioGroupProps) {\n const f = useKrizakaField<string>(name);\n return (\n <Field.Root className={className} role=\"group\" aria-labelledby={`${f.id}-label`}>\n <span id={`${f.id}-label`} className=\"text-xs font-semibold text-fg-secondary\">\n {label}\n </span>\n <RadioGroupControl.Root\n aria-labelledby={`${f.id}-label`}\n value={f.value ?? \"\"}\n onValueChange={(v) => f.setValue(v)}\n onBlur={f.onBlur}\n orientation={orientation}\n disabled={disabled}\n invalid={Boolean(f.error)}\n aria-describedby={ids(f, hint)}\n name={name}\n variant={variant}\n className={variant === \"segmented\" ? \"self-start\" : undefined}\n >\n {options.map((o) =>\n variant === \"cards\" ? (\n <RadioGroupControl.Card key={o.value} value={o.value} disabled={o.disabled}>\n <span className=\"font-semibold\">{o.label}</span>\n {o.description ? <span className=\"text-xs text-fg-secondary\">{o.description}</span> : null}\n </RadioGroupControl.Card>\n ) : variant === \"buttons\" ? (\n <RadioGroupControl.Button key={o.value} value={o.value} disabled={o.disabled} hint={o.description}>\n {o.label}\n </RadioGroupControl.Button>\n ) : variant === \"segmented\" ? (\n <RadioGroupControl.Segment key={o.value} value={o.value} disabled={o.disabled}>\n {o.label}\n </RadioGroupControl.Segment>\n ) : (\n <RadioGroupControl.Item key={o.value} value={o.value} disabled={o.disabled}>\n {o.label}\n {o.description ? <span className=\"block text-xs text-fg-secondary\">{o.description}</span> : null}\n </RadioGroupControl.Item>\n ),\n )}\n </RadioGroupControl.Root>\n <Caption field={f} hint={hint} />\n </Field.Root>\n );\n}\n\nexport type SelectProps = Base & {\n /** The choices, in the platform's own menu (a country, a category). */\n options: readonly FormOption[];\n /** The first line while nothing is chosen (\"Choose a category\"), passed translated. */\n placeholder?: string;\n};\n\n/** One choice among many, in the platform's menu (`<select>`: accessible and right on phones). */\nexport function Select({ name, label, hint, disabled, className, options, placeholder }: SelectProps) {\n const f = useKrizakaField<string>(name);\n return (\n <Field.Root className={className}>\n <Field.Label htmlFor={f.id}>{label}</Field.Label>\n <SelectControl id={f.id} name={name} value={f.value ?? \"\"} disabled={disabled} invalid={Boolean(f.error)} aria-describedby={ids(f, hint)} onChange={(e) => f.setValue(e.target.value)} onBlur={f.onBlur}>\n {placeholder !== undefined ? (\n <option value=\"\" disabled>\n {placeholder}\n </option>\n ) : null}\n {options.map((o) => (\n <option key={o.value} value={o.value} disabled={o.disabled}>\n {o.label}\n </option>\n ))}\n </SelectControl>\n <Caption field={f} hint={hint} />\n </Field.Root>\n );\n}\n\nexport type ComboboxProps = Base & {\n /** The options, filtered as the person types. */\n options?: readonly ComboboxOption[];\n /** Fetches the options for a query (debounced, aborted by a newer one). */\n onSearch?: (query: string, signal: AbortSignal) => Promise<readonly ComboboxOption[]>;\n /** Several values (`string[]`), shown as chips; one (`string`) by default. */\n multiple?: boolean;\n /** Offers to create the query as a value. */\n creatable?: boolean;\n /** The input's placeholder, passed translated. */\n placeholder?: string;\n /** The words of the control, passed translated. */\n labels?: Partial<ComboboxLabels>;\n};\n\n/** A choice among many, typed to filter or fetched: one value (`string`) or several (`string[]`). */\nexport function Combobox({ name, label, hint, disabled, className, options = [], onSearch, multiple, creatable, placeholder, labels }: ComboboxProps) {\n const f = useKrizakaField<string | string[]>(name);\n // The options chosen from a search, by value: their labels once the search has moved on.\n const [seen, setSeen] = React.useState<Record<string, ComboboxOption>>({});\n const option = (value: string) => options.find((o) => o.value === value) ?? seen[value] ?? { value, label: value };\n const remember = (o: ComboboxOption) => setSeen((known) => (known[o.value] === o ? known : { ...known, [o.value]: o }));\n const shared = { id: f.id, label, hint, error: f.error, disabled, placeholder, labels, options, onSearch, creatable, name };\n return (\n <div className={className} onBlur={(e) => !e.currentTarget.contains(e.relatedTarget as Node | null) && f.onBlur()}>\n {multiple ? (\n <ComboboxControl\n {...shared}\n multiple\n value={((f.value as string[] | undefined) ?? []).map(option)}\n onValueChange={(next) => {\n next.forEach(remember);\n f.setValue(next.map((o) => o.value));\n }}\n />\n ) : (\n <ComboboxControl\n {...shared}\n value={f.value ? option(f.value as string) : null}\n onValueChange={(next) => {\n if (next) remember(next);\n f.setValue(next?.value ?? \"\");\n }}\n />\n )}\n </div>\n );\n}\n\nexport type DateFieldProps = Base & {\n /**\n * `calendar` (default: a date near today — a publication, an appointment), `parts` (day · month · year typed: a\n * memorable date, a birth date) or `wheel` (three wheels bounded by `min` / `max`: a birth date on a phone).\n */\n entry?: \"calendar\" | \"parts\" | \"wheel\";\n /** The earliest date (ISO), for the calendar and the wheels. */\n min?: string;\n /** The latest date (ISO), for the calendar and the wheels (`latestBirthDate(18)` for an age gate). */\n max?: string;\n /** The words of the calendar, or the names of the parts (`day`, `month`, `year`), passed translated. */\n labels?: Partial<DatePickerLabels> & Partial<Record<DatePart, string>>;\n /** `bday` for a date of birth: typed boxes are autofilled; the wheels rest on 1 January 2000 until turned. */\n autoComplete?: \"bday\" | \"off\";\n};\n\n/** A date of the form (`YYYY-MM-DD`, `\"\"` for none): a calendar, day · month · year typed, or wheels. */\nexport function DateField({ name, label, hint, disabled, className, entry = \"calendar\", min, max, labels, autoComplete }: DateFieldProps) {\n const f = useKrizakaField<string>(name);\n const onBlur = (e: React.FocusEvent<HTMLElement>) => !e.currentTarget.contains(e.relatedTarget as Node | null) && f.onBlur();\n if (entry === \"calendar\")\n return (\n <div className={className} onBlur={onBlur}>\n <DatePicker label={label} hint={hint} error={f.error} disabled={disabled} name={name} locale={f.locale} min={min} max={max} labels={labels} value={f.value || null} onValueChange={(v) => f.setValue(v ?? \"\")} />\n </div>\n );\n if (entry === \"wheel\")\n return (\n <div className={className} onBlur={onBlur}>\n <DateWheel label={label} hint={hint} error={f.error} disabled={disabled} name={name} locale={f.locale} min={min} max={max} labels={labels} defaultView={autoComplete === \"bday\" ? \"2000-01-01\" : undefined} value={f.value || null} onValueChange={(v) => f.setValue(v)} />\n </div>\n );\n return <DatePartsControl label={label} hint={hint} error={f.error} disabled={disabled} name={name} locale={f.locale} labels={labels} autoComplete={autoComplete} className={className} value={f.value ?? \"\"} onValueChange={(v) => f.setValue(v)} onBlur={f.onBlur} />;\n}\n\nexport type TagsProps = Base & Pick<TagInputProps, \"suggestions\" | \"normalize\" | \"max\" | \"separators\" | \"placeholder\" | \"labels\">;\n\n/** Free words of the form as chips (`string[]`): tags, keywords. */\nexport function TagInput({ name, label, hint, disabled, className, ...props }: TagsProps) {\n const f = useKrizakaField<string[]>(name);\n return (\n <div className={className} onBlur={(e) => !e.currentTarget.contains(e.relatedTarget as Node | null) && f.onBlur()}>\n <TagInputControl label={label} hint={hint} error={f.error} disabled={disabled} name={name} value={f.value ?? []} onValueChange={(tags) => f.setValue(tags)} {...props} />\n </div>\n );\n}\n\nexport type FileUploadProps = Omit<Base, \"hint\"> & {\n /** The title in the zone (\"Drop your video here\"), passed translated. */\n title: string;\n /** The button that opens the file picker, passed translated. */\n browseLabel: string;\n /** What is accepted, in words (\"MP4 or MOV, up to 4 GB\"). */\n hint?: string;\n /** The types accepted (`video/*`, `image/png,.pdf`). */\n accept?: string;\n /** The largest file, in bytes. */\n maxSize?: number;\n /** Several files (`File[]`, up to `maxFiles`); one by default (still a `File[]` of one). */\n multiple?: boolean;\n /** The most files. */\n maxFiles?: number;\n /** The name of a file's remove button (`(name) => \"Remove \" + name`), passed translated. */\n removeLabel: (fileName: string) => string;\n /** The words of a refused file (`(r) => r.file.name + \" is too large\"`). */\n refusalLabel?: React.ComponentProps<typeof Dropzone>[\"refusalLabel\"];\n};\n\n/** Files of the form (`File[]`): a drop zone, then the chosen files, each removable. */\nexport function FileUpload({ name, label, hint, disabled, className, title, browseLabel, accept, maxSize, multiple, maxFiles, removeLabel, refusalLabel }: FileUploadProps) {\n const f = useKrizakaField<File[]>(name);\n const files = f.value ?? [];\n return (\n <div className={className ?? \"flex flex-col gap-2\"} role=\"group\" aria-label={label} onBlur={(e) => !e.currentTarget.contains(e.relatedTarget as Node | null) && f.onBlur()}>\n <span className=\"text-xs font-semibold text-fg-secondary\">{label}</span>\n <Dropzone\n title={title}\n browseLabel={browseLabel}\n hint={hint}\n accept={accept}\n maxSize={maxSize}\n multiple={multiple}\n maxFiles={maxFiles}\n disabled={disabled}\n refusalLabel={refusalLabel}\n onFiles={(chosen) => f.setValue(multiple ? [...files, ...chosen].slice(0, maxFiles ?? Infinity) : chosen.slice(0, 1))}\n />\n {files.length > 0 ? (\n <ul className=\"flex flex-col gap-1.5\">\n {files.map((file, i) => (\n <li key={`${file.name}-${i}`} className=\"flex items-center justify-between gap-3 rounded-lg border border-border-default bg-surface-1 px-3 py-2 text-sm\">\n <span className=\"min-w-0 truncate text-fg\">{file.name}</span>\n <span className=\"flex shrink-0 items-center gap-2\">\n <span className=\"font-mono text-xs text-fg-secondary\">{formatBytes(file.size, f.locale)}</span>\n <Button type=\"button\" size=\"sm\" variant=\"ghost\" onClick={() => f.setValue(files.filter((_, j) => j !== i))}>\n {removeLabel(file.name)}\n </Button>\n </span>\n </li>\n ))}\n </ul>\n ) : null}\n {f.error ? <Field.Error id={f.errorId}>{f.error}</Field.Error> : null}\n </div>\n );\n}\n\nexport type MoneyProps = Base & {\n /** The currency (ISO 4217: `USD`, `EUR`, `JPY`): its sign before the amount, its decimals. */\n currency: string;\n /** An example of an amount, passed translated. */\n placeholder?: string;\n};\n\n/** An amount of the form, stored as integer minor units (cents: `1250` = 12.50), typed the locale's way. */\nexport function Money({ name, label, hint, disabled, className, currency, placeholder }: MoneyProps) {\n const f = useKrizakaField<number | null>(name);\n const [text, setText] = React.useState(() => moneyInputText(f.value, currency, f.locale));\n const [editing, setEditing] = React.useState(false);\n const shown = editing ? text : moneyInputText(f.value, currency, f.locale);\n return (\n <Field.Root className={className}>\n <Field.Label htmlFor={f.id}>{label}</Field.Label>\n <span className=\"relative flex items-center\">\n <span className=\"pointer-events-none absolute left-3 text-sm text-fg-secondary\" aria-hidden>\n {currencySymbol(currency, f.locale)}\n </span>\n <Input\n id={f.id}\n name={name}\n inputMode=\"decimal\"\n value={shown}\n placeholder={placeholder}\n disabled={disabled}\n invalid={Boolean(f.error)}\n aria-describedby={ids(f, hint)}\n className=\"pl-9 tabular-nums\"\n onFocus={() => {\n setText(moneyInputText(f.value, currency, f.locale));\n setEditing(true);\n }}\n onChange={(e) => {\n setText(e.target.value);\n const units = parseMoney(e.target.value, currency, f.locale);\n f.setValue(units === undefined ? null : units === null ? Number.NaN : units);\n }}\n onBlur={() => {\n setEditing(false);\n f.onBlur();\n }}\n />\n </span>\n <Caption field={f} hint={hint} />\n </Field.Root>\n );\n}\n\nexport type SliderProps = Base & {\n /** The lowest value. Default 0. */\n min?: number;\n /** The highest value. Default 100. */\n max?: number;\n /** The step. Default 1. */\n step?: number;\n /** The value as words (\"15 %\", \"3 min\"), shown and read. */\n formatValue?: (value: number) => string;\n /** For a range (`[number, number]`): each thumb's name, passed translated. */\n thumbLabels?: [string, string];\n /** A graduation per step (`true`) or at the values given. */\n ticks?: boolean | readonly number[];\n /** Words under the track at some values. */\n marks?: readonly SliderMark[];\n};\n\n/** A number (or a range) of the form, chosen by feel: a share, a volume, a price range — the value floats while it is touched. */\nexport function Slider({ name, label, hint, disabled, className, min, max, step, formatValue, thumbLabels, ticks, marks }: SliderProps) {\n const f = useKrizakaField<SliderValue>(name);\n return (\n <div className={className ?? \"flex flex-col gap-1.5\"}>\n <SliderControl label={label} showLabel floatingValue value={f.value} min={min} max={max} step={step} ticks={ticks} marks={marks} disabled={disabled} formatValue={formatValue} thumbLabels={thumbLabels} aria-describedby={ids(f, hint)} onValueChange={(v) => f.setValue(v)} onValueCommit={() => f.onBlur()} />\n <Caption field={f} hint={hint} />\n </div>\n );\n}\n\nconst fields = { TextField, TextArea, Checkbox, Switch, RadioGroup, Select, Combobox, DateField, TagInput, FileUpload, Money, Slider, Field: FormField, FieldArray, Watch, Submit, FormError };\n\n/**\n * A form, defined once: its schema (zod 4) and default values — the same schema the server parses with. In a component,\n * `signUp.useForm({ onSubmit })` gives the form and its fields, typed by the schema: `<form.Form>`, `<form.TextField\n * name=\"email\" …/>`, `<form.Submit>`. Errors are i18n keys (`form.errors.tooShort`), never the engine's English.\n */\nexport const createKrizakaForm = makeCreateKrizakaForm(fields, FormRoot);\n\n/** The form sent by a Server Action: `useFormWithAction(signUp, createAccount)` — `signUp.useFormWithAction(createAccount)`. */\nexport function useFormWithAction<F extends { useFormWithAction: (...args: never[]) => unknown }>(form: F, ...args: Parameters<F[\"useFormWithAction\"]>): ReturnType<F[\"useFormWithAction\"]> {\n return form.useFormWithAction(...args) as ReturnType<F[\"useFormWithAction\"]>;\n}\n"
2099
+ "content": "// Client. The form's fields for the web: thin adapters from a form field (useKrizakaField) to the platform's current\n// primitives — Field + Input, Checkbox, Switch, RadioGroup (dots, cards, tactile keys, segments), Combobox, the date\n// pickers (calendar, typed, wheels), TagInput, Dropzone, Slider. A new look for a primitive changes an adapter here,\n// never a form.\nimport { Alert } from \"@krizaka/ui/alert\";\nimport { Button, type ButtonProps } from \"@krizaka/ui/button\";\nimport { Checkbox as CheckboxControl } from \"@krizaka/ui/checkbox\";\nimport { Combobox as ComboboxControl, type ComboboxLabels, type ComboboxOption } from \"@krizaka/ui/combobox\";\nimport { DateField as DatePartsControl, DatePicker, type DatePickerLabels, DateWheel } from \"@krizaka/ui/date-picker\";\nimport { Field, Input, Select as SelectControl, Textarea } from \"@krizaka/ui/field\";\nimport { Dropzone, formatBytes } from \"@krizaka/ui/file-upload\";\nimport { RadioGroup as RadioGroupControl } from \"@krizaka/ui/radio-group\";\nimport { Slider as SliderControl, type SliderMark, type SliderValue } from \"@krizaka/ui/slider\";\nimport { Spinner } from \"@krizaka/ui/spinner\";\nimport { Switch as SwitchControl } from \"@krizaka/ui/switch\";\nimport { TagInput as TagInputControl, type TagInputProps } from \"@krizaka/ui/tag-input\";\nimport * as React from \"react\";\n\nimport type { DatePart } from \"../date-picker/parts\";\nimport {\n FieldArray,\n type FieldCheck,\n FormContext,\n type FormContextValue,\n FormField,\n type KrizakaField,\n makeCreateKrizakaForm,\n useFormContext,\n useFormStatus,\n useKrizakaField,\n Watch,\n} from \"./core\";\nimport { formMessage } from \"./errors\";\nimport { currencySymbol, moneyInputText, parseMoney } from \"./money\";\n\nexport type { FieldArrayProps, FormFieldProps, WatchProps } from \"./core\";\n\ntype Base = {\n /** The field's name in the schema: `email`, `address.city`, `links[0].url` (typed by the form). */\n name: string;\n /** The visible label, passed translated (also the control's accessible name). */\n label: string;\n /** A help text under the control, read with it; the error takes its place when there is one. */\n hint?: string;\n /** Not available. */\n disabled?: boolean;\n /** Classes merged on the field's root. */\n className?: string;\n};\n\nconst ids = (f: KrizakaField, hint?: string) => [hint && !f.error ? f.hintId : null, f.error ? f.errorId : null].filter(Boolean).join(\" \") || undefined;\n\nfunction Caption({ field, hint, ok }: Readonly<{ field: KrizakaField; hint?: string; ok?: string }>) {\n const suggestion = field.errorDetail?.suggestion;\n if (field.error)\n return (\n <Field.Error id={field.errorId}>\n <span>\n {field.error}\n {suggestion ? (\n <>\n {\" \"}\n <button type=\"button\" className=\"font-semibold text-accent-text underline underline-offset-2\" onClick={() => field.setValue(suggestion.value)}>\n {suggestion.label}\n </button>\n </>\n ) : null}\n </span>\n </Field.Error>\n );\n const text = field.available && ok ? (hint ? `${ok} · ${hint}` : ok) : hint;\n return text ? <Field.Hint id={field.hintId}>{text}</Field.Hint> : null;\n}\n\nconst Check = () => (\n <svg viewBox=\"0 0 24 24\" className=\"h-4 w-4 text-fg-success\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n);\n\nexport type FormProps = Omit<React.ComponentProps<\"form\">, \"onSubmit\" | \"noValidate\"> & {\n /** The fields, the error and the button. */\n children?: React.ReactNode;\n};\n\n/** The `<form>` of a form (`form.Form`): `noValidate` (the schema validates), the first error focused after a refused submit. */\nfunction FormRoot({ value, className, children, ...props }: FormProps & { value: FormContextValue }) {\n const ref = React.useRef<HTMLFormElement>(null);\n return (\n <FormContext.Provider value={value}>\n <form\n ref={ref}\n noValidate\n className={className ?? \"flex flex-col gap-4\"}\n onSubmit={async (event) => {\n event.preventDefault();\n if (!(await value.submit())) requestAnimationFrame(() => ref.current?.querySelector<HTMLElement>('[aria-invalid=\"true\"], [data-invalid] input')?.focus());\n }}\n {...props}\n >\n {children}\n </form>\n </FormContext.Provider>\n );\n}\n\nexport type SubmitProps = Omit<ButtonProps, \"type\" | \"loading\"> & {\n /** The button's words, passed translated (\"Create my account\"). */\n children: React.ReactNode;\n};\n\n/** The submit button: busy while the form is sent (not pressable twice), never disabled for an invalid form. */\nexport function Submit({ variant = \"primary\", children, ...props }: Readonly<SubmitProps>) {\n const { submitting } = useFormStatus();\n return (\n <Button type=\"submit\" variant={variant} loading={submitting} {...props}>\n {children}\n </Button>\n );\n}\n\nexport type FormErrorProps = {\n /** A headline above the message (\"We could not create your account\"), passed translated. */\n title?: string;\n /** Classes merged on the alert. */\n className?: string;\n};\n\n/** The whole form's error — a refusal of the server that belongs to no field (a conflict, too many tries, no network). */\nexport function FormError({ title, className }: Readonly<FormErrorProps>) {\n const ctx = useFormContext();\n if (!ctx.error) return null;\n return (\n <Alert tone=\"danger\" title={title} className={className}>\n {formMessage(ctx.error, ctx.i18n)}\n </Alert>\n );\n}\n\nexport type TextFieldProps = Base & {\n /** `text` (default), `email`, `password`, `url`, `tel`, `search`: the right keyboard on a phone. */\n type?: \"text\" | \"email\" | \"password\" | \"url\" | \"tel\" | \"search\";\n /** The browser's autofill (`email`, `username`, `new-password`, `name`). */\n autoComplete?: string;\n /** An example of a value, passed translated — never the label. */\n placeholder?: string;\n /** The keyboard on a phone (`numeric`, `decimal`). */\n inputMode?: React.HTMLAttributes<HTMLInputElement>[\"inputMode\"];\n /** The most characters. */\n maxLength?: number;\n /** Cleans what is typed before it is stored (`(v) => v.toLowerCase().replace(/\\s+/g, \"_\")`). */\n transform?: (raw: string) => string;\n /** Checks the value on the server as it is typed (availability): an error key, or nothing when it is fine. */\n validateAsync?: FieldCheck<string>;\n /** The wait, in ms, between the last key and `validateAsync`. Default 350. */\n asyncDebounceMs?: number;\n /** The words once `validateAsync` accepted the value (\"@eric is free\"), passed translated. */\n availableHint?: string;\n /** The name of the wait while it checks (\"Checking\"), passed translated. */\n checkingLabel?: string;\n /** Something before the text (an `@`, an icon). */\n start?: React.ReactNode;\n};\n\n/** A text field of the form: label, input, hint or error, an optional check on the server. */\nexport function TextField({ name, label, hint, disabled, className, type = \"text\", transform, validateAsync, asyncDebounceMs, availableHint, checkingLabel = \"Checking\", start, ...input }: Readonly<TextFieldProps>) {\n const f = useKrizakaField<string>(name, { validateAsync, asyncDebounceMs });\n const end = f.validating ? <Spinner size=\"sm\" label={checkingLabel} /> : f.available ? <Check /> : null;\n return (\n <Field.Root className={className}>\n <Field.Label htmlFor={f.id}>{label}</Field.Label>\n <span className=\"relative flex items-center\">\n {start ? <span className=\"pointer-events-none absolute left-3 text-fg-muted\">{start}</span> : null}\n <Input\n id={f.id}\n name={name}\n type={type}\n value={f.value ?? \"\"}\n disabled={disabled}\n invalid={Boolean(f.error)}\n aria-describedby={ids(f, hint ?? availableHint)}\n onChange={(event) => f.setValue(transform ? transform(event.target.value) : event.target.value)}\n onBlur={f.onBlur}\n className={[start ? \"pl-9\" : \"\", end ? \"pr-10\" : \"\"].join(\" \").trim() || undefined}\n {...input}\n />\n {end ? <span className=\"absolute right-3 flex\">{end}</span> : null}\n </span>\n <Caption field={f} hint={hint} ok={availableHint} />\n </Field.Root>\n );\n}\n\nexport type TextAreaProps = Base & {\n /** An example of a value, passed translated. */\n placeholder?: string;\n /** The visible lines. Default 4. */\n rows?: number;\n /** The most characters. */\n maxLength?: number;\n};\n\n/** A longer text of the form (a bio, a description, a report). */\nexport function TextArea({ name, label, hint, disabled, className, rows = 4, ...input }: TextAreaProps) {\n const f = useKrizakaField<string>(name);\n return (\n <Field.Root className={className}>\n <Field.Label htmlFor={f.id}>{label}</Field.Label>\n <Textarea id={f.id} name={name} rows={rows} value={f.value ?? \"\"} disabled={disabled} invalid={Boolean(f.error)} aria-describedby={ids(f, hint)} onChange={(e) => f.setValue(e.target.value)} onBlur={f.onBlur} {...input} />\n <Caption field={f} hint={hint} />\n </Field.Root>\n );\n}\n\nexport type CheckboxProps = Omit<Base, \"label\"> & {\n /** The words next to the box, clickable with it — text, or a sentence with links (terms, privacy). */\n label: React.ReactNode;\n};\n\n/** A box of the form (`boolean`): terms to accept, an option. */\nexport function Checkbox({ name, label, hint, disabled, className }: Readonly<CheckboxProps>) {\n const f = useKrizakaField<boolean>(name);\n return (\n <div className={className ?? \"flex flex-col gap-1.5\"}>\n <CheckboxControl id={f.id} name={name} checked={f.value === true} disabled={disabled} invalid={Boolean(f.error)} aria-describedby={ids(f, hint)} onCheckedChange={(c) => f.setValue(c === true)} onBlur={f.onBlur}>\n {label}\n </CheckboxControl>\n <Caption field={f} hint={hint} />\n </div>\n );\n}\n\n/** An on/off setting of the form (`boolean`): the label and its hint beside the switch. */\nexport function Switch({ name, label, hint, disabled, className }: Readonly<Base>) {\n const f = useKrizakaField<boolean>(name);\n return (\n <div className={className ?? \"flex items-start justify-between gap-4\"}>\n <div className=\"flex min-w-0 flex-col gap-0.5\">\n <Field.Label htmlFor={f.id} className=\"text-sm font-medium text-fg\">\n {label}\n </Field.Label>\n <Caption field={f} hint={hint} />\n </div>\n <SwitchControl id={f.id} name={name} checked={f.value === true} disabled={disabled} invalid={Boolean(f.error)} aria-describedby={ids(f, hint)} onCheckedChange={(c) => f.setValue(c)} onBlur={f.onBlur} />\n </div>\n );\n}\n\n/** A choice of the form: the value stored, its words (passed translated), a line under them. */\nexport type FormOption = { value: string; label: string; description?: string; disabled?: boolean };\n\nexport type RadioGroupProps = Base & {\n /** The choices, all visible (two to five). */\n options: readonly FormOption[];\n /**\n * `list` (a dot and its words, default), `cards` (a whole card is the radio: an amount, a plan, an audience),\n * `buttons` (tactile keys that press in: a size, a tip; `description` is the key's second line) or `segmented`\n * (two to four short choices on one line).\n */\n variant?: \"list\" | \"cards\" | \"buttons\" | \"segmented\";\n /** `vertical` (default) or `horizontal`. */\n orientation?: \"vertical\" | \"horizontal\";\n};\n\n/** One choice among a few, all visible. */\nexport function RadioGroup({ name, label, hint, disabled, className, options, variant = \"list\", orientation = \"vertical\" }: Readonly<RadioGroupProps>) {\n const f = useKrizakaField<string>(name);\n return (\n <Field.Root className={className} role=\"group\" aria-labelledby={`${f.id}-label`}>\n <span id={`${f.id}-label`} className=\"text-xs font-semibold text-fg-secondary\">\n {label}\n </span>\n <RadioGroupControl.Root\n aria-labelledby={`${f.id}-label`}\n value={f.value ?? \"\"}\n onValueChange={(v) => f.setValue(v)}\n onBlur={f.onBlur}\n orientation={orientation}\n disabled={disabled}\n invalid={Boolean(f.error)}\n aria-describedby={ids(f, hint)}\n name={name}\n variant={variant}\n className={variant === \"segmented\" ? \"self-start\" : undefined}\n >\n {options.map((o) =>\n variant === \"cards\" ? (\n <RadioGroupControl.Card key={o.value} value={o.value} disabled={o.disabled}>\n <span className=\"font-semibold\">{o.label}</span>\n {o.description ? <span className=\"text-xs text-fg-secondary\">{o.description}</span> : null}\n </RadioGroupControl.Card>\n ) : variant === \"buttons\" ? (\n <RadioGroupControl.Button key={o.value} value={o.value} disabled={o.disabled} hint={o.description}>\n {o.label}\n </RadioGroupControl.Button>\n ) : variant === \"segmented\" ? (\n <RadioGroupControl.Segment key={o.value} value={o.value} disabled={o.disabled}>\n {o.label}\n </RadioGroupControl.Segment>\n ) : (\n <RadioGroupControl.Item key={o.value} value={o.value} disabled={o.disabled}>\n {o.label}\n {o.description ? <span className=\"block text-xs text-fg-secondary\">{o.description}</span> : null}\n </RadioGroupControl.Item>\n ),\n )}\n </RadioGroupControl.Root>\n <Caption field={f} hint={hint} />\n </Field.Root>\n );\n}\n\nexport type SelectProps = Base & {\n /** The choices, in the platform's own menu (a country, a category). */\n options: readonly FormOption[];\n /** The first line while nothing is chosen (\"Choose a category\"), passed translated. */\n placeholder?: string;\n};\n\n/** One choice among many, in the platform's menu (`<select>`: accessible and right on phones). */\nexport function Select({ name, label, hint, disabled, className, options, placeholder }: SelectProps) {\n const f = useKrizakaField<string>(name);\n return (\n <Field.Root className={className}>\n <Field.Label htmlFor={f.id}>{label}</Field.Label>\n <SelectControl id={f.id} name={name} value={f.value ?? \"\"} disabled={disabled} invalid={Boolean(f.error)} aria-describedby={ids(f, hint)} onChange={(e) => f.setValue(e.target.value)} onBlur={f.onBlur}>\n {placeholder !== undefined ? (\n <option value=\"\" disabled>\n {placeholder}\n </option>\n ) : null}\n {options.map((o) => (\n <option key={o.value} value={o.value} disabled={o.disabled}>\n {o.label}\n </option>\n ))}\n </SelectControl>\n <Caption field={f} hint={hint} />\n </Field.Root>\n );\n}\n\nexport type ComboboxProps = Base & {\n /** The options, filtered as the person types. */\n options?: readonly ComboboxOption[];\n /** Fetches the options for a query (debounced, aborted by a newer one). */\n onSearch?: (query: string, signal: AbortSignal) => Promise<readonly ComboboxOption[]>;\n /** Several values (`string[]`), shown as chips; one (`string`) by default. */\n multiple?: boolean;\n /** Offers to create the query as a value. */\n creatable?: boolean;\n /** The input's placeholder, passed translated. */\n placeholder?: string;\n /** The words of the control, passed translated. */\n labels?: Partial<ComboboxLabels>;\n};\n\n/** A choice among many, typed to filter or fetched: one value (`string`) or several (`string[]`). */\nexport function Combobox({ name, label, hint, disabled, className, options = [], onSearch, multiple, creatable, placeholder, labels }: Readonly<ComboboxProps>) {\n const f = useKrizakaField<string | string[]>(name);\n // The options chosen from a search, by value: their labels once the search has moved on.\n const [seen, setSeen] = React.useState<Record<string, ComboboxOption>>({});\n const option = (value: string) => options.find((o) => o.value === value) ?? seen[value] ?? { value, label: value };\n const remember = (o: ComboboxOption) => setSeen((known) => (known[o.value] === o ? known : { ...known, [o.value]: o }));\n const shared = { id: f.id, label, hint, error: f.error, disabled, placeholder, labels, options, onSearch, creatable, name };\n return (\n <div className={className} onBlur={(e) => !e.currentTarget.contains(e.relatedTarget as Node | null) && f.onBlur()}>\n {multiple ? (\n <ComboboxControl\n {...shared}\n multiple\n value={((f.value as string[] | undefined) ?? []).map(option)}\n onValueChange={(next) => {\n next.forEach(remember);\n f.setValue(next.map((o) => o.value));\n }}\n />\n ) : (\n <ComboboxControl\n {...shared}\n value={f.value ? option(f.value as string) : null}\n onValueChange={(next) => {\n if (next) remember(next);\n f.setValue(next?.value ?? \"\");\n }}\n />\n )}\n </div>\n );\n}\n\nexport type DateFieldProps = Base & {\n /**\n * `calendar` (default: a date near today — a publication, an appointment), `parts` (day · month · year typed: a\n * memorable date, a birth date) or `wheel` (three wheels bounded by `min` / `max`: a birth date on a phone).\n */\n entry?: \"calendar\" | \"parts\" | \"wheel\";\n /** The earliest date (ISO), for the calendar and the wheels. */\n min?: string;\n /** The latest date (ISO), for the calendar and the wheels (`latestBirthDate(18)` for an age gate). */\n max?: string;\n /** The words of the calendar, or the names of the parts (`day`, `month`, `year`), passed translated. */\n labels?: Partial<DatePickerLabels> & Partial<Record<DatePart, string>>;\n /** `bday` for a date of birth: typed boxes are autofilled; the wheels rest on 1 January 2000 until turned. */\n autoComplete?: \"bday\" | \"off\";\n};\n\n/** A date of the form (`YYYY-MM-DD`, `\"\"` for none): a calendar, day · month · year typed, or wheels. */\nexport function DateField({ name, label, hint, disabled, className, entry = \"calendar\", min, max, labels, autoComplete }: Readonly<DateFieldProps>) {\n const f = useKrizakaField<string>(name);\n const onBlur = (e: React.FocusEvent<HTMLElement>) => !e.currentTarget.contains(e.relatedTarget as Node | null) && f.onBlur();\n if (entry === \"calendar\")\n return (\n <div className={className} onBlur={onBlur}>\n <DatePicker label={label} hint={hint} error={f.error} disabled={disabled} name={name} locale={f.locale} min={min} max={max} labels={labels} value={f.value || null} onValueChange={(v) => f.setValue(v ?? \"\")} />\n </div>\n );\n if (entry === \"wheel\")\n return (\n <div className={className} onBlur={onBlur}>\n <DateWheel label={label} hint={hint} error={f.error} disabled={disabled} name={name} locale={f.locale} min={min} max={max} labels={labels} defaultView={autoComplete === \"bday\" ? \"2000-01-01\" : undefined} value={f.value || null} onValueChange={(v) => f.setValue(v)} />\n </div>\n );\n return <DatePartsControl label={label} hint={hint} error={f.error} disabled={disabled} name={name} locale={f.locale} labels={labels} autoComplete={autoComplete} className={className} value={f.value ?? \"\"} onValueChange={(v) => f.setValue(v)} onBlur={f.onBlur} />;\n}\n\nexport type TagsProps = Base & Pick<TagInputProps, \"suggestions\" | \"normalize\" | \"max\" | \"separators\" | \"placeholder\" | \"labels\">;\n\n/** Free words of the form as chips (`string[]`): tags, keywords. */\nexport function TagInput({ name, label, hint, disabled, className, ...props }: Readonly<TagsProps>) {\n const f = useKrizakaField<string[]>(name);\n return (\n <div className={className} onBlur={(e) => !e.currentTarget.contains(e.relatedTarget as Node | null) && f.onBlur()}>\n <TagInputControl label={label} hint={hint} error={f.error} disabled={disabled} name={name} value={f.value ?? []} onValueChange={(tags) => f.setValue(tags)} {...props} />\n </div>\n );\n}\n\nexport type FileUploadProps = Omit<Base, \"hint\"> & {\n /** The title in the zone (\"Drop your video here\"), passed translated. */\n title: string;\n /** The button that opens the file picker, passed translated. */\n browseLabel: string;\n /** What is accepted, in words (\"MP4 or MOV, up to 4 GB\"). */\n hint?: string;\n /** The types accepted (`video/*`, `image/png,.pdf`). */\n accept?: string;\n /** The largest file, in bytes. */\n maxSize?: number;\n /** Several files (`File[]`, up to `maxFiles`); one by default (still a `File[]` of one). */\n multiple?: boolean;\n /** The most files. */\n maxFiles?: number;\n /** The name of a file's remove button (`(name) => \"Remove \" + name`), passed translated. */\n removeLabel: (fileName: string) => string;\n /** The words of a refused file (`(r) => r.file.name + \" is too large\"`). */\n refusalLabel?: React.ComponentProps<typeof Dropzone>[\"refusalLabel\"];\n};\n\n/** Files of the form (`File[]`): a drop zone, then the chosen files, each removable. */\nexport function FileUpload({ name, label, hint, disabled, className, title, browseLabel, accept, maxSize, multiple, maxFiles, removeLabel, refusalLabel }: Readonly<FileUploadProps>) {\n const f = useKrizakaField<File[]>(name);\n const files = f.value ?? [];\n return (\n <div className={className ?? \"flex flex-col gap-2\"} role=\"group\" aria-label={label} onBlur={(e) => !e.currentTarget.contains(e.relatedTarget as Node | null) && f.onBlur()}>\n <span className=\"text-xs font-semibold text-fg-secondary\">{label}</span>\n <Dropzone\n title={title}\n browseLabel={browseLabel}\n hint={hint}\n accept={accept}\n maxSize={maxSize}\n multiple={multiple}\n maxFiles={maxFiles}\n disabled={disabled}\n refusalLabel={refusalLabel}\n onFiles={(chosen) => f.setValue(multiple ? [...files, ...chosen].slice(0, maxFiles ?? Infinity) : chosen.slice(0, 1))}\n />\n {files.length > 0 ? (\n <ul className=\"flex flex-col gap-1.5\">\n {files.map((file, i) => (\n <li key={`${file.name}-${i}`} className=\"flex items-center justify-between gap-3 rounded-lg border border-border-default bg-surface-1 px-3 py-2 text-sm\">\n <span className=\"min-w-0 truncate text-fg\">{file.name}</span>\n <span className=\"flex shrink-0 items-center gap-2\">\n <span className=\"font-mono text-xs text-fg-secondary\">{formatBytes(file.size, f.locale)}</span>\n <Button type=\"button\" size=\"sm\" variant=\"ghost\" onClick={() => f.setValue(files.filter((_, j) => j !== i))}>\n {removeLabel(file.name)}\n </Button>\n </span>\n </li>\n ))}\n </ul>\n ) : null}\n {f.error ? <Field.Error id={f.errorId}>{f.error}</Field.Error> : null}\n </div>\n );\n}\n\nexport type MoneyProps = Base & {\n /** The currency (ISO 4217: `USD`, `EUR`, `JPY`): its sign before the amount, its decimals. */\n currency: string;\n /** An example of an amount, passed translated. */\n placeholder?: string;\n};\n\n/** An amount of the form, stored as integer minor units (cents: `1250` = 12.50), typed the locale's way. */\nexport function Money({ name, label, hint, disabled, className, currency, placeholder }: Readonly<MoneyProps>) {\n const f = useKrizakaField<number | null>(name);\n const [text, setText] = React.useState(() => moneyInputText(f.value, currency, f.locale));\n const [editing, setEditing] = React.useState(false);\n const shown = editing ? text : moneyInputText(f.value, currency, f.locale);\n return (\n <Field.Root className={className}>\n <Field.Label htmlFor={f.id}>{label}</Field.Label>\n <span className=\"relative flex items-center\">\n <span className=\"pointer-events-none absolute left-3 text-sm text-fg-secondary\" aria-hidden>\n {currencySymbol(currency, f.locale)}\n </span>\n <Input\n id={f.id}\n name={name}\n inputMode=\"decimal\"\n value={shown}\n placeholder={placeholder}\n disabled={disabled}\n invalid={Boolean(f.error)}\n aria-describedby={ids(f, hint)}\n className=\"pl-9 tabular-nums\"\n onFocus={() => {\n setText(moneyInputText(f.value, currency, f.locale));\n setEditing(true);\n }}\n onChange={(e) => {\n setText(e.target.value);\n const units = parseMoney(e.target.value, currency, f.locale);\n f.setValue(units === undefined ? null : units === null ? Number.NaN : units);\n }}\n onBlur={() => {\n setEditing(false);\n f.onBlur();\n }}\n />\n </span>\n <Caption field={f} hint={hint} />\n </Field.Root>\n );\n}\n\nexport type SliderProps = Base & {\n /** The lowest value. Default 0. */\n min?: number;\n /** The highest value. Default 100. */\n max?: number;\n /** The step. Default 1. */\n step?: number;\n /** The value as words (\"15 %\", \"3 min\"), shown and read. */\n formatValue?: (value: number) => string;\n /** For a range (`[number, number]`): each thumb's name, passed translated. */\n thumbLabels?: [string, string];\n /** A graduation per step (`true`) or at the values given. */\n ticks?: boolean | readonly number[];\n /** Words under the track at some values. */\n marks?: readonly SliderMark[];\n};\n\n/** A number (or a range) of the form, chosen by feel: a share, a volume, a price range — the value floats while it is touched. */\nexport function Slider({ name, label, hint, disabled, className, min, max, step, formatValue, thumbLabels, ticks, marks }: Readonly<SliderProps>) {\n const f = useKrizakaField<SliderValue>(name);\n return (\n <div className={className ?? \"flex flex-col gap-1.5\"}>\n <SliderControl label={label} showLabel floatingValue value={f.value} min={min} max={max} step={step} ticks={ticks} marks={marks} disabled={disabled} formatValue={formatValue} thumbLabels={thumbLabels} aria-describedby={ids(f, hint)} onValueChange={(v) => f.setValue(v)} onValueCommit={() => f.onBlur()} />\n <Caption field={f} hint={hint} />\n </div>\n );\n}\n\nconst fields = { TextField, TextArea, Checkbox, Switch, RadioGroup, Select, Combobox, DateField, TagInput, FileUpload, Money, Slider, Field: FormField, FieldArray, Watch, Submit, FormError };\n\n/**\n * A form, defined once: its schema (zod 4) and default values — the same schema the server parses with. In a component,\n * `signUp.useForm({ onSubmit })` gives the form and its fields, typed by the schema: `<form.Form>`, `<form.TextField\n * name=\"email\" …/>`, `<form.Submit>`. Errors are i18n keys (`form.errors.tooShort`), never the engine's English.\n */\nexport const createKrizakaForm = makeCreateKrizakaForm(fields, FormRoot);\n\n/** The form sent by a Server Action: `useFormWithAction(signUp, createAccount)` — `signUp.useFormWithAction(createAccount)`. */\nexport function useFormWithAction<F extends { useFormWithAction: (...args: never[]) => unknown }>(form: F, ...args: Parameters<F[\"useFormWithAction\"]>): ReturnType<F[\"useFormWithAction\"]> {\n return form.useFormWithAction(...args) as ReturnType<F[\"useFormWithAction\"]>;\n}\n\nexport { FieldArray, FormField, Watch } from \"./core\";"
2100
2100
  },
2101
2101
  {
2102
2102
  "path": "meta.ts",
@@ -169,7 +169,7 @@
169
169
  },
170
170
  {
171
171
  "path": "gallery-page/gallery-page.tsx",
172
- "content": "// Server-safe. A demo or a gallery (blocks.css `.kz-tpl-gallery`): the hero, the filters as chips, then the pieces in\n// columns of different heights — each a framed media with its title and caption (a recording of the real product, an\n// image it generated, with its prompt) — and the closing call.\nimport { CtaPanel } from \"@krizaka/ui/cta-panel\";\nimport { Section } from \"@krizaka/ui/page\";\nimport type { LinkComponent } from \"@krizaka/ui/page-hero\";\nimport { PageHero } from \"@krizaka/ui/page-hero\";\nimport type * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { warnDeprecated } from \"../deprecated\";\n\nexport interface GalleryItem {\n /** A stable key. */\n id: string;\n /** The media: an `<img>` with its `alt`, a `<video>` with its label, a VideoPlayer. */\n media: React.ReactNode;\n /** Its title. */\n title: React.ReactNode;\n /** One line: what it shows, how it was made (a prompt, a seed). */\n caption?: React.ReactNode;\n}\n\nexport type GalleryPageProps = Omit<React.HTMLAttributes<HTMLElement>, \"title\"> & {\n /** The brand the page wears (`.brand-<id>`). */\n brand?: string;\n /** The way back. */\n back?: { href: string; label: string };\n /** A mono line above the title. */\n eyebrow?: React.ReactNode;\n /** The page's `h1`. */\n title: React.ReactNode;\n /** One or two sentences under it. */\n lead?: React.ReactNode;\n /** The hero's actions. */\n actions?: React.ReactNode;\n /** Above the pieces: the filters (ChipLink, a Chip group) — the address says which one is on. */\n filters?: React.ReactNode;\n /** The gallery's accessible name. */\n galleryLabel: string;\n /** The pieces, featured first. */\n items: readonly GalleryItem[];\n /** After the gallery: how it was made, the facts. */\n children?: React.ReactNode;\n /** The closing call. */\n closing?: { title: React.ReactNode; body?: React.ReactNode; actions: React.ReactNode };\n /** The app's link component (Next's `Link`). */\n linkAs?: LinkComponent;\n};\n\n/**\n * A demo or a gallery: hero, filters, media in staggered columns, closing call.\n * @deprecated Since 3.55 (ADR-006, krizaka-ui#674): no product uses it. Removed in 4.0.\n */\nexport function GalleryPage({ brand, back, eyebrow, title, lead, actions, filters, galleryLabel, items, closing, linkAs, className, children, ...props }: GalleryPageProps) {\n warnDeprecated(\"gallery-page\");\n return (\n <div className={cn(brand && \"brand-\" + brand, className)} {...props}>\n <PageHero back={back} linkAs={linkAs} eyebrow={eyebrow} title={title} lead={lead} align=\"center\" backdrop=\"plain\">\n {actions}\n </PageHero>\n <Section aria-label={galleryLabel} spacing=\"sm\">\n {filters && <div className=\"kz-tpl-filters\">{filters}</div>}\n <ul className=\"kz-tpl-gallery\">\n {items.map((item) => (\n <li key={item.id}>\n <figure className=\"kz-tpl-figure\">\n <div className=\"kz-tpl-figure-media\">{item.media}</div>\n <figcaption>\n <strong>{item.title}</strong>\n {item.caption && <span>{item.caption}</span>}\n </figcaption>\n </figure>\n </li>\n ))}\n </ul>\n </Section>\n {children}\n {closing && (\n <Section spacing=\"sm\" aria-labelledby=\"gallery-closing\">\n <CtaPanel id=\"gallery-closing\" title={closing.title} body={closing.body} reveal>\n {closing.actions}\n </CtaPanel>\n </Section>\n )}\n </div>\n );\n}\n"
172
+ "content": "// Server-safe. A demo or a gallery (blocks.css `.kz-tpl-gallery`): the hero, the filters as chips, then the pieces in\n// columns of different heights — each a framed media with its title and caption (a recording of the real product, an\n// image it generated, with its prompt) — and the closing call.\nimport { CtaPanel } from \"@krizaka/ui/cta-panel\";\nimport { Section } from \"@krizaka/ui/page\";\nimport type { LinkComponent } from \"@krizaka/ui/page-hero\";\nimport { PageHero } from \"@krizaka/ui/page-hero\";\nimport type * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { warnDeprecated } from \"../deprecated\";\n\nexport interface GalleryItem {\n /** A stable key. */\n id: string;\n /** The media: an `<img>` with its `alt`, a `<video>` with its label, a VideoPlayer. */\n media: React.ReactNode;\n /** Its title. */\n title: React.ReactNode;\n /** One line: what it shows, how it was made (a prompt, a seed). */\n caption?: React.ReactNode;\n}\n\nexport type GalleryPageProps = Omit<React.HTMLAttributes<HTMLElement>, \"title\"> & {\n /** The brand the page wears (`.brand-<id>`). */\n brand?: string;\n /** The way back. */\n back?: { href: string; label: string };\n /** A mono line above the title. */\n eyebrow?: React.ReactNode;\n /** The page's `h1`. */\n title: React.ReactNode;\n /** One or two sentences under it. */\n lead?: React.ReactNode;\n /** The hero's actions. */\n actions?: React.ReactNode;\n /** Above the pieces: the filters (ChipLink, a Chip group) — the address says which one is on. */\n filters?: React.ReactNode;\n /** The gallery's accessible name. */\n galleryLabel: string;\n /** The pieces, featured first. */\n items: readonly GalleryItem[];\n /** After the gallery: how it was made, the facts. */\n children?: React.ReactNode;\n /** The closing call. */\n closing?: { title: React.ReactNode; body?: React.ReactNode; actions: React.ReactNode };\n /** The app's link component (Next's `Link`). */\n linkAs?: LinkComponent;\n};\n\n/**\n * A demo or a gallery: hero, filters, media in staggered columns, closing call.\n * @deprecated Since 3.55 (ADR-006, krizaka-ui#674): no product uses it. Removed in 4.0.\n */\nexport function GalleryPage({ brand, back, eyebrow, title, lead, actions, filters, galleryLabel, items, closing, linkAs, className, children, ...props }: Readonly<GalleryPageProps>) {\n warnDeprecated(\"gallery-page\");\n return (\n <div className={cn(brand && \"brand-\" + brand, className)} {...props}>\n <PageHero back={back} linkAs={linkAs} eyebrow={eyebrow} title={title} lead={lead} align=\"center\" backdrop=\"plain\">\n {actions}\n </PageHero>\n <Section aria-label={galleryLabel} spacing=\"sm\">\n {filters && <div className=\"kz-tpl-filters\">{filters}</div>}\n <ul className=\"kz-tpl-gallery\">\n {items.map((item) => (\n <li key={item.id}>\n <figure className=\"kz-tpl-figure\">\n <div className=\"kz-tpl-figure-media\">{item.media}</div>\n <figcaption>\n <strong>{item.title}</strong>\n {item.caption && <span>{item.caption}</span>}\n </figcaption>\n </figure>\n </li>\n ))}\n </ul>\n </Section>\n {children}\n {closing && (\n <Section spacing=\"sm\" aria-labelledby=\"gallery-closing\">\n <CtaPanel id=\"gallery-closing\" title={closing.title} body={closing.body} reveal>\n {closing.actions}\n </CtaPanel>\n </Section>\n )}\n </div>\n );\n}\n"
173
173
  },
174
174
  {
175
175
  "path": "gallery-page/index.ts",
@@ -226,7 +226,7 @@
226
226
  "files": [
227
227
  {
228
228
  "path": "genui/catalog.tsx",
229
- "content": "// The base catalog of `krizaka:genui/v1` (ADR-082): layout, text, card, callout and table — what a model may draw with\n// @krizaka/ui alone. `KpiStat` and `ChartCard` come from @krizaka/charts (`chartsGenUiCatalog`), which depends on this\n// package, never the reverse.\nimport { formatCompact, formatMoney, formatNumber, formatPercent } from \"@krizaka/intl\";\nimport type * as React from \"react\";\n\nimport { Alert } from \"../alert\";\nimport { CardBody, CardRoot, CardTitle } from \"../card\";\nimport { DataTable, type DataTableColumn } from \"../data-table\";\nimport {\n allowKeys,\n checkBinding,\n checkChildren,\n checkCurrency,\n checkEnum,\n checkId,\n checkText,\n GENUI_FORMATS,\n GENUI_LIMITS,\n type GenUiComponent,\n type GenUiFormat,\n} from \"./spec\";\nimport type { GenUiCatalog, GenUiEntry, GenUiRenderContext } from \"./surface\";\n\nconst first = (...problems: (string | null)[]) => problems.find((p) => p !== null) ?? null;\n\n/** A resolved value as text — strings and numbers only; anything else is not drawn. */\nfunction asText(value: unknown): string {\n if (typeof value === \"string\") return value.slice(0, GENUI_LIMITS.string);\n if (typeof value === \"number\" && Number.isFinite(value)) return String(value);\n return \"\";\n}\n\n/** A number written in one of the closed formats. */\nexport function formatGenUiValue(value: unknown, format: GenUiFormat | undefined, locale: string, currency?: string): string {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return asText(value);\n switch (format) {\n case \"integer\":\n return formatNumber(Math.round(value), { locale, maximumFractionDigits: 0 });\n case \"compact\":\n return formatCompact(value, { locale });\n case \"percent\":\n return formatPercent(value, { locale, maximumFractionDigits: 1 });\n case \"money\":\n return currency ? formatMoney(Math.round(value), { currency, locale }) : formatNumber(value, { locale });\n default:\n return formatNumber(value, { locale, maximumFractionDigits: 2 });\n }\n}\n\nconst TONES = [\"info\", \"success\", \"warning\", \"danger\"] as const;\nconst VARIANTS = [\"body\", \"heading\", \"caption\"] as const;\n\nconst column: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"children\"]), checkChildren(c.children)),\n render: (c, ctx) => <div className=\"flex min-w-0 flex-col gap-4\">{ctx.children(c.children)}</div>,\n};\n\nconst row: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"children\"]), checkChildren(c.children)),\n render: (c, ctx) => <div className=\"grid min-w-0 gap-4 [grid-template-columns:repeat(auto-fit,minmax(12rem,1fr))]\">{ctx.children(c.children)}</div>,\n};\n\nconst text: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"text\", \"variant\"]), checkText(c.text, \"text\", true), checkEnum(c.variant, \"variant\", VARIANTS)),\n render: (c, ctx) => {\n const value = asText(ctx.resolve(c.text));\n if (c.variant === \"heading\") return <h3 className=\"text-base font-semibold text-fg\">{value}</h3>;\n if (c.variant === \"caption\") return <p className=\"text-xs text-fg-muted\">{value}</p>;\n return <p className=\"text-sm text-fg\">{value}</p>;\n },\n};\n\nconst card: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"title\", \"child\"]), checkText(c.title, \"title\", false), c.child === undefined ? null : checkId(c.child, \"child\")),\n render: (c, ctx) => (\n <CardRoot>\n <CardBody>\n {c.title !== undefined && <CardTitle>{asText(ctx.resolve(c.title))}</CardTitle>}\n {c.child !== undefined && <div className=\"mt-3\">{ctx.child(c.child)}</div>}\n </CardBody>\n </CardRoot>\n ),\n};\n\nconst callout: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"tone\", \"title\", \"text\"]), checkEnum(c.tone, \"tone\", TONES), checkText(c.title, \"title\", false), checkText(c.text, \"text\", false)),\n render: (c, ctx) => (\n <Alert tone={(c.tone as (typeof TONES)[number] | undefined) ?? \"info\"} title={c.title === undefined ? undefined : asText(ctx.resolve(c.title))}>\n {c.text === undefined ? undefined : asText(ctx.resolve(c.text))}\n </Alert>\n ),\n};\n\ntype Column = { key: string; label: string; format?: GenUiFormat; currency?: string };\n\nfunction checkColumns(value: unknown): string | null {\n if (!Array.isArray(value) || value.length === 0 || value.length > 12) return \"columns is an array of 1 to 12\";\n for (const raw of value) {\n if (raw === null || typeof raw !== \"object\" || Array.isArray(raw)) return \"a column is an object\";\n const col = raw as Record<string, unknown>;\n const keys = Object.keys(col).find((k) => ![\"key\", \"label\", \"format\", \"currency\"].includes(k));\n if (keys) return `a column has no key \"${keys}\"`;\n if (typeof col.key !== \"string\" || !/^[A-Za-z0-9_]{1,64}$/.test(col.key)) return \"a column key is 1-64 characters of [A-Za-z0-9_]\";\n if (typeof col.label !== \"string\" || col.label.length > 120) return \"a column label is a string\";\n const problem = first(checkEnum(col.format, \"format\", GENUI_FORMATS), checkCurrency(col.currency, col.format === \"money\"));\n if (problem) return problem;\n }\n return null;\n}\n\ntype Row = Record<string, unknown> & { __genuiRow: string };\n\nfunction TableView({ c, ctx }: { c: GenUiComponent; ctx: GenUiRenderContext }) {\n const columns = c.columns as readonly Column[];\n const raw = ctx.resolve(c.rows);\n const rows: Row[] = Array.isArray(raw)\n ? raw.slice(0, GENUI_LIMITS.array).flatMap((r, i) => (r !== null && typeof r === \"object\" && !Array.isArray(r) ? [{ ...(r as Record<string, unknown>), __genuiRow: String(i) }] : []))\n : [];\n const cols: DataTableColumn<Row>[] = columns.map((col) => ({\n id: col.key,\n header: col.label,\n sortable: true,\n type: col.format ? \"number\" : \"text\",\n value: (r) => {\n const v = r[col.key];\n return typeof v === \"number\" || typeof v === \"string\" ? v : null;\n },\n cell: (r) => formatGenUiValue(r[col.key], col.format, ctx.locale, col.currency),\n }));\n if (rows.length === 0) return <p className=\"text-sm text-fg-muted\">{ctx.labels.noData}</p>;\n return <DataTable rows={rows} columns={cols} getRowId={(r) => r.__genuiRow} caption={c.caption === undefined ? ctx.labels.surface : asText(ctx.resolve(c.caption))} showCaption={c.caption !== undefined} />;\n}\n\nconst table: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"caption\", \"columns\", \"rows\"]), checkText(c.caption, \"caption\", false), checkColumns(c.columns), checkBinding(c.rows, \"rows\")),\n render: (c, ctx): React.ReactNode => <TableView c={c} ctx={ctx} />,\n};\n\n/** `Column`, `Row`, `Text`, `Card`, `Callout`, `Table` — the catalog @krizaka/ui draws on its own. */\nexport const baseGenUiCatalog: GenUiCatalog = { Column: column, Row: row, Text: text, Card: card, Callout: callout, Table: table };\n"
229
+ "content": "// The base catalog of `krizaka:genui/v1` (ADR-082): layout, text, card, callout and table — what a model may draw with\n// @krizaka/ui alone. `KpiStat` and `ChartCard` come from @krizaka/charts (`chartsGenUiCatalog`), which depends on this\n// package, never the reverse.\nimport { formatCompact, formatMoney, formatNumber, formatPercent } from \"@krizaka/intl\";\nimport type * as React from \"react\";\n\nimport { Alert } from \"../alert\";\nimport { CardBody, CardRoot, CardTitle } from \"../card\";\nimport { DataTable, type DataTableColumn } from \"../data-table\";\nimport {\n allowKeys,\n checkBinding,\n checkChildren,\n checkCurrency,\n checkEnum,\n checkId,\n checkText,\n GENUI_FORMATS,\n GENUI_LIMITS,\n type GenUiComponent,\n type GenUiFormat,\n} from \"./spec\";\nimport type { GenUiCatalog, GenUiEntry, GenUiRenderContext } from \"./surface\";\n\nconst first = (...problems: (string | null)[]) => problems.find((p) => p !== null) ?? null;\n\n/** A resolved value as text — strings and numbers only; anything else is not drawn. */\nfunction asText(value: unknown): string {\n if (typeof value === \"string\") return value.slice(0, GENUI_LIMITS.string);\n if (typeof value === \"number\" && Number.isFinite(value)) return String(value);\n return \"\";\n}\n\n/** A number written in one of the closed formats. */\nexport function formatGenUiValue(value: unknown, format: GenUiFormat | undefined, locale: string, currency?: string): string {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return asText(value);\n switch (format) {\n case \"integer\":\n return formatNumber(Math.round(value), { locale, maximumFractionDigits: 0 });\n case \"compact\":\n return formatCompact(value, { locale });\n case \"percent\":\n return formatPercent(value, { locale, maximumFractionDigits: 1 });\n case \"money\":\n return currency ? formatMoney(Math.round(value), { currency, locale }) : formatNumber(value, { locale });\n default:\n return formatNumber(value, { locale, maximumFractionDigits: 2 });\n }\n}\n\nconst TONES = [\"info\", \"success\", \"warning\", \"danger\"] as const;\nconst VARIANTS = [\"body\", \"heading\", \"caption\"] as const;\n\nconst column: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"children\"]), checkChildren(c.children)),\n render: (c, ctx) => <div className=\"flex min-w-0 flex-col gap-4\">{ctx.children(c.children)}</div>,\n};\n\nconst row: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"children\"]), checkChildren(c.children)),\n render: (c, ctx) => <div className=\"grid min-w-0 gap-4 [grid-template-columns:repeat(auto-fit,minmax(12rem,1fr))]\">{ctx.children(c.children)}</div>,\n};\n\nconst text: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"text\", \"variant\"]), checkText(c.text, \"text\", true), checkEnum(c.variant, \"variant\", VARIANTS)),\n render: (c, ctx) => {\n const value = asText(ctx.resolve(c.text));\n if (c.variant === \"heading\") return <h3 className=\"text-base font-semibold text-fg\">{value}</h3>;\n if (c.variant === \"caption\") return <p className=\"text-xs text-fg-muted\">{value}</p>;\n return <p className=\"text-sm text-fg\">{value}</p>;\n },\n};\n\nconst card: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"title\", \"child\"]), checkText(c.title, \"title\", false), c.child === undefined ? null : checkId(c.child, \"child\")),\n render: (c, ctx) => (\n <CardRoot>\n <CardBody>\n {c.title !== undefined && <CardTitle>{asText(ctx.resolve(c.title))}</CardTitle>}\n {c.child !== undefined && <div className=\"mt-3\">{ctx.child(c.child)}</div>}\n </CardBody>\n </CardRoot>\n ),\n};\n\nconst callout: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"tone\", \"title\", \"text\"]), checkEnum(c.tone, \"tone\", TONES), checkText(c.title, \"title\", false), checkText(c.text, \"text\", false)),\n render: (c, ctx) => (\n <Alert tone={(c.tone as (typeof TONES)[number] | undefined) ?? \"info\"} title={c.title === undefined ? undefined : asText(ctx.resolve(c.title))}>\n {c.text === undefined ? undefined : asText(ctx.resolve(c.text))}\n </Alert>\n ),\n};\n\ntype Column = { key: string; label: string; format?: GenUiFormat; currency?: string };\n\nfunction checkColumns(value: unknown): string | null {\n if (!Array.isArray(value) || value.length === 0 || value.length > 12) return \"columns is an array of 1 to 12\";\n for (const raw of value) {\n if (raw === null || typeof raw !== \"object\" || Array.isArray(raw)) return \"a column is an object\";\n const col = raw as Record<string, unknown>;\n const keys = Object.keys(col).find((k) => ![\"key\", \"label\", \"format\", \"currency\"].includes(k));\n if (keys) return `a column has no key \"${keys}\"`;\n if (typeof col.key !== \"string\" || !/^[A-Za-z0-9_]{1,64}$/.test(col.key)) return \"a column key is 1-64 characters of [A-Za-z0-9_]\";\n if (typeof col.label !== \"string\" || col.label.length > 120) return \"a column label is a string\";\n const problem = first(checkEnum(col.format, \"format\", GENUI_FORMATS), checkCurrency(col.currency, col.format === \"money\"));\n if (problem) return problem;\n }\n return null;\n}\n\ntype Row = Record<string, unknown> & { __genuiRow: string };\n\nfunction TableView({ c, ctx }: Readonly<{ c: GenUiComponent; ctx: GenUiRenderContext }>) {\n const columns = c.columns as readonly Column[];\n const raw = ctx.resolve(c.rows);\n const rows: Row[] = Array.isArray(raw)\n ? raw.slice(0, GENUI_LIMITS.array).flatMap((r, i) => (r !== null && typeof r === \"object\" && !Array.isArray(r) ? [{ ...(r as Record<string, unknown>), __genuiRow: String(i) }] : []))\n : [];\n const cols: DataTableColumn<Row>[] = columns.map((col) => ({\n id: col.key,\n header: col.label,\n sortable: true,\n type: col.format ? \"number\" : \"text\",\n value: (r) => {\n const v = r[col.key];\n return typeof v === \"number\" || typeof v === \"string\" ? v : null;\n },\n cell: (r) => formatGenUiValue(r[col.key], col.format, ctx.locale, col.currency),\n }));\n if (rows.length === 0) return <p className=\"text-sm text-fg-muted\">{ctx.labels.noData}</p>;\n return <DataTable rows={rows} columns={cols} getRowId={(r) => r.__genuiRow} caption={c.caption === undefined ? ctx.labels.surface : asText(ctx.resolve(c.caption))} showCaption={c.caption !== undefined} />;\n}\n\nconst table: GenUiEntry = {\n check: (c) => first(allowKeys(c, [\"caption\", \"columns\", \"rows\"]), checkText(c.caption, \"caption\", false), checkColumns(c.columns), checkBinding(c.rows, \"rows\")),\n render: (c, ctx): React.ReactNode => <TableView c={c} ctx={ctx} />,\n};\n\n/** `Column`, `Row`, `Text`, `Card`, `Callout`, `Table` — the catalog @krizaka/ui draws on its own. */\nexport const baseGenUiCatalog: GenUiCatalog = { Column: column, Row: row, Text: text, Card: card, Callout: callout, Table: table };\n"
230
230
  },
231
231
  {
232
232
  "path": "genui/index.ts",
@@ -246,7 +246,7 @@
246
246
  },
247
247
  {
248
248
  "path": "genui/surface.tsx",
249
- "content": "// Renders a surface from its root: each component through its catalog entry, children by id, bound values from the data\n// model. A tree only — a component met twice (a cycle, two parents) or beyond the depth is not drawn — and a child still\n// to come (the answer is streaming) is a skeleton. Text is text: React escapes it, nothing is ever parsed as HTML.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { Skeleton } from \"../skeleton\";\nimport { GENUI_LIMITS, type GenUiComponent, type GenUiPropsCheck, isBinding } from \"./spec\";\nimport { type GenUiState, type GenUiSurfaceState, readPath, readStream } from \"./store\";\n\n/** What an entry gets to draw a component. */\nexport type GenUiRenderContext = {\n /** A child by id: drawn, a skeleton while it has not arrived, nothing when refused. */\n child: (id: unknown) => React.ReactNode;\n /** Children by id, in order. */\n children: (ids: unknown) => React.ReactNode[];\n /** A literal, or the value a binding `{ path }` points at in the data model. */\n resolve: (value: unknown) => unknown;\n /** The words of the surface. */\n labels: GenUiLabels;\n /** The locale numbers and dates are written in. */\n locale: string;\n};\n\n/** One component of a catalog: how its properties are checked, how it is drawn. */\nexport type GenUiEntry = {\n /** `null` when the component's own properties are fine, else why not (the message is refused). */\n readonly check: GenUiPropsCheck;\n /** Draws the component. */\n readonly render: (component: GenUiComponent, context: GenUiRenderContext) => React.ReactNode;\n};\n\n/** The components a model may use, by name: `baseGenUiCatalog`, merged with `chartsGenUiCatalog` of @krizaka/charts. */\nexport type GenUiCatalog = Readonly<Record<string, GenUiEntry>>;\n\n/** The surface's own words (passed translated). */\nexport type GenUiLabels = {\n /** Announced while the surface is still arriving. */\n loading: string;\n /** The accessible name of the surface. */\n surface: string;\n /** Under a table whose data has not arrived or is not a list. */\n noData: string;\n};\n\nexport const genUiLabels: GenUiLabels = { loading: \"Building the view…\", surface: \"Generated view\", noData: \"No data\" };\n\nexport type GenUiSurfaceProps = {\n /** The surface to draw (from `readStream` or `applyMessage`). */\n surface: GenUiSurfaceState;\n /** The components it may use. */\n catalog: GenUiCatalog;\n /** The answer is still arriving: missing children are skeletons and the surface is busy. */\n streaming?: boolean;\n /** The surface's words. */\n labels?: Partial<GenUiLabels>;\n /** The locale numbers are written in. Default `en`. */\n locale?: string;\n /** Called with what could not be drawn (a cycle, a missing child once the answer is complete). */\n onError?: (error: string) => void;\n /** Extra classes on the frame. */\n className?: string;\n};\n\n/** One surface, drawn from its root. */\nexport function GenUiSurface({ surface, catalog, streaming = false, labels, locale = \"en\", onError, className }: GenUiSurfaceProps) {\n const words = { ...genUiLabels, ...labels };\n const problems: string[] = [];\n const seen = new Set<string>();\n\n const draw = (id: unknown, depth: number): React.ReactNode => {\n if (typeof id !== \"string\") return null;\n if (depth > GENUI_LIMITS.depth) {\n problems.push(`\"${id}\" is deeper than ${GENUI_LIMITS.depth}`);\n return null;\n }\n if (seen.has(id)) {\n problems.push(`\"${id}\" is drawn twice (a cycle or two parents)`);\n return null;\n }\n const component = surface.components.get(id);\n if (!component) {\n if (!streaming) problems.push(`\"${id}\" never arrived`);\n return streaming ? <Skeleton key={id} className=\"h-10 w-full rounded-lg\" /> : null;\n }\n const entry = Object.hasOwn(catalog, component.component) ? catalog[component.component] : undefined;\n if (!entry) return null;\n seen.add(id);\n const context: GenUiRenderContext = {\n child: (c) => draw(c, depth + 1),\n children: (ids) => (Array.isArray(ids) ? ids.map((c) => <React.Fragment key={String(c)}>{draw(c, depth + 1)}</React.Fragment>) : []),\n resolve: (value) => (isBinding(value) ? readPath(surface.data, value.path) : value),\n labels: words,\n locale,\n };\n return <React.Fragment key={id}>{entry.render(component, context)}</React.Fragment>;\n };\n\n const root = draw(\"root\", 0);\n React.useEffect(() => {\n if (onError) for (const problem of problems) onError(problem);\n // Reported once per drawn state.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [surface, streaming]);\n\n return (\n <section aria-label={words.surface} aria-busy={streaming || undefined} data-genui-surface={surface.id} className={cn(\"flex flex-col gap-4\", className)}>\n {root ?? (streaming ? <Skeleton className=\"h-24 w-full rounded-xl\" /> : null)}\n </section>\n );\n}\n\nexport type GenUiStreamProps = Omit<GenUiSurfaceProps, \"surface\"> & {\n /** A model's answer, complete or still arriving: its prose and its `a2ui` fence. */\n text: string;\n /** Draws the prose (markdown in a chat); default: paragraphs of text. */\n renderProse?: (prose: string) => React.ReactNode;\n /** What to show when the answer holds no valid surface: the answer itself, as text (the fallback). */\n fallback?: (text: string) => React.ReactNode;\n};\n\n/**\n * A model's answer with its generated view: the prose, then every surface of its `a2ui` fence, growing as the answer\n * streams. An answer without a valid surface falls back to its text.\n */\nexport function GenUiStream({ text, catalog, streaming, renderProse, fallback, onError, ...rest }: GenUiStreamProps) {\n const state = React.useMemo(() => readStream(text, catalog), [text, catalog]);\n const reported = React.useRef(0);\n React.useEffect(() => {\n if (!onError) return;\n for (const error of state.errors.slice(reported.current)) onError(error);\n reported.current = state.errors.length;\n }, [state, onError]);\n const prose = (value: string) => (renderProse ? renderProse(value) : value.split(/\\n{2,}/).map((p, i) => <p key={i}>{p}</p>));\n const surfaces = state.order.map((id) => state.surfaces.get(id)).filter((s): s is GenUiSurfaceState => !!s && s.components.has(\"root\"));\n if (!state.found || (!streaming && surfaces.length === 0)) return <>{fallback ? fallback(text) : prose(text)}</>;\n return (\n <div className=\"flex flex-col gap-4\" data-genui-stream=\"\">\n {state.prose && prose(state.prose)}\n {surfaces.map((surface) => (\n <GenUiSurface key={surface.id} surface={surface} catalog={catalog} streaming={streaming} onError={onError} {...rest} />\n ))}\n {streaming && surfaces.length === 0 && <Skeleton className=\"h-24 w-full rounded-xl\" />}\n </div>\n );\n}\n\n/** The state a list of messages builds — for a surface the app holds itself (not from a model's text). */\nexport type { GenUiState };\n"
249
+ "content": "// Renders a surface from its root: each component through its catalog entry, children by id, bound values from the data\n// model. A tree only — a component met twice (a cycle, two parents) or beyond the depth is not drawn — and a child still\n// to come (the answer is streaming) is a skeleton. Text is text: React escapes it, nothing is ever parsed as HTML.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { Skeleton } from \"../skeleton\";\nimport { GENUI_LIMITS, type GenUiComponent, type GenUiPropsCheck, isBinding } from \"./spec\";\nimport { type GenUiState, type GenUiSurfaceState, readPath, readStream } from \"./store\";\n\n/** What an entry gets to draw a component. */\nexport type GenUiRenderContext = {\n /** A child by id: drawn, a skeleton while it has not arrived, nothing when refused. */\n child: (id: unknown) => React.ReactNode;\n /** Children by id, in order. */\n children: (ids: unknown) => React.ReactNode[];\n /** A literal, or the value a binding `{ path }` points at in the data model. */\n resolve: (value: unknown) => unknown;\n /** The words of the surface. */\n labels: GenUiLabels;\n /** The locale numbers and dates are written in. */\n locale: string;\n};\n\n/** One component of a catalog: how its properties are checked, how it is drawn. */\nexport type GenUiEntry = {\n /** `null` when the component's own properties are fine, else why not (the message is refused). */\n readonly check: GenUiPropsCheck;\n /** Draws the component. */\n readonly render: (component: GenUiComponent, context: GenUiRenderContext) => React.ReactNode;\n};\n\n/** The components a model may use, by name: `baseGenUiCatalog`, merged with `chartsGenUiCatalog` of @krizaka/charts. */\nexport type GenUiCatalog = Readonly<Record<string, GenUiEntry>>;\n\n/** The surface's own words (passed translated). */\nexport type GenUiLabels = {\n /** Announced while the surface is still arriving. */\n loading: string;\n /** The accessible name of the surface. */\n surface: string;\n /** Under a table whose data has not arrived or is not a list. */\n noData: string;\n};\n\nexport const genUiLabels: GenUiLabels = { loading: \"Building the view…\", surface: \"Generated view\", noData: \"No data\" };\n\nexport type GenUiSurfaceProps = {\n /** The surface to draw (from `readStream` or `applyMessage`). */\n surface: GenUiSurfaceState;\n /** The components it may use. */\n catalog: GenUiCatalog;\n /** The answer is still arriving: missing children are skeletons and the surface is busy. */\n streaming?: boolean;\n /** The surface's words. */\n labels?: Partial<GenUiLabels>;\n /** The locale numbers are written in. Default `en`. */\n locale?: string;\n /** Called with what could not be drawn (a cycle, a missing child once the answer is complete). */\n onError?: (error: string) => void;\n /** Extra classes on the frame. */\n className?: string;\n};\n\n/** One surface, drawn from its root. */\nexport function GenUiSurface({ surface, catalog, streaming = false, labels, locale = \"en\", onError, className }: Readonly<GenUiSurfaceProps>) {\n const words = { ...genUiLabels, ...labels };\n const problems: string[] = [];\n const seen = new Set<string>();\n\n const draw = (id: unknown, depth: number): React.ReactNode => {\n if (typeof id !== \"string\") return null;\n if (depth > GENUI_LIMITS.depth) {\n problems.push(`\"${id}\" is deeper than ${GENUI_LIMITS.depth}`);\n return null;\n }\n if (seen.has(id)) {\n problems.push(`\"${id}\" is drawn twice (a cycle or two parents)`);\n return null;\n }\n const component = surface.components.get(id);\n if (!component) {\n if (!streaming) problems.push(`\"${id}\" never arrived`);\n return streaming ? <Skeleton key={id} className=\"h-10 w-full rounded-lg\" /> : null;\n }\n const entry = Object.hasOwn(catalog, component.component) ? catalog[component.component] : undefined;\n if (!entry) return null;\n seen.add(id);\n const context: GenUiRenderContext = {\n child: (c) => draw(c, depth + 1),\n children: (ids) => (Array.isArray(ids) ? ids.map((c) => <React.Fragment key={String(c)}>{draw(c, depth + 1)}</React.Fragment>) : []),\n resolve: (value) => (isBinding(value) ? readPath(surface.data, value.path) : value),\n labels: words,\n locale,\n };\n return <React.Fragment key={id}>{entry.render(component, context)}</React.Fragment>;\n };\n\n const root = draw(\"root\", 0);\n React.useEffect(() => {\n if (onError) for (const problem of problems) onError(problem);\n // Reported once per drawn state.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [surface, streaming]);\n\n return (\n <section aria-label={words.surface} aria-busy={streaming || undefined} data-genui-surface={surface.id} className={cn(\"flex flex-col gap-4\", className)}>\n {root ?? (streaming ? <Skeleton className=\"h-24 w-full rounded-xl\" /> : null)}\n </section>\n );\n}\n\nexport type GenUiStreamProps = Omit<GenUiSurfaceProps, \"surface\"> & {\n /** A model's answer, complete or still arriving: its prose and its `a2ui` fence. */\n text: string;\n /** Draws the prose (markdown in a chat); default: paragraphs of text. */\n renderProse?: (prose: string) => React.ReactNode;\n /** What to show when the answer holds no valid surface: the answer itself, as text (the fallback). */\n fallback?: (text: string) => React.ReactNode;\n};\n\n/**\n * A model's answer with its generated view: the prose, then every surface of its `a2ui` fence, growing as the answer\n * streams. An answer without a valid surface falls back to its text.\n */\nexport function GenUiStream({ text, catalog, streaming, renderProse, fallback, onError, ...rest }: Readonly<GenUiStreamProps>) {\n const state = React.useMemo(() => readStream(text, catalog), [text, catalog]);\n const reported = React.useRef(0);\n React.useEffect(() => {\n if (!onError) return;\n for (const error of state.errors.slice(reported.current)) onError(error);\n reported.current = state.errors.length;\n }, [state, onError]);\n const prose = (value: string) => (renderProse ? renderProse(value) : value.split(/\\n{2,}/).map((p, i) => <p key={i}>{p}</p>));\n const surfaces = state.order.map((id) => state.surfaces.get(id)).filter((s): s is GenUiSurfaceState => !!s && s.components.has(\"root\"));\n if (!state.found || (!streaming && surfaces.length === 0)) return <>{fallback ? fallback(text) : prose(text)}</>;\n return (\n <div className=\"flex flex-col gap-4\" data-genui-stream=\"\">\n {state.prose && prose(state.prose)}\n {surfaces.map((surface) => (\n <GenUiSurface key={surface.id} surface={surface} catalog={catalog} streaming={streaming} onError={onError} {...rest} />\n ))}\n {streaming && surfaces.length === 0 && <Skeleton className=\"h-24 w-full rounded-xl\" />}\n </div>\n );\n}\n\n/** The state a list of messages builds — for a surface the app holds itself (not from a model's text). */\nexport type { GenUiState };\n"
250
250
  },
251
251
  {
252
252
  "path": "meta.ts",