@kerfjs/ui 5.0.0-beta.131 → 5.0.0-beta.133

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 (484) hide show
  1. package/README.md +26 -14
  2. package/ai/application-ui-profile-sync.cjs +5 -14
  3. package/ai/application-ui-profile.d.ts +0 -2
  4. package/ai/application-ui-profile.defaults.json +0 -4
  5. package/ai/application-ui-profile.mjs +5 -14
  6. package/ai/application-ui-profile.schema.json +0 -4
  7. package/ai/choice-wiring-mode.cjs +68 -0
  8. package/ai/component-catalog.json +13 -9
  9. package/ai/component-composition-rules.json +2 -10
  10. package/ai/component-composition.d.ts +0 -17
  11. package/ai/component-composition.json +9 -12
  12. package/ai/component-composition.schema.json +0 -59
  13. package/ai/components/combobox.md +1 -1
  14. package/ai/components/disclosure.md +2 -0
  15. package/ai/components/form.md +1 -2
  16. package/ai/components/popup-menu.md +1 -0
  17. package/ai/components/switch.md +1 -1
  18. package/ai/components/tab-panel.md +0 -1
  19. package/ai/components/toolbar-control-group.md +2 -2
  20. package/ai/public-api-signatures-v1.md +218 -205
  21. package/ai/skill.md +3 -20
  22. package/ai/webawesome-jsx-signatures-v1.md +1 -1
  23. package/dist/backdrop-image.d.ts +1 -1
  24. package/dist/backdrop-image.js +1 -1
  25. package/dist/badge.js +1 -1
  26. package/dist/button.js +1 -1
  27. package/dist/catalog-library.d.ts +26 -0
  28. package/dist/catalog-library.js +2484 -0
  29. package/dist/catalog-library.js.map +1 -0
  30. package/dist/catalog-resources.d.ts +3 -3
  31. package/dist/catalog-resources.js +1 -20
  32. package/dist/catalog-resources.js.map +1 -1
  33. package/dist/catalog.d.ts +5 -4
  34. package/dist/catalog.js +151 -24
  35. package/dist/catalog.js.map +1 -1
  36. package/dist/checkbox-group.js +1 -1
  37. package/dist/checkbox.js +1 -1
  38. package/dist/chip.js +1 -1
  39. package/dist/choice-chips.d.ts +3 -3
  40. package/dist/choice-chips.js +1 -1
  41. package/dist/{chunk-Q5BPZPCO.js → chunk-22T7FFCL.js} +2 -2
  42. package/dist/{chunk-Q5BPZPCO.js.map → chunk-22T7FFCL.js.map} +1 -1
  43. package/dist/{chunk-BCHK33XL.js → chunk-27NEAPV7.js} +2 -2
  44. package/dist/{chunk-BCHK33XL.js.map → chunk-27NEAPV7.js.map} +1 -1
  45. package/dist/{chunk-76BLSFEA.js → chunk-2OYMXGW2.js} +6 -5
  46. package/dist/chunk-2OYMXGW2.js.map +1 -0
  47. package/dist/{chunk-EHR7R7YP.js → chunk-3DPHCZQB.js} +2 -2
  48. package/dist/{chunk-EHR7R7YP.js.map → chunk-3DPHCZQB.js.map} +1 -1
  49. package/dist/{chunk-RPJOLDSR.js → chunk-3UIZ36BP.js} +3 -3
  50. package/dist/{chunk-RPJOLDSR.js.map → chunk-3UIZ36BP.js.map} +1 -1
  51. package/dist/{chunk-QZA75NOK.js → chunk-42NLFCIN.js} +6 -6
  52. package/dist/{chunk-QZA75NOK.js.map → chunk-42NLFCIN.js.map} +1 -1
  53. package/dist/{chunk-UPHPFKAD.js → chunk-4GGIML4E.js} +2 -2
  54. package/dist/{chunk-UPHPFKAD.js.map → chunk-4GGIML4E.js.map} +1 -1
  55. package/dist/{chunk-5KWXM5O7.js → chunk-5C34PAUY.js} +2 -2
  56. package/dist/{chunk-5KWXM5O7.js.map → chunk-5C34PAUY.js.map} +1 -1
  57. package/dist/{chunk-6PHG2DMG.js → chunk-6OH734CG.js} +2 -2
  58. package/dist/{chunk-6PHG2DMG.js.map → chunk-6OH734CG.js.map} +1 -1
  59. package/dist/{chunk-E7ZRBMVQ.js → chunk-7XIY7G4K.js} +3 -3
  60. package/dist/{chunk-E7ZRBMVQ.js.map → chunk-7XIY7G4K.js.map} +1 -1
  61. package/dist/{chunk-OKZTLRGG.js → chunk-B5Q3KE4Z.js} +2 -2
  62. package/dist/{chunk-OKZTLRGG.js.map → chunk-B5Q3KE4Z.js.map} +1 -1
  63. package/dist/{chunk-SGYBIKQA.js → chunk-BADEZQ3V.js} +4 -4
  64. package/dist/chunk-BADEZQ3V.js.map +1 -0
  65. package/dist/{chunk-CJAKN2KZ.js → chunk-BLBMUD2W.js} +2 -2
  66. package/dist/{chunk-CJAKN2KZ.js.map → chunk-BLBMUD2W.js.map} +1 -1
  67. package/dist/{chunk-TRJS7M2H.js → chunk-BNRH7XG5.js} +2 -2
  68. package/dist/{chunk-TRJS7M2H.js.map → chunk-BNRH7XG5.js.map} +1 -1
  69. package/dist/{chunk-NA4LKVPX.js → chunk-BNXJQB2Y.js} +2 -2
  70. package/dist/{chunk-NA4LKVPX.js.map → chunk-BNXJQB2Y.js.map} +1 -1
  71. package/dist/{chunk-CCPWJDRW.js → chunk-BQHGXQVA.js} +2 -2
  72. package/dist/{chunk-CCPWJDRW.js.map → chunk-BQHGXQVA.js.map} +1 -1
  73. package/dist/{chunk-COQI4OMZ.js → chunk-BRDTP3RT.js} +1 -1
  74. package/dist/chunk-BRDTP3RT.js.map +1 -0
  75. package/dist/{chunk-RGB4DPMN.js → chunk-DGYGRMES.js} +3 -3
  76. package/dist/chunk-DGYGRMES.js.map +1 -0
  77. package/dist/{chunk-V3IXAI4L.js → chunk-DNNHT7RB.js} +2 -2
  78. package/dist/{chunk-V3IXAI4L.js.map → chunk-DNNHT7RB.js.map} +1 -1
  79. package/dist/{chunk-UU37OR3D.js → chunk-DT7KOBQJ.js} +1 -1
  80. package/dist/chunk-DT7KOBQJ.js.map +1 -0
  81. package/dist/{chunk-CUUW57WB.js → chunk-DXZA7OC6.js} +58 -14
  82. package/dist/chunk-DXZA7OC6.js.map +1 -0
  83. package/dist/{chunk-4OH6JSGU.js → chunk-F25UMYDX.js} +2 -2
  84. package/dist/{chunk-4OH6JSGU.js.map → chunk-F25UMYDX.js.map} +1 -1
  85. package/dist/{chunk-76VCWWUA.js → chunk-HSMSTCNZ.js} +2 -2
  86. package/dist/{chunk-76VCWWUA.js.map → chunk-HSMSTCNZ.js.map} +1 -1
  87. package/dist/{chunk-ECVTRAXN.js → chunk-IQOO3ZQK.js} +2 -2
  88. package/dist/{chunk-ECVTRAXN.js.map → chunk-IQOO3ZQK.js.map} +1 -1
  89. package/dist/{chunk-2FA3SX57.js → chunk-IXT2ARIM.js} +4 -4
  90. package/dist/{chunk-2FA3SX57.js.map → chunk-IXT2ARIM.js.map} +1 -1
  91. package/dist/{chunk-DBP3N6E5.js → chunk-JBL6SCNN.js} +3 -3
  92. package/dist/{chunk-DBP3N6E5.js.map → chunk-JBL6SCNN.js.map} +1 -1
  93. package/dist/{chunk-7KN5OQVN.js → chunk-JNQBPRAA.js} +2 -2
  94. package/dist/{chunk-7KN5OQVN.js.map → chunk-JNQBPRAA.js.map} +1 -1
  95. package/dist/{chunk-CPTQABDQ.js → chunk-JNSPYECP.js} +2 -2
  96. package/dist/{chunk-CPTQABDQ.js.map → chunk-JNSPYECP.js.map} +1 -1
  97. package/dist/{chunk-E7Q6UNCB.js → chunk-KBDYXGYT.js} +2 -2
  98. package/dist/{chunk-E7Q6UNCB.js.map → chunk-KBDYXGYT.js.map} +1 -1
  99. package/dist/{chunk-WVQDIOD7.js → chunk-KKMZP3YL.js} +2 -2
  100. package/dist/{chunk-WVQDIOD7.js.map → chunk-KKMZP3YL.js.map} +1 -1
  101. package/dist/{chunk-WSPXSWFG.js → chunk-KZEHTRPC.js} +3 -3
  102. package/dist/chunk-KZEHTRPC.js.map +1 -0
  103. package/dist/{chunk-KACJOE2N.js → chunk-LH5V6XGH.js} +2 -2
  104. package/dist/{chunk-KACJOE2N.js.map → chunk-LH5V6XGH.js.map} +1 -1
  105. package/dist/{chunk-VBXKYT4O.js → chunk-LH7YRRY7.js} +2 -2
  106. package/dist/{chunk-VBXKYT4O.js.map → chunk-LH7YRRY7.js.map} +1 -1
  107. package/dist/{chunk-QXXLDY6I.js → chunk-LI7AQ5NQ.js} +4 -4
  108. package/dist/{chunk-QXXLDY6I.js.map → chunk-LI7AQ5NQ.js.map} +1 -1
  109. package/dist/{chunk-CAB5IWV7.js → chunk-LSFPZR52.js} +4 -4
  110. package/dist/{chunk-CAB5IWV7.js.map → chunk-LSFPZR52.js.map} +1 -1
  111. package/dist/{chunk-CRHKWHTA.js → chunk-LUWZ7UZQ.js} +4 -4
  112. package/dist/{chunk-CRHKWHTA.js.map → chunk-LUWZ7UZQ.js.map} +1 -1
  113. package/dist/{chunk-CMG4OZPV.js → chunk-LWWIBUDK.js} +2 -2
  114. package/dist/{chunk-CMG4OZPV.js.map → chunk-LWWIBUDK.js.map} +1 -1
  115. package/dist/{chunk-LOW7J7SE.js → chunk-MHF2NK7F.js} +4 -4
  116. package/dist/{chunk-LOW7J7SE.js.map → chunk-MHF2NK7F.js.map} +1 -1
  117. package/dist/{chunk-JHUEYWWI.js → chunk-MPM6YBOM.js} +2 -2
  118. package/dist/{chunk-JHUEYWWI.js.map → chunk-MPM6YBOM.js.map} +1 -1
  119. package/dist/{chunk-3UEMBHBK.js → chunk-MPT6Y7Z2.js} +2 -2
  120. package/dist/{chunk-3UEMBHBK.js.map → chunk-MPT6Y7Z2.js.map} +1 -1
  121. package/dist/{chunk-OZKBIPXU.js → chunk-NO2XO7S6.js} +3 -3
  122. package/dist/{chunk-OZKBIPXU.js.map → chunk-NO2XO7S6.js.map} +1 -1
  123. package/dist/{chunk-FQETQ7CM.js → chunk-NSNQWDJ4.js} +2 -2
  124. package/dist/{chunk-FQETQ7CM.js.map → chunk-NSNQWDJ4.js.map} +1 -1
  125. package/dist/{chunk-UOBC36FL.js → chunk-OW2ODKHN.js} +2 -2
  126. package/dist/{chunk-UOBC36FL.js.map → chunk-OW2ODKHN.js.map} +1 -1
  127. package/dist/{chunk-PVKAIVKE.js → chunk-P427MACE.js} +63 -74
  128. package/dist/chunk-P427MACE.js.map +1 -0
  129. package/dist/{chunk-LET362AM.js → chunk-PBXTHYB4.js} +2 -2
  130. package/dist/chunk-PBXTHYB4.js.map +1 -0
  131. package/dist/{chunk-C4FBYP2D.js → chunk-PIYFVFPL.js} +9 -3
  132. package/dist/chunk-PIYFVFPL.js.map +1 -0
  133. package/dist/{chunk-FR5G77K5.js → chunk-PJKH2GZ3.js} +2 -2
  134. package/dist/{chunk-FR5G77K5.js.map → chunk-PJKH2GZ3.js.map} +1 -1
  135. package/dist/{chunk-FNJA4S6J.js → chunk-QNA27ABY.js} +3 -3
  136. package/dist/{chunk-FNJA4S6J.js.map → chunk-QNA27ABY.js.map} +1 -1
  137. package/dist/{chunk-RHMY45DK.js → chunk-QNB5DKKP.js} +5 -5
  138. package/dist/{chunk-RHMY45DK.js.map → chunk-QNB5DKKP.js.map} +1 -1
  139. package/dist/{chunk-XO5IOPM5.js → chunk-QWAAR5JX.js} +8 -8
  140. package/dist/{chunk-XO5IOPM5.js.map → chunk-QWAAR5JX.js.map} +1 -1
  141. package/dist/{chunk-6BXPN5SC.js → chunk-RO3TSZ5W.js} +3 -3
  142. package/dist/{chunk-6BXPN5SC.js.map → chunk-RO3TSZ5W.js.map} +1 -1
  143. package/dist/{chunk-4IXG6XCT.js → chunk-RUCUU7Z7.js} +2 -2
  144. package/dist/{chunk-4IXG6XCT.js.map → chunk-RUCUU7Z7.js.map} +1 -1
  145. package/dist/{chunk-QSJAIXLM.js → chunk-SDQZYSCA.js} +3 -3
  146. package/dist/{chunk-QSJAIXLM.js.map → chunk-SDQZYSCA.js.map} +1 -1
  147. package/dist/{chunk-3XSY5LAB.js → chunk-SXZTDJMG.js} +4 -4
  148. package/dist/{chunk-3XSY5LAB.js.map → chunk-SXZTDJMG.js.map} +1 -1
  149. package/dist/{chunk-LJV2FNOC.js → chunk-T7M5FKCE.js} +3 -3
  150. package/dist/{chunk-LJV2FNOC.js.map → chunk-T7M5FKCE.js.map} +1 -1
  151. package/dist/{chunk-KS7EXW4P.js → chunk-TIRBSPP2.js} +2 -2
  152. package/dist/{chunk-KS7EXW4P.js.map → chunk-TIRBSPP2.js.map} +1 -1
  153. package/dist/{chunk-2GEGIPDR.js → chunk-U5SQOZNK.js} +4 -4
  154. package/dist/{chunk-2GEGIPDR.js.map → chunk-U5SQOZNK.js.map} +1 -1
  155. package/dist/{chunk-Y4VR6VNM.js → chunk-UPOS666Q.js} +2 -2
  156. package/dist/{chunk-Y4VR6VNM.js.map → chunk-UPOS666Q.js.map} +1 -1
  157. package/dist/{chunk-YE6KCAIN.js → chunk-USSGJ3MD.js} +2 -2
  158. package/dist/{chunk-YE6KCAIN.js.map → chunk-USSGJ3MD.js.map} +1 -1
  159. package/dist/{chunk-4UWLHKNU.js → chunk-UWLJ7UEK.js} +3 -3
  160. package/dist/{chunk-4UWLHKNU.js.map → chunk-UWLJ7UEK.js.map} +1 -1
  161. package/dist/{chunk-SNUDT6AX.js → chunk-VHAYQGWR.js} +2 -2
  162. package/dist/{chunk-SNUDT6AX.js.map → chunk-VHAYQGWR.js.map} +1 -1
  163. package/dist/{chunk-DV6GE57V.js → chunk-VWGRAE2Q.js} +2 -2
  164. package/dist/chunk-VWGRAE2Q.js.map +1 -0
  165. package/dist/{chunk-4L5ZIKDZ.js → chunk-W7J3MQNV.js} +2 -2
  166. package/dist/{chunk-4L5ZIKDZ.js.map → chunk-W7J3MQNV.js.map} +1 -1
  167. package/dist/{chunk-MVWR5WRX.js → chunk-WWDDKUDW.js} +3 -3
  168. package/dist/{chunk-MVWR5WRX.js.map → chunk-WWDDKUDW.js.map} +1 -1
  169. package/dist/{chunk-4CYCJ3NY.js → chunk-XNSYDA6G.js} +10 -10
  170. package/dist/{chunk-4CYCJ3NY.js.map → chunk-XNSYDA6G.js.map} +1 -1
  171. package/dist/{chunk-WEQNPYVA.js → chunk-XXKRHKFH.js} +2 -2
  172. package/dist/{chunk-WEQNPYVA.js.map → chunk-XXKRHKFH.js.map} +1 -1
  173. package/dist/{chunk-OQFWF7Q7.js → chunk-XZ253TGP.js} +3 -3
  174. package/dist/{chunk-OQFWF7Q7.js.map → chunk-XZ253TGP.js.map} +1 -1
  175. package/dist/{chunk-3TBMGGTA.js → chunk-Y672Z7QY.js} +2 -2
  176. package/dist/{chunk-3TBMGGTA.js.map → chunk-Y672Z7QY.js.map} +1 -1
  177. package/dist/chunk-YM7VF5SY.js +22 -0
  178. package/dist/chunk-YM7VF5SY.js.map +1 -0
  179. package/dist/{chunk-S7QB5KMM.js → chunk-YRQ4KKLG.js} +29 -56
  180. package/dist/chunk-YRQ4KKLG.js.map +1 -0
  181. package/dist/{chunk-MMOQR426.js → chunk-YS3H6DEQ.js} +2 -2
  182. package/dist/{chunk-MMOQR426.js.map → chunk-YS3H6DEQ.js.map} +1 -1
  183. package/dist/{chunk-QR7MGGOM.js → chunk-YVGHWCMY.js} +3 -3
  184. package/dist/{chunk-QR7MGGOM.js.map → chunk-YVGHWCMY.js.map} +1 -1
  185. package/dist/{chunk-IPYQYLSX.js → chunk-ZDI5I2HT.js} +6 -6
  186. package/dist/{chunk-IPYQYLSX.js.map → chunk-ZDI5I2HT.js.map} +1 -1
  187. package/dist/{chunk-JAC6AVZN.js → chunk-ZIZXXYXM.js} +3 -3
  188. package/dist/{chunk-JAC6AVZN.js.map → chunk-ZIZXXYXM.js.map} +1 -1
  189. package/dist/collapsible-panel.d.ts +5 -5
  190. package/dist/collapsible-panel.js +4 -4
  191. package/dist/collapsible-panel.js.map +1 -1
  192. package/dist/color-field.js +2 -2
  193. package/dist/color-picker.js +1 -1
  194. package/dist/color-swatches.js +1 -1
  195. package/dist/column-explorer.d.ts +2 -2
  196. package/dist/column-explorer.js +166 -21
  197. package/dist/column-explorer.js.map +1 -1
  198. package/dist/column-track.d.ts +1 -1
  199. package/dist/column-track.js +1 -1
  200. package/dist/combobox.d.ts +8 -4
  201. package/dist/combobox.js +1 -1
  202. package/dist/compose-B_GFfFhm.d.ts +36 -0
  203. package/dist/content-item.d.ts +1 -1
  204. package/dist/content-item.js +1 -1
  205. package/dist/content-swap.d.ts +3 -3
  206. package/dist/content-swap.js +1 -1
  207. package/dist/corner-status.d.ts +3 -3
  208. package/dist/corner-status.js +1 -1
  209. package/dist/device-class.js +101 -1
  210. package/dist/device-class.js.map +1 -1
  211. package/dist/disclosure-arrow.d.ts +3 -3
  212. package/dist/disclosure-arrow.js +1 -1
  213. package/dist/disclosure.d.ts +14 -2
  214. package/dist/disclosure.js +13 -4
  215. package/dist/disclosure.js.map +1 -1
  216. package/dist/edge-activity-indicator.d.ts +3 -3
  217. package/dist/edge-activity-indicator.js +1 -1
  218. package/dist/empty-state.d.ts +3 -3
  219. package/dist/empty-state.js +1 -1
  220. package/dist/{extension-attributes-IJ4decoa.d.ts → extension-attributes-CnqvBmj3.d.ts} +1 -1
  221. package/dist/file-picker.d.ts +3 -3
  222. package/dist/file-picker.js +1 -1
  223. package/dist/floating-toolbar.d.ts +3 -3
  224. package/dist/floating-toolbar.js +1 -1
  225. package/dist/form.d.ts +3 -3
  226. package/dist/form.js +1 -1
  227. package/dist/framed-list.js +1 -1
  228. package/dist/gauge.js +1 -1
  229. package/dist/grid.js +1 -1
  230. package/dist/index.d.ts +2 -2
  231. package/dist/index.js +66 -66
  232. package/dist/list-action-row.js +1 -1
  233. package/dist/list-detail-dialog.d.ts +3 -3
  234. package/dist/list-detail-dialog.js +7 -7
  235. package/dist/list-detail-dialog.js.map +1 -1
  236. package/dist/list-header.d.ts +1 -1
  237. package/dist/list-header.js +1 -1
  238. package/dist/list-inset-control.d.ts +3 -3
  239. package/dist/list-inset-control.js +1 -1
  240. package/dist/list-inset-text.js +1 -1
  241. package/dist/list-item.js +1 -1
  242. package/dist/list.d.ts +1 -1
  243. package/dist/list.js +1 -1
  244. package/dist/loading-spinner.d.ts +3 -3
  245. package/dist/loading-spinner.js +1 -1
  246. package/dist/lucide-icon.d.ts +3 -3
  247. package/dist/lucide-icon.js +1 -1
  248. package/dist/message-composer.js +1 -1
  249. package/dist/{nav-stack-DKrvqFjA.d.ts → nav-stack-IKSMxo2A.d.ts} +3 -3
  250. package/dist/nav-stack.d.ts +2 -2
  251. package/dist/nav-stack.js +1 -1
  252. package/dist/paged-view.d.ts +3 -3
  253. package/dist/paged-view.js +1 -1
  254. package/dist/paged-view.js.map +1 -1
  255. package/dist/pane.js +1 -1
  256. package/dist/popup-menu-register.js +7 -1
  257. package/dist/popup-menu-register.js.map +1 -1
  258. package/dist/popup-menu.d.ts +3 -20
  259. package/dist/popup-menu.js +1 -1
  260. package/dist/progress-bar.js +1 -1
  261. package/dist/progress-ring.js +1 -1
  262. package/dist/radio-group.js +1 -1
  263. package/dist/resizable-region.d.ts +3 -3
  264. package/dist/resizable-region.js +1 -1
  265. package/dist/row.d.ts +1 -1
  266. package/dist/row.js +1 -1
  267. package/dist/scroll-effect.d.ts +1 -1
  268. package/dist/scroll-effect.js +1 -1
  269. package/dist/{search-field-7wLt3Bd5.d.ts → search-field-BA48RaJY.d.ts} +3 -3
  270. package/dist/search-field-model.d.ts +2 -2
  271. package/dist/search-field.d.ts +2 -2
  272. package/dist/search-field.js +1 -1
  273. package/dist/segmented-control.d.ts +3 -3
  274. package/dist/segmented-control.js +1 -1
  275. package/dist/select-register.js +3 -2
  276. package/dist/select-register.js.map +1 -1
  277. package/dist/select.d.ts +3 -13
  278. package/dist/select.js +1 -1
  279. package/dist/sized-region.d.ts +3 -3
  280. package/dist/sized-region.js +1 -1
  281. package/dist/skeleton.d.ts +3 -3
  282. package/dist/skeleton.js +1 -1
  283. package/dist/slider.js +1 -1
  284. package/dist/spacer.d.ts +3 -3
  285. package/dist/spacer.js +1 -1
  286. package/dist/split-button.js +1 -1
  287. package/dist/split-view.d.ts +4 -4
  288. package/dist/split-view.js +1 -1
  289. package/dist/state-banner.js +1 -1
  290. package/dist/styles/components/actions/popup-menu/popup-menu.css +12 -125
  291. package/dist/styles/components/actions/toolbar/toolbar.css +0 -7
  292. package/dist/styles/components/data-display/value-table/value-table.css +3 -1
  293. package/dist/styles/components/forms/select/select.css +0 -60
  294. package/dist/styles/components/forms/switch/switch.css +9 -0
  295. package/dist/styles/components/forms/text-field/text-field.css +1 -1
  296. package/dist/styles/components/surfaces/disclosure/disclosure.css +24 -4
  297. package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +1 -1
  298. package/dist/styles/disclosure.css +24 -4
  299. package/dist/styles/popup-menu.css +12 -125
  300. package/dist/styles/select.css +0 -60
  301. package/dist/styles/surface-scaffold.css +1 -1
  302. package/dist/styles/switch.css +9 -0
  303. package/dist/styles/text-field.css +1 -1
  304. package/dist/styles/toolbar.css +0 -7
  305. package/dist/styles/value-table.css +3 -1
  306. package/dist/styles/webawesome.css +7 -0
  307. package/dist/summary-row.js +1 -1
  308. package/dist/sunken-panel.d.ts +3 -3
  309. package/dist/sunken-panel.js +1 -1
  310. package/dist/surface-scaffold.d.ts +9 -5
  311. package/dist/surface-scaffold.js +1 -1
  312. package/dist/switch.d.ts +3 -1
  313. package/dist/switch.js +1 -1
  314. package/dist/tab-bar-item.js +1 -1
  315. package/dist/tab-bar.d.ts +3 -3
  316. package/dist/tab-bar.js +1 -1
  317. package/dist/tab-navigator.d.ts +3 -3
  318. package/dist/tab-navigator.js +2 -2
  319. package/dist/tab-navigator.js.map +1 -1
  320. package/dist/tab-panel.d.ts +3 -3
  321. package/dist/tab-panel.js +1 -1
  322. package/dist/tag-field.d.ts +3 -3
  323. package/dist/tag-field.js +1 -1
  324. package/dist/text-field.d.ts +2 -2
  325. package/dist/text-field.js +1 -1
  326. package/dist/text.d.ts +1 -1
  327. package/dist/text.js +1 -1
  328. package/dist/toolbar-control-group.d.ts +7 -7
  329. package/dist/toolbar-control-group.js +1 -1
  330. package/dist/toolbar-text.d.ts +3 -3
  331. package/dist/toolbar-text.js +1 -1
  332. package/dist/toolbar.d.ts +3 -3
  333. package/dist/toolbar.js +1 -1
  334. package/dist/tree-list.d.ts +3 -3
  335. package/dist/tree-list.js +151 -3
  336. package/dist/tree-list.js.map +1 -1
  337. package/dist/{tree-rows-Bms5QJvG.d.ts → tree-rows-BXChApji.d.ts} +1 -1
  338. package/dist/{types-DmHWkSd6.d.ts → types-CuKf5G87.d.ts} +6 -2
  339. package/dist/value-preview.d.ts +3 -3
  340. package/dist/value-preview.js +1 -1
  341. package/dist/value-table.d.ts +5 -5
  342. package/dist/value-table.js +1 -1
  343. package/dist/wire-catalog.d.ts +5 -5
  344. package/dist/wire-catalog.js +13 -4
  345. package/dist/wire-catalog.js.map +1 -1
  346. package/dist/wire-color-fields.js +73 -2
  347. package/dist/wire-color-fields.js.map +1 -1
  348. package/dist/wire-color-pickers.js +1 -1
  349. package/dist/wire-column-explorer.js +92 -1
  350. package/dist/wire-column-explorer.js.map +1 -1
  351. package/dist/wire-content-items.js +204 -1
  352. package/dist/wire-content-items.js.map +1 -1
  353. package/dist/wire-nav-stack.js +423 -1
  354. package/dist/wire-nav-stack.js.map +1 -1
  355. package/dist/wire-resizable-regions.js +1 -1
  356. package/dist/wire-search-fields.d.ts +2 -2
  357. package/dist/wire-search-fields.js +1 -1
  358. package/dist/wire-sidebar.js +228 -1
  359. package/dist/wire-sidebar.js.map +1 -1
  360. package/dist/wire-sliders.js +29 -1
  361. package/dist/wire-sliders.js.map +1 -1
  362. package/dist/wire-tab-bars.d.ts +1 -1
  363. package/dist/wire-tab-navigator.js +150 -1
  364. package/dist/wire-tab-navigator.js.map +1 -1
  365. package/dist/wire-tag-fields.js +252 -2
  366. package/dist/wire-tag-fields.js.map +1 -1
  367. package/dist/wire-tree-list.js +186 -1
  368. package/dist/wire-tree-list.js.map +1 -1
  369. package/dist/wire-workbench.js +1 -1
  370. package/dist/workbench-dialog.d.ts +3 -3
  371. package/dist/workbench-dialog.js +5 -5
  372. package/dist/workbench-dialog.js.map +1 -1
  373. package/dist/workbench.d.ts +4 -4
  374. package/dist/workbench.js +1 -1
  375. package/docs/accessibility.md +1 -1
  376. package/docs/catalog.md +59 -0
  377. package/docs/component-contract.md +4 -3
  378. package/docs/component-selection.md +7 -2
  379. package/docs/disclosure.md +22 -0
  380. package/docs/examples/composed-catalog.tsx +113 -0
  381. package/docs/examples/scoped-combobox.ts +99 -0
  382. package/docs/examples/typed-action-table.tsx +34 -0
  383. package/docs/forms-and-validation.md +2 -0
  384. package/docs/investigations/combobox-seed-ownership.md +49 -0
  385. package/docs/investigations/measure-scoped-combobox.mjs +87 -0
  386. package/docs/investigations/scoped-combobox.md +98 -0
  387. package/docs/list-detail-dialog.md +2 -3
  388. package/docs/scroll-effect.md +2 -2
  389. package/docs/surface-scaffold.md +5 -6
  390. package/docs/switch.md +21 -0
  391. package/docs/ui-doctor.md +16 -0
  392. package/docs/workbench-dialog.md +2 -3
  393. package/doctor/cli.mjs +38 -25
  394. package/doctor/explain-use.mjs +320 -0
  395. package/llms.txt +3 -44
  396. package/package.json +6 -33
  397. package/ux-demo/recipes/app-shell.tsx +141 -48
  398. package/ux-demo/recipes/collapsible-sidebar.tsx +169 -43
  399. package/ux-demo/recipes/compact-toolbar.tsx +114 -22
  400. package/ux-demo/recipes/composer-form.tsx +104 -14
  401. package/ux-demo/recipes/list-detail-dialog.tsx +84 -38
  402. package/ux-demo/recipes/list-workspace-states.tsx +152 -29
  403. package/ux-demo/recipes/loading-inspector.tsx +174 -30
  404. package/ux-demo/recipes/media-detail.tsx +146 -29
  405. package/ux-demo/recipes/navigation-sidebar.tsx +113 -24
  406. package/ux-demo/recipes/navigation-stack.tsx +43 -7
  407. package/ux-demo/recipes/workspace-header.tsx +66 -2
  408. package/ai/component-props-overlay.json +0 -8910
  409. package/ai/component-props-overlay.schema.json +0 -82
  410. package/ai/component-props.json +0 -34289
  411. package/ai/component-props.schema.json +0 -408
  412. package/ai/view-document.schema.json +0 -467
  413. package/dist/browser/editor.js +0 -50
  414. package/dist/chunk-3K5V3ZSD.js +0 -77
  415. package/dist/chunk-3K5V3ZSD.js.map +0 -1
  416. package/dist/chunk-63TJH2RF.js +0 -231
  417. package/dist/chunk-63TJH2RF.js.map +0 -1
  418. package/dist/chunk-6V6UHPJD.js +0 -153
  419. package/dist/chunk-6V6UHPJD.js.map +0 -1
  420. package/dist/chunk-76BLSFEA.js.map +0 -1
  421. package/dist/chunk-C4FBYP2D.js.map +0 -1
  422. package/dist/chunk-COQI4OMZ.js.map +0 -1
  423. package/dist/chunk-CUUW57WB.js.map +0 -1
  424. package/dist/chunk-D2KHQNJ6.js +0 -155
  425. package/dist/chunk-D2KHQNJ6.js.map +0 -1
  426. package/dist/chunk-DV6GE57V.js.map +0 -1
  427. package/dist/chunk-FCO7BT4P.js +0 -256
  428. package/dist/chunk-FCO7BT4P.js.map +0 -1
  429. package/dist/chunk-GHV36C6I.js +0 -94
  430. package/dist/chunk-GHV36C6I.js.map +0 -1
  431. package/dist/chunk-HPOXLOVC.js +0 -184
  432. package/dist/chunk-HPOXLOVC.js.map +0 -1
  433. package/dist/chunk-I2K4OQKB.js +0 -426
  434. package/dist/chunk-I2K4OQKB.js.map +0 -1
  435. package/dist/chunk-LET362AM.js.map +0 -1
  436. package/dist/chunk-PVKAIVKE.js.map +0 -1
  437. package/dist/chunk-RGB4DPMN.js.map +0 -1
  438. package/dist/chunk-S7QB5KMM.js.map +0 -1
  439. package/dist/chunk-SGYBIKQA.js.map +0 -1
  440. package/dist/chunk-TXBNPEIJ.js +0 -31
  441. package/dist/chunk-TXBNPEIJ.js.map +0 -1
  442. package/dist/chunk-UU37OR3D.js.map +0 -1
  443. package/dist/chunk-WCMGPAY2.js +0 -103
  444. package/dist/chunk-WCMGPAY2.js.map +0 -1
  445. package/dist/chunk-WSPXSWFG.js.map +0 -1
  446. package/dist/chunk-X43QQWVC.js +0 -208
  447. package/dist/chunk-X43QQWVC.js.map +0 -1
  448. package/dist/chunk-YA6OAJY6.js +0 -155
  449. package/dist/chunk-YA6OAJY6.js.map +0 -1
  450. package/dist/editor.d.ts +0 -447
  451. package/dist/editor.js +0 -15608
  452. package/dist/editor.js.map +0 -1
  453. package/dist/styles/editor/editor.css +0 -585
  454. package/dist/styles/editor.css +0 -4
  455. package/dist/view-runtime.d.ts +0 -9
  456. package/dist/view-runtime.js +0 -8
  457. package/dist/view-runtime.js.map +0 -1
  458. package/docs/editor-host.md +0 -397
  459. package/docs/view.md +0 -314
  460. package/props/cli.d.mts +0 -1
  461. package/props/cli.mjs +0 -142
  462. package/props/component-props.d.mts +0 -180
  463. package/props/component-props.mjs +0 -1208
  464. package/view/catalog.mjs +0 -229
  465. package/view/child-kind.mjs +0 -22
  466. package/view/cli.d.mts +0 -18
  467. package/view/cli.mjs +0 -316
  468. package/view/contract.mjs +0 -418
  469. package/view/css-grammar.mjs +0 -93
  470. package/view/generate.d.mts +0 -16
  471. package/view/generate.mjs +0 -739
  472. package/view/index.d.mts +0 -491
  473. package/view/index.mjs +0 -36
  474. package/view/interpret.mjs +0 -339
  475. package/view/project-types-worker.mjs +0 -55
  476. package/view/project-types.d.mts +0 -43
  477. package/view/project-types.mjs +0 -618
  478. package/view/type-expression.d.mts +0 -15
  479. package/view/type-expression.mjs +0 -162
  480. package/view/types.mjs +0 -165
  481. package/view/validate-move.mjs +0 -353
  482. package/view/validate.mjs +0 -1649
  483. package/vite-editor.d.mts +0 -173
  484. package/vite-editor.mjs +0 -548
