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

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 (449) hide show
  1. package/README.md +0 -13
  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/component-catalog.json +9 -7
  8. package/ai/component-composition-rules.json +2 -10
  9. package/ai/component-composition.d.ts +0 -17
  10. package/ai/component-composition.json +3 -11
  11. package/ai/component-composition.schema.json +0 -59
  12. package/ai/components/disclosure.md +2 -0
  13. package/ai/components/form.md +1 -2
  14. package/ai/components/tab-panel.md +0 -1
  15. package/ai/components/toolbar-control-group.md +2 -2
  16. package/ai/public-api-signatures-v1.md +170 -197
  17. package/ai/skill.md +3 -20
  18. package/ai/webawesome-jsx-signatures-v1.md +1 -1
  19. package/dist/backdrop-image.d.ts +1 -1
  20. package/dist/backdrop-image.js +1 -1
  21. package/dist/badge.js +1 -1
  22. package/dist/button.js +1 -1
  23. package/dist/catalog-resources.d.ts +2 -2
  24. package/dist/catalog.d.ts +2 -2
  25. package/dist/catalog.js +16 -16
  26. package/dist/checkbox-group.js +1 -1
  27. package/dist/checkbox.js +1 -1
  28. package/dist/chip.js +1 -1
  29. package/dist/choice-chips.d.ts +3 -3
  30. package/dist/choice-chips.js +1 -1
  31. package/dist/{chunk-Q5BPZPCO.js → chunk-22T7FFCL.js} +2 -2
  32. package/dist/{chunk-Q5BPZPCO.js.map → chunk-22T7FFCL.js.map} +1 -1
  33. package/dist/{chunk-BCHK33XL.js → chunk-27NEAPV7.js} +2 -2
  34. package/dist/{chunk-BCHK33XL.js.map → chunk-27NEAPV7.js.map} +1 -1
  35. package/dist/{chunk-76BLSFEA.js → chunk-2OYMXGW2.js} +6 -5
  36. package/dist/chunk-2OYMXGW2.js.map +1 -0
  37. package/dist/{chunk-EHR7R7YP.js → chunk-3DPHCZQB.js} +2 -2
  38. package/dist/{chunk-EHR7R7YP.js.map → chunk-3DPHCZQB.js.map} +1 -1
  39. package/dist/{chunk-RPJOLDSR.js → chunk-3UIZ36BP.js} +3 -3
  40. package/dist/{chunk-RPJOLDSR.js.map → chunk-3UIZ36BP.js.map} +1 -1
  41. package/dist/{chunk-QZA75NOK.js → chunk-42NLFCIN.js} +6 -6
  42. package/dist/{chunk-QZA75NOK.js.map → chunk-42NLFCIN.js.map} +1 -1
  43. package/dist/{chunk-UPHPFKAD.js → chunk-4GGIML4E.js} +2 -2
  44. package/dist/{chunk-UPHPFKAD.js.map → chunk-4GGIML4E.js.map} +1 -1
  45. package/dist/{chunk-LET362AM.js → chunk-4YXKDS6I.js} +2 -2
  46. package/dist/{chunk-LET362AM.js.map → chunk-4YXKDS6I.js.map} +1 -1
  47. package/dist/{chunk-5KWXM5O7.js → chunk-5C34PAUY.js} +2 -2
  48. package/dist/{chunk-5KWXM5O7.js.map → chunk-5C34PAUY.js.map} +1 -1
  49. package/dist/{chunk-S7QB5KMM.js → chunk-5L3MLWD5.js} +19 -55
  50. package/dist/chunk-5L3MLWD5.js.map +1 -0
  51. package/dist/{chunk-6PHG2DMG.js → chunk-6OH734CG.js} +2 -2
  52. package/dist/{chunk-6PHG2DMG.js.map → chunk-6OH734CG.js.map} +1 -1
  53. package/dist/{chunk-E7ZRBMVQ.js → chunk-7XIY7G4K.js} +3 -3
  54. package/dist/{chunk-E7ZRBMVQ.js.map → chunk-7XIY7G4K.js.map} +1 -1
  55. package/dist/{chunk-OKZTLRGG.js → chunk-B5Q3KE4Z.js} +2 -2
  56. package/dist/{chunk-OKZTLRGG.js.map → chunk-B5Q3KE4Z.js.map} +1 -1
  57. package/dist/{chunk-SGYBIKQA.js → chunk-BADEZQ3V.js} +4 -4
  58. package/dist/chunk-BADEZQ3V.js.map +1 -0
  59. package/dist/{chunk-CJAKN2KZ.js → chunk-BLBMUD2W.js} +2 -2
  60. package/dist/{chunk-CJAKN2KZ.js.map → chunk-BLBMUD2W.js.map} +1 -1
  61. package/dist/{chunk-TRJS7M2H.js → chunk-BNRH7XG5.js} +2 -2
  62. package/dist/{chunk-TRJS7M2H.js.map → chunk-BNRH7XG5.js.map} +1 -1
  63. package/dist/{chunk-NA4LKVPX.js → chunk-BNXJQB2Y.js} +2 -2
  64. package/dist/{chunk-NA4LKVPX.js.map → chunk-BNXJQB2Y.js.map} +1 -1
  65. package/dist/{chunk-CCPWJDRW.js → chunk-BQHGXQVA.js} +2 -2
  66. package/dist/{chunk-CCPWJDRW.js.map → chunk-BQHGXQVA.js.map} +1 -1
  67. package/dist/{chunk-COQI4OMZ.js → chunk-BRDTP3RT.js} +1 -1
  68. package/dist/chunk-BRDTP3RT.js.map +1 -0
  69. package/dist/{chunk-RGB4DPMN.js → chunk-DGYGRMES.js} +3 -3
  70. package/dist/chunk-DGYGRMES.js.map +1 -0
  71. package/dist/{chunk-V3IXAI4L.js → chunk-DNNHT7RB.js} +2 -2
  72. package/dist/{chunk-V3IXAI4L.js.map → chunk-DNNHT7RB.js.map} +1 -1
  73. package/dist/{chunk-UU37OR3D.js → chunk-DT7KOBQJ.js} +1 -1
  74. package/dist/chunk-DT7KOBQJ.js.map +1 -0
  75. package/dist/{chunk-CUUW57WB.js → chunk-DUKE3PLH.js} +2 -2
  76. package/dist/chunk-DUKE3PLH.js.map +1 -0
  77. package/dist/{chunk-IPYQYLSX.js → chunk-EWCTBJ5O.js} +6 -6
  78. package/dist/{chunk-IPYQYLSX.js.map → chunk-EWCTBJ5O.js.map} +1 -1
  79. package/dist/{chunk-4OH6JSGU.js → chunk-F25UMYDX.js} +2 -2
  80. package/dist/{chunk-4OH6JSGU.js.map → chunk-F25UMYDX.js.map} +1 -1
  81. package/dist/{chunk-C4FBYP2D.js → chunk-FJAAOIMP.js} +2 -2
  82. package/dist/{chunk-C4FBYP2D.js.map → chunk-FJAAOIMP.js.map} +1 -1
  83. package/dist/{chunk-RHMY45DK.js → chunk-H2XGWH4V.js} +5 -5
  84. package/dist/{chunk-RHMY45DK.js.map → chunk-H2XGWH4V.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-DBP3N6E5.js → chunk-JBL6SCNN.js} +3 -3
  90. package/dist/{chunk-DBP3N6E5.js.map → chunk-JBL6SCNN.js.map} +1 -1
  91. package/dist/{chunk-7KN5OQVN.js → chunk-JNQBPRAA.js} +2 -2
  92. package/dist/{chunk-7KN5OQVN.js.map → chunk-JNQBPRAA.js.map} +1 -1
  93. package/dist/{chunk-CPTQABDQ.js → chunk-JNSPYECP.js} +2 -2
  94. package/dist/{chunk-CPTQABDQ.js.map → chunk-JNSPYECP.js.map} +1 -1
  95. package/dist/{chunk-E7Q6UNCB.js → chunk-KBDYXGYT.js} +2 -2
  96. package/dist/{chunk-E7Q6UNCB.js.map → chunk-KBDYXGYT.js.map} +1 -1
  97. package/dist/{chunk-WVQDIOD7.js → chunk-KKMZP3YL.js} +2 -2
  98. package/dist/{chunk-WVQDIOD7.js.map → chunk-KKMZP3YL.js.map} +1 -1
  99. package/dist/{chunk-WSPXSWFG.js → chunk-KZEHTRPC.js} +3 -3
  100. package/dist/chunk-KZEHTRPC.js.map +1 -0
  101. package/dist/{chunk-KACJOE2N.js → chunk-LH5V6XGH.js} +2 -2
  102. package/dist/{chunk-KACJOE2N.js.map → chunk-LH5V6XGH.js.map} +1 -1
  103. package/dist/{chunk-VBXKYT4O.js → chunk-LH7YRRY7.js} +2 -2
  104. package/dist/{chunk-VBXKYT4O.js.map → chunk-LH7YRRY7.js.map} +1 -1
  105. package/dist/{chunk-QXXLDY6I.js → chunk-LI7AQ5NQ.js} +4 -4
  106. package/dist/{chunk-QXXLDY6I.js.map → chunk-LI7AQ5NQ.js.map} +1 -1
  107. package/dist/{chunk-CAB5IWV7.js → chunk-LSFPZR52.js} +4 -4
  108. package/dist/{chunk-CAB5IWV7.js.map → chunk-LSFPZR52.js.map} +1 -1
  109. package/dist/{chunk-CRHKWHTA.js → chunk-LUWZ7UZQ.js} +4 -4
  110. package/dist/{chunk-CRHKWHTA.js.map → chunk-LUWZ7UZQ.js.map} +1 -1
  111. package/dist/{chunk-CMG4OZPV.js → chunk-LWWIBUDK.js} +2 -2
  112. package/dist/{chunk-CMG4OZPV.js.map → chunk-LWWIBUDK.js.map} +1 -1
  113. package/dist/{chunk-LOW7J7SE.js → chunk-MHF2NK7F.js} +4 -4
  114. package/dist/{chunk-LOW7J7SE.js.map → chunk-MHF2NK7F.js.map} +1 -1
  115. package/dist/{chunk-JHUEYWWI.js → chunk-MPM6YBOM.js} +2 -2
  116. package/dist/{chunk-JHUEYWWI.js.map → chunk-MPM6YBOM.js.map} +1 -1
  117. package/dist/{chunk-3UEMBHBK.js → chunk-MPT6Y7Z2.js} +2 -2
  118. package/dist/{chunk-3UEMBHBK.js.map → chunk-MPT6Y7Z2.js.map} +1 -1
  119. package/dist/{chunk-OZKBIPXU.js → chunk-NO2XO7S6.js} +3 -3
  120. package/dist/{chunk-OZKBIPXU.js.map → chunk-NO2XO7S6.js.map} +1 -1
  121. package/dist/{chunk-FQETQ7CM.js → chunk-NSNQWDJ4.js} +2 -2
  122. package/dist/{chunk-FQETQ7CM.js.map → chunk-NSNQWDJ4.js.map} +1 -1
  123. package/dist/{chunk-UOBC36FL.js → chunk-OW2ODKHN.js} +2 -2
  124. package/dist/{chunk-UOBC36FL.js.map → chunk-OW2ODKHN.js.map} +1 -1
  125. package/dist/{chunk-PVKAIVKE.js → chunk-P427MACE.js} +63 -74
  126. package/dist/chunk-P427MACE.js.map +1 -0
  127. package/dist/{chunk-FR5G77K5.js → chunk-PJKH2GZ3.js} +2 -2
  128. package/dist/{chunk-FR5G77K5.js.map → chunk-PJKH2GZ3.js.map} +1 -1
  129. package/dist/{chunk-FNJA4S6J.js → chunk-QNA27ABY.js} +3 -3
  130. package/dist/{chunk-FNJA4S6J.js.map → chunk-QNA27ABY.js.map} +1 -1
  131. package/dist/{chunk-6BXPN5SC.js → chunk-RO3TSZ5W.js} +3 -3
  132. package/dist/{chunk-6BXPN5SC.js.map → chunk-RO3TSZ5W.js.map} +1 -1
  133. package/dist/{chunk-4IXG6XCT.js → chunk-RUCUU7Z7.js} +2 -2
  134. package/dist/{chunk-4IXG6XCT.js.map → chunk-RUCUU7Z7.js.map} +1 -1
  135. package/dist/{chunk-2FA3SX57.js → chunk-RYBJ7OZB.js} +4 -4
  136. package/dist/{chunk-2FA3SX57.js.map → chunk-RYBJ7OZB.js.map} +1 -1
  137. package/dist/{chunk-QSJAIXLM.js → chunk-SDQZYSCA.js} +3 -3
  138. package/dist/{chunk-QSJAIXLM.js.map → chunk-SDQZYSCA.js.map} +1 -1
  139. package/dist/{chunk-3XSY5LAB.js → chunk-SXZTDJMG.js} +4 -4
  140. package/dist/{chunk-3XSY5LAB.js.map → chunk-SXZTDJMG.js.map} +1 -1
  141. package/dist/{chunk-LJV2FNOC.js → chunk-T7M5FKCE.js} +3 -3
  142. package/dist/{chunk-LJV2FNOC.js.map → chunk-T7M5FKCE.js.map} +1 -1
  143. package/dist/{chunk-KS7EXW4P.js → chunk-TIRBSPP2.js} +2 -2
  144. package/dist/{chunk-KS7EXW4P.js.map → chunk-TIRBSPP2.js.map} +1 -1
  145. package/dist/{chunk-XO5IOPM5.js → chunk-TNJGPG6R.js} +8 -8
  146. package/dist/{chunk-XO5IOPM5.js.map → chunk-TNJGPG6R.js.map} +1 -1
  147. package/dist/{chunk-2GEGIPDR.js → chunk-U5SQOZNK.js} +4 -4
  148. package/dist/{chunk-2GEGIPDR.js.map → chunk-U5SQOZNK.js.map} +1 -1
  149. package/dist/{chunk-Y4VR6VNM.js → chunk-UPOS666Q.js} +2 -2
  150. package/dist/{chunk-Y4VR6VNM.js.map → chunk-UPOS666Q.js.map} +1 -1
  151. package/dist/{chunk-YE6KCAIN.js → chunk-USSGJ3MD.js} +2 -2
  152. package/dist/{chunk-YE6KCAIN.js.map → chunk-USSGJ3MD.js.map} +1 -1
  153. package/dist/{chunk-4UWLHKNU.js → chunk-UWLJ7UEK.js} +3 -3
  154. package/dist/{chunk-4UWLHKNU.js.map → chunk-UWLJ7UEK.js.map} +1 -1
  155. package/dist/{chunk-SNUDT6AX.js → chunk-VHAYQGWR.js} +2 -2
  156. package/dist/{chunk-SNUDT6AX.js.map → chunk-VHAYQGWR.js.map} +1 -1
  157. package/dist/{chunk-DV6GE57V.js → chunk-VWGRAE2Q.js} +2 -2
  158. package/dist/chunk-VWGRAE2Q.js.map +1 -0
  159. package/dist/{chunk-4L5ZIKDZ.js → chunk-W7J3MQNV.js} +2 -2
  160. package/dist/{chunk-4L5ZIKDZ.js.map → chunk-W7J3MQNV.js.map} +1 -1
  161. package/dist/{chunk-MVWR5WRX.js → chunk-WWDDKUDW.js} +3 -3
  162. package/dist/{chunk-MVWR5WRX.js.map → chunk-WWDDKUDW.js.map} +1 -1
  163. package/dist/{chunk-WEQNPYVA.js → chunk-XXKRHKFH.js} +2 -2
  164. package/dist/{chunk-WEQNPYVA.js.map → chunk-XXKRHKFH.js.map} +1 -1
  165. package/dist/{chunk-OQFWF7Q7.js → chunk-XZ253TGP.js} +3 -3
  166. package/dist/{chunk-OQFWF7Q7.js.map → chunk-XZ253TGP.js.map} +1 -1
  167. package/dist/{chunk-3TBMGGTA.js → chunk-Y672Z7QY.js} +2 -2
  168. package/dist/{chunk-3TBMGGTA.js.map → chunk-Y672Z7QY.js.map} +1 -1
  169. package/dist/{chunk-MMOQR426.js → chunk-YS3H6DEQ.js} +2 -2
  170. package/dist/{chunk-MMOQR426.js.map → chunk-YS3H6DEQ.js.map} +1 -1
  171. package/dist/{chunk-QR7MGGOM.js → chunk-YVGHWCMY.js} +3 -3
  172. package/dist/{chunk-QR7MGGOM.js.map → chunk-YVGHWCMY.js.map} +1 -1
  173. package/dist/{chunk-4CYCJ3NY.js → chunk-Z4PGAYO7.js} +10 -10
  174. package/dist/{chunk-4CYCJ3NY.js.map → chunk-Z4PGAYO7.js.map} +1 -1
  175. package/dist/{chunk-JAC6AVZN.js → chunk-ZIZXXYXM.js} +3 -3
  176. package/dist/{chunk-JAC6AVZN.js.map → chunk-ZIZXXYXM.js.map} +1 -1
  177. package/dist/collapsible-panel.d.ts +5 -5
  178. package/dist/collapsible-panel.js +4 -4
  179. package/dist/collapsible-panel.js.map +1 -1
  180. package/dist/color-field.js +2 -2
  181. package/dist/color-picker.js +1 -1
  182. package/dist/color-swatches.js +1 -1
  183. package/dist/column-explorer.d.ts +2 -2
  184. package/dist/column-explorer.js +166 -21
  185. package/dist/column-explorer.js.map +1 -1
  186. package/dist/column-track.d.ts +1 -1
  187. package/dist/column-track.js +1 -1
  188. package/dist/combobox.d.ts +3 -3
  189. package/dist/combobox.js +1 -1
  190. package/dist/content-item.d.ts +1 -1
  191. package/dist/content-item.js +1 -1
  192. package/dist/content-swap.d.ts +3 -3
  193. package/dist/content-swap.js +1 -1
  194. package/dist/corner-status.d.ts +3 -3
  195. package/dist/corner-status.js +1 -1
  196. package/dist/device-class.js +101 -1
  197. package/dist/device-class.js.map +1 -1
  198. package/dist/disclosure-arrow.d.ts +3 -3
  199. package/dist/disclosure-arrow.js +1 -1
  200. package/dist/disclosure.d.ts +14 -2
  201. package/dist/disclosure.js +13 -4
  202. package/dist/disclosure.js.map +1 -1
  203. package/dist/edge-activity-indicator.d.ts +3 -3
  204. package/dist/edge-activity-indicator.js +1 -1
  205. package/dist/empty-state.d.ts +3 -3
  206. package/dist/empty-state.js +1 -1
  207. package/dist/{extension-attributes-IJ4decoa.d.ts → extension-attributes-CnqvBmj3.d.ts} +1 -1
  208. package/dist/file-picker.d.ts +3 -3
  209. package/dist/file-picker.js +1 -1
  210. package/dist/floating-toolbar.d.ts +3 -3
  211. package/dist/floating-toolbar.js +1 -1
  212. package/dist/form.d.ts +3 -3
  213. package/dist/form.js +1 -1
  214. package/dist/framed-list.js +1 -1
  215. package/dist/gauge.js +1 -1
  216. package/dist/grid.js +1 -1
  217. package/dist/index.d.ts +2 -2
  218. package/dist/index.js +68 -68
  219. package/dist/list-action-row.js +1 -1
  220. package/dist/list-detail-dialog.d.ts +3 -3
  221. package/dist/list-detail-dialog.js +7 -7
  222. package/dist/list-detail-dialog.js.map +1 -1
  223. package/dist/list-header.d.ts +1 -1
  224. package/dist/list-header.js +1 -1
  225. package/dist/list-inset-control.d.ts +3 -3
  226. package/dist/list-inset-control.js +1 -1
  227. package/dist/list-inset-text.js +1 -1
  228. package/dist/list-item.js +1 -1
  229. package/dist/list.d.ts +1 -1
  230. package/dist/list.js +1 -1
  231. package/dist/loading-spinner.d.ts +3 -3
  232. package/dist/loading-spinner.js +1 -1
  233. package/dist/lucide-icon.d.ts +3 -3
  234. package/dist/lucide-icon.js +1 -1
  235. package/dist/message-composer.js +1 -1
  236. package/dist/{nav-stack-DKrvqFjA.d.ts → nav-stack-IKSMxo2A.d.ts} +3 -3
  237. package/dist/nav-stack.d.ts +2 -2
  238. package/dist/nav-stack.js +1 -1
  239. package/dist/paged-view.d.ts +3 -3
  240. package/dist/paged-view.js +1 -1
  241. package/dist/paged-view.js.map +1 -1
  242. package/dist/pane.js +1 -1
  243. package/dist/popup-menu-register.js +1 -1
  244. package/dist/popup-menu.d.ts +1 -20
  245. package/dist/popup-menu.js +1 -1
  246. package/dist/progress-bar.js +1 -1
  247. package/dist/progress-ring.js +1 -1
  248. package/dist/radio-group.js +1 -1
  249. package/dist/resizable-region.d.ts +3 -3
  250. package/dist/resizable-region.js +1 -1
  251. package/dist/row.d.ts +1 -1
  252. package/dist/row.js +1 -1
  253. package/dist/scroll-effect.d.ts +1 -1
  254. package/dist/scroll-effect.js +1 -1
  255. package/dist/{search-field-7wLt3Bd5.d.ts → search-field-BA48RaJY.d.ts} +3 -3
  256. package/dist/search-field-model.d.ts +2 -2
  257. package/dist/search-field.d.ts +2 -2
  258. package/dist/search-field.js +1 -1
  259. package/dist/segmented-control.d.ts +3 -3
  260. package/dist/segmented-control.js +1 -1
  261. package/dist/select-register.js +2 -2
  262. package/dist/select-register.js.map +1 -1
  263. package/dist/select.d.ts +3 -13
  264. package/dist/select.js +1 -1
  265. package/dist/sized-region.d.ts +3 -3
  266. package/dist/sized-region.js +1 -1
  267. package/dist/skeleton.d.ts +3 -3
  268. package/dist/skeleton.js +1 -1
  269. package/dist/slider.js +1 -1
  270. package/dist/spacer.d.ts +3 -3
  271. package/dist/spacer.js +1 -1
  272. package/dist/split-button.js +1 -1
  273. package/dist/split-view.d.ts +4 -4
  274. package/dist/split-view.js +1 -1
  275. package/dist/state-banner.js +1 -1
  276. package/dist/styles/components/actions/popup-menu/popup-menu.css +0 -124
  277. package/dist/styles/components/actions/toolbar/toolbar.css +0 -7
  278. package/dist/styles/components/forms/select/select.css +0 -60
  279. package/dist/styles/components/forms/text-field/text-field.css +1 -1
  280. package/dist/styles/components/surfaces/disclosure/disclosure.css +24 -4
  281. package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +1 -1
  282. package/dist/styles/disclosure.css +24 -4
  283. package/dist/styles/popup-menu.css +0 -124
  284. package/dist/styles/select.css +0 -60
  285. package/dist/styles/surface-scaffold.css +1 -1
  286. package/dist/styles/text-field.css +1 -1
  287. package/dist/styles/toolbar.css +0 -7
  288. package/dist/styles/webawesome.css +7 -0
  289. package/dist/summary-row.js +1 -1
  290. package/dist/sunken-panel.d.ts +3 -3
  291. package/dist/sunken-panel.js +1 -1
  292. package/dist/surface-scaffold.d.ts +9 -5
  293. package/dist/surface-scaffold.js +1 -1
  294. package/dist/switch.js +1 -1
  295. package/dist/tab-bar-item.js +1 -1
  296. package/dist/tab-bar.d.ts +3 -3
  297. package/dist/tab-bar.js +1 -1
  298. package/dist/tab-navigator.d.ts +3 -3
  299. package/dist/tab-navigator.js +2 -2
  300. package/dist/tab-navigator.js.map +1 -1
  301. package/dist/tab-panel.d.ts +3 -3
  302. package/dist/tab-panel.js +1 -1
  303. package/dist/tag-field.d.ts +3 -3
  304. package/dist/tag-field.js +1 -1
  305. package/dist/text-field.d.ts +2 -2
  306. package/dist/text-field.js +1 -1
  307. package/dist/text.d.ts +1 -1
  308. package/dist/text.js +1 -1
  309. package/dist/toolbar-control-group.d.ts +7 -7
  310. package/dist/toolbar-control-group.js +1 -1
  311. package/dist/toolbar-text.d.ts +3 -3
  312. package/dist/toolbar-text.js +1 -1
  313. package/dist/toolbar.d.ts +3 -3
  314. package/dist/toolbar.js +1 -1
  315. package/dist/tree-list.d.ts +3 -3
  316. package/dist/tree-list.js +151 -3
  317. package/dist/tree-list.js.map +1 -1
  318. package/dist/{tree-rows-Bms5QJvG.d.ts → tree-rows-BXChApji.d.ts} +1 -1
  319. package/dist/value-preview.d.ts +3 -3
  320. package/dist/value-preview.js +1 -1
  321. package/dist/value-table.d.ts +5 -5
  322. package/dist/value-table.js +1 -1
  323. package/dist/wire-catalog.d.ts +2 -2
  324. package/dist/wire-catalog.js +2 -2
  325. package/dist/wire-color-fields.js +73 -2
  326. package/dist/wire-color-fields.js.map +1 -1
  327. package/dist/wire-color-pickers.js +1 -1
  328. package/dist/wire-column-explorer.js +92 -1
  329. package/dist/wire-column-explorer.js.map +1 -1
  330. package/dist/wire-content-items.js +204 -1
  331. package/dist/wire-content-items.js.map +1 -1
  332. package/dist/wire-nav-stack.js +423 -1
  333. package/dist/wire-nav-stack.js.map +1 -1
  334. package/dist/wire-resizable-regions.js +1 -1
  335. package/dist/wire-search-fields.d.ts +2 -2
  336. package/dist/wire-search-fields.js +1 -1
  337. package/dist/wire-sidebar.js +228 -1
  338. package/dist/wire-sidebar.js.map +1 -1
  339. package/dist/wire-sliders.js +29 -1
  340. package/dist/wire-sliders.js.map +1 -1
  341. package/dist/wire-tab-bars.d.ts +1 -1
  342. package/dist/wire-tab-navigator.js +150 -1
  343. package/dist/wire-tab-navigator.js.map +1 -1
  344. package/dist/wire-tag-fields.js +252 -2
  345. package/dist/wire-tag-fields.js.map +1 -1
  346. package/dist/wire-tree-list.js +186 -1
  347. package/dist/wire-tree-list.js.map +1 -1
  348. package/dist/wire-workbench.js +1 -1
  349. package/dist/workbench-dialog.d.ts +3 -3
  350. package/dist/workbench-dialog.js +5 -5
  351. package/dist/workbench-dialog.js.map +1 -1
  352. package/dist/workbench.d.ts +4 -4
  353. package/dist/workbench.js +1 -1
  354. package/docs/accessibility.md +1 -1
  355. package/docs/component-contract.md +4 -3
  356. package/docs/component-selection.md +1 -1
  357. package/docs/disclosure.md +22 -0
  358. package/docs/list-detail-dialog.md +2 -3
  359. package/docs/scroll-effect.md +2 -2
  360. package/docs/surface-scaffold.md +5 -6
  361. package/docs/workbench-dialog.md +2 -3
  362. package/llms.txt +3 -44
  363. package/package.json +3 -33
  364. package/ux-demo/recipes/app-shell.tsx +141 -48
  365. package/ux-demo/recipes/collapsible-sidebar.tsx +169 -43
  366. package/ux-demo/recipes/compact-toolbar.tsx +114 -22
  367. package/ux-demo/recipes/composer-form.tsx +104 -14
  368. package/ux-demo/recipes/list-detail-dialog.tsx +84 -38
  369. package/ux-demo/recipes/list-workspace-states.tsx +152 -29
  370. package/ux-demo/recipes/loading-inspector.tsx +174 -30
  371. package/ux-demo/recipes/media-detail.tsx +146 -29
  372. package/ux-demo/recipes/navigation-sidebar.tsx +113 -24
  373. package/ux-demo/recipes/navigation-stack.tsx +43 -7
  374. package/ux-demo/recipes/workspace-header.tsx +66 -2
  375. package/ai/component-props-overlay.json +0 -8910
  376. package/ai/component-props-overlay.schema.json +0 -82
  377. package/ai/component-props.json +0 -34289
  378. package/ai/component-props.schema.json +0 -408
  379. package/ai/view-document.schema.json +0 -467
  380. package/dist/browser/editor.js +0 -50
  381. package/dist/chunk-3K5V3ZSD.js +0 -77
  382. package/dist/chunk-3K5V3ZSD.js.map +0 -1
  383. package/dist/chunk-63TJH2RF.js +0 -231
  384. package/dist/chunk-63TJH2RF.js.map +0 -1
  385. package/dist/chunk-6V6UHPJD.js +0 -153
  386. package/dist/chunk-6V6UHPJD.js.map +0 -1
  387. package/dist/chunk-76BLSFEA.js.map +0 -1
  388. package/dist/chunk-COQI4OMZ.js.map +0 -1
  389. package/dist/chunk-CUUW57WB.js.map +0 -1
  390. package/dist/chunk-D2KHQNJ6.js +0 -155
  391. package/dist/chunk-D2KHQNJ6.js.map +0 -1
  392. package/dist/chunk-DV6GE57V.js.map +0 -1
  393. package/dist/chunk-FCO7BT4P.js +0 -256
  394. package/dist/chunk-FCO7BT4P.js.map +0 -1
  395. package/dist/chunk-GHV36C6I.js +0 -94
  396. package/dist/chunk-GHV36C6I.js.map +0 -1
  397. package/dist/chunk-HPOXLOVC.js +0 -184
  398. package/dist/chunk-HPOXLOVC.js.map +0 -1
  399. package/dist/chunk-I2K4OQKB.js +0 -426
  400. package/dist/chunk-I2K4OQKB.js.map +0 -1
  401. package/dist/chunk-PVKAIVKE.js.map +0 -1
  402. package/dist/chunk-RGB4DPMN.js.map +0 -1
  403. package/dist/chunk-S7QB5KMM.js.map +0 -1
  404. package/dist/chunk-SGYBIKQA.js.map +0 -1
  405. package/dist/chunk-TXBNPEIJ.js +0 -31
  406. package/dist/chunk-TXBNPEIJ.js.map +0 -1
  407. package/dist/chunk-UU37OR3D.js.map +0 -1
  408. package/dist/chunk-WCMGPAY2.js +0 -103
  409. package/dist/chunk-WCMGPAY2.js.map +0 -1
  410. package/dist/chunk-WSPXSWFG.js.map +0 -1
  411. package/dist/chunk-X43QQWVC.js +0 -208
  412. package/dist/chunk-X43QQWVC.js.map +0 -1
  413. package/dist/chunk-YA6OAJY6.js +0 -155
  414. package/dist/chunk-YA6OAJY6.js.map +0 -1
  415. package/dist/editor.d.ts +0 -447
  416. package/dist/editor.js +0 -15608
  417. package/dist/editor.js.map +0 -1
  418. package/dist/styles/editor/editor.css +0 -585
  419. package/dist/styles/editor.css +0 -4
  420. package/dist/view-runtime.d.ts +0 -9
  421. package/dist/view-runtime.js +0 -8
  422. package/dist/view-runtime.js.map +0 -1
  423. package/docs/editor-host.md +0 -397
  424. package/docs/view.md +0 -314
  425. package/props/cli.d.mts +0 -1
  426. package/props/cli.mjs +0 -142
  427. package/props/component-props.d.mts +0 -180
  428. package/props/component-props.mjs +0 -1208
  429. package/view/catalog.mjs +0 -229
  430. package/view/child-kind.mjs +0 -22
  431. package/view/cli.d.mts +0 -18
  432. package/view/cli.mjs +0 -316
  433. package/view/contract.mjs +0 -418
  434. package/view/css-grammar.mjs +0 -93
  435. package/view/generate.d.mts +0 -16
  436. package/view/generate.mjs +0 -739
  437. package/view/index.d.mts +0 -491
  438. package/view/index.mjs +0 -36
  439. package/view/interpret.mjs +0 -339
  440. package/view/project-types-worker.mjs +0 -55
  441. package/view/project-types.d.mts +0 -43
  442. package/view/project-types.mjs +0 -618
  443. package/view/type-expression.d.mts +0 -15
  444. package/view/type-expression.mjs +0 -162
  445. package/view/types.mjs +0 -165
  446. package/view/validate-move.mjs +0 -353
  447. package/view/validate.mjs +0 -1649
  448. package/vite-editor.d.mts +0 -173
  449. package/vite-editor.mjs +0 -548
@@ -1,1208 +0,0 @@
1
- // Structured per-component prop schema (ui/ai/component-props.json): reads
2
- // the published component types with the TypeScript JS API and projects each
3
- // component's props into a small JSON type grammar that editors, validators,
4
- // and generated view contracts can consume without parsing TypeScript.
5
- import { existsSync, readFileSync } from 'node:fs';
6
- import { relative, resolve, sep } from 'node:path';
7
-
8
- import ts from 'typescript';
9
-
10
- export const COMPONENT_PROPS_SCHEMA_ID = 'kerf-ui-component-props/v1';
11
-
12
- // Type aliases that render application content rather than a configured value.
13
- const CONTENT_ALIASES = new Set([
14
- 'SafeHtml',
15
- 'KerfUiContent',
16
- 'JSXChildren',
17
- 'JSXChild',
18
- ]);
19
- // css-values brands and token unions; each is authored through a builder or
20
- // a token name, never a raw string (docs/22-ui-css-authoring.md).
21
- const CSS_VALUE_ALIAS =
22
- /^(Css[A-Z]\w*|Ui(Color|ForegroundColor|Gap|GapValue|SpaceName|ColorName|ForegroundColorName))$/;
23
- // Anonymous object literals inline up to this depth; named ones become
24
- // shared definitions, so recursion and repetition stay bounded.
25
- const MAX_INLINE_DEPTH = 5;
26
- const PRINT_FLAGS =
27
- ts.TypeFormatFlags.NoTruncation |
28
- ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
29
-
30
- /** Creates a TypeScript program over declaration files. */
31
- export function createDeclarationProgram(files, options = {}) {
32
- return ts.createProgram(files, {
33
- target: ts.ScriptTarget.ES2022,
34
- module: ts.ModuleKind.ESNext,
35
- moduleResolution: ts.ModuleResolutionKind.Bundler,
36
- strict: true,
37
- skipLibCheck: true,
38
- types: [],
39
- ...options,
40
- noEmit: true,
41
- });
42
- }
43
-
44
- /**
45
- * Compiler options from a package's own tsconfig.json (JSX settings, paths),
46
- * for reading component source files; empty when it has none.
47
- */
48
- function packageCompilerOptions(root) {
49
- const configPath = ts.findConfigFile(
50
- root,
51
- ts.sys.fileExists,
52
- 'tsconfig.json',
53
- );
54
- if (!configPath || !configPath.startsWith(root)) return {};
55
- const parsed = ts.getParsedCommandLineOfConfigFile(
56
- configPath,
57
- {},
58
- {
59
- ...ts.sys,
60
- onUnRecoverableConfigFileDiagnostic: () => undefined,
61
- },
62
- );
63
- return parsed?.options ?? {};
64
- }
65
-
66
- /** A root-relative ESM import for a source file (`src/x.tsx` → `./src/x.js`). */
67
- function sourceImport(root, file) {
68
- const path = relative(root, file).split(sep).join('/');
69
- return `./${path.replace(/\.(?:tsx?|jsx?|mts|cts)$/, '.js')}`;
70
- }
71
-
72
- /**
73
- * Extraction state for one program: the checker, the shared `definitions`
74
- * table, and the directory whose declarations count as the package's own
75
- * (props declared elsewhere are inherited native attributes).
76
- */
77
- export function createPropsContext(checker, ownDirectory) {
78
- return {
79
- checker,
80
- ownDirectory: ownDirectory.endsWith(sep)
81
- ? ownDirectory
82
- : ownDirectory + sep,
83
- definitions: new Map(),
84
- definitionNames: new Map(),
85
- };
86
- }
87
-
88
- // The printer can overflow the stack on a recursive alias (JSX child trees)
89
- // when truncation is off; fall back to the truncating printer for those.
90
- function printType(checker, type) {
91
- try {
92
- return checker.typeToString(type, undefined, PRINT_FLAGS);
93
- } catch {
94
- return checker.typeToString(type);
95
- }
96
- }
97
-
98
- function documentation(checker, symbol) {
99
- if (!symbol) return '';
100
- return ts
101
- .displayPartsToString(symbol.getDocumentationComment(checker))
102
- .trim();
103
- }
104
-
105
- function jsDocTag(symbol, name) {
106
- const tag = symbol?.getJsDocTags().find((item) => item.name === name);
107
- if (!tag) return undefined;
108
- return ts.displayPartsToString(tag.text ?? []).trim();
109
- }
110
-
111
- /** Literal value a single-literal type carries, or undefined. */
112
- function literalOf(type) {
113
- if (type.isStringLiteral() || type.isNumberLiteral()) return type.value;
114
- if (type.flags & ts.TypeFlags.BooleanLiteral) {
115
- return type.intrinsicName === 'true';
116
- }
117
- return undefined;
118
- }
119
-
120
- const isNullish = (type) =>
121
- (type.flags &
122
- (ts.TypeFlags.Undefined | ts.TypeFlags.Null | ts.TypeFlags.Void)) !==
123
- 0;
124
-
125
- const membersOf = (type) => (type.isUnion() ? type.types : [type]);
126
-
127
- const isObjectLike = (type) =>
128
- (type.flags & ts.TypeFlags.Object) !== 0 || type.isIntersection();
129
-
130
- // TypeScript's own utility types say nothing about the shape they produce,
131
- // so a type named by one stays anonymous (inlined, not a definition).
132
- const UTILITY_NAMES = new Set([
133
- 'Readonly',
134
- 'ReadonlyArray',
135
- 'Record',
136
- 'Partial',
137
- 'Required',
138
- 'Pick',
139
- 'Omit',
140
- 'Exclude',
141
- 'Extract',
142
- 'NonNullable',
143
- ]);
144
- const SIGNAL_NAMES = new Set(['Signal', 'ReadonlySignal']);
145
-
146
- /** A user-facing name for an object or union type, or undefined. */
147
- function nameOf(type) {
148
- const alias = type.aliasSymbol?.getName();
149
- if (alias && !UTILITY_NAMES.has(alias)) return alias;
150
- const symbol = type.getSymbol()?.getName();
151
- return symbol && !symbol.startsWith('__') && !UTILITY_NAMES.has(symbol)
152
- ? symbol
153
- : undefined;
154
- }
155
-
156
- const isSafeHtml = (type) => type.getSymbol()?.getName() === 'SafeHtml';
157
- const isPrimitive = (type) =>
158
- (type.flags &
159
- (ts.TypeFlags.StringLike |
160
- ts.TypeFlags.NumberLike |
161
- ts.TypeFlags.BooleanLike)) !==
162
- 0;
163
-
164
- // Content that also takes a plain string or number (ButtonLabel, TextContent)
165
- // says so; bare `KerfUiContent` rejects arbitrary text (docs/21's compile-time
166
- // contracts), so a document must give it markup instead.
167
- const TEXT_FLAGS = ts.TypeFlags.StringLike | ts.TypeFlags.NumberLike;
168
- function contentOf(members, text) {
169
- return members.some((member) => member.flags & TEXT_FLAGS)
170
- ? { kind: 'content', acceptsText: true, text }
171
- : { kind: 'content', text };
172
- }
173
-
174
- /**
175
- * Described members that are all content, text, or numbers (a branded
176
- * SafeHtml, an alias of content, or one prop's type in each variant) are one
177
- * content slot (KF-24G2KV); undefined for any other set.
178
- */
179
- function contentOfDescribed(members, text) {
180
- if (
181
- !members.some((member) => member.kind === 'content') ||
182
- !members.every((member) =>
183
- ['content', 'string', 'number'].includes(member.kind),
184
- )
185
- )
186
- return undefined;
187
- return members.some(
188
- (member) => member.kind !== 'content' || member.acceptsText,
189
- )
190
- ? { kind: 'content', acceptsText: true, text }
191
- : { kind: 'content', text };
192
- }
193
-
194
- /**
195
- * Text, numbers, rendered markup, or lists of them: application content for
196
- * a slot.
197
- */
198
- function isContentUnion(checker, members) {
199
- return (
200
- members.some(isSafeHtml) &&
201
- members.every(
202
- (member) =>
203
- isSafeHtml(member) ||
204
- isPrimitive(member) ||
205
- checker.isArrayType(member),
206
- )
207
- );
208
- }
209
-
210
- /**
211
- * Registers a named type in the shared table and returns a reference to it.
212
- * Two different types that share a name get distinct `Name`, `Name#2` keys.
213
- */
214
- function reference(ctx, type, name, text, build) {
215
- let key = ctx.definitionNames.get(type);
216
- if (!key) {
217
- key = name;
218
- for (let index = 2; ctx.definitions.has(key); index += 1) {
219
- key = `${name}#${index}`;
220
- }
221
- ctx.definitionNames.set(type, key);
222
- ctx.definitions.set(key, { kind: 'pending', text });
223
- ctx.definitions.set(key, { ...build(), text });
224
- }
225
- return { kind: 'ref', ref: key, text };
226
- }
227
-
228
- /**
229
- * Describes a type in the component-props type grammar. Every descriptor
230
- * carries the printed TypeScript `text`; `kind` narrows it for tooling.
231
- */
232
- export function describeType(ctx, type, depth = 0) {
233
- const text = printType(ctx.checker, type);
234
- const all = membersOf(type);
235
- const members = all.filter((member) => !isNullish(member));
236
- const nullable = members.length !== all.length;
237
- const described = describeNonNull(ctx, type, members, text, depth);
238
- return nullable ? { ...described, nullable: true } : described;
239
- }
240
-
241
- function describeNonNull(ctx, type, members, text, depth) {
242
- if (members.length === 0) return { kind: 'never', text };
243
- const named = type.aliasSymbol?.getName();
244
- if (named && CONTENT_ALIASES.has(named)) return contentOf(members, text);
245
- // A css-values alias that also takes token names (`UiGapValue` is
246
- // `UiSpaceName | CssLength`) keeps its tokens as literals beside the
247
- // builder, as it reads once `| undefined` drops the alias, so a nested
248
- // `{ column: 'm' }` validates (KF-VA14AP).
249
- if (named && CSS_VALUE_ALIAS.test(named)) {
250
- if (!members.some((member) => typeof literalOf(member) === 'string'))
251
- return { kind: 'css-value', grammar: named, text };
252
- }
253
- if (isContentUnion(ctx.checker, members)) return contentOf(members, text);
254
- if (members.length === 1) return describeSingle(ctx, members[0], depth);
255
-
256
- const literals = members.map(literalOf);
257
- if (literals.every((value) => typeof value === 'boolean')) {
258
- return { kind: 'boolean', text };
259
- }
260
- if (literals.every((value) => value !== undefined)) {
261
- const declared = type.aliasSymbol?.declarations?.[0];
262
- return {
263
- kind: 'enum',
264
- values: inDeclaredOrder(
265
- ctx.checker,
266
- literals,
267
- declared && 'type' in declared ? declared.type : undefined,
268
- ),
269
- text,
270
- };
271
- }
272
- const build = () => {
273
- // `true` | `false` print as separate members; fold them back into
274
- // boolean. A lone `true` (a Button's dot badge) stays that literal, so
275
- // nothing offers the `false` the type excludes (KF-FY62FK).
276
- const booleans = members.filter(
277
- (member) => member.flags & ts.TypeFlags.BooleanLiteral,
278
- );
279
- const folded = [];
280
- let sawBoolean = false;
281
- for (const member of members) {
282
- if (member.flags & ts.TypeFlags.BooleanLiteral) {
283
- if (!sawBoolean)
284
- folded.push(
285
- booleans.length === 1
286
- ? describeType(ctx, member, depth + 1)
287
- : { kind: 'boolean', text: 'boolean' },
288
- );
289
- sawBoolean = true;
290
- continue;
291
- }
292
- folded.push(describeType(ctx, member, depth + 1));
293
- }
294
- // Text and markup TypeScript kept apart are still one content slot.
295
- const content = contentOfDescribed(folded, text);
296
- if (content) return content;
297
- const union = { kind: 'union', members: folded };
298
- const discriminant = discriminantOf(ctx.checker, members);
299
- if (discriminant) union.discriminant = discriminant;
300
- return union;
301
- };
302
- if (named && members.some(isObjectLike)) {
303
- return reference(ctx, type, named, text, build);
304
- }
305
- return { ...build(), text };
306
- }
307
-
308
- function describeSingle(ctx, type, depth) {
309
- const { checker } = ctx;
310
- const text = printType(checker, type);
311
- const name = nameOf(type);
312
- if (name && CONTENT_ALIASES.has(name)) return { kind: 'content', text };
313
- if (name && SIGNAL_NAMES.has(name)) return { kind: 'signal', text };
314
- if (name && CSS_VALUE_ALIAS.test(name)) {
315
- return { kind: 'css-value', grammar: name, text };
316
- }
317
- const literal = literalOf(type);
318
- if (literal !== undefined) return { kind: 'literal', value: literal, text };
319
- // `NoInfer<T>` is a substitution type; describe what it wraps.
320
- if (type.flags & ts.TypeFlags.Substitution && type.baseType) {
321
- return { ...describeType(ctx, type.baseType, depth), text };
322
- }
323
- if (type.flags & ts.TypeFlags.TypeParameter) {
324
- const constraint = type.getConstraint();
325
- const described = constraint
326
- ? describeType(ctx, constraint, depth)
327
- : { kind: 'unknown' };
328
- return { ...described, typeParameter: type.getSymbol()?.getName(), text };
329
- }
330
- if (type.flags & ts.TypeFlags.StringLike) return { kind: 'string', text };
331
- if (type.flags & ts.TypeFlags.NumberLike) return { kind: 'number', text };
332
- if (type.flags & ts.TypeFlags.BooleanLike) return { kind: 'boolean', text };
333
- if (type.flags & ts.TypeFlags.Never) return { kind: 'never', text };
334
- if (type.getCallSignatures().length > 0) return { kind: 'function', text };
335
- if (checker.isArrayType(type) || checker.isTupleType(type)) {
336
- const [item] = checker.getTypeArguments(type);
337
- return {
338
- kind: 'array',
339
- items: item ? describeType(ctx, item, depth + 1) : { kind: 'unknown' },
340
- text,
341
- };
342
- }
343
- if (isObjectLike(type)) {
344
- if (/^(HTML\w*Element|Element|Node)$/.test(name ?? '')) {
345
- return { kind: 'element', text };
346
- }
347
- if (
348
- checker.getIndexInfosOfType(type).length > 0 &&
349
- checker.getPropertiesOfType(type).length === 0
350
- ) {
351
- return { kind: 'record', text };
352
- }
353
- const build = () => {
354
- const object = {
355
- kind: 'object',
356
- props: describeProps(ctx, type, depth + 1).props,
357
- };
358
- const index = indexOf(ctx, type, depth);
359
- if (index) object.index = index;
360
- return object;
361
- };
362
- if (name) return reference(ctx, type, name, text, build);
363
- if (depth >= MAX_INLINE_DEPTH) return { kind: 'object', text };
364
- return { ...build(), text };
365
- }
366
- return { kind: 'unknown', text };
367
- }
368
-
369
- /**
370
- * An object's string index signature (`Record<\`data-${string}\`, string>`
371
- * behind `rootAttributes`), as the key prefix it allows and its value type.
372
- * Returns undefined when the object has none.
373
- */
374
- function indexOf(ctx, type, depth) {
375
- const info = ctx.checker
376
- .getIndexInfosOfType(type)
377
- .find(
378
- (item) =>
379
- item.keyType.flags &
380
- (ts.TypeFlags.String | ts.TypeFlags.TemplateLiteral),
381
- );
382
- if (!info) return undefined;
383
- const prefix =
384
- info.keyType.flags & ts.TypeFlags.TemplateLiteral
385
- ? info.keyType.texts[0]
386
- : '';
387
- return { keyPrefix: prefix, value: describeType(ctx, info.type, depth + 1) };
388
- }
389
-
390
- /**
391
- * The props that distinguish union members: present in every member, each a
392
- * single literal, and not all equal. Returns their names, or undefined.
393
- */
394
- function discriminantOf(checker, members) {
395
- if (members.length < 2 || !members.every(isObjectLike)) return undefined;
396
- const names = checker
397
- .getPropertiesOfType(members[0])
398
- .map((symbol) => symbol.getName())
399
- .filter((name) => {
400
- const values = members.map((member) => {
401
- const property = member.getProperty(name);
402
- if (!property) return undefined;
403
- const typed = membersOf(checker.getTypeOfSymbol(property)).filter(
404
- (item) => !isNullish(item),
405
- );
406
- return typed.length === 1 ? literalOf(typed[0]) : undefined;
407
- });
408
- return (
409
- values.every((value) => value !== undefined) && new Set(values).size > 1
410
- );
411
- });
412
- return names.length > 0 ? names : undefined;
413
- }
414
-
415
- /** Literal values a type node spells out, in source order (aliases followed). */
416
- function declaredLiterals(checker, node, seen = new Set()) {
417
- if (!node || seen.has(node)) return [];
418
- seen.add(node);
419
- if (ts.isParenthesizedTypeNode(node)) {
420
- return declaredLiterals(checker, node.type, seen);
421
- }
422
- if (ts.isUnionTypeNode(node)) {
423
- return node.types.flatMap((item) => declaredLiterals(checker, item, seen));
424
- }
425
- if (ts.isTypeReferenceNode(node) && !node.typeArguments) {
426
- let target = checker.getSymbolAtLocation(node.typeName);
427
- if (target && target.getFlags() & ts.SymbolFlags.Alias) {
428
- target = checker.getAliasedSymbol(target);
429
- }
430
- const declaration = target?.declarations?.[0];
431
- return declaration && ts.isTypeAliasDeclaration(declaration)
432
- ? declaredLiterals(checker, declaration.type, seen)
433
- : [];
434
- }
435
- if (ts.isLiteralTypeNode(node)) {
436
- const { literal } = node;
437
- if (ts.isStringLiteral(literal)) return [literal.text];
438
- if (ts.isNumericLiteral(literal)) return [Number(literal.text)];
439
- if (literal.kind === ts.SyntaxKind.TrueKeyword) return [true];
440
- if (literal.kind === ts.SyntaxKind.FalseKeyword) return [false];
441
- }
442
- return [];
443
- }
444
-
445
- /**
446
- * TypeScript orders union members by internal type id, which shifts when
447
- * unrelated declarations change; source order is stable and is what an
448
- * inspector should show. Values the node does not spell out keep their place
449
- * after the declared ones.
450
- */
451
- function inDeclaredOrder(checker, values, node) {
452
- const order = declaredLiterals(checker, node);
453
- if (order.length === 0) return values;
454
- const rank = (value) => {
455
- const index = order.indexOf(value);
456
- return index === -1 ? order.length : index;
457
- };
458
- return [...values].sort((a, b) => rank(a) - rank(b));
459
- }
460
-
461
- const isOptional = (symbol) =>
462
- (symbol.getFlags() & ts.SymbolFlags.Optional) !== 0;
463
-
464
- /** Parses a JSDoc default from `@default`, "(default `x`)", or "`x` (default)". */
465
- export function parseDocumentedDefault(text, tagValue) {
466
- if (tagValue) return tagValue.replace(/^['"`]|['"`]$/g, '');
467
- if (!text) return undefined;
468
- const patterns = [
469
- /\(default:?\s+`([^`]+)`/i,
470
- /\bdefaults? (?:to|is) `([^`]+)`/i,
471
- /`([^`]+)`\s+\((?:the )?default\)/i,
472
- // A boolean's default often goes unquoted: "(default true)", "Defaults
473
- // to true.", "Default false." (KF-YNEMFD).
474
- /\bdefaults?(?:\s+(?:to|is))?:?\s+(true|false)\b/i,
475
- ];
476
- for (const pattern of patterns) {
477
- const match = pattern.exec(text);
478
- if (match) return match[1].replace(/^['"]|['"]$/g, '');
479
- }
480
- return undefined;
481
- }
482
-
483
- /** Coerces a documented default to the prop's type, or drops it. */
484
- export function coerceDefault(raw, descriptor) {
485
- if (raw === undefined) return undefined;
486
- switch (descriptor.kind) {
487
- case 'boolean':
488
- return raw === 'true' ? true : raw === 'false' ? false : undefined;
489
- case 'number': {
490
- const value = Number(raw);
491
- return raw.trim() !== '' && Number.isFinite(value) ? value : undefined;
492
- }
493
- case 'enum':
494
- return descriptor.values.find((value) => String(value) === raw);
495
- case 'string':
496
- return raw;
497
- default:
498
- return undefined;
499
- }
500
- }
501
-
502
- /** Documentation on the aliases a property's declared type names. */
503
- function declaredTypeDocs(checker, symbol) {
504
- const node = symbol.valueDeclaration ?? symbol.declarations?.[0];
505
- const typeNode = node && 'type' in node ? node.type : undefined;
506
- if (!typeNode) return [];
507
- const references = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode];
508
- return references
509
- .filter((item) => ts.isTypeReferenceNode(item))
510
- .map((item) => {
511
- let target = checker.getSymbolAtLocation(item.typeName);
512
- if (target && target.getFlags() & ts.SymbolFlags.Alias) {
513
- target = checker.getAliasedSymbol(target);
514
- }
515
- return documentation(checker, target);
516
- })
517
- .filter(Boolean);
518
- }
519
-
520
- function isNative(ctx, symbol) {
521
- const declarations = symbol.declarations ?? [];
522
- // A package's own declarations live under its directory, never in a
523
- // dependency's node_modules beneath it.
524
- const own = (fileName) =>
525
- fileName.startsWith(ctx.ownDirectory) &&
526
- !fileName.slice(ctx.ownDirectory.length).includes('node_modules/');
527
- return (
528
- declarations.length > 0 &&
529
- declarations.every((item) => !own(item.getSourceFile().fileName))
530
- );
531
- }
532
-
533
- function describeProperty(ctx, symbol, depth) {
534
- const { checker } = ctx;
535
- const type = checker.getTypeOfSymbol(symbol);
536
- const descriptor = describeType(ctx, type, depth);
537
- const description = documentation(checker, symbol);
538
- if (descriptor.kind === 'enum') {
539
- const node = symbol.valueDeclaration ?? symbol.declarations?.[0];
540
- if (node && 'type' in node && node.type) {
541
- descriptor.values = inDeclaredOrder(
542
- checker,
543
- descriptor.values,
544
- node.type,
545
- );
546
- }
547
- }
548
- const prop = {
549
- name: symbol.getName(),
550
- type: descriptor,
551
- required: !isOptional(symbol) && descriptor.kind !== 'never',
552
- };
553
- const documented =
554
- parseDocumentedDefault(description, jsDocTag(symbol, 'default')) ??
555
- declaredTypeDocs(checker, symbol)
556
- .map((doc) => parseDocumentedDefault(doc))
557
- .find((value) => value !== undefined);
558
- const fallback = coerceDefault(documented, descriptor);
559
- if (fallback !== undefined) prop.default = fallback;
560
- if (description) prop.description = description;
561
- if (jsDocTag(symbol, 'deprecated') !== undefined) prop.deprecated = true;
562
- // Lucide icon data is a nested array no document can spell as a literal;
563
- // marking it lets documents name the icon instead (`$icon`).
564
- if (ICON_DATA.test(descriptor.text ?? '')) prop.iconSource = 'lucide';
565
- return prop;
566
- }
567
-
568
- const ICON_DATA = /^(IconNode|LucideNode)( \| undefined)?$/;
569
-
570
- /** Splits an object type's properties into own props and native attributes. */
571
- function describeProps(ctx, type, depth) {
572
- const props = [];
573
- const nativeAttributes = [];
574
- for (const symbol of ctx.checker.getPropertiesOfType(type)) {
575
- if (isNative(ctx, symbol)) nativeAttributes.push(symbol.getName());
576
- else props.push(describeProperty(ctx, symbol, depth));
577
- }
578
- return { props, nativeAttributes };
579
- }
580
-
581
- function mergeMemberProps(memberProps, memberCount) {
582
- const byName = new Map();
583
- for (const props of memberProps) {
584
- for (const prop of props) {
585
- const seen = byName.get(prop.name);
586
- if (!seen) {
587
- byName.set(prop.name, {
588
- prop: { ...prop },
589
- present: 1,
590
- required: prop.required ? 1 : 0,
591
- types: [prop.type],
592
- });
593
- continue;
594
- }
595
- seen.present += 1;
596
- if (prop.required) seen.required += 1;
597
- if (!seen.types.some((item) => item.text === prop.type.text)) {
598
- seen.types.push(prop.type);
599
- }
600
- if (!seen.prop.description && prop.description) {
601
- seen.prop.description = prop.description;
602
- }
603
- if (seen.prop.default === undefined && prop.default !== undefined) {
604
- seen.prop.default = prop.default;
605
- }
606
- }
607
- }
608
- return [...byName.values()].map(({ prop, present, required, types }) => {
609
- const usable = types.filter((item) => item.kind !== 'never');
610
- let type = usable[0] ?? prop.type;
611
- const literals = usable.map((item) =>
612
- item.kind === 'literal' ? item.value : undefined,
613
- );
614
- // `boolean` beside `true` / `false` (Badge's `ariaHidden?: boolean` plus
615
- // the `false` / `true` of its labeled and hidden variants) is still one
616
- // boolean, so the editor offers a switch rather than a two-item select.
617
- if (
618
- usable.length > 1 &&
619
- usable.every(
620
- (item, index) =>
621
- item.kind === 'boolean' || typeof literals[index] === 'boolean',
622
- )
623
- ) {
624
- type = { kind: 'boolean', text: 'boolean' };
625
- } else if (
626
- usable.length > 1 &&
627
- literals.every((value) => value !== undefined)
628
- ) {
629
- type = {
630
- kind: 'enum',
631
- values: literals,
632
- text: usable.map((item) => item.text).join(' | '),
633
- };
634
- } else if (usable.length > 1) {
635
- const text = usable.map((item) => item.text).join(' | ');
636
- type = contentOfDescribed(usable, text) ?? {
637
- kind: 'union',
638
- members: usable,
639
- text,
640
- };
641
- }
642
- const merged = { ...prop, type, required: required === memberCount };
643
- if (present < memberCount || usable.length !== types.length) {
644
- merged.variantOnly = true;
645
- }
646
- return merged;
647
- });
648
- }
649
-
650
- /**
651
- * Projects a props type into `{ props, nativeAttributes, variants? }`. A
652
- * union props type (Button's labeled-or-icon-only content, ListHeader's
653
- * toggle mode) lists every prop once, marks the ones only some members allow
654
- * as `variantOnly`, and records each member's required and forbidden props
655
- * as a variant.
656
- */
657
- export function describePropsType(ctx, type) {
658
- const members = membersOf(type).filter((member) => !isNullish(member));
659
- if (members.length <= 1) {
660
- return members.length
661
- ? describeProps(ctx, members[0], 0)
662
- : { props: [], nativeAttributes: [] };
663
- }
664
- const described = members.map((member) => describeProps(ctx, member, 0));
665
- const props = mergeMemberProps(
666
- described.map((item) => item.props),
667
- members.length,
668
- );
669
- const nativeAttributes = [
670
- ...new Set(described.flatMap((item) => item.nativeAttributes)),
671
- ];
672
- const discriminant = discriminantOf(ctx.checker, members);
673
- const seen = new Set();
674
- const variants = [];
675
- for (const { props: list } of described) {
676
- const variant = {};
677
- if (discriminant) {
678
- variant.when = Object.fromEntries(
679
- discriminant.map((name) => [
680
- name,
681
- list.find((prop) => prop.name === name)?.type.value,
682
- ]),
683
- );
684
- }
685
- variant.required = list
686
- .filter((prop) => prop.required)
687
- .map((prop) => prop.name);
688
- variant.forbidden = list
689
- .filter((prop) => prop.type.kind === 'never')
690
- .map((prop) => prop.name);
691
- const key = JSON.stringify(variant);
692
- if (!seen.has(key)) {
693
- seen.add(key);
694
- variants.push(variant);
695
- }
696
- }
697
- if (variants.length < 2) return { props, nativeAttributes };
698
- return {
699
- props,
700
- nativeAttributes,
701
- variants,
702
- ...(discriminant ? { discriminant } : {}),
703
- };
704
- }
705
-
706
- function exportSymbol(checker, sourceFile, name) {
707
- const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
708
- if (!moduleSymbol) return undefined;
709
- const found = checker
710
- .getExportsOfModule(moduleSymbol)
711
- .find((symbol) => symbol.getName() === name);
712
- if (!found) return undefined;
713
- return found.getFlags() & ts.SymbolFlags.Alias
714
- ? checker.getAliasedSymbol(found)
715
- : found;
716
- }
717
-
718
- /**
719
- * How a component carries application `data-*` attributes to its root (the
720
- * Kerf UI editor's node marker and row keys): a `rootAttributes` prop, native
721
- * `data-*` passthrough (a `data-${string}` index signature on the props), or
722
- * none.
723
- */
724
- function dataChannelOf(checker, type, props) {
725
- if (props.some((prop) => prop.name === 'rootAttributes'))
726
- return 'rootAttributes';
727
- const members = type
728
- ? membersOf(type).filter((member) => !isNullish(member))
729
- : [];
730
- const native =
731
- members.length > 0 &&
732
- members.every((member) =>
733
- checker
734
- .getIndexInfosOfType(member)
735
- .some(
736
- (info) =>
737
- info.keyType.flags & ts.TypeFlags.TemplateLiteral &&
738
- info.keyType.texts[0] === 'data-',
739
- ),
740
- );
741
- return native ? 'native' : 'none';
742
- }
743
-
744
- /**
745
- * Reads one exported component function: its props (from the first
746
- * parameter), type parameters, and documentation. Returns undefined for an
747
- * export that is not a component (a type, a wiring helper, a non-SafeHtml
748
- * function).
749
- */
750
- export function readComponentExport(ctx, sourceFile, name) {
751
- const { checker } = ctx;
752
- if (!/^[A-Z]/.test(name)) return undefined;
753
- const symbol = exportSymbol(checker, sourceFile, name);
754
- if (!symbol || !(symbol.getFlags() & ts.SymbolFlags.Function))
755
- return undefined;
756
- const [signature] = checker.getTypeOfSymbol(symbol).getCallSignatures();
757
- if (!signature) return undefined;
758
- if (!/SafeHtml$/.test(checker.typeToString(signature.getReturnType()))) {
759
- return undefined;
760
- }
761
- const [parameter] = signature.getParameters();
762
- const result = parameter
763
- ? describePropsType(ctx, checker.getTypeOfSymbol(parameter))
764
- : { props: [], nativeAttributes: [] };
765
- result.dataChannel = dataChannelOf(
766
- checker,
767
- parameter && checker.getTypeOfSymbol(parameter),
768
- result.props,
769
- );
770
- const typeParameters = (signature.getTypeParameters() ?? []).map((item) => {
771
- const constraint = item.getConstraint();
772
- return {
773
- name: item.getSymbol()?.getName(),
774
- ...(constraint ? { constraint: printType(checker, constraint) } : {}),
775
- };
776
- });
777
- const description = documentation(checker, symbol);
778
- return {
779
- export: name,
780
- ...(description ? { description } : {}),
781
- ...(typeParameters.length ? { typeParameters } : {}),
782
- ...result,
783
- };
784
- }
785
-
786
- const QUOTED = /^(['"])(.*)\1$/;
787
-
788
- function customElementDefault(raw, type) {
789
- if (raw === undefined) return undefined;
790
- const quoted = QUOTED.exec(raw);
791
- let value;
792
- if (quoted) value = quoted[2];
793
- else if (raw === 'true' || raw === 'false') value = raw === 'true';
794
- else if (/^-?\d+(\.\d+)?$/.test(raw)) value = Number(raw);
795
- if (value === undefined || value === '') return undefined;
796
- if (type.kind === 'enum' && !type.values.includes(value)) return undefined;
797
- return value;
798
- }
799
-
800
- /** Projects a Web Awesome `custom-elements.json` declaration into props. */
801
- export function describeCustomElement(declaration) {
802
- const props = (declaration.attributes ?? []).map((attribute) => {
803
- const text = (attribute.type?.text ?? 'string')
804
- .replace(/\s+/g, ' ')
805
- .replace(/^\| /, '');
806
- const parts = text
807
- .split('|')
808
- .map((part) => part.trim())
809
- .filter((part) => part !== 'undefined' && part !== 'null');
810
- const quoted = parts.filter((part) => QUOTED.test(part));
811
- const values = quoted.map((part) => QUOTED.exec(part)[2]);
812
- let type;
813
- if (parts.length > 0 && quoted.length === parts.length) {
814
- type = { kind: 'enum', values, text };
815
- } else if (
816
- quoted.length > 0 &&
817
- quoted.length === parts.length - 1 &&
818
- parts.includes('string')
819
- ) {
820
- type = { kind: 'string', suggestions: values, text };
821
- } else if (
822
- parts.length === 1 &&
823
- ['string', 'number', 'boolean'].includes(parts[0])
824
- ) {
825
- type = { kind: parts[0], text };
826
- } else {
827
- type = { kind: 'unknown', text };
828
- }
829
- const prop = { name: attribute.name, type, required: false };
830
- if (attribute.fieldName && attribute.fieldName !== attribute.name) {
831
- prop.property = attribute.fieldName;
832
- }
833
- const fallback = customElementDefault(attribute.default, type);
834
- if (fallback !== undefined) prop.default = fallback;
835
- if (attribute.description) prop.description = attribute.description;
836
- if (attribute.deprecated) prop.deprecated = true;
837
- return prop;
838
- });
839
- const slots = (declaration.slots ?? []).map((slot) => ({
840
- name: slot.name === '' ? 'default' : slot.name,
841
- ...(slot.description ? { description: slot.description } : {}),
842
- }));
843
- return { props, slots };
844
- }
845
-
846
- const qualify = (pkg, id) => `${pkg}:${id}`;
847
-
848
- function dtsFor(root, browserImport, pkg) {
849
- return resolve(root, 'dist', `${browserImport.slice(pkg.length + 1)}.d.ts`);
850
- }
851
-
852
- /** Marks zone props (composition catalog) and css-value grammars (catalog). */
853
- export function applyCrossReferences(
854
- component,
855
- { zones = [], cssValueProps = [] },
856
- ) {
857
- const zoneByProp = new Map(
858
- zones.filter((zone) => zone.jsx?.prop).map((zone) => [zone.jsx.prop, zone]),
859
- );
860
- const cssByPath = new Map(cssValueProps.map((item) => [item.path, item]));
861
- for (const prop of component.props) {
862
- const zone = zoneByProp.get(prop.name);
863
- if (zone) prop.zone = zone.id;
864
- const css = cssByPath.get(prop.name);
865
- if (css) {
866
- prop.cssValue = {
867
- grammar: css.grammar,
868
- helpers: css.helpers,
869
- rawPolicy: css.rawPolicy,
870
- };
871
- }
872
- // Content with no curated zone is still a slot an editor can fill.
873
- if (!prop.zone && prop.type.kind === 'content') prop.slot = true;
874
- }
875
- }
876
-
877
- // Plumbing props an inspector never shows by default: inner styling hooks,
878
- // slot placement, and attribute bags the editor owns (the node marker). The
879
- // overlay can still give any of them a visible control.
880
- const HIDDEN_PROP = /^(\w+ClassName|slot|rootAttributes|triggerAttributes)$/;
881
- // A component's own class list is an advanced field, not a main prop
882
- // (KF-X8X8VX: an author sets `className`, such as an appearance scope).
883
- const CLASSES_PROP = /^(class|className)$/;
884
-
885
- /** Generated inspector defaults, applied before the curated overlay. */
886
- export function applyControlDefaults(component) {
887
- for (const prop of component.props) {
888
- if (HIDDEN_PROP.test(prop.name)) prop.control = 'hidden';
889
- else if (CLASSES_PROP.test(prop.name)) prop.control = 'classes';
890
- }
891
- }
892
-
893
- /** Merges curated overlay fields; unknown component or prop keys are problems. */
894
- export function applyOverlay(component, overlay, problems) {
895
- const curated = overlay?.components?.[component.key];
896
- if (!curated) return;
897
- for (const [name, fields] of Object.entries(curated.props ?? {})) {
898
- const prop = component.props.find((item) => item.name === name);
899
- if (prop) Object.assign(prop, fields);
900
- else
901
- problems.push(`${component.key}: overlay names unknown prop "${name}"`);
902
- }
903
- // KF-H1X3S7: a value's options list names a sibling list prop.
904
- for (const prop of component.props) {
905
- if (
906
- prop.choicesFrom !== undefined &&
907
- !component.props.some((item) => item.name === prop.choicesFrom)
908
- )
909
- problems.push(
910
- `${component.key}: prop "${prop.name}" takes choices from unknown prop "${prop.choicesFrom}"`,
911
- );
912
- }
913
- if (curated.groups) component.groups = curated.groups;
914
- for (const [name, fields] of Object.entries(curated.props ?? {})) {
915
- if (fields.group && !curated.groups?.includes(fields.group)) {
916
- problems.push(
917
- `${component.key}: prop "${name}" names undeclared group "${fields.group}"`,
918
- );
919
- }
920
- }
921
- }
922
-
923
- /**
924
- * Reads the components a set of catalog entries declare. Each spec names an
925
- * entry's id and display name, the declaration file and import specifier of
926
- * its public module, its export names, and its zones and css-value props.
927
- */
928
- function readComponentEntries(ctx, program, pkg, specs, source, problems) {
929
- const components = [];
930
- for (const spec of specs) {
931
- const sourceFile = spec.file && program.getSourceFile(spec.file);
932
- if (!sourceFile) {
933
- problems.push(
934
- `${spec.id}: no declarations for ${spec.import ?? '(no import)'}`,
935
- );
936
- continue;
937
- }
938
- const found = spec.exports
939
- .map((name) => readComponentExport(ctx, sourceFile, name))
940
- .filter(Boolean);
941
- // An entry of imperative helpers only (openAnchoredSurface) has no
942
- // component; an entry whose uppercase exports all fail to resolve does.
943
- if (found.length === 0) {
944
- if (
945
- spec.exports.some(
946
- (name) =>
947
- /^[A-Z]/.test(name) &&
948
- exportSymbol(ctx.checker, sourceFile, name)?.getFlags() &
949
- ts.SymbolFlags.Function,
950
- )
951
- ) {
952
- problems.push(
953
- `${spec.id}: no SafeHtml component among ${spec.exports.join(', ')}`,
954
- );
955
- }
956
- continue;
957
- }
958
- const primary = found.find((item) => item.export === spec.name) ?? found[0];
959
- for (const item of found) {
960
- const isPrimary = item === primary;
961
- const component = {
962
- key: isPrimary
963
- ? qualify(pkg, spec.id)
964
- : `${qualify(pkg, spec.id)}#${item.export}`,
965
- id: spec.id,
966
- source,
967
- import: spec.import,
968
- ...item,
969
- };
970
- applyCrossReferences(component, {
971
- zones: isPrimary ? spec.zones : [],
972
- cssValueProps: isPrimary ? spec.cssValueProps : [],
973
- });
974
- components.push(component);
975
- }
976
- }
977
- return components;
978
- }
979
-
980
- function readKerfEntries(ctx, program, root, catalog, composition, problems) {
981
- const pkg = catalog.package;
982
- const zones = new Map(
983
- (composition.entries ?? []).map((entry) => [entry.id, entry.zones ?? []]),
984
- );
985
- const specs = catalog.entries
986
- .filter((entry) => entry.source === 'kerf' && entry.kind === 'component')
987
- .map((entry) => {
988
- const browserImport = entry.delivery?.browserImport;
989
- return {
990
- id: entry.id,
991
- name: entry.name,
992
- import: browserImport,
993
- file: browserImport && dtsFor(root, browserImport, pkg),
994
- exports: entry.publicExports ?? [],
995
- zones: zones.get(entry.id) ?? [],
996
- cssValueProps: entry.cssValueProps ?? [],
997
- };
998
- });
999
- return readComponentEntries(ctx, program, pkg, specs, 'kerf', problems);
1000
- }
1001
-
1002
- function readWebAwesomeEntries(catalog, customElements, problems) {
1003
- const declarations = new Map(
1004
- (customElements?.modules ?? [])
1005
- .flatMap((module) => module.declarations ?? [])
1006
- .filter((declaration) => declaration.tagName)
1007
- .map((declaration) => [declaration.tagName, declaration]),
1008
- );
1009
- const components = [];
1010
- for (const entry of catalog.entries) {
1011
- if (entry.source !== 'webawesome') continue;
1012
- const declaration = declarations.get(entry.id);
1013
- if (!declaration) {
1014
- problems.push(`${entry.id}: not in Web Awesome custom-elements.json`);
1015
- continue;
1016
- }
1017
- components.push({
1018
- key: qualify(catalog.package, entry.id),
1019
- id: entry.id,
1020
- source: 'webawesome',
1021
- tagName: entry.id,
1022
- import: entry.delivery?.registrationImport,
1023
- ...describeCustomElement(declaration),
1024
- });
1025
- }
1026
- return components;
1027
- }
1028
-
1029
- /**
1030
- * Builds the component-props document from the catalog, composition catalog,
1031
- * curated overlay, built declarations under `<root>/dist`, and Web Awesome's
1032
- * manifest. Returns `{ document, problems }`; the sync script fails on any
1033
- * problem (an unresolved component, an overlay key that names nothing).
1034
- */
1035
- export function buildComponentProps({
1036
- root,
1037
- catalog,
1038
- composition,
1039
- overlay,
1040
- customElements,
1041
- }) {
1042
- const problems = [];
1043
- const pkg = catalog.package;
1044
- const files = catalog.entries
1045
- .filter((entry) => entry.source === 'kerf' && entry.delivery?.browserImport)
1046
- .map((entry) => dtsFor(root, entry.delivery.browserImport, pkg));
1047
- const program = createDeclarationProgram([...new Set(files)]);
1048
- const ctx = createPropsContext(
1049
- program.getTypeChecker(),
1050
- resolve(root, 'dist'),
1051
- );
1052
- const components = [
1053
- ...readKerfEntries(ctx, program, root, catalog, composition, problems),
1054
- ...readWebAwesomeEntries(catalog, customElements, problems),
1055
- ];
1056
- for (const component of components) {
1057
- applyControlDefaults(component);
1058
- applyOverlay(component, overlay, problems);
1059
- }
1060
- const known = new Set(components.map((component) => component.key));
1061
- for (const key of Object.keys(overlay?.components ?? {})) {
1062
- if (!known.has(key))
1063
- problems.push(`overlay names unknown component "${key}"`);
1064
- }
1065
- const byKey = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
1066
- components.sort((a, b) => byKey(a.key, b.key));
1067
- const definitions = Object.fromEntries(
1068
- [...ctx.definitions.entries()].sort(([a], [b]) => byKey(a, b)),
1069
- );
1070
- return {
1071
- document: {
1072
- $schema: './component-props.schema.json',
1073
- schema: COMPONENT_PROPS_SCHEMA_ID,
1074
- package: pkg,
1075
- description:
1076
- 'Generated per-component prop schema for Kerf UI: each public component function and Web Awesome element with its props (type grammar, required, default, enum values, zones and slots, discriminated variants, css-value grammars). Regenerate with `npm run props:sync`; do not edit.',
1077
- components,
1078
- definitions,
1079
- },
1080
- problems,
1081
- };
1082
- }
1083
-
1084
- /** The declaration file a package export condition points to. */
1085
- function declarationsFor(root, target) {
1086
- const path =
1087
- typeof target === 'string'
1088
- ? target.replace(/\.(m?)js$/, '.d.$1ts')
1089
- : (target?.types ??
1090
- (target?.import ? declarationsFor(root, target.import) : undefined));
1091
- return path ? resolve(root, path) : undefined;
1092
- }
1093
-
1094
- /**
1095
- * Builds a component package's `component-props.json` (KF-B8TGP4: component
1096
- * packages ship the same prop schema as @kerfjs/ui). Components and zones come
1097
- * from the package's composition catalog (`package.json#kerfComponentCatalog
1098
- * .output`, written by create-kerf-component); each component's declarations
1099
- * come from the `types` of the package export its `publicExports` name (a
1100
- * named subpath before `.`). Run after the package's build. Returns
1101
- * `{ document, problems }`.
1102
- */
1103
- export function buildPackageComponentProps({
1104
- root,
1105
- packageJson,
1106
- composition,
1107
- overlay,
1108
- }) {
1109
- const problems = [];
1110
- const pkg = packageJson.name;
1111
- const exportMap =
1112
- typeof packageJson.exports === 'string' || packageJson.exports?.types
1113
- ? { '.': packageJson.exports }
1114
- : (packageJson.exports ?? {});
1115
- const specs = [];
1116
- let usesSource = false;
1117
- for (const entry of composition.entries ?? []) {
1118
- if (entry.kind !== 'component' || (entry.package && entry.package !== pkg))
1119
- continue;
1120
- const exported = (entry.publicExports ?? []).map((item) =>
1121
- typeof item === 'string' ? { name: item, subpath: '.' } : item,
1122
- );
1123
- const subpaths = [...new Set(exported.map((item) => item.subpath ?? '.'))];
1124
- const subpath = subpaths.find((item) => item !== '.') ?? subpaths[0] ?? '.';
1125
- const declarations = declarationsFor(root, exportMap[subpath]);
1126
- // A component that lives in app source has no package export: read its
1127
- // source file and import it by a root-relative path, which view tools
1128
- // rewrite relative to each document (KF-7JP509: app-source catalogs).
1129
- const source =
1130
- entry.source && existsSync(resolve(root, entry.source))
1131
- ? resolve(root, entry.source)
1132
- : undefined;
1133
- const fromSource = !(declarations && existsSync(declarations)) && source;
1134
- const file = fromSource ? source : declarations;
1135
- if (fromSource) usesSource = true;
1136
- specs.push({
1137
- id: entry.id,
1138
- name: entry.name,
1139
- import: fromSource
1140
- ? sourceImport(root, source)
1141
- : subpath === '.'
1142
- ? pkg
1143
- : `${pkg}${subpath.slice(1)}`,
1144
- file: file && existsSync(file) ? file : undefined,
1145
- exports: [
1146
- ...new Set(
1147
- exported
1148
- .filter((item) => (item.subpath ?? '.') === subpath)
1149
- .map((item) => item.name),
1150
- ),
1151
- ],
1152
- zones: entry.zones ?? [],
1153
- cssValueProps: entry.cssValueProps ?? [],
1154
- });
1155
- }
1156
- const program = createDeclarationProgram(
1157
- [...new Set(specs.map((spec) => spec.file).filter(Boolean))],
1158
- usesSource ? packageCompilerOptions(root) : {},
1159
- );
1160
- const ctx = createPropsContext(program.getTypeChecker(), root);
1161
- const components = readComponentEntries(
1162
- ctx,
1163
- program,
1164
- pkg,
1165
- specs,
1166
- 'package',
1167
- problems,
1168
- );
1169
- for (const component of components) {
1170
- applyControlDefaults(component);
1171
- applyOverlay(component, overlay, problems);
1172
- }
1173
- const known = new Set(components.map((component) => component.key));
1174
- for (const key of Object.keys(overlay?.components ?? {})) {
1175
- if (!known.has(key))
1176
- problems.push(`overlay names unknown component "${key}"`);
1177
- }
1178
- const byKey = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
1179
- components.sort((a, b) => byKey(a.key, b.key));
1180
- return {
1181
- document: {
1182
- $schema:
1183
- 'https://raw.githubusercontent.com/brianwestphal/kerf/main/ui/ai/component-props.schema.json',
1184
- schema: COMPONENT_PROPS_SCHEMA_ID,
1185
- package: pkg,
1186
- description: `Generated prop schema for ${pkg}'s Kerf components. Regenerate with \`kerf-ui-props --write\` after a build; do not edit.`,
1187
- components,
1188
- definitions: Object.fromEntries(
1189
- [...ctx.definitions.entries()].sort(([a], [b]) => byKey(a, b)),
1190
- ),
1191
- },
1192
- problems,
1193
- };
1194
- }
1195
-
1196
- /** Reads the JSON inputs relative to the ui package root. */
1197
- export function readComponentPropsInputs(root) {
1198
- const json = (path) => JSON.parse(readFileSync(resolve(root, path), 'utf8'));
1199
- return {
1200
- root,
1201
- catalog: json('ai/component-catalog.json'),
1202
- composition: json('ai/component-composition.json'),
1203
- overlay: json('ai/component-props-overlay.json'),
1204
- customElements: json(
1205
- 'node_modules/@awesome.me/webawesome/dist/custom-elements.json',
1206
- ),
1207
- };
1208
- }