package/view/generate.mjs DELETED
@@ -1,739 +0,0 @@
1
- // generateView: turns a valid view document into its read-only view module
2
- // (docs/26-ui-editor.md §4). Output is plain TypeScript (or JavaScript plus a
3
- // .d.ts) that invokes component functions through a small typed call boundary
4
- // — no JSX compiler in the consumer's build. Same document and catalogs in,
5
- // byte-identical code out.
6
- import {
7
- canonicalJson,
8
- contractDigest,
9
- contractOf,
10
- propertyName,
11
- serializeContract,
12
- viewDigest,
13
- } from './contract.mjs';
14
- import {
15
- channelOf,
16
- fieldZoneOf,
17
- withFieldZones,
18
- ZoneFill,
19
- zonePropOf,
20
- } from './catalog.mjs';
21
- import { childKind } from './child-kind.mjs';
22
- import { parseCssCall } from './css-grammar.mjs';
23
- import { composedViewPath, eachNodes } from './validate.mjs';
24
- import { typeExpressionText } from './type-expression.mjs';
25
-
26
- export const GENERATOR_VERSION = 1;
27
- const HEADER_LINES = 3;
28
-
29
- const isObject = (value) =>
30
- value !== null && typeof value === 'object' && !Array.isArray(value);
31
- const lowerFirst = (name) => name[0].toLowerCase() + name.slice(1);
32
- const literal = (value) => JSON.stringify(value);
33
-
34
- // A tiny layout printer: expressions are built as docs and printed flat when
35
- // they fit the line, otherwise broken one entry per line. Deterministic, so
36
- // output never depends on the consumer's formatter.
37
- const WIDTH = 100;
38
- const raw = (text) => ({ raw: text });
39
- const call = (prefix, arg, suffix = ')') => ({ call: prefix, arg, suffix });
40
- const obj = (entries) => ({ obj: entries });
41
- const arr = (items) => ({ arr: items });
42
- const cond = (test, then, otherwise) => ({ cond: test, then, otherwise });
43
- // An object entry is `[key, doc]`, or `[spread]` for `...expression`.
44
- const entry = ([key, value]) =>
45
- value === undefined ? key : `${key}: ${flat(value)}`;
46
-
47
- function flat(doc) {
48
- if (doc.raw !== undefined) return doc.raw;
49
- if (doc.call !== undefined) return `${doc.call}${flat(doc.arg)}${doc.suffix}`;
50
- if (doc.obj)
51
- return doc.obj.length ? `{ ${doc.obj.map(entry).join(', ')} }` : '{}';
52
- if (doc.cond !== undefined) {
53
- return `(${doc.cond} ? ${flat(doc.then)} : ${flat(doc.otherwise)})`;
54
- }
55
- return `[${doc.arr.map(flat).join(', ')}]`;
56
- }
57
-
58
- /** Prints a doc starting at column `indent`. */
59
- export function printDoc(doc, indent = 0) {
60
- const single = flat(doc);
61
- if (indent + single.length <= WIDTH || doc.raw !== undefined) return single;
62
- const pad = ' '.repeat(indent + 2);
63
- const end = ' '.repeat(indent);
64
- if (doc.call !== undefined) {
65
- return `${doc.call}${printDoc(doc.arg, indent)}${doc.suffix}`;
66
- }
67
- if (doc.obj) {
68
- return `{
69
- ${doc.obj
70
- .map(([key, value]) =>
71
- value === undefined
72
- ? `${pad}${key},`
73
- : `${pad}${key}: ${printDoc(value, indent + 2)},`,
74
- )
75
- .join('\n')}\n${end}}`;
76
- }
77
- if (doc.cond !== undefined) {
78
- return `(${doc.cond}\n${pad}? ${printDoc(doc.then, indent + 4)}\n${pad}: ${printDoc(doc.otherwise, indent + 4)})`;
79
- }
80
- return `[\n${doc.arr.map((item) => `${pad}${printDoc(item, indent + 2)},`).join('\n')}\n${end}]`;
81
- }
82
-
83
- /** Lucide's export name for a kebab-case icon name (`a-arrow-down` → `AArrowDown`). */
84
- export function lucideExportName(name) {
85
- return name
86
- .split('-')
87
- .map((part) => part[0].toUpperCase() + part.slice(1))
88
- .join('');
89
- }
90
-
91
- /**
92
- * The import specifier for a component module. A package specifier is used
93
- * as is. An absolute path (an app-source component whose catalog the caller
94
- * resolved) becomes relative to `importFrom`, the generated module's folder.
95
- * Pure string work, so it also runs in the browser.
96
- */
97
- export function moduleSpecifier(specifier, importFrom) {
98
- if (!specifier.startsWith('/') || !importFrom) return specifier;
99
- const from = importFrom.split('/').filter(Boolean);
100
- const to = specifier.split('/').filter(Boolean);
101
- let shared = 0;
102
- while (
103
- shared < from.length &&
104
- shared < to.length - 1 &&
105
- from[shared] === to[shared]
106
- )
107
- shared += 1;
108
- const up = from.length - shared;
109
- const rest = to.slice(shared).join('/');
110
- return up === 0 ? `./${rest}` : `${'../'.repeat(up)}${rest}`;
111
- }
112
-
113
- /** The module path generated for a document path (`x.kui.json` → `x.view.ts`). */
114
- export function viewModulePath(documentPath, target = 'ts') {
115
- const base = documentPath.replace(/\.kui\.json$/, '');
116
- return `${base}.view.${target === 'js' ? 'js' : 'ts'}`;
117
- }
118
-
119
- /** The import specifier of a composed document's generated module. */
120
- function viewImport(src) {
121
- return `${src.replace(/\.kui\.json$/, '')}.view.js`;
122
- }
123
-
124
- /** The composed document's exported names, from its `name`. */
125
- const namesOf = (name) => ({
126
- render: `render${name}`,
127
- inputs: `${name}Inputs`,
128
- });
129
-
130
- /**
131
- * Splits generated source into its header and body, and checks the body
132
- * against the header's recorded digest. Used by `kerf-ui-view check` and the
133
- * `kerfjs/no-generated-view-edits` lint rule.
134
- */
135
- export function readViewHeader(code) {
136
- // A checkout may convert line endings; the digest covers LF text.
137
- const lines = code.replace(/\r\n/g, '\n').split('\n');
138
- const stamp =
139
- /^\/\/ kui-view: (\d+) contract (kui1:[0-9a-f]{16}) source (kui1:[0-9a-f]{16}) body (kui1:[0-9a-f]{16})$/.exec(
140
- lines[1] ?? '',
141
- );
142
- const recorded = /^\/\/ kui-contract: (.*)$/.exec(lines[2] ?? '');
143
- if (
144
- !lines[0]?.startsWith('// GENERATED by kerf-ui-view') ||
145
- !stamp ||
146
- !recorded
147
- ) {
148
- return undefined;
149
- }
150
- const body = lines.slice(HEADER_LINES).join('\n');
151
- let contract;
152
- try {
153
- contract = JSON.parse(recorded[1]);
154
- } catch {
155
- return undefined;
156
- }
157
- return {
158
- version: Number(stamp[1]),
159
- contractDigest: stamp[2],
160
- sourceDigest: stamp[3],
161
- bodyDigest: stamp[4],
162
- contract,
163
- // The contract line is the canonical JSON the contract digest hashes, so
164
- // an edited contract line is caught just like an edited body.
165
- intact:
166
- viewDigest(body) === stamp[4] && viewDigest(recorded[1]) === stamp[2],
167
- };
168
- }
169
-
170
- function header(sourceName, contract, sourceDigest, body) {
171
- return [
172
- `// GENERATED by kerf-ui-view from ${sourceName} — do not edit.`,
173
- `// kui-view: ${GENERATOR_VERSION} contract ${contractDigest(contract)} source ${sourceDigest} body ${viewDigest(body)}`,
174
- `// kui-contract: ${serializeContract(contract)}`,
175
- ].join('\n');
176
- }
177
-
178
- /** Collects imports as specifier → names, rendered sorted for determinism. */
179
- function createImports() {
180
- const values = new Map();
181
- const types = new Map();
182
- const add = (map, specifier, name) => {
183
- if (!map.has(specifier)) map.set(specifier, new Set());
184
- map.get(specifier).add(name);
185
- };
186
- return {
187
- value: (specifier, name) => add(values, specifier, name),
188
- type: (specifier, name) => add(types, specifier, name),
189
- render(ts) {
190
- const specifiers = [
191
- ...new Set([...values.keys(), ...(ts ? types.keys() : [])]),
192
- ].sort();
193
- return specifiers
194
- .map((specifier) => {
195
- const named = values.get(specifier) ?? new Set();
196
- const names = [
197
- ...[...named].sort(),
198
- ...(ts
199
- ? [...(types.get(specifier) ?? [])]
200
- .filter((name) => !named.has(name))
201
- .sort()
202
- .map((name) => `type ${name}`)
203
- : []),
204
- ];
205
- return `import { ${names.join(', ')} } from '${specifier}';`;
206
- })
207
- .join('\n');
208
- },
209
- };
210
- }
211
-
212
- function createEmitter(document, catalog, imports, importFrom) {
213
- let usesKerfComponent = false;
214
- const value = (input, scope) => {
215
- // A field zone's children, in the content field it fills (KF-PD6QC5).
216
- if (input instanceof ZoneFill) return children(input.children, scope);
217
- if (isObject(input) && '$param' in input) {
218
- const param = document.params[input.$param];
219
- const read = `inputs.${input.$param}`;
220
- return raw(
221
- 'default' in param ? `(${read} ?? ${literal(param.default)})` : read,
222
- );
223
- }
224
- if (isObject(input) && '$bind' in input) {
225
- const [head, ...rest] = input.$bind.split('.');
226
- // A head that is not an item is a param, read with its default as a
227
- // `$param` is (KF-8P3H7F).
228
- return raw(
229
- [
230
- scope.has(head) ? head : flat(value({ $param: head }, scope)),
231
- ...rest,
232
- ].join('.'),
233
- );
234
- }
235
- if (isObject(input) && '$action' in input)
236
- return raw(literal(input.$action));
237
- if (isObject(input) && '$icon' in input) {
238
- const exported = lucideExportName(input.$icon);
239
- // Aliased so a Lucide name never collides with a component (List, Text).
240
- imports.value('lucide', `${exported} as lucide${exported}`);
241
- return raw(`lucide${exported}`);
242
- }
243
- if (isObject(input) && '$css' in input) {
244
- for (const helper of parseCssCall(input.$css)) {
245
- imports.value('@kerfjs/ui/css-values', helper);
246
- }
247
- return raw(input.$css.trim());
248
- }
249
- // An item slot (KF-SXDM56): content the application fills, as a zone's.
250
- if (isObject(input) && '$slot' in input)
251
- return raw(`slots.${input.$slot}()`);
252
- if (isObject(input)) {
253
- return obj(
254
- Object.keys(input)
255
- .sort()
256
- .map((key) => [propertyName(key), value(input[key], scope)]),
257
- );
258
- }
259
- if (Array.isArray(input))
260
- return arr(input.map((item) => value(item, scope)));
261
- return raw(literal(input));
262
- };
263
-
264
- // KF-EP2152: the document root's key is the render function's optional
265
- // `rowKey` argument, given when a composing document renders this one as a
266
- // row; every other row root's key is an expression over its item.
267
- const ROOT_KEY = Symbol('root key');
268
- const keyEntries = (rowKey) => {
269
- if (rowKey === ROOT_KEY)
270
- return [["...(rowKey === undefined ? {} : { 'data-key': rowKey })"]];
271
- return rowKey ? [["'data-key'", raw(`String(${rowKey})`)]] : [];
272
- };
273
-
274
- /** Marker (and row key) attributes merged into a node's data-* channel. */
275
- const markers = (node, rowKey, base, scope) => {
276
- const entries = [];
277
- if (isObject(base) && !('$param' in base) && !('$bind' in base)) {
278
- for (const key of Object.keys(base).sort())
279
- entries.push([literal(key), value(base[key], scope)]);
280
- } else if (base !== undefined) {
281
- entries.push([`...${flat(value(base, scope))}`]);
282
- }
283
- entries.push(["'data-kerf-node'", raw(literal(node.id))]);
284
- entries.push(...keyEntries(rowKey));
285
- return obj(entries);
286
- };
287
-
288
- const children = (list, scope, slot) => {
289
- const items = list.map((child) => childExpr(child, scope, slot));
290
- // KF-YCM09F: an empty zone is an explicit null.
291
- if (items.length === 0) return raw('null');
292
- return items.length === 1 ? items[0] : arr(items);
293
- };
294
-
295
- const childExpr = (child, scope, slot) => {
296
- switch (childKind(child)) {
297
- case 'each':
298
- return eachExpr(child, scope, slot);
299
- case 'if': {
300
- const otherwise =
301
- 'else' in child ? childExpr(child.else, scope, slot) : raw('null');
302
- return cond(
303
- flat(value(child.$if, scope)),
304
- childExpr(child.then, scope, slot),
305
- otherwise,
306
- );
307
- }
308
- case 'slot':
309
- return isObject(child.input)
310
- ? call(`slots.${child.$slot}(`, value(child.input, scope))
311
- : raw(`slots.${child.$slot}()`);
312
- default:
313
- return nodeExpr(child, scope, undefined, slot);
314
- }
315
- };
316
-
317
- const eachExpr = (child, scope, slot) => {
318
- const inner = new Map(scope).set(child.as, true);
319
- const template =
320
- 'templates' in child
321
- ? kindExpr(child, inner, child.key, slot)
322
- : rowExpr(child.template, inner, child.key, slot);
323
- // Scope holds only `$each` items, so a non-empty scope is a row
324
- // template. kerf never reconciles a list inside a row (a keyed each()
325
- // there throws), so an inner repeat is a plain map that re-renders with
326
- // its row (KF-CFA1S1).
327
- if (scope.size > 0) {
328
- return call(
329
- `${flat(value(child.$each, scope))}.map((${child.as}) => `,
330
- template,
331
- );
332
- }
333
- imports.value('kerfjs', 'each');
334
- return call(
335
- `each(${flat(value(child.$each, scope))}, (${child.as}) => `,
336
- template,
337
- `, { key: ${literal(eachNodes(child)[0].id)} })`,
338
- );
339
- };
340
-
341
- // A row: the template node, or the branch its `$if` chain picks per item
342
- // (KF-8J8E5V). Every branch is a keyed node, and `else` is required.
343
- const rowExpr = (template, scope, rowKey, slot) =>
344
- '$if' in template
345
- ? cond(
346
- flat(value(template.$if, scope)),
347
- rowExpr(template.then, scope, rowKey, slot),
348
- rowExpr(template.else, scope, rowKey, slot),
349
- )
350
- : nodeExpr(template, scope, rowKey, slot);
351
-
352
- // KF-YX6HMT: the template an item's `kind` picks from `templates`, one
353
- // comparison per kind in document order, with `default` for the rest.
354
- const kindExpr = (child, scope, rowKey, slot) => {
355
- const kind = flat(value(child.kind, scope));
356
- return Object.entries(child.templates)
357
- .filter(([name]) => name !== 'default')
358
- .reduceRight(
359
- (otherwise, [name, node]) =>
360
- cond(
361
- `${kind} === ${literal(name)}`,
362
- nodeExpr(node, scope, rowKey, slot),
363
- otherwise,
364
- ),
365
- nodeExpr(child.templates.default, scope, rowKey, slot),
366
- );
367
- };
368
-
369
- const nodeExpr = (node, scope, rowKey, slot) => {
370
- if (node.type === '#text') {
371
- const text = value(node.value, scope);
372
- if (!slot) return text;
373
- imports.value('kerfjs/jsx-runtime', 'jsx');
374
- return call(
375
- "jsx('span', ",
376
- obj([
377
- ['slot', raw(literal(slot))],
378
- ['children', text],
379
- ]),
380
- );
381
- }
382
- if (node.type === '#view') {
383
- const child = document.views[node.src];
384
- const names = namesOf(child.name);
385
- imports.value(viewImport(node.src), names.render);
386
- // A composed row's root carries the row's key (KF-EP2152); a composed
387
- // document has no slots, so the second argument is always empty.
388
- if (rowKey === ROOT_KEY)
389
- return call(
390
- `${names.render}(`,
391
- value(node.props ?? {}, scope),
392
- ', {}, rowKey)',
393
- );
394
- if (rowKey)
395
- return call(
396
- `${names.render}(`,
397
- value(node.props ?? {}, scope),
398
- `, {}, String(${rowKey}))`,
399
- );
400
- return call(`${names.render}(`, value(node.props ?? {}, scope));
401
- }
402
- const { component: definition, definitions } = catalog.components.get(
403
- node.type,
404
- );
405
- const zones = isObject(node.zones) ? node.zones : {};
406
- const props = withFieldZones(
407
- isObject(node.props) ? node.props : {},
408
- zones,
409
- definition,
410
- definitions,
411
- );
412
- const entries = [];
413
- for (const name of Object.keys(props).sort()) {
414
- if (name === 'rootAttributes') continue;
415
- entries.push([propertyName(name), value(props[name], scope)]);
416
- }
417
- if (definition.source === 'webawesome') {
418
- entries.push(["'data-kerf-node'", raw(literal(node.id))]);
419
- entries.push(...keyEntries(rowKey));
420
- if (slot) entries.push(['slot', raw(literal(slot))]);
421
- const parts = Object.keys(zones)
422
- .sort()
423
- .flatMap((key) =>
424
- zones[key].map((child) =>
425
- childExpr(child, scope, key === 'default' ? undefined : key),
426
- ),
427
- );
428
- if (parts.length)
429
- entries.push(['children', parts.length === 1 ? parts[0] : arr(parts)]);
430
- imports.value('kerfjs/jsx-runtime', 'jsx');
431
- return call(`jsx(${literal(definition.tagName)}, `, obj(entries));
432
- }
433
- for (const key of Object.keys(zones).sort()) {
434
- if (fieldZoneOf(definition, definitions, key)) continue;
435
- entries.push([
436
- propertyName(zonePropOf(catalog, definition, key)),
437
- children(zones[key], scope),
438
- ]);
439
- }
440
- if (slot && definition.props.some((prop) => prop.name === 'slot')) {
441
- entries.push(['slot', raw(literal(slot))]);
442
- }
443
- // A component without the channel has no rootAttributes prop at all, so
444
- // validation already rejected one in its props.
445
- const channel = channelOf(definition);
446
- if (channel === 'rootAttributes') {
447
- entries.push([
448
- 'rootAttributes',
449
- markers(node, rowKey, props.rootAttributes, scope),
450
- ]);
451
- } else if (channel === 'native') {
452
- // The component passes data-* props straight through to its root.
453
- entries.push(["'data-kerf-node'", raw(literal(node.id))]);
454
- entries.push(...keyEntries(rowKey));
455
- }
456
- imports.value(
457
- moduleSpecifier(definition.import, importFrom),
458
- definition.export,
459
- );
460
- // Rollup's effect analysis recursively walks direct component calls in
461
- // large generated trees. A curried typed boundary preserves the exact
462
- // call while keeping that analysis linear for the catalog bundle.
463
- usesKerfComponent = true;
464
- return call(`kuiComponent(${definition.export})(`, obj(entries));
465
- };
466
-
467
- return {
468
- root: (node) => nodeExpr(node, new Map(), ROOT_KEY, undefined),
469
- usesKerfComponent: () => usesKerfComponent,
470
- };
471
- }
472
-
473
- function typesBlock(name, contract, inputType = (input) => input.type) {
474
- const inputs = Object.entries(contract.inputs);
475
- const actions = Object.entries(contract.actions);
476
- const slots = Object.entries(contract.slots);
477
- const refs = Object.entries(contract.refs);
478
- const lines = [];
479
- lines.push(
480
- inputs.length
481
- ? `export interface ${name}Inputs {\n${inputs
482
- .map(
483
- ([key, input]) =>
484
- ` readonly ${key}${input.optional ? '?' : ''}: ${inputType(input)};`,
485
- )
486
- .join('\n')}\n}`
487
- : `export type ${name}Inputs = Readonly<Record<string, never>>;`,
488
- );
489
- lines.push(
490
- `export type ${name}Action = ${actions.length ? actions.map(([key]) => literal(key)).join(' | ') : 'never'};`,
491
- );
492
- lines.push(
493
- `export interface ${name}ActionContext {\n readonly event: Event;\n readonly target: HTMLElement;\n}`,
494
- );
495
- if (actions.some(([, scope]) => scope === 'row')) {
496
- lines.push(
497
- `export interface ${name}RowActionContext extends ${name}ActionContext {\n /** The \`data-key\` of the row the action came from. */\n readonly key: string;\n}`,
498
- );
499
- }
500
- lines.push(
501
- actions.length
502
- ? `export interface ${name}Handlers {\n${actions
503
- .map(
504
- ([key, scope]) =>
505
- ` ${propertyName(key)}(context: ${name}${scope === 'row' ? 'Row' : ''}ActionContext): void;`,
506
- )
507
- .join('\n')}\n}`
508
- : `export type ${name}Handlers = Readonly<Record<string, never>>;`,
509
- );
510
- lines.push(
511
- slots.length
512
- ? `export interface ${name}Slots {\n${slots
513
- .map(
514
- ([key, input]) =>
515
- ` ${key}(${input ? `input: ${input}` : ''}): SafeHtml;`,
516
- )
517
- .join('\n')}\n}`
518
- : `export type ${name}Slots = Readonly<Record<string, never>>;`,
519
- );
520
- lines.push(
521
- refs.length
522
- ? `export interface ${name}Refs {\n${refs
523
- .map(([key, ref]) =>
524
- ref.keyed
525
- ? ` readonly ${key}: (key: string) => ${ref.element} | null;`
526
- : ` readonly ${key}: ${ref.element};`,
527
- )
528
- .join('\n')}\n}`
529
- : `export type ${name}Refs = Readonly<Record<string, never>>;`,
530
- );
531
- // KF-YX6HMT: the kinds a `templates` repeat renders, by its item name.
532
- for (const [as, kinds] of Object.entries(contract.kinds ?? {}))
533
- lines.push(
534
- `/** The \`kind\` values with a row design of their own; any other takes \`default\`. */\nexport type ${name}${as[0].toUpperCase()}${as.slice(1)}Kind = ${kinds.map(literal).join(' | ')};`,
535
- );
536
- return lines.join('\n\n');
537
- }
538
-
539
- // A parameter the body never reads is marked used, so the module compiles
540
- // under a consumer's noUnusedParameters.
541
- const unused = (body, ...names) =>
542
- names
543
- .filter((name) => !new RegExp(`\\b${name}\\b`).test(body))
544
- .map((name) => ` void ${name};\n`)
545
- .join('');
546
-
547
- function functionsBlock(name, contract, rootExpr, ts) {
548
- const camel = lowerFirst(name);
549
- const t = (annotation) => (ts ? annotation : '');
550
- const actions = Object.entries(contract.actions);
551
- const refs = Object.entries(contract.refs);
552
- const optional = (entries) =>
553
- Object.values(entries).every((entry) => entry?.optional !== false);
554
- const blocks = [];
555
- if (rootExpr !== undefined) {
556
- const inputsDefault = optional(contract.inputs) ? ' = {}' : '';
557
- const slotsDefault =
558
- Object.keys(contract.slots).length === 0 ? ' = {}' : '';
559
- blocks.push(
560
- `export function render${name}(inputs${t(`: ${name}Inputs`)}${inputsDefault}, slots${t(`: ${name}Slots`)}${slotsDefault}, rowKey${t('?: string')})${t(': SafeHtml')} {\n${unused(rootExpr, 'inputs', 'slots', 'rowKey')} return ${rootExpr};\n}`,
561
- );
562
- }
563
- const handlerLines = actions.map(([key, scope]) => {
564
- const context =
565
- scope === 'row'
566
- ? '{ event, target, key: rowKey(target) }'
567
- : '{ event, target }';
568
- return ` ${literal(key)}: (event, target) => handlers[${literal(key)}](${context}),`;
569
- });
570
- blocks.push(
571
- `export function wire${name}(root${t(': HTMLElement')}, handlers${t(`: ${name}Handlers`)})${t(': () => void')} {\n${unused(handlerLines.join(''), 'handlers')} return delegateActions${t('<HTMLElement>')}(root, 'click', {\n${handlerLines.join('\n')}${handlerLines.length ? '\n' : ''} });\n}`,
572
- );
573
- const refLines = refs.map(([key, ref]) =>
574
- ref.keyed
575
- ? ` ${key}: (key${t(': string')}) => rowRef(root, ${literal(ref.id)}, key)${t(` as ${ref.element} | null`)},`
576
- : ` ${key}: nodeRef(root, ${literal(ref.id)}, ${literal(key)})${t(` as ${ref.element}`)},`,
577
- );
578
- blocks.push(
579
- `export function ${camel}Refs(root${t(': ParentNode')})${t(`: ${name}Refs`)} {\n${unused(refLines.join(''), 'root')} return {\n${refLines.join('\n')}${refLines.length ? '\n' : ''} };\n}`,
580
- );
581
- if (actions.some(([, scope]) => scope === 'row')) {
582
- blocks.push(
583
- `function rowKey(target${t(': Element')})${t(': string')} {\n return target.closest('[data-key]')?.getAttribute('data-key') ?? '';\n}`,
584
- );
585
- }
586
- if (refs.some(([, ref]) => !ref.keyed)) {
587
- blocks.push(
588
- `function nodeRef(root${t(': ParentNode')}, id${t(': string')}, name${t(': string')})${t(': Element')} {\n const found = root.querySelector(\`[data-kerf-node="\${id}"]\`);\n if (!found) throw new Error(\`${name} ref "\${name}" (\${id}) is not rendered\`);\n return found;\n}`,
589
- );
590
- }
591
- if (refs.some(([, ref]) => ref.keyed)) {
592
- blocks.push(
593
- `function rowRef(root${t(': ParentNode')}, id${t(': string')}, key${t(': string')})${t(': Element | null')} {\n for (const found of root.querySelectorAll(\`[data-kerf-node="\${id}"]\`)) {\n if (found.closest('[data-key]')?.getAttribute('data-key') === key) return found;\n }\n return null;\n}`,
594
- );
595
- }
596
- return blocks.join('\n\n');
597
- }
598
-
599
- function declarationsBlock(name, contract, includeRender) {
600
- const camel = lowerFirst(name);
601
- const lines = [];
602
- if (includeRender) {
603
- const inputsDefault = Object.values(contract.inputs).every(
604
- (input) => input.optional,
605
- )
606
- ? '?'
607
- : '';
608
- const slotsDefault = Object.keys(contract.slots).length === 0 ? '?' : '';
609
- lines.push(
610
- `export declare function render${name}(inputs${inputsDefault}: ${name}Inputs, slots${slotsDefault}: ${name}Slots, rowKey?: string): SafeHtml;`,
611
- );
612
- }
613
- lines.push(
614
- `export declare function wire${name}(root: HTMLElement, handlers: ${name}Handlers): () => void;`,
615
- );
616
- lines.push(
617
- `export declare function ${camel}Refs(root: ParentNode): ${name}Refs;`,
618
- );
619
- return lines.join('\n');
620
- }
621
-
622
- /**
623
- * Generates a view module. `options.source` names the document file in the
624
- * header; `options.resolveView(src, path)` loads composed documents (required when
625
- * the document has `#view` nodes); `options.target` is `ts` (default) or `js`;
626
- * `options.declarationsOnly` omits `render<Name>` for documents an app loads
627
- * at runtime through `interpretView`.
628
- *
629
- * Returns `{ code, declarations?, contract, digest }` — `declarations` is the
630
- * `.d.ts` for the `js` target. Throws on an invalid document.
631
- */
632
- export function generateView(document, catalog, options = {}) {
633
- const contract = contractOf(document, catalog, {
634
- resolveView: options.resolveView,
635
- });
636
- const name = document.name;
637
- const camel = lowerFirst(name);
638
- const target = options.target === 'js' ? 'js' : 'ts';
639
- const imports = createImports();
640
- imports.type('kerfjs', 'SafeHtml');
641
- imports.value('kerfjs/actions', 'delegateActions');
642
-
643
- // Composed documents' names, so #view nodes import the right render function.
644
- const views = {};
645
- const collectViews = (node) => {
646
- if (!isObject(node)) return;
647
- if (node.type === '#view')
648
- views[node.src] = options.resolveView(
649
- node.src,
650
- composedViewPath(undefined, node.src),
651
- );
652
- for (const list of Object.values(isObject(node.zones) ? node.zones : {})) {
653
- for (const child of list) {
654
- switch (childKind(child)) {
655
- case 'each':
656
- eachNodes(child).forEach(collectViews);
657
- break;
658
- case 'if':
659
- collectViews(child.then);
660
- collectViews(child.else);
661
- break;
662
- case 'slot':
663
- break;
664
- default:
665
- collectViews(child);
666
- }
667
- }
668
- }
669
- };
670
- collectViews(document.root);
671
-
672
- let rootExpr;
673
- let usesKerfComponent = false;
674
- if (!options.declarationsOnly) {
675
- const emitter = createEmitter(
676
- { ...document, views },
677
- catalog,
678
- imports,
679
- options.importFrom,
680
- );
681
- rootExpr = printDoc(emitter.root(document.root), 2);
682
- usesKerfComponent = emitter.usesKerfComponent();
683
- }
684
- const digest = contractDigest(contract);
685
- const sourceDigest = viewDigest(canonicalJson(document));
686
- const sourceName = options.source ?? `${camel}.kui.json`;
687
- // A prop-typed input is that component prop's own type, read from the
688
- // component function so the app's value is checked against it (KF-H3CB2P).
689
- const types = typesBlock(name, contract, (input) => {
690
- if (input.shape.typescript)
691
- return typeExpressionText(
692
- input.shape,
693
- options.typeSource ?? input.shape.typescript.source,
694
- );
695
- if (input.shape.kind !== 'prop') return input.type;
696
- const owner = catalog.components.get(input.shape.component).component;
697
- imports.type(
698
- moduleSpecifier(owner.import, options.importFrom),
699
- owner.export,
700
- );
701
- return `Parameters<typeof ${owner.export}>[0][${literal(input.shape.prop)}]`;
702
- });
703
- const contractLine = `export const ${camel}Contract = ${literal(digest)};`;
704
- if (usesKerfComponent)
705
- imports.value('@kerfjs/ui/view-runtime', 'kuiComponent');
706
-
707
- const assemble = (body) =>
708
- `${header(sourceName, contract, sourceDigest, body)}\n${body}`;
709
- if (target === 'ts') {
710
- const body = [
711
- imports.render(true),
712
- types,
713
- contractLine,
714
- functionsBlock(name, contract, rootExpr, true),
715
- ]
716
- .filter(Boolean)
717
- .join('\n\n');
718
- return { code: assemble(`${body}\n`), contract, digest };
719
- }
720
- const code = [
721
- imports.render(false),
722
- contractLine,
723
- functionsBlock(name, contract, rootExpr, false),
724
- ]
725
- .filter(Boolean)
726
- .join('\n\n');
727
- const dts = [
728
- `import type { SafeHtml } from 'kerfjs';`,
729
- types,
730
- `export declare const ${camel}Contract: ${literal(digest)};`,
731
- declarationsBlock(name, contract, rootExpr !== undefined),
732
- ].join('\n\n');
733
- return {
734
- code: assemble(`${code}\n`),
735
- declarations: assemble(`${dts}\n`),
736
- contract,
737
- digest,
738
- };
739
- }