@kerfjs/ui 5.0.0-beta.123 → 5.0.0-beta.124

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 (721) hide show
  1. package/README.md +28 -5
  2. package/ai/application-ui-diagnostic-ids-v1.json +25 -1
  3. package/ai/application-ui-profile-sync.cjs +16 -8
  4. package/ai/application-ui-profile.d.ts +2 -0
  5. package/ai/application-ui-profile.defaults.json +6 -2
  6. package/ai/application-ui-profile.mjs +16 -8
  7. package/ai/application-ui-profile.schema.json +133 -38
  8. package/ai/component-catalog.json +1499 -213
  9. package/ai/component-catalog.schema.json +19 -0
  10. package/ai/component-composition-rules.json +18 -2
  11. package/ai/component-composition.d.ts +13 -0
  12. package/ai/component-composition.json +684 -25
  13. package/ai/component-composition.schema.json +58 -0
  14. package/ai/component-props-overlay.json +952 -0
  15. package/ai/component-props-overlay.schema.json +68 -0
  16. package/ai/component-props.json +29624 -0
  17. package/ai/component-props.schema.json +401 -0
  18. package/ai/components/README.md +11 -4
  19. package/ai/components/application-tabs.md +2 -2
  20. package/ai/components/backdrop-image.md +2 -1
  21. package/ai/components/button.md +12 -6
  22. package/ai/components/checkbox-group.md +2 -0
  23. package/ai/components/checkbox.md +2 -0
  24. package/ai/components/chip.md +2 -0
  25. package/ai/components/choice-chips.md +5 -1
  26. package/ai/components/color-field.md +2 -0
  27. package/ai/components/color-picker.md +2 -0
  28. package/ai/components/color-swatches.md +2 -0
  29. package/ai/components/column-explorer.md +89 -0
  30. package/ai/components/column-track.md +3 -2
  31. package/ai/components/combobox.md +2 -0
  32. package/ai/components/content-item.md +7 -2
  33. package/ai/components/disclosure.md +2 -0
  34. package/ai/components/file-picker.md +5 -2
  35. package/ai/components/form.md +86 -0
  36. package/ai/components/foundation.md +1 -1
  37. package/ai/components/list-action-row.md +2 -0
  38. package/ai/components/list-detail-dialog.md +2 -0
  39. package/ai/components/list-header.md +2 -0
  40. package/ai/components/list-item.md +4 -0
  41. package/ai/components/list.md +6 -2
  42. package/ai/components/message-composer.md +3 -1
  43. package/ai/components/nav-stack.md +2 -0
  44. package/ai/components/paged-view.md +89 -0
  45. package/ai/components/pane.md +4 -1
  46. package/ai/components/popup-menu.md +5 -2
  47. package/ai/components/radio-group.md +2 -0
  48. package/ai/components/recipe-composer-form.md +2 -2
  49. package/ai/components/scroll-effect.md +84 -0
  50. package/ai/components/search-field.md +2 -0
  51. package/ai/components/segmented-control.md +2 -0
  52. package/ai/components/select.md +4 -0
  53. package/ai/components/sized-region.md +86 -0
  54. package/ai/components/slider.md +2 -0
  55. package/ai/components/split-button.md +3 -1
  56. package/ai/components/split-view.md +1 -1
  57. package/ai/components/state-banner.md +2 -0
  58. package/ai/components/summary-row.md +14 -8
  59. package/ai/components/surface-scaffold.md +5 -3
  60. package/ai/components/switch.md +2 -0
  61. package/ai/components/tab-bar.md +5 -2
  62. package/ai/components/tab-navigator.md +2 -0
  63. package/ai/components/tab-panel.md +84 -0
  64. package/ai/components/tabs.md +6 -2
  65. package/ai/components/tag-field.md +2 -0
  66. package/ai/components/text-field.md +2 -0
  67. package/ai/components/text.md +3 -0
  68. package/ai/components/toolbar-control-group.md +10 -3
  69. package/ai/components/toolbar-text.md +2 -0
  70. package/ai/components/toolbar.md +4 -3
  71. package/ai/components/tree-list.md +95 -0
  72. package/ai/components/wa-accordion-item.md +2 -0
  73. package/ai/components/wa-breadcrumb-item.md +2 -0
  74. package/ai/components/wa-button.md +2 -0
  75. package/ai/components/wa-carousel.md +2 -0
  76. package/ai/components/wa-checkbox.md +2 -0
  77. package/ai/components/wa-color-picker.md +2 -0
  78. package/ai/components/wa-comparison.md +2 -0
  79. package/ai/components/wa-copy-button.md +2 -0
  80. package/ai/components/wa-details.md +2 -0
  81. package/ai/components/wa-dialog.md +2 -0
  82. package/ai/components/wa-drawer.md +2 -0
  83. package/ai/components/wa-dropdown-item.md +2 -0
  84. package/ai/components/wa-input.md +2 -0
  85. package/ai/components/wa-known-date.md +2 -0
  86. package/ai/components/wa-number-input.md +2 -0
  87. package/ai/components/wa-otp-input.md +2 -0
  88. package/ai/components/wa-pagination.md +2 -0
  89. package/ai/components/wa-radio.md +2 -0
  90. package/ai/components/wa-rating.md +2 -0
  91. package/ai/components/wa-select.md +2 -0
  92. package/ai/components/wa-slider.md +2 -0
  93. package/ai/components/wa-switch.md +2 -0
  94. package/ai/components/wa-tab-panel.md +5 -5
  95. package/ai/components/wa-tab.md +2 -0
  96. package/ai/components/wa-tag-input.md +2 -0
  97. package/ai/components/wa-textarea.md +2 -0
  98. package/ai/components/wa-time-input.md +2 -0
  99. package/ai/components/wa-tree-item.md +12 -5
  100. package/ai/components/wa-tree.md +10 -5
  101. package/ai/components/wa-zoomable-frame.md +2 -0
  102. package/ai/components/workbench-dialog.md +2 -0
  103. package/ai/public-api-signatures-v1.md +1249 -127
  104. package/ai/skill.md +106 -39
  105. package/ai/view-document.schema.json +360 -0
  106. package/ai/webawesome-jsx-signatures-v1.md +1 -1
  107. package/analyzer/index.mjs +89 -1
  108. package/dist/anchor-name-BZ1rpxaw.d.ts +4 -0
  109. package/dist/backdrop-image.d.ts +6 -2
  110. package/dist/backdrop-image.js +2 -1
  111. package/dist/badge.js +1 -1
  112. package/dist/browser/backdrop-image.js +1 -0
  113. package/dist/browser/catalog.js +1 -1
  114. package/dist/browser/collapsible-panel.js +1 -0
  115. package/dist/browser/column-explorer.js +9 -0
  116. package/dist/browser/content-item.js +1 -0
  117. package/dist/browser/editor.js +45 -0
  118. package/dist/browser/form.js +3 -0
  119. package/dist/browser/list-detail-dialog.js +1 -0
  120. package/dist/browser/nav-stack.js +1 -0
  121. package/dist/browser/paged-view.js +3 -0
  122. package/dist/browser/scroll-effect.js +3 -0
  123. package/dist/browser/sized-region.js +3 -0
  124. package/dist/browser/split-view.js +1 -0
  125. package/dist/browser/tab-panel.js +3 -0
  126. package/dist/browser/toolbar-control-group.js +1 -0
  127. package/dist/browser/tree-list.js +7 -0
  128. package/dist/browser/workbench-dialog.js +1 -0
  129. package/dist/browser/workbench.js +1 -0
  130. package/dist/button.d.ts +54 -13
  131. package/dist/button.js +2 -1
  132. package/dist/catalog-resources.d.ts +3 -2
  133. package/dist/catalog.d.ts +3 -2
  134. package/dist/catalog.js +21 -17
  135. package/dist/catalog.js.map +1 -1
  136. package/dist/checkbox-group.js +1 -1
  137. package/dist/checkbox.js +1 -1
  138. package/dist/chip.js +1 -1
  139. package/dist/choice-chips.d.ts +21 -2
  140. package/dist/choice-chips.js +2 -1
  141. package/dist/{chunk-3WWX2O4G.js → chunk-2E7S5C4D.js} +5 -46
  142. package/dist/chunk-2E7S5C4D.js.map +1 -0
  143. package/dist/{chunk-QYMJHS4K.js → chunk-34FWYJX6.js} +9 -3
  144. package/dist/chunk-34FWYJX6.js.map +1 -0
  145. package/dist/{chunk-OUCHU7JB.js → chunk-3JOEJT2Z.js} +7 -7
  146. package/dist/{chunk-OUCHU7JB.js.map → chunk-3JOEJT2Z.js.map} +1 -1
  147. package/dist/chunk-3S3WXAZ5.js +207 -0
  148. package/dist/chunk-3S3WXAZ5.js.map +1 -0
  149. package/dist/{chunk-AN5IWMTM.js → chunk-3TBMGGTA.js} +6 -3
  150. package/dist/chunk-3TBMGGTA.js.map +1 -0
  151. package/dist/{chunk-3Z7N2NAZ.js → chunk-3XSY5LAB.js} +4 -4
  152. package/dist/{chunk-3Z7N2NAZ.js.map → chunk-3XSY5LAB.js.map} +1 -1
  153. package/dist/chunk-44AOBT2F.js +16 -0
  154. package/dist/chunk-44AOBT2F.js.map +1 -0
  155. package/dist/{chunk-YWLDLNAV.js → chunk-4IXG6XCT.js} +18 -3
  156. package/dist/chunk-4IXG6XCT.js.map +1 -0
  157. package/dist/chunk-4K7XXSOX.js +21 -0
  158. package/dist/chunk-4K7XXSOX.js.map +1 -0
  159. package/dist/{chunk-LZUUUHNH.js → chunk-4Z4QSTRF.js} +20 -3
  160. package/dist/chunk-4Z4QSTRF.js.map +1 -0
  161. package/dist/{chunk-QH5KOFNS.js → chunk-5KWXM5O7.js} +15 -3
  162. package/dist/chunk-5KWXM5O7.js.map +1 -0
  163. package/dist/{chunk-EYDXFOSH.js → chunk-5SFHBYEY.js} +2 -2
  164. package/dist/chunk-5SFHBYEY.js.map +1 -0
  165. package/dist/{chunk-HU5IHXCI.js → chunk-6BXPN5SC.js} +3 -3
  166. package/dist/{chunk-HU5IHXCI.js.map → chunk-6BXPN5SC.js.map} +1 -1
  167. package/dist/{chunk-6VVIW7VB.js → chunk-73LC3JAL.js} +13 -4
  168. package/dist/chunk-73LC3JAL.js.map +1 -0
  169. package/dist/{chunk-IO27YTL3.js → chunk-76VCWWUA.js} +2 -2
  170. package/dist/{chunk-IO27YTL3.js.map → chunk-76VCWWUA.js.map} +1 -1
  171. package/dist/{chunk-ETFP7HAR.js → chunk-7AUZG5EW.js} +13 -4
  172. package/dist/chunk-7AUZG5EW.js.map +1 -0
  173. package/dist/{chunk-3V4OCDTL.js → chunk-7DIWVGGA.js} +2 -14
  174. package/dist/chunk-7DIWVGGA.js.map +1 -0
  175. package/dist/chunk-7KN5OQVN.js +157 -0
  176. package/dist/chunk-7KN5OQVN.js.map +1 -0
  177. package/dist/chunk-7QQ3HE47.js +17 -0
  178. package/dist/chunk-7QQ3HE47.js.map +1 -0
  179. package/dist/{chunk-WPP5Q4A5.js → chunk-ADMWT7FX.js} +19 -1
  180. package/dist/chunk-ADMWT7FX.js.map +1 -0
  181. package/dist/{chunk-LMHN2TJL.js → chunk-BCHK33XL.js} +2 -2
  182. package/dist/{chunk-LMHN2TJL.js.map → chunk-BCHK33XL.js.map} +1 -1
  183. package/dist/chunk-BCO673YW.js +123 -0
  184. package/dist/chunk-BCO673YW.js.map +1 -0
  185. package/dist/{chunk-OQP3PFKQ.js → chunk-BZXA5SSA.js} +90 -33
  186. package/dist/chunk-BZXA5SSA.js.map +1 -0
  187. package/dist/{chunk-LTBVP6VN.js → chunk-C4FBYP2D.js} +2 -2
  188. package/dist/{chunk-LTBVP6VN.js.map → chunk-C4FBYP2D.js.map} +1 -1
  189. package/dist/{chunk-AMIHGFLP.js → chunk-CCPWJDRW.js} +4 -2
  190. package/dist/chunk-CCPWJDRW.js.map +1 -0
  191. package/dist/{chunk-S4Y3YTAI.js → chunk-CJAKN2KZ.js} +2 -2
  192. package/dist/{chunk-S4Y3YTAI.js.map → chunk-CJAKN2KZ.js.map} +1 -1
  193. package/dist/chunk-CKPI4WIN.js +58 -0
  194. package/dist/chunk-CKPI4WIN.js.map +1 -0
  195. package/dist/{chunk-HJXVVFBT.js → chunk-CMG4OZPV.js} +13 -2
  196. package/dist/chunk-CMG4OZPV.js.map +1 -0
  197. package/dist/{chunk-KH4KEMSP.js → chunk-COQI4OMZ.js} +1 -1
  198. package/dist/chunk-COQI4OMZ.js.map +1 -0
  199. package/dist/{chunk-G3J7JDP6.js → chunk-CPTQABDQ.js} +10 -3
  200. package/dist/chunk-CPTQABDQ.js.map +1 -0
  201. package/dist/{chunk-TI2GV36S.js → chunk-CRHKWHTA.js} +4 -4
  202. package/dist/{chunk-TI2GV36S.js.map → chunk-CRHKWHTA.js.map} +1 -1
  203. package/dist/{chunk-3KFMLOTH.js → chunk-DBP3N6E5.js} +8 -5
  204. package/dist/chunk-DBP3N6E5.js.map +1 -0
  205. package/dist/chunk-DJ65XFVN.js +231 -0
  206. package/dist/chunk-DJ65XFVN.js.map +1 -0
  207. package/dist/chunk-DKPYHVIV.js +13 -0
  208. package/dist/chunk-DKPYHVIV.js.map +1 -0
  209. package/dist/{chunk-ITUQC4FW.js → chunk-DV6GE57V.js} +31 -3
  210. package/dist/chunk-DV6GE57V.js.map +1 -0
  211. package/dist/{chunk-S3ECMF23.js → chunk-E7Q6UNCB.js} +11 -3
  212. package/dist/chunk-E7Q6UNCB.js.map +1 -0
  213. package/dist/{chunk-C26Q6P4Q.js → chunk-E7ZRBMVQ.js} +3 -3
  214. package/dist/{chunk-C26Q6P4Q.js.map → chunk-E7ZRBMVQ.js.map} +1 -1
  215. package/dist/chunk-ECVTRAXN.js +37 -0
  216. package/dist/chunk-ECVTRAXN.js.map +1 -0
  217. package/dist/{chunk-EIET4QLK.js → chunk-EHR7R7YP.js} +14 -3
  218. package/dist/chunk-EHR7R7YP.js.map +1 -0
  219. package/dist/{chunk-5J6Z4BWY.js → chunk-EXGDKG7B.js} +127 -5
  220. package/dist/chunk-EXGDKG7B.js.map +1 -0
  221. package/dist/{chunk-7K6U6FCN.js → chunk-F34LHBQI.js} +47 -12
  222. package/dist/chunk-F34LHBQI.js.map +1 -0
  223. package/dist/{chunk-IIQ2XIMU.js → chunk-F3PZGFEA.js} +32 -11
  224. package/dist/chunk-F3PZGFEA.js.map +1 -0
  225. package/dist/{chunk-3OP66VXU.js → chunk-FJMABKKV.js} +5 -3
  226. package/dist/chunk-FJMABKKV.js.map +1 -0
  227. package/dist/{chunk-B53PS2LE.js → chunk-FNJA4S6J.js} +7 -3
  228. package/dist/chunk-FNJA4S6J.js.map +1 -0
  229. package/dist/{chunk-YMUIQRWK.js → chunk-FQETQ7CM.js} +6 -2
  230. package/dist/chunk-FQETQ7CM.js.map +1 -0
  231. package/dist/{chunk-KCS6NJ3O.js → chunk-FR5G77K5.js} +2 -2
  232. package/dist/{chunk-KCS6NJ3O.js.map → chunk-FR5G77K5.js.map} +1 -1
  233. package/dist/chunk-GVII4JSD.js +153 -0
  234. package/dist/chunk-GVII4JSD.js.map +1 -0
  235. package/dist/chunk-HPOXLOVC.js +184 -0
  236. package/dist/chunk-HPOXLOVC.js.map +1 -0
  237. package/dist/{chunk-EKHDLBRP.js → chunk-JAC6AVZN.js} +21 -3
  238. package/dist/chunk-JAC6AVZN.js.map +1 -0
  239. package/dist/{chunk-CTQUDCY5.js → chunk-JG4ONAOI.js} +4 -2
  240. package/dist/{chunk-CTQUDCY5.js.map → chunk-JG4ONAOI.js.map} +1 -1
  241. package/dist/{chunk-K67XBCHG.js → chunk-JHUEYWWI.js} +6 -4
  242. package/dist/chunk-JHUEYWWI.js.map +1 -0
  243. package/dist/{chunk-GS2QD3N7.js → chunk-JZZVWTUB.js} +2 -2
  244. package/dist/{chunk-GS2QD3N7.js.map → chunk-JZZVWTUB.js.map} +1 -1
  245. package/dist/{chunk-XRZSK2WC.js → chunk-KACJOE2N.js} +16 -5
  246. package/dist/chunk-KACJOE2N.js.map +1 -0
  247. package/dist/chunk-KELWWCMX.js +426 -0
  248. package/dist/chunk-KELWWCMX.js.map +1 -0
  249. package/dist/{chunk-KDQZ3E5C.js → chunk-KLR3DCHH.js} +58 -4
  250. package/dist/chunk-KLR3DCHH.js.map +1 -0
  251. package/dist/{chunk-S3DCRI2M.js → chunk-LD6A6PYB.js} +43 -5
  252. package/dist/chunk-LD6A6PYB.js.map +1 -0
  253. package/dist/{chunk-BKUMG2KB.js → chunk-LET362AM.js} +13 -3
  254. package/dist/chunk-LET362AM.js.map +1 -0
  255. package/dist/{chunk-C2ZO3OZZ.js → chunk-LOW7J7SE.js} +4 -4
  256. package/dist/chunk-LOW7J7SE.js.map +1 -0
  257. package/dist/{chunk-ITENVZ6Q.js → chunk-M72QLDUO.js} +13 -4
  258. package/dist/chunk-M72QLDUO.js.map +1 -0
  259. package/dist/{chunk-OHPYT2BH.js → chunk-MLDO7WLA.js} +2 -2
  260. package/dist/{chunk-OHPYT2BH.js.map → chunk-MLDO7WLA.js.map} +1 -1
  261. package/dist/{chunk-D5RGM3XA.js → chunk-NA4LKVPX.js} +12 -2
  262. package/dist/chunk-NA4LKVPX.js.map +1 -0
  263. package/dist/chunk-NR3ZO4LK.js +67 -0
  264. package/dist/chunk-NR3ZO4LK.js.map +1 -0
  265. package/dist/{chunk-YPAQFBMN.js → chunk-NYNNNEAU.js} +44 -10
  266. package/dist/chunk-NYNNNEAU.js.map +1 -0
  267. package/dist/chunk-OKZTLRGG.js +34 -0
  268. package/dist/chunk-OKZTLRGG.js.map +1 -0
  269. package/dist/{chunk-ZX2QQJXD.js → chunk-PVKAIVKE.js} +95 -61
  270. package/dist/chunk-PVKAIVKE.js.map +1 -0
  271. package/dist/{chunk-Y6KT7ZTR.js → chunk-Q2CLQ3IJ.js} +21 -3
  272. package/dist/chunk-Q2CLQ3IJ.js.map +1 -0
  273. package/dist/{chunk-2J7XKAZX.js → chunk-Q2SLOMN6.js} +7 -6
  274. package/dist/chunk-Q2SLOMN6.js.map +1 -0
  275. package/dist/{chunk-S2XULQEK.js → chunk-Q5BPZPCO.js} +2 -2
  276. package/dist/{chunk-S2XULQEK.js.map → chunk-Q5BPZPCO.js.map} +1 -1
  277. package/dist/{chunk-ROEBKSIY.js → chunk-Q7RILH2D.js} +14 -6
  278. package/dist/chunk-Q7RILH2D.js.map +1 -0
  279. package/dist/chunk-QR7MGGOM.js +49 -0
  280. package/dist/chunk-QR7MGGOM.js.map +1 -0
  281. package/dist/{chunk-PS24PVR6.js → chunk-QXXLDY6I.js} +50 -10
  282. package/dist/chunk-QXXLDY6I.js.map +1 -0
  283. package/dist/chunk-QY77Q7RY.js +129 -0
  284. package/dist/chunk-QY77Q7RY.js.map +1 -0
  285. package/dist/{chunk-4OV272LF.js → chunk-R6FIXYAE.js} +4 -4
  286. package/dist/{chunk-4OV272LF.js.map → chunk-R6FIXYAE.js.map} +1 -1
  287. package/dist/{chunk-N2K3QGSX.js → chunk-RGB4DPMN.js} +16 -3
  288. package/dist/chunk-RGB4DPMN.js.map +1 -0
  289. package/dist/{chunk-TKNVL53O.js → chunk-RPJOLDSR.js} +11 -3
  290. package/dist/chunk-RPJOLDSR.js.map +1 -0
  291. package/dist/chunk-SBCXWGNP.js +256 -0
  292. package/dist/chunk-SBCXWGNP.js.map +1 -0
  293. package/dist/{chunk-WPNIKZMJ.js → chunk-SJBMKA4X.js} +2 -2
  294. package/dist/{chunk-WPNIKZMJ.js.map → chunk-SJBMKA4X.js.map} +1 -1
  295. package/dist/{chunk-RMWNO6BA.js → chunk-SNUDT6AX.js} +2 -2
  296. package/dist/{chunk-RMWNO6BA.js.map → chunk-SNUDT6AX.js.map} +1 -1
  297. package/dist/{chunk-NR6O74ST.js → chunk-SPI6VMIY.js} +14 -10
  298. package/dist/chunk-SPI6VMIY.js.map +1 -0
  299. package/dist/{chunk-ZN7KUMPY.js → chunk-SWXWLSUD.js} +17 -3
  300. package/dist/chunk-SWXWLSUD.js.map +1 -0
  301. package/dist/chunk-TBVSPSGX.js +14 -0
  302. package/dist/chunk-TBVSPSGX.js.map +1 -0
  303. package/dist/{chunk-UMNHJSIO.js → chunk-TPLVC5BE.js} +2 -2
  304. package/dist/{chunk-UMNHJSIO.js.map → chunk-TPLVC5BE.js.map} +1 -1
  305. package/dist/chunk-TRJS7M2H.js +39 -0
  306. package/dist/chunk-TRJS7M2H.js.map +1 -0
  307. package/dist/chunk-TXBNPEIJ.js +31 -0
  308. package/dist/chunk-TXBNPEIJ.js.map +1 -0
  309. package/dist/{chunk-VEME3D7K.js → chunk-UD5KHQOH.js} +27 -3
  310. package/dist/chunk-UD5KHQOH.js.map +1 -0
  311. package/dist/{chunk-5CLMV5YU.js → chunk-UPHPFKAD.js} +54 -18
  312. package/dist/chunk-UPHPFKAD.js.map +1 -0
  313. package/dist/{chunk-WVS6CUCT.js → chunk-V3IXAI4L.js} +6 -2
  314. package/dist/chunk-V3IXAI4L.js.map +1 -0
  315. package/dist/{chunk-CVD5IZGB.js → chunk-VBXKYT4O.js} +7 -2
  316. package/dist/chunk-VBXKYT4O.js.map +1 -0
  317. package/dist/{chunk-OZ6X76G5.js → chunk-VNT4MXR5.js} +4 -3
  318. package/dist/chunk-VNT4MXR5.js.map +1 -0
  319. package/dist/{chunk-K57NINLH.js → chunk-VPDSPD76.js} +54 -1
  320. package/dist/chunk-VPDSPD76.js.map +1 -0
  321. package/dist/chunk-VX3YF2UD.js +77 -0
  322. package/dist/chunk-VX3YF2UD.js.map +1 -0
  323. package/dist/chunk-WCMGPAY2.js +103 -0
  324. package/dist/chunk-WCMGPAY2.js.map +1 -0
  325. package/dist/{chunk-DZJ4GBSP.js → chunk-WSPXSWFG.js} +21 -4
  326. package/dist/chunk-WSPXSWFG.js.map +1 -0
  327. package/dist/{chunk-NB6POCFH.js → chunk-WVQDIOD7.js} +56 -11
  328. package/dist/chunk-WVQDIOD7.js.map +1 -0
  329. package/dist/{chunk-F653O57X.js → chunk-Y4VR6VNM.js} +6 -3
  330. package/dist/chunk-Y4VR6VNM.js.map +1 -0
  331. package/dist/{chunk-CEJ5FK6G.js → chunk-YHRJNKD5.js} +2 -2
  332. package/dist/{chunk-CEJ5FK6G.js.map → chunk-YHRJNKD5.js.map} +1 -1
  333. package/dist/{chunk-XWNXGFX3.js → chunk-Z3T24FX3.js} +2 -2
  334. package/dist/{chunk-XWNXGFX3.js.map → chunk-Z3T24FX3.js.map} +1 -1
  335. package/dist/collapsible-panel.d.ts +10 -3
  336. package/dist/collapsible-panel.js +45 -5
  337. package/dist/collapsible-panel.js.map +1 -1
  338. package/dist/color-field.js +2 -2
  339. package/dist/color-picker.js +1 -1
  340. package/dist/color-swatches.js +1 -1
  341. package/dist/column-explorer.d.ts +67 -0
  342. package/dist/column-explorer.js +140 -0
  343. package/dist/column-explorer.js.map +1 -0
  344. package/dist/column-track.d.ts +12 -3
  345. package/dist/column-track.js +1 -1
  346. package/dist/combobox.d.ts +5 -1
  347. package/dist/combobox.js +2 -1
  348. package/dist/content-item.d.ts +14 -4
  349. package/dist/content-item.js +2 -1
  350. package/dist/content-swap.d.ts +5 -1
  351. package/dist/content-swap.js +2 -1
  352. package/dist/corner-status.d.ts +5 -1
  353. package/dist/corner-status.js +2 -1
  354. package/dist/device-class.js +1 -101
  355. package/dist/device-class.js.map +1 -1
  356. package/dist/disclosure-arrow.d.ts +5 -1
  357. package/dist/disclosure-arrow.js +2 -1
  358. package/dist/disclosure.js +2 -2
  359. package/dist/edge-activity-indicator.d.ts +5 -1
  360. package/dist/edge-activity-indicator.js +2 -1
  361. package/dist/editor.d.ts +344 -0
  362. package/dist/editor.js +10076 -0
  363. package/dist/editor.js.map +1 -0
  364. package/dist/empty-state.d.ts +5 -1
  365. package/dist/empty-state.js +2 -1
  366. package/dist/{extension-attributes-mu8MFUl0.d.ts → extension-attributes-IJ4decoa.d.ts} +7 -1
  367. package/dist/file-picker.d.ts +25 -4
  368. package/dist/file-picker.js +2 -1
  369. package/dist/floating-toolbar.d.ts +5 -1
  370. package/dist/floating-toolbar.js +2 -1
  371. package/dist/form.d.ts +45 -0
  372. package/dist/form.js +4 -0
  373. package/dist/form.js.map +1 -0
  374. package/dist/framed-list.js +1 -1
  375. package/dist/grid.js +1 -1
  376. package/dist/index.d.ts +14 -7
  377. package/dist/index.js +82 -70
  378. package/dist/list-action-row.d.ts +1 -1
  379. package/dist/list-action-row.js +2 -1
  380. package/dist/list-detail-dialog.d.ts +10 -3
  381. package/dist/list-detail-dialog.js +15 -11
  382. package/dist/list-detail-dialog.js.map +1 -1
  383. package/dist/list-header.d.ts +11 -3
  384. package/dist/list-header.js +1 -1
  385. package/dist/list-inset-control.d.ts +5 -1
  386. package/dist/list-inset-control.js +2 -1
  387. package/dist/list-inset-text.js +1 -1
  388. package/dist/list-item.js +3 -1
  389. package/dist/list.d.ts +130 -11
  390. package/dist/list.js +1 -1
  391. package/dist/loading-spinner.d.ts +5 -1
  392. package/dist/loading-spinner.js +2 -1
  393. package/dist/lucide-icon.d.ts +5 -1
  394. package/dist/lucide-icon.js +2 -1
  395. package/dist/message-composer.js +1 -1
  396. package/dist/{nav-stack-CrZF95VO.d.ts → nav-stack-DwxpXxqJ.d.ts} +13 -2
  397. package/dist/nav-stack.d.ts +3 -2
  398. package/dist/nav-stack.js +4 -1
  399. package/dist/paged-view.d.ts +47 -0
  400. package/dist/paged-view.js +86 -0
  401. package/dist/paged-view.js.map +1 -0
  402. package/dist/pane.d.ts +42 -5
  403. package/dist/pane.js +2 -1
  404. package/dist/popup-menu-register.js +1 -1
  405. package/dist/popup-menu.d.ts +42 -2
  406. package/dist/popup-menu.js +2 -1
  407. package/dist/progress-bar.js +1 -1
  408. package/dist/progress-ring.js +1 -1
  409. package/dist/radio-group.js +1 -1
  410. package/dist/resizable-region.d.ts +5 -1
  411. package/dist/resizable-region.js +2 -1
  412. package/dist/row.d.ts +7 -2
  413. package/dist/row.js +1 -1
  414. package/dist/scroll-effect.d.ts +86 -0
  415. package/dist/scroll-effect.js +5 -0
  416. package/dist/scroll-effect.js.map +1 -0
  417. package/dist/{search-field-CrGTN5sa.d.ts → search-field-5lNIszda.d.ts} +5 -1
  418. package/dist/search-field-model.d.ts +2 -1
  419. package/dist/search-field.d.ts +2 -1
  420. package/dist/search-field.js +2 -1
  421. package/dist/segmented-control.d.ts +5 -1
  422. package/dist/segmented-control.js +2 -1
  423. package/dist/select-register.js +9 -2
  424. package/dist/select-register.js.map +1 -1
  425. package/dist/select.d.ts +22 -1
  426. package/dist/select.js +1 -1
  427. package/dist/sized-region.d.ts +44 -0
  428. package/dist/sized-region.js +4 -0
  429. package/dist/sized-region.js.map +1 -0
  430. package/dist/skeleton.d.ts +5 -1
  431. package/dist/skeleton.js +2 -1
  432. package/dist/slider.js +1 -1
  433. package/dist/spacer.d.ts +5 -1
  434. package/dist/spacer.js +2 -1
  435. package/dist/split-button.js +1 -1
  436. package/dist/split-view.d.ts +7 -3
  437. package/dist/split-view.js +4 -1
  438. package/dist/state-banner.d.ts +7 -0
  439. package/dist/state-banner.js +1 -1
  440. package/dist/styles/backdrop-image.css +136 -70
  441. package/dist/styles/badge.css +31 -0
  442. package/dist/styles/button.css +103 -0
  443. package/dist/styles/choice-chips.css +45 -0
  444. package/dist/styles/column-explorer.css +6 -0
  445. package/dist/styles/components/actions/button/button.css +103 -0
  446. package/dist/styles/components/actions/popup-menu/popup-menu.css +154 -1
  447. package/dist/styles/components/actions/toolbar/toolbar.css +19 -11
  448. package/dist/styles/components/actions/toolbar-control-group/toolbar-control-group.css +38 -200
  449. package/dist/styles/components/collections/column-explorer/column-explorer.css +6 -0
  450. package/dist/styles/components/collections/list/list.css +6 -0
  451. package/dist/styles/components/collections/list-item/list-item.css +68 -2
  452. package/dist/styles/components/collections/summary-row/summary-row.css +39 -6
  453. package/dist/styles/components/collections/tree-list/tree-list.css +7 -0
  454. package/dist/styles/components/data-display/value-table/value-table.css +1 -1
  455. package/dist/styles/components/feedback/badge/badge.css +31 -0
  456. package/dist/styles/components/feedback/state-banner/state-banner.css +12 -7
  457. package/dist/styles/components/forms/choice-chips/choice-chips.css +45 -0
  458. package/dist/styles/components/forms/file-picker/file-picker.css +13 -2
  459. package/dist/styles/components/forms/form/form.css +6 -0
  460. package/dist/styles/components/forms/select/select.css +85 -2
  461. package/dist/styles/components/forms/text-field/text-field.css +44 -0
  462. package/dist/styles/components/layout/pane/pane.css +16 -0
  463. package/dist/styles/components/layout/resizable-region/resizable-region.css +0 -10
  464. package/dist/styles/components/layout/sized-region/sized-region.css +22 -0
  465. package/dist/styles/components/layout/workbench/workbench.css +0 -21
  466. package/dist/styles/components/navigation/nav-stack/nav-stack.css +2 -0
  467. package/dist/styles/components/navigation/paged-view/paged-view.css +160 -0
  468. package/dist/styles/components/navigation/tab-bar/tab-bar.css +9 -0
  469. package/dist/styles/components/navigation/tab-bar-item/tab-bar-item.css +110 -2
  470. package/dist/styles/components/navigation/tab-panel/tab-panel.css +7 -0
  471. package/dist/styles/components/surfaces/backdrop-image/backdrop-image.css +14 -70
  472. package/dist/styles/components/surfaces/scroll-effect/scroll-effect.css +121 -0
  473. package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +77 -29
  474. package/dist/styles/components/typography/text/text.css +4 -4
  475. package/dist/styles/content-item.css +551 -3
  476. package/dist/styles/document.css +1 -6
  477. package/dist/styles/editor/editor.css +530 -0
  478. package/dist/styles/editor.css +4 -0
  479. package/dist/styles/file-picker.css +13 -2
  480. package/dist/styles/form.css +6 -0
  481. package/dist/styles/foundation.css +55 -1
  482. package/dist/styles/list-item.css +68 -2
  483. package/dist/styles/list.css +6 -0
  484. package/dist/styles/nav-stack.css +2 -0
  485. package/dist/styles/overlay-sheet.css +7 -7
  486. package/dist/styles/paged-view.css +160 -0
  487. package/dist/styles/pane.css +16 -0
  488. package/dist/styles/popup-menu.css +154 -1
  489. package/dist/styles/resizable-region.css +0 -10
  490. package/dist/styles/scroll-effect.css +121 -0
  491. package/dist/styles/select.css +85 -2
  492. package/dist/styles/sized-region.css +22 -0
  493. package/dist/styles/state-banner.css +12 -7
  494. package/dist/styles/styles.css +11 -0
  495. package/dist/styles/summary-row.css +39 -6
  496. package/dist/styles/surface-scaffold.css +77 -29
  497. package/dist/styles/tab-bar-item.css +110 -2
  498. package/dist/styles/tab-bar.css +9 -0
  499. package/dist/styles/tab-panel.css +7 -0
  500. package/dist/styles/text-field.css +44 -0
  501. package/dist/styles/text.css +4 -4
  502. package/dist/styles/toolbar-control-group.css +38 -200
  503. package/dist/styles/toolbar.css +19 -11
  504. package/dist/styles/tree-list.css +7 -0
  505. package/dist/styles/value-table.css +1 -1
  506. package/dist/styles/webawesome.css +350 -6
  507. package/dist/styles/workbench.css +0 -21
  508. package/dist/summary-row.d.ts +9 -1
  509. package/dist/summary-row.js +1 -1
  510. package/dist/sunken-panel.d.ts +5 -1
  511. package/dist/sunken-panel.js +2 -1
  512. package/dist/surface-scaffold-register.js +1 -1
  513. package/dist/surface-scaffold.d.ts +37 -6
  514. package/dist/surface-scaffold.js +3 -2
  515. package/dist/switch.js +1 -1
  516. package/dist/tab-bar-item.d.ts +8 -1
  517. package/dist/tab-bar-item.js +1 -1
  518. package/dist/tab-bar.d.ts +15 -2
  519. package/dist/tab-bar.js +2 -1
  520. package/dist/tab-navigator.d.ts +25 -3
  521. package/dist/tab-navigator.js +42 -19
  522. package/dist/tab-navigator.js.map +1 -1
  523. package/dist/tab-panel.d.ts +35 -0
  524. package/dist/tab-panel.js +4 -0
  525. package/dist/tab-panel.js.map +1 -0
  526. package/dist/tag-field.d.ts +5 -1
  527. package/dist/tag-field.js +2 -1
  528. package/dist/text-field.d.ts +22 -4
  529. package/dist/text-field.js +1 -1
  530. package/dist/text.d.ts +37 -5
  531. package/dist/text.js +2 -1
  532. package/dist/toolbar-control-group.d.ts +83 -3
  533. package/dist/toolbar-control-group.js +4 -1
  534. package/dist/toolbar-text.d.ts +9 -1
  535. package/dist/toolbar-text.js +2 -1
  536. package/dist/toolbar.d.ts +6 -1
  537. package/dist/toolbar.js +2 -1
  538. package/dist/tree-list.d.ts +42 -0
  539. package/dist/tree-list.js +12 -0
  540. package/dist/tree-list.js.map +1 -0
  541. package/dist/tree-rows-eHnnGLGM.d.ts +65 -0
  542. package/dist/value-preview.d.ts +5 -1
  543. package/dist/value-preview.js +2 -1
  544. package/dist/value-table.d.ts +9 -2
  545. package/dist/value-table.js +2 -1
  546. package/dist/wire-catalog.d.ts +3 -2
  547. package/dist/wire-catalog.js +4 -3
  548. package/dist/wire-catalog.js.map +1 -1
  549. package/dist/wire-choice-chips.d.ts +3 -1
  550. package/dist/wire-choice-chips.js +1 -1
  551. package/dist/wire-color-fields.js +2 -73
  552. package/dist/wire-color-fields.js.map +1 -1
  553. package/dist/wire-color-pickers.js +1 -1
  554. package/dist/wire-column-explorer.d.ts +13 -0
  555. package/dist/wire-column-explorer.js +94 -0
  556. package/dist/wire-column-explorer.js.map +1 -0
  557. package/dist/wire-content-items.d.ts +10 -1
  558. package/dist/wire-content-items.js +1 -293
  559. package/dist/wire-content-items.js.map +1 -1
  560. package/dist/wire-forms.d.ts +14 -0
  561. package/dist/wire-forms.js +3 -0
  562. package/dist/wire-forms.js.map +1 -0
  563. package/dist/wire-nav-stack.js +1 -423
  564. package/dist/wire-nav-stack.js.map +1 -1
  565. package/dist/wire-paged-views.d.ts +27 -0
  566. package/dist/wire-paged-views.js +186 -0
  567. package/dist/wire-paged-views.js.map +1 -0
  568. package/dist/wire-resizable-regions.js +2 -1
  569. package/dist/wire-scroll-dividers.js +1 -1
  570. package/dist/wire-search-fields.d.ts +2 -1
  571. package/dist/wire-search-fields.js +2 -1
  572. package/dist/wire-sidebar.js +1 -229
  573. package/dist/wire-sidebar.js.map +1 -1
  574. package/dist/wire-sliders.js +1 -29
  575. package/dist/wire-sliders.js.map +1 -1
  576. package/dist/wire-summary-rows.d.ts +18 -0
  577. package/dist/wire-summary-rows.js +4 -0
  578. package/dist/wire-summary-rows.js.map +1 -0
  579. package/dist/wire-tab-bars.d.ts +1 -0
  580. package/dist/wire-tab-bars.js +1 -1
  581. package/dist/wire-tab-navigator.js +1 -151
  582. package/dist/wire-tab-navigator.js.map +1 -1
  583. package/dist/wire-tag-fields.js +3 -252
  584. package/dist/wire-tag-fields.js.map +1 -1
  585. package/dist/wire-tree-list.d.ts +53 -0
  586. package/dist/wire-tree-list.js +3 -0
  587. package/dist/wire-tree-list.js.map +1 -0
  588. package/dist/wire-workbench.js +2 -1
  589. package/dist/workbench-dialog.d.ts +10 -3
  590. package/dist/workbench-dialog.js +13 -9
  591. package/dist/workbench-dialog.js.map +1 -1
  592. package/dist/workbench.d.ts +7 -3
  593. package/dist/workbench.js +4 -1
  594. package/docs/accessibility.md +52 -9
  595. package/docs/app-layouts.md +70 -1
  596. package/docs/backdrop-image.md +10 -0
  597. package/docs/button.md +30 -2
  598. package/docs/column-explorer.md +75 -0
  599. package/docs/component-contract.md +38 -8
  600. package/docs/component-selection.md +150 -107
  601. package/docs/data-tables-and-lists.md +1 -1
  602. package/docs/design/sketch/Kerf-UI.sketch +0 -0
  603. package/docs/design/sketch/README.md +1 -1
  604. package/docs/design/sketch/coverage.md +120 -118
  605. package/docs/design/sketch/lists/README.md +6 -6
  606. package/docs/design/sketch/unified/README.md +1 -1
  607. package/docs/design/sketch/unified/pages/lists.png +0 -0
  608. package/docs/design/templates/button/emphasis-dark.svg +1 -1
  609. package/docs/design/templates/button/emphasis.svg +1 -1
  610. package/docs/design/templates/button-dark.svg +1 -1
  611. package/docs/design/templates/button.svg +1 -1
  612. package/docs/design/templates/tree-list/files-dark.svg +1 -0
  613. package/docs/design/templates/tree-list/files.svg +1 -0
  614. package/docs/design/templates/tree-list/outline-dark.svg +1 -0
  615. package/docs/design/templates/tree-list/outline.svg +1 -0
  616. package/docs/design/templates/tree-list-dark.svg +1 -0
  617. package/docs/design/templates/tree-list.svg +1 -0
  618. package/docs/design/templates.md +2 -2
  619. package/docs/document-baseline.md +6 -3
  620. package/docs/editor-host.md +299 -0
  621. package/docs/forms-and-validation.md +39 -0
  622. package/docs/interaction-conventions.md +1 -0
  623. package/docs/layout.md +87 -4
  624. package/docs/list-detail-dialog.md +5 -0
  625. package/docs/manual-test-plan.md +32 -0
  626. package/docs/nav-stack.md +2 -1
  627. package/docs/paged-view.md +89 -0
  628. package/docs/scroll-effect.md +127 -0
  629. package/docs/split-view.md +4 -1
  630. package/docs/surface-scaffold.md +32 -2
  631. package/docs/tab-navigator.md +5 -4
  632. package/docs/tree-list.md +134 -0
  633. package/docs/ui-analyzer.md +43 -25
  634. package/docs/ui-doctor.md +4 -1
  635. package/docs/ui-evaluator.md +2 -0
  636. package/docs/webawesome-migration.md +32 -31
  637. package/docs/webawesome-theme.md +27 -17
  638. package/docs/workbench-dialog.md +4 -0
  639. package/evaluator/index.mjs +14 -2
  640. package/llms.txt +159 -18
  641. package/package.json +90 -3
  642. package/props/cli.d.mts +1 -0
  643. package/props/cli.mjs +116 -0
  644. package/props/component-props.d.mts +177 -0
  645. package/props/component-props.mjs +1208 -0
  646. package/scripts/lib/json-schema-subset.mjs +137 -0
  647. package/ux-demo/recipes/app-shell.tsx +20 -22
  648. package/ux-demo/recipes/collapsible-sidebar.tsx +2 -2
  649. package/ux-demo/recipes/compact-toolbar.tsx +26 -29
  650. package/ux-demo/recipes/composer-form.tsx +6 -5
  651. package/ux-demo/recipes/list-workspace-states.tsx +39 -39
  652. package/ux-demo/recipes/loading-inspector.tsx +8 -6
  653. package/ux-demo/recipes/media-detail.tsx +29 -15
  654. package/ux-demo/recipes/navigation-sidebar.tsx +18 -19
  655. package/ux-demo/recipes/navigation-stack.tsx +2 -2
  656. package/ux-demo/recipes/workspace-header.tsx +16 -16
  657. package/view/cli.d.mts +18 -0
  658. package/view/cli.mjs +262 -0
  659. package/view/contract.mjs +342 -0
  660. package/view/generate.mjs +639 -0
  661. package/view/index.d.mts +411 -0
  662. package/view/index.mjs +40 -0
  663. package/view/interpret.mjs +271 -0
  664. package/view/validate-move.mjs +317 -0
  665. package/view/validate.mjs +1864 -0
  666. package/vite-editor.d.mts +130 -0
  667. package/vite-editor.mjs +314 -0
  668. package/dist/chunk-2J7XKAZX.js.map +0 -1
  669. package/dist/chunk-3KFMLOTH.js.map +0 -1
  670. package/dist/chunk-3OP66VXU.js.map +0 -1
  671. package/dist/chunk-3V4OCDTL.js.map +0 -1
  672. package/dist/chunk-3WWX2O4G.js.map +0 -1
  673. package/dist/chunk-5CLMV5YU.js.map +0 -1
  674. package/dist/chunk-5J6Z4BWY.js.map +0 -1
  675. package/dist/chunk-6VVIW7VB.js.map +0 -1
  676. package/dist/chunk-7K6U6FCN.js.map +0 -1
  677. package/dist/chunk-AMIHGFLP.js.map +0 -1
  678. package/dist/chunk-AN5IWMTM.js.map +0 -1
  679. package/dist/chunk-B53PS2LE.js.map +0 -1
  680. package/dist/chunk-BKUMG2KB.js.map +0 -1
  681. package/dist/chunk-C2ZO3OZZ.js.map +0 -1
  682. package/dist/chunk-CVD5IZGB.js.map +0 -1
  683. package/dist/chunk-D5RGM3XA.js.map +0 -1
  684. package/dist/chunk-DZJ4GBSP.js.map +0 -1
  685. package/dist/chunk-EIET4QLK.js.map +0 -1
  686. package/dist/chunk-EKHDLBRP.js.map +0 -1
  687. package/dist/chunk-ETFP7HAR.js.map +0 -1
  688. package/dist/chunk-EYDXFOSH.js.map +0 -1
  689. package/dist/chunk-F653O57X.js.map +0 -1
  690. package/dist/chunk-G3J7JDP6.js.map +0 -1
  691. package/dist/chunk-HJXVVFBT.js.map +0 -1
  692. package/dist/chunk-IIQ2XIMU.js.map +0 -1
  693. package/dist/chunk-ITENVZ6Q.js.map +0 -1
  694. package/dist/chunk-ITUQC4FW.js.map +0 -1
  695. package/dist/chunk-K57NINLH.js.map +0 -1
  696. package/dist/chunk-K67XBCHG.js.map +0 -1
  697. package/dist/chunk-KDQZ3E5C.js.map +0 -1
  698. package/dist/chunk-KH4KEMSP.js.map +0 -1
  699. package/dist/chunk-LZUUUHNH.js.map +0 -1
  700. package/dist/chunk-N2K3QGSX.js.map +0 -1
  701. package/dist/chunk-NB6POCFH.js.map +0 -1
  702. package/dist/chunk-NR6O74ST.js.map +0 -1
  703. package/dist/chunk-OQP3PFKQ.js.map +0 -1
  704. package/dist/chunk-OZ6X76G5.js.map +0 -1
  705. package/dist/chunk-PS24PVR6.js.map +0 -1
  706. package/dist/chunk-QH5KOFNS.js.map +0 -1
  707. package/dist/chunk-QYMJHS4K.js.map +0 -1
  708. package/dist/chunk-ROEBKSIY.js.map +0 -1
  709. package/dist/chunk-S3DCRI2M.js.map +0 -1
  710. package/dist/chunk-S3ECMF23.js.map +0 -1
  711. package/dist/chunk-TKNVL53O.js.map +0 -1
  712. package/dist/chunk-VEME3D7K.js.map +0 -1
  713. package/dist/chunk-WPP5Q4A5.js.map +0 -1
  714. package/dist/chunk-WVS6CUCT.js.map +0 -1
  715. package/dist/chunk-XRZSK2WC.js.map +0 -1
  716. package/dist/chunk-Y6KT7ZTR.js.map +0 -1
  717. package/dist/chunk-YMUIQRWK.js.map +0 -1
  718. package/dist/chunk-YPAQFBMN.js.map +0 -1
  719. package/dist/chunk-YWLDLNAV.js.map +0 -1
  720. package/dist/chunk-ZN7KUMPY.js.map +0 -1
  721. package/dist/chunk-ZX2QQJXD.js.map +0 -1
@@ -0,0 +1,1864 @@
1
+ // validateView: checks a Kerf UI view document (kerf-ui-document/v1, see
2
+ // docs/26-ui-editor.md) against the component-props and composition
3
+ // catalogs. Pure and synchronous, with no Node APIs, so the editor runs it in
4
+ // the browser and the CLI runs it in Node.
5
+
6
+ export const VIEW_DOCUMENT_SCHEMA_ID = 'kerf-ui-document/v1';
7
+
8
+ const ULID = /^[0-9A-HJKMNP-TV-Z]{26}$/;
9
+ const CAMEL = /^[a-z][A-Za-z0-9]*$/;
10
+ const PASCAL = /^[A-Z][A-Za-z0-9]*$/;
11
+ const ACTION_NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
12
+ const ACTION_PROP = /^action$|[a-z]Action$/;
13
+ const ICON_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
14
+ // Loop variable names the generated module already uses.
15
+ const RESERVED_NAMES = new Set(['inputs', 'slots', 'each', 'handlers']);
16
+ // Every builder `@kerfjs/ui/css-values` exports; a css-value prop without a
17
+ // catalog `cssValue` restriction accepts any of them.
18
+ const CSS_HELPERS = [
19
+ 'calc',
20
+ 'colorVar',
21
+ 'em',
22
+ 'fillColor',
23
+ 'flex',
24
+ 'foregroundColor',
25
+ 'foregroundColorVar',
26
+ 'lengthVar',
27
+ 'pct',
28
+ 'plus',
29
+ 'px',
30
+ 'rem',
31
+ 'remify',
32
+ 'space',
33
+ 'uiColor',
34
+ ];
35
+ const PARAM_KINDS = new Set([
36
+ 'string',
37
+ 'number',
38
+ 'boolean',
39
+ 'enum',
40
+ 'literal',
41
+ 'content',
42
+ 'array',
43
+ 'object',
44
+ // The exact type of one component prop (KF-H3CB2P: app-supplied values):
45
+ // `{ kind: 'prop', component: '@kerfjs/ui:search-field', prop: 'model' }`,
46
+ // for values a document cannot spell, such as functions and signals.
47
+ 'prop',
48
+ ]);
49
+
50
+ const isObject = (value) =>
51
+ value !== null && typeof value === 'object' && !Array.isArray(value);
52
+ const only = (value, keys) =>
53
+ Object.keys(value).filter((key) => !keys.includes(key));
54
+ const keyOf = (type) => type.split('#')[0];
55
+
56
+ /**
57
+ * Indexes component-props and composition documents for validation. Each
58
+ * component keeps the `definitions` table of the document that declared it,
59
+ * so two packages' same-named types never collide.
60
+ */
61
+ export function createViewCatalog({ props = [], composition = [] }) {
62
+ const components = new Map();
63
+ for (const document of props) {
64
+ for (const component of document.components ?? []) {
65
+ components.set(component.key, {
66
+ component,
67
+ definitions: document.definitions ?? {},
68
+ });
69
+ }
70
+ }
71
+ const entries = new Map();
72
+ // A config type another component renders as an entry (KF-THTR71), keyed
73
+ // `package:TypeName` since type names are only unique within a package.
74
+ const configParents = new Map();
75
+ for (const document of composition) {
76
+ for (const entry of document.entries ?? []) {
77
+ entries.set(entry.key, entry);
78
+ for (const name of entry.configTypes ?? [])
79
+ configParents.set(
80
+ `${keyOf(entry.key).split(':')[0]}:${name}`,
81
+ entry.key,
82
+ );
83
+ }
84
+ }
85
+ return { components, entries, configParents };
86
+ }
87
+
88
+ function resolveType(type, definitions) {
89
+ let current = type;
90
+ for (let hops = 0; current?.kind === 'ref' && hops < 32; hops += 1) {
91
+ current = definitions[current.ref];
92
+ }
93
+ return current ?? { kind: 'unknown' };
94
+ }
95
+
96
+ const propsOf = (type, definitions) => resolveType(type, definitions).props;
97
+
98
+ /** A type, or each member of a union of it (unions of unions flattened). */
99
+ function membersOf(type, definitions) {
100
+ const resolved = resolveType(type, definitions);
101
+ return resolved.kind === 'union'
102
+ ? resolved.members.flatMap((member) => membersOf(member, definitions))
103
+ : [resolved];
104
+ }
105
+
106
+ const INDEX = /^\d+$/;
107
+
108
+ /**
109
+ * A zone key that names a content field inside a prop value (KF-PD6QC5:
110
+ * field zones): the prop, then field names and list indexes, dot-separated
111
+ * (`leftRail.content`, `mainToolbar.title`, `views.0.content`). Walks the
112
+ * prop's type through refs, union members, objects (never a field the type
113
+ * forbids), and lists, and ends at rendered content. Returns the prop, the
114
+ * path inside its value, and whether the field takes text; undefined for any
115
+ * other key.
116
+ */
117
+ export function fieldZoneOf(component, definitions, key) {
118
+ const walked = walkField(component, definitions, key);
119
+ if (!walked) return undefined;
120
+ const content = walked.types
121
+ .flatMap((type) => membersOf(type, definitions))
122
+ .find((type) => type.kind === 'content');
123
+ return content
124
+ ? {
125
+ prop: walked.name,
126
+ path: walked.path.map((step) =>
127
+ INDEX.test(step) ? Number(step) : step,
128
+ ),
129
+ text: content.acceptsText === true,
130
+ }
131
+ : undefined;
132
+ }
133
+
134
+ /**
135
+ * The types a field zone key reaches in a component's prop value, with the
136
+ * named types (`ref`s) of the value that holds that field: a NavStack view's
137
+ * `views.0.toolbar.leading` is held by a `NavStackViewToolbar`.
138
+ */
139
+ function walkField(component, definitions, key) {
140
+ if (typeof key !== 'string' || !key.includes('.')) return undefined;
141
+ const [name, ...path] = key.split('.');
142
+ const prop = component.props.find((item) => item.name === name);
143
+ if (!prop || prop.slot || prop.zone) return undefined;
144
+ let types = [prop.type];
145
+ let holders = [];
146
+ for (const step of path) {
147
+ holders = types.flatMap((type) => (type.kind === 'ref' ? [type.ref] : []));
148
+ const next = [];
149
+ for (const type of types.flatMap((item) => membersOf(item, definitions))) {
150
+ if (INDEX.test(step)) {
151
+ if (type.kind === 'array') next.push(type.items);
152
+ continue;
153
+ }
154
+ const field =
155
+ type.kind === 'object'
156
+ ? type.props?.find((item) => item.name === step)
157
+ : undefined;
158
+ if (field && resolveType(field.type, definitions).kind !== 'never')
159
+ next.push(field.type);
160
+ }
161
+ if (!next.length) return undefined;
162
+ types = next;
163
+ }
164
+ return { name, path, types, holders };
165
+ }
166
+
167
+ /**
168
+ * The component a field zone's children are placed in (KF-THTR71): a
169
+ * content field inside a value another component renders, such as a
170
+ * NavStack view's toolbar config, which renders as a Toolbar. A config type
171
+ * may name one field (`ListDetailDialogList.toolbar`) when only that field
172
+ * renders in the component. Undefined when neither the field nor its holder
173
+ * is cataloged.
174
+ */
175
+ function fieldParent(ctx, node, component, definitions, key) {
176
+ const pkg = keyOf(node.type).split(':')[0];
177
+ const walked = walkField(component, definitions, key);
178
+ const field = walked?.path.at(-1);
179
+ for (const holder of walked?.holders ?? []) {
180
+ // KF-WBH5P2: one field of a holder that renders only that field in
181
+ // another component (`ListDetailDialogList.toolbar` in a Toolbar)
182
+ // names it alone; the whole holder's mapping is the fallback.
183
+ const parent =
184
+ ctx.catalog.configParents?.get(`${pkg}:${holder}.${field}`) ??
185
+ ctx.catalog.configParents?.get(`${pkg}:${holder}`);
186
+ if (parent) return parent;
187
+ }
188
+ return undefined;
189
+ }
190
+
191
+ /**
192
+ * Where a field zone's children go in a prop value while it is checked,
193
+ * interpreted, or generated: a placeholder no document can spell, so it
194
+ * never reads as a literal of the document's own.
195
+ */
196
+ export class ZoneFill {
197
+ constructor(key, children) {
198
+ this.key = key;
199
+ this.children = children;
200
+ }
201
+ }
202
+
203
+ /**
204
+ * A prop value as a problem quotes it: JSON, with each field zone written as
205
+ * `<zone key>` rather than its nodes (KF-20GMVX), so the message stays short
206
+ * and does not change when something inside the zone does.
207
+ */
208
+ function quoteValue(value) {
209
+ return JSON.stringify(value, (_key, item) =>
210
+ item instanceof ZoneFill ? `<zone ${item.key}>` : item,
211
+ );
212
+ }
213
+
214
+ /** `value` with `fill` at `path`, copying each object and list on the way. */
215
+ function withAt(value, path, fill) {
216
+ if (!path.length) return fill;
217
+ const [step, ...rest] = path;
218
+ if (typeof step === 'number') {
219
+ const list = Array.isArray(value) ? [...value] : [];
220
+ list[step] = withAt(list[step], rest, fill);
221
+ return list;
222
+ }
223
+ const object = isObject(value) ? { ...value } : {};
224
+ object[step] = withAt(object[step], rest, fill);
225
+ return object;
226
+ }
227
+
228
+ /** Whether a value is a binding (`$param`, `$bind`, …) rather than a literal. */
229
+ const isBinding = (value) =>
230
+ isObject(value) && Object.keys(value).some((key) => key.startsWith('$'));
231
+
232
+ /**
233
+ * `props` with each filled field zone's placeholder (a `ZoneFill`) at its
234
+ * path, so the zone fills that content field (KF-PD6QC5). A prop held by a
235
+ * binding is left alone; validation reports the clash.
236
+ */
237
+ export function withFieldZones(props, zones, component, definitions) {
238
+ let merged = props;
239
+ for (const key of Object.keys(zones)) {
240
+ const field = fieldZoneOf(component, definitions, key);
241
+ if (!field || !zones[key].length || isBinding(merged[field.prop])) continue;
242
+ merged = {
243
+ ...merged,
244
+ [field.prop]: withAt(
245
+ merged[field.prop],
246
+ field.path,
247
+ new ZoneFill(key, zones[key]),
248
+ ),
249
+ };
250
+ }
251
+ return merged;
252
+ }
253
+
254
+ /** Whether a value of type `from` (a param or binding) fits type `to`. */
255
+ export function isAssignable(from, to, definitions = {}) {
256
+ // A component prop's type fits only that same component prop.
257
+ if (from?.kind === 'prop' || to?.kind === 'prop')
258
+ return (
259
+ from?.kind === to?.kind &&
260
+ from.component === to.component &&
261
+ from.prop === to.prop
262
+ );
263
+ const target = resolveType(to, definitions);
264
+ const source = resolveType(from, definitions);
265
+ if (target.kind === 'unknown' || source.kind === 'unknown') return true;
266
+ if (target.kind === 'union') {
267
+ return target.members.some((member) =>
268
+ isAssignable(source, member, definitions),
269
+ );
270
+ }
271
+ const values =
272
+ source.kind === 'enum'
273
+ ? source.values
274
+ : source.kind === 'literal'
275
+ ? [source.value]
276
+ : undefined;
277
+ if (values) {
278
+ if (target.kind === 'enum') {
279
+ return values.every((value) => target.values.includes(value));
280
+ }
281
+ if (target.kind === 'literal') {
282
+ return values.length === 1 && values[0] === target.value;
283
+ }
284
+ return values.every((value) => isLiteralOf(value, target, definitions));
285
+ }
286
+ switch (source.kind) {
287
+ case 'string':
288
+ case 'number':
289
+ return (
290
+ target.kind === source.kind ||
291
+ (target.kind === 'content' && target.acceptsText === true)
292
+ );
293
+ case 'boolean':
294
+ case 'content':
295
+ return target.kind === source.kind;
296
+ case 'array':
297
+ return (
298
+ target.kind === 'array' &&
299
+ isAssignable(source.items, target.items, definitions)
300
+ );
301
+ case 'object': {
302
+ if (target.kind === 'record') return true;
303
+ if (target.kind !== 'object') return false;
304
+ const given = new Map(
305
+ (source.props ?? []).map((prop) => [prop.name, prop]),
306
+ );
307
+ return (target.props ?? []).every((prop) => {
308
+ const match = given.get(prop.name);
309
+ if (!match) return !prop.required;
310
+ return (
311
+ (match.required || !prop.required) &&
312
+ isAssignable(match.type, prop.type, definitions)
313
+ );
314
+ });
315
+ }
316
+ default:
317
+ return false;
318
+ }
319
+ }
320
+
321
+ /** Whether a JSON literal is a valid value of a type descriptor. */
322
+ export function isLiteralOf(value, type, definitions = {}) {
323
+ return literalOf(value, type, definitions);
324
+ }
325
+
326
+ /**
327
+ * `isLiteralOf`, with `hooks` for the forms a prop value may nest:
328
+ * `hooks.slot` decides a `{ $slot }` at a content-typed position (KF-SXDM56:
329
+ * item slots), and `hooks.dynamic` a `{ $param }` / `{ $bind }` at any typed
330
+ * position against that position's type (KF-3QEZFB: nested params). Without
331
+ * them, neither is a literal.
332
+ */
333
+ function literalOf(value, type, definitions, hooks) {
334
+ if (
335
+ hooks?.dynamic &&
336
+ isObject(value) &&
337
+ ('$param' in value || '$bind' in value)
338
+ )
339
+ return hooks.dynamic(value, type);
340
+ const target = resolveType(type, definitions);
341
+ if (value === null) return target.nullable === true;
342
+ switch (target.kind) {
343
+ case 'unknown':
344
+ return true;
345
+ case 'union':
346
+ return target.members.some((member) =>
347
+ literalOf(value, member, definitions, hooks),
348
+ );
349
+ case 'string':
350
+ return typeof value === 'string';
351
+ case 'number':
352
+ return typeof value === 'number' && Number.isFinite(value);
353
+ case 'boolean':
354
+ return typeof value === 'boolean';
355
+ case 'enum':
356
+ return target.values.includes(value);
357
+ case 'literal':
358
+ return value === target.value;
359
+ // A builder call inside a list or object value (KF-3J9GJV).
360
+ case 'css-value':
361
+ return isObject(value) && parseCssCall(value.$css) !== undefined;
362
+ case 'content':
363
+ if (value instanceof ZoneFill) return true;
364
+ if (hooks?.slot && isObject(value) && '$slot' in value)
365
+ return hooks.slot(value);
366
+ return (
367
+ target.acceptsText === true &&
368
+ (typeof value === 'string' || typeof value === 'number')
369
+ );
370
+ case 'array':
371
+ return (
372
+ Array.isArray(value) &&
373
+ value.every((item) => literalOf(item, target.items, definitions, hooks))
374
+ );
375
+ case 'record':
376
+ return (
377
+ isObject(value) &&
378
+ Object.values(value).every((item) => typeof item === 'string')
379
+ );
380
+ case 'object': {
381
+ if (!isObject(value)) return false;
382
+ const known = new Map(
383
+ (target.props ?? []).map((prop) => [prop.name, prop]),
384
+ );
385
+ const { index } = target;
386
+ return (
387
+ Object.entries(value).every(([name, item]) =>
388
+ known.has(name)
389
+ ? // An icon-data field names its icon (KF-3J9GJV).
390
+ (known.get(name).iconSource &&
391
+ ICON_NAME.test(item?.$icon ?? '')) ||
392
+ literalOf(item, known.get(name).type, definitions, hooks)
393
+ : index !== undefined &&
394
+ name.startsWith(index.keyPrefix) &&
395
+ literalOf(item, index.value, definitions, hooks),
396
+ ) &&
397
+ [...known.values()].every(
398
+ (prop) => !prop.required || prop.name in value,
399
+ )
400
+ );
401
+ }
402
+ default:
403
+ return false;
404
+ }
405
+ }
406
+
407
+ /**
408
+ * Parses a `$css` builder call with literal arguments only: numbers, quoted
409
+ * strings without quotes or backslashes inside, and nested builder calls.
410
+ * Generated code emits the call verbatim and the interpreter evaluates the
411
+ * tree, so anything else (an identifier, an operator, a template) is rejected
412
+ * rather than trusted. Returns `{ name, args }` (each argument a number,
413
+ * string, or nested call), or undefined when it does not parse.
414
+ */
415
+ export function parseCssTree(source) {
416
+ if (typeof source !== 'string') return undefined;
417
+ const text = source.trim();
418
+ let index = 0;
419
+ const space = () => {
420
+ while (text[index] === ' ') index += 1;
421
+ };
422
+ const call = () => {
423
+ const name = /^[A-Za-z]+/.exec(text.slice(index))?.[0];
424
+ if (!name || text[index + name.length] !== '(') return undefined;
425
+ const node = { name, args: [] };
426
+ index += name.length + 1;
427
+ space();
428
+ if (text[index] === ')') {
429
+ index += 1;
430
+ return node;
431
+ }
432
+ for (;;) {
433
+ space();
434
+ const value = argument();
435
+ if (value === undefined) return undefined;
436
+ node.args.push(value);
437
+ space();
438
+ if (text[index] === ',') index += 1;
439
+ else if (text[index] === ')') {
440
+ index += 1;
441
+ return node;
442
+ } else return undefined;
443
+ }
444
+ };
445
+ const argument = () => {
446
+ const rest = text.slice(index);
447
+ const number = /^-?\d+(?:\.\d+)?/.exec(rest)?.[0];
448
+ if (number) {
449
+ index += number.length;
450
+ return Number(number);
451
+ }
452
+ const quoted =
453
+ /^'[^'\\\n]*'/.exec(rest)?.[0] ?? /^"[^"\\\n]*"/.exec(rest)?.[0];
454
+ if (quoted) {
455
+ index += quoted.length;
456
+ return quoted.slice(1, -1);
457
+ }
458
+ return call();
459
+ };
460
+ const tree = call();
461
+ return tree && index === text.length ? tree : undefined;
462
+ }
463
+
464
+ /** The helper names a `$css` call uses, outermost first, or undefined. */
465
+ export function parseCssCall(source) {
466
+ const tree = parseCssTree(source);
467
+ if (!tree) return undefined;
468
+ const names = [];
469
+ const visit = (node) => {
470
+ names.push(node.name);
471
+ for (const arg of node.args) if (typeof arg === 'object') visit(arg);
472
+ };
473
+ visit(tree);
474
+ return names;
475
+ }
476
+
477
+ // Optional props print as `T | undefined`; messages name the type itself.
478
+ function describe(type) {
479
+ return (type?.text ?? type?.kind ?? 'unknown').replace(/ \| undefined$/, '');
480
+ }
481
+
482
+ /** Validates one param or slot-input type in the document's own grammar. */
483
+ function validateDeclaredType(ctx, type, path) {
484
+ if (!isObject(type) || !PARAM_KINDS.has(type.kind)) {
485
+ ctx.report(
486
+ 'KUI-V001',
487
+ path,
488
+ `type must be one of ${[...PARAM_KINDS].join(', ')}`,
489
+ );
490
+ return;
491
+ }
492
+ if (
493
+ type.kind === 'enum' &&
494
+ !(Array.isArray(type.values) && type.values.length)
495
+ ) {
496
+ ctx.report(
497
+ 'KUI-V001',
498
+ path,
499
+ 'an enum type needs a non-empty `values` list',
500
+ );
501
+ }
502
+ if (type.kind === 'prop') {
503
+ const owner =
504
+ typeof type.component === 'string'
505
+ ? ctx.catalog.components.get(type.component)?.component
506
+ : undefined;
507
+ if (!owner?.props.some((prop) => prop.name === type.prop)) {
508
+ ctx.report(
509
+ 'KUI-V001',
510
+ path,
511
+ 'a prop type names a catalog `component` key and one of its `prop`s',
512
+ );
513
+ }
514
+ return;
515
+ }
516
+ if (type.kind === 'array') {
517
+ if (!isObject(type.items))
518
+ ctx.report('KUI-V001', path, 'an array type needs `items`');
519
+ else validateDeclaredType(ctx, type.items, `${path}.items`);
520
+ }
521
+ if (type.kind === 'object') {
522
+ if (!Array.isArray(type.props)) {
523
+ ctx.report('KUI-V001', path, 'an object type needs a `props` list');
524
+ return;
525
+ }
526
+ type.props.forEach((prop, index) => {
527
+ const at = `${path}.props[${index}]`;
528
+ if (
529
+ !isObject(prop) ||
530
+ typeof prop.name !== 'string' ||
531
+ typeof prop.required !== 'boolean'
532
+ ) {
533
+ ctx.report(
534
+ 'KUI-V001',
535
+ at,
536
+ 'a prop needs `name`, `type`, and `required`',
537
+ );
538
+ return;
539
+ }
540
+ validateDeclaredType(ctx, prop.type, `${at}.type`);
541
+ });
542
+ }
543
+ }
544
+
545
+ /** Resolves a `$bind` path to its type, or reports why it cannot. */
546
+ function bindingType(ctx, path, scope, at) {
547
+ if (typeof path !== 'string' || path === '') {
548
+ ctx.report('KUI-V007', at, '`$bind` needs a dotted path');
549
+ return undefined;
550
+ }
551
+ const [head, ...rest] = path.split('.');
552
+ let type = scope.get(head) ?? ctx.params.get(head)?.type;
553
+ if (!type) {
554
+ ctx.report(
555
+ 'KUI-V007',
556
+ at,
557
+ `\`$bind\` path "${path}" names nothing in scope`,
558
+ );
559
+ return undefined;
560
+ }
561
+ for (const segment of rest) {
562
+ const prop = propsOf(type, {})?.find((item) => item.name === segment);
563
+ if (!prop) {
564
+ ctx.report(
565
+ 'KUI-V007',
566
+ at,
567
+ `\`$bind\` path "${path}" has no "${segment}"`,
568
+ );
569
+ return undefined;
570
+ }
571
+ type = prop.type;
572
+ }
573
+ return type;
574
+ }
575
+
576
+ /**
577
+ * The type of a dynamic value (`$param` or `$bind`), `null` for a literal, or
578
+ * `undefined` after reporting an unresolvable reference.
579
+ */
580
+ function dynamicType(ctx, value, scope, at) {
581
+ if (!isObject(value)) return null;
582
+ if ('$param' in value) {
583
+ const param = ctx.params.get(value.$param);
584
+ if (!param)
585
+ ctx.report(
586
+ 'KUI-V007',
587
+ at,
588
+ `\`$param\` "${value.$param}" is not a document param`,
589
+ );
590
+ return param?.type;
591
+ }
592
+ if ('$bind' in value) return bindingType(ctx, value.$bind, scope, at);
593
+ return null;
594
+ }
595
+
596
+ function checkPropValue(ctx, prop, value, definitions, scope, at, rowScoped) {
597
+ if (isObject(value) && '$action' in value) {
598
+ if (
599
+ !ACTION_PROP.test(prop.name) ||
600
+ resolveType(prop.type, definitions).kind !== 'string'
601
+ ) {
602
+ ctx.report(
603
+ 'KUI-V009',
604
+ at,
605
+ `\`$action\` is only valid on an action-name prop, not "${prop.name}"`,
606
+ );
607
+ } else if (
608
+ typeof value.$action !== 'string' ||
609
+ !ACTION_NAME.test(value.$action)
610
+ ) {
611
+ ctx.report('KUI-V001', at, 'an action name is lowercase kebab-case');
612
+ } else {
613
+ ctx.noteAction(value.$action, rowScoped ? 'row' : 'view', at);
614
+ }
615
+ return;
616
+ }
617
+ if (isObject(value) && '$icon' in value) {
618
+ if (prop.iconSource !== 'lucide') {
619
+ ctx.report(
620
+ 'KUI-V013',
621
+ at,
622
+ `\`$icon\` is only valid on an icon-data prop, not "${prop.name}"`,
623
+ );
624
+ } else if (
625
+ typeof value.$icon !== 'string' ||
626
+ !ICON_NAME.test(value.$icon)
627
+ ) {
628
+ ctx.report(
629
+ 'KUI-V013',
630
+ at,
631
+ 'an icon name is a kebab-case Lucide name such as "inbox"',
632
+ );
633
+ } else if (ctx.icons && !ctx.icons.has(value.$icon)) {
634
+ ctx.report('KUI-V013', at, `unknown Lucide icon "${value.$icon}"`);
635
+ }
636
+ return;
637
+ }
638
+ if (isObject(value) && '$css' in value) {
639
+ const target = resolveType(prop.type, definitions);
640
+ const kinds =
641
+ target.kind === 'union'
642
+ ? target.members.map((member) => member.kind)
643
+ : [target.kind];
644
+ if (!kinds.includes('css-value')) {
645
+ ctx.report(
646
+ 'KUI-V010',
647
+ at,
648
+ `\`$css\` is only valid on a css-value prop, not "${prop.name}"`,
649
+ );
650
+ return;
651
+ }
652
+ const helpers = parseCssCall(value.$css);
653
+ const allowed = prop.cssValue?.helpers ?? CSS_HELPERS;
654
+ // The catalog's non-standalone helpers (`plus`) may appear nested.
655
+ const nested = [...allowed, ...(prop.cssValue?.nonStandaloneHelpers ?? [])];
656
+ if (
657
+ !helpers ||
658
+ !allowed.includes(helpers[0]) ||
659
+ !helpers
660
+ .slice(1)
661
+ .every((name) => nested.includes(name) || CSS_HELPERS.includes(name))
662
+ ) {
663
+ ctx.report(
664
+ 'KUI-V010',
665
+ at,
666
+ `\`$css\` must be one literal-argument call to ${allowed.join(', ')}`,
667
+ );
668
+ }
669
+ return;
670
+ }
671
+ const type = dynamicType(ctx, value, scope, at);
672
+ if (type === undefined) return;
673
+ // A param typed as a component prop binds only to that prop.
674
+ if (type?.kind === 'prop') {
675
+ // Outside a node's own props (a `#text` value, a `#view` prop, a `$if`
676
+ // condition, a `$slot` input) no component prop is being set, so a
677
+ // prop-typed value fits nothing there (KF-3624D4). Reading
678
+ // `ctx.component` there would name whichever component was checked last.
679
+ if (!ctx.inProps) {
680
+ ctx.report(
681
+ 'KUI-V004',
682
+ at,
683
+ `a ${type.component} "${type.prop}" value fits only that prop, not "${prop.name}"`,
684
+ );
685
+ return;
686
+ }
687
+ if (type.component !== ctx.component || type.prop !== prop.name) {
688
+ ctx.report(
689
+ 'KUI-V004',
690
+ at,
691
+ `a ${type.component} "${type.prop}" value does not fit "${prop.name}" of ${ctx.component}`,
692
+ );
693
+ }
694
+ return;
695
+ }
696
+ if (type === null) {
697
+ const hooks = {
698
+ slot: (slot) => checkValueSlot(ctx, slot, at),
699
+ dynamic: (item, type) =>
700
+ nestedDynamicFits(ctx, item, type, definitions, scope, at),
701
+ };
702
+ if (!literalOf(value, prop.type, definitions, hooks)) {
703
+ ctx.report(
704
+ 'KUI-V004',
705
+ at,
706
+ `${quoteValue(value)} is not a valid ${describe(prop.type)}`,
707
+ );
708
+ }
709
+ } else if (!isAssignable(type, prop.type, definitions)) {
710
+ ctx.report(
711
+ 'KUI-V004',
712
+ at,
713
+ `a ${describe(type)} value does not fit ${describe(prop.type)}`,
714
+ );
715
+ }
716
+ }
717
+
718
+ /**
719
+ * A `$param` / `$bind` inside a list or object prop value (KF-3QEZFB: nested
720
+ * params): it fits when its type is assignable to that position's type, as a
721
+ * whole prop's does. A prop-typed param names a whole component prop, so it
722
+ * never fits inside one. Each value object resolves once (an unknown param or
723
+ * an out-of-scope path reports once, though a union may try it against
724
+ * several members); an unresolved one counts as fitting, so it is not also a
725
+ * type mismatch.
726
+ */
727
+ function nestedDynamicFits(ctx, value, type, definitions, scope, at) {
728
+ if (!ctx.nestedDynamics.has(value))
729
+ ctx.nestedDynamics.set(value, dynamicType(ctx, value, scope, at));
730
+ const found = ctx.nestedDynamics.get(value);
731
+ if (found === undefined) return true;
732
+ if (found?.kind === 'prop') return false;
733
+ return isAssignable(found, type, definitions);
734
+ }
735
+
736
+ /**
737
+ * A `$slot` inside a prop value (KF-SXDM56: item slots): the application
738
+ * fills it with content, as a zone's `$slot`, but it passes no input. Each
739
+ * slot object reports once, though a union may try it against several
740
+ * members. Returns true, so a malformed slot is not also a type mismatch.
741
+ */
742
+ function checkValueSlot(ctx, slot, at) {
743
+ if (ctx.checkedSlots.has(slot)) return true;
744
+ ctx.checkedSlots.add(slot);
745
+ for (const key of only(slot, ['$slot']))
746
+ ctx.report(
747
+ 'KUI-V001',
748
+ `${at}`,
749
+ `a \`$slot\` in a prop value passes no "${key}"`,
750
+ );
751
+ if (typeof slot.$slot !== 'string' || !CAMEL.test(slot.$slot)) {
752
+ ctx.report('KUI-V001', at, 'a slot name is a camelCase identifier');
753
+ } else if (ctx.slots.get(slot.$slot)?.input) {
754
+ ctx.report(
755
+ 'KUI-V001',
756
+ at,
757
+ `slot "${slot.$slot}" declares an input, which a \`$slot\` in a prop value cannot pass`,
758
+ );
759
+ }
760
+ return true;
761
+ }
762
+
763
+ /**
764
+ * Why a `rootAttributes` key cannot appear in a document (KF-65FTKX: data-*
765
+ * only), or undefined. Documents carry lowercase `data-*` names only; the
766
+ * node marker and other `data-kerf-*` names, the row key (`data-key`), and
767
+ * the editor's `data-editor-*` hooks are reserved for the generated view.
768
+ */
769
+ export function dataAttributeProblem(key) {
770
+ if (!/^data-[a-z0-9]+(?:[-_.][a-z0-9]+)*$/.test(key))
771
+ return `"${key}" is not a lowercase data-* attribute name`;
772
+ if (/^data-(?:kerf-|editor-|key$)/.test(key))
773
+ return `"${key}" is reserved for the generated view and the editor`;
774
+ }
775
+
776
+ /**
777
+ * How a component carries application `data-*` attributes (the node marker
778
+ * and a row key): its `rootAttributes` prop, a Web Awesome element's own
779
+ * attributes, or nothing. A generated `dataChannel` field wins when present.
780
+ */
781
+ export function channelOf(component) {
782
+ if (component.dataChannel) return component.dataChannel;
783
+ if (component.source === 'webawesome') return 'attributes';
784
+ return component.props.some((prop) => prop.name === 'rootAttributes')
785
+ ? 'rootAttributes'
786
+ : 'none';
787
+ }
788
+
789
+ /** The prop a zone key fills: the composition zone's binding or the prop itself. */
790
+ export function zonePropOf(catalog, component, key) {
791
+ const entry = component.key.includes('#')
792
+ ? undefined
793
+ : catalog.entries.get(component.key);
794
+ const zone = entry?.zones?.find((item) => item.id === key && item.jsx?.prop);
795
+ return zone ? zone.jsx.prop : key;
796
+ }
797
+
798
+ /** A zone key's binding: the composition zone, or a content (`slot`) prop. */
799
+ function zonesOf(ctx, component) {
800
+ const zones = new Map();
801
+ const entry =
802
+ component.export && component.key.includes('#')
803
+ ? undefined
804
+ : ctx.catalog.entries.get(component.key);
805
+ for (const zone of entry?.zones ?? []) {
806
+ if (zone.jsx?.prop) zones.set(zone.id, { prop: zone.jsx.prop, zone });
807
+ }
808
+ for (const prop of component.props) {
809
+ if (prop.slot) {
810
+ zones.set(prop.name, {
811
+ prop: prop.name,
812
+ text: prop.type.acceptsText === true,
813
+ });
814
+ }
815
+ }
816
+ // A Web Awesome element's slots are its zones; its default slot is its
817
+ // children, and slotted text is ordinary light-DOM text.
818
+ for (const slot of component.slots ?? []) {
819
+ zones.set(slot.name, { prop: 'children', slot: slot.name, text: true });
820
+ }
821
+ for (const binding of zones.values()) {
822
+ if (binding.text === undefined) {
823
+ const prop = component.props.find((item) => item.name === binding.prop);
824
+ binding.text = prop?.type.acceptsText === true;
825
+ }
826
+ }
827
+ return zones;
828
+ }
829
+
830
+ function variantMatches(variant, present, literals) {
831
+ if (!variant.required.every((name) => present.has(name))) return false;
832
+ if (variant.forbidden.some((name) => present.has(name))) return false;
833
+ return Object.entries(variant.when ?? {}).every(([name, value]) => {
834
+ if (!present.has(name)) return value === false || value === undefined;
835
+ return !literals.has(name) || literals.get(name) === value;
836
+ });
837
+ }
838
+
839
+ // Callers pass only objects: checkChild classifies non-objects, and root and
840
+ // `$each` templates are checked for a `type` before they get here.
841
+ function checkNode(ctx, node, at, scope, rowScoped, parentKey, text = false) {
842
+ // A scoped run (validate-move.mjs) records where each node is checked:
843
+ // these arguments and the enclosing control.
844
+ const trace = ctx.trace;
845
+ trace?.entries?.set(node, [
846
+ at,
847
+ scope,
848
+ rowScoped,
849
+ parentKey,
850
+ text,
851
+ ctx.interactiveHost,
852
+ ]);
853
+ ctx.noteId(node.id, at);
854
+ if (node.type === '#text') {
855
+ for (const key of only(node, ['id', 'type', 'value']))
856
+ ctx.report('KUI-V001', `${at}.${key}`, 'unknown field on a text node');
857
+ if (!text) {
858
+ ctx.report(
859
+ 'KUI-V004',
860
+ at,
861
+ 'this zone does not take plain text; place a text component (such as Text) instead',
862
+ );
863
+ }
864
+ checkPropValue(
865
+ ctx,
866
+ { name: 'value', type: { kind: 'string' } },
867
+ node.value,
868
+ {},
869
+ scope,
870
+ `${at}.value`,
871
+ rowScoped,
872
+ );
873
+ return;
874
+ }
875
+ if (node.type === '#view') {
876
+ for (const key of only(node, ['id', 'type', 'src', 'props']))
877
+ ctx.report('KUI-V001', `${at}.${key}`, 'unknown field on a #view node');
878
+ checkView(ctx, node, at, scope, rowScoped);
879
+ return;
880
+ }
881
+ for (const key of only(node, ['id', 'type', 'name', 'props', 'zones']))
882
+ ctx.report('KUI-V001', `${at}.${key}`, 'unknown node field');
883
+ const resolved =
884
+ typeof node.type === 'string'
885
+ ? ctx.catalog.components.get(node.type)
886
+ : undefined;
887
+ if (!resolved) {
888
+ ctx.report(
889
+ 'KUI-V002',
890
+ `${at}.type`,
891
+ `unknown component type ${JSON.stringify(node.type)}`,
892
+ );
893
+ return;
894
+ }
895
+ const { component, definitions } = resolved;
896
+ const pkg = keyOf(node.type).slice(0, keyOf(node.type).lastIndexOf(':'));
897
+ if (ctx.packages && !ctx.packages.has(pkg)) {
898
+ ctx.report(
899
+ 'KUI-V002',
900
+ `${at}.type`,
901
+ `${pkg} is not listed in the document's catalogs`,
902
+ );
903
+ }
904
+ if (node.name !== undefined) {
905
+ ctx.noteName(node.name, at);
906
+ if (channelOf(component) === 'none') {
907
+ ctx.report(
908
+ 'KUI-V011',
909
+ `${at}.name`,
910
+ `${node.type} has no data-* channel for the node marker, so it cannot be named`,
911
+ );
912
+ }
913
+ }
914
+ const interactive = interactiveOf(ctx.catalog, node);
915
+ if (interactive && ctx.interactiveHost) {
916
+ ctx.report(
917
+ 'KUI-V014',
918
+ at,
919
+ `${node.type} renders a control or link, so it cannot sit inside ${ctx.interactiveHost}, which renders one itself`,
920
+ );
921
+ }
922
+ const host = ctx.interactiveHost;
923
+ if (interactive === 'root' && !host) ctx.interactiveHost = node.type;
924
+ if (trace?.shallow === node) trace.hostAfter = ctx.interactiveHost;
925
+ const zones = zonesOf(ctx, component);
926
+ // The component whose props are checked next, for a prop-typed param.
927
+ ctx.component = node.type;
928
+ const byName = new Map(component.props.map((prop) => [prop.name, prop]));
929
+ const native = new Set(component.nativeAttributes ?? []);
930
+ const present = new Set();
931
+ const literals = new Map();
932
+ if (node.props !== undefined && !isObject(node.props))
933
+ ctx.report('KUI-V001', `${at}.props`, '`props` is an object');
934
+ // A field zone fills a content field inside a prop value (KF-PD6QC5), so
935
+ // the prop is checked with the zone's placeholder in that field.
936
+ const ownProps = isObject(node.props) ? node.props : {};
937
+ const ownZones = isObject(node.zones) ? node.zones : {};
938
+ const filledProps = withFieldZones(
939
+ ownProps,
940
+ Object.fromEntries(
941
+ Object.entries(ownZones).filter(([, children]) =>
942
+ Array.isArray(children),
943
+ ),
944
+ ),
945
+ component,
946
+ definitions,
947
+ );
948
+ ctx.inProps = true;
949
+ for (const [name, value] of Object.entries(filledProps)) {
950
+ const propAt = `${at}.props.${name}`;
951
+ const prop = byName.get(name);
952
+ if ([...zones.values()].some((zone) => zone.zone && zone.prop === name)) {
953
+ ctx.report(
954
+ 'KUI-V003',
955
+ propAt,
956
+ `"${name}" is a zone; fill it through \`zones\``,
957
+ );
958
+ continue;
959
+ }
960
+ if (!prop && !native.has(name)) {
961
+ ctx.report('KUI-V003', propAt, `${node.type} has no prop "${name}"`);
962
+ continue;
963
+ }
964
+ present.add(name);
965
+ if (!isObject(value) || Array.isArray(value)) literals.set(name, value);
966
+ // A literal data-* channel names only unreserved data-* keys (KF-65FTKX).
967
+ if (
968
+ name === 'rootAttributes' &&
969
+ isObject(value) &&
970
+ !isBinding(value) &&
971
+ Object.keys(value).filter((key) => {
972
+ const problem = dataAttributeProblem(key);
973
+ if (problem) ctx.report('KUI-V015', `${propAt}.${key}`, problem);
974
+ return problem;
975
+ }).length
976
+ )
977
+ continue;
978
+ checkPropValue(
979
+ ctx,
980
+ prop ?? {
981
+ name,
982
+ type: {
983
+ kind: 'union',
984
+ members: [
985
+ { kind: 'string' },
986
+ { kind: 'number' },
987
+ { kind: 'boolean' },
988
+ ],
989
+ },
990
+ },
991
+ value,
992
+ definitions,
993
+ scope,
994
+ propAt,
995
+ rowScoped,
996
+ );
997
+ }
998
+ ctx.inProps = false;
999
+ if (node.zones !== undefined && !isObject(node.zones))
1000
+ ctx.report('KUI-V001', `${at}.zones`, '`zones` is an object');
1001
+ const shapes = new Map();
1002
+ for (const [zoneKey, children] of Object.entries(
1003
+ isObject(node.zones) ? node.zones : {},
1004
+ )) {
1005
+ const zoneAt = `${at}.zones.${zoneKey}`;
1006
+ const field = zones.has(zoneKey)
1007
+ ? undefined
1008
+ : fieldZoneOf(component, definitions, zoneKey);
1009
+ const binding = zones.get(zoneKey) ?? field;
1010
+ if (!binding) {
1011
+ ctx.report('KUI-V003', zoneAt, `${node.type} has no zone "${zoneKey}"`);
1012
+ continue;
1013
+ }
1014
+ if (!Array.isArray(children)) {
1015
+ ctx.report('KUI-V001', zoneAt, 'a zone is a list of children');
1016
+ continue;
1017
+ }
1018
+ if (field) {
1019
+ const own = ownProps[field.prop];
1020
+ if (isBinding(own)) {
1021
+ ctx.report(
1022
+ 'KUI-V003',
1023
+ zoneAt,
1024
+ `"${field.prop}" is bound, so a zone cannot fill "${zoneKey}"`,
1025
+ );
1026
+ } else if (
1027
+ field.path.reduce(
1028
+ (current, step) =>
1029
+ current === undefined || current === null
1030
+ ? undefined
1031
+ : current[step],
1032
+ own,
1033
+ ) !== undefined
1034
+ ) {
1035
+ ctx.report(
1036
+ 'KUI-V003',
1037
+ zoneAt,
1038
+ `"${zoneKey}" is set in both \`props\` and \`zones\``,
1039
+ );
1040
+ }
1041
+ } else if (isObject(node.props) && binding.prop in node.props) {
1042
+ ctx.report(
1043
+ 'KUI-V003',
1044
+ zoneAt,
1045
+ `"${binding.prop}" is set in both \`props\` and \`zones\``,
1046
+ );
1047
+ }
1048
+ // KF-YCM09F: an empty zone list is an explicit null, which a required
1049
+ // prop of a nullable type (SplitView's `detail` with nothing selected)
1050
+ // accepts; a zone left out entirely still leaves the prop missing.
1051
+ if (
1052
+ children.length > 0 ||
1053
+ (!field && byName.get(binding.prop)?.type?.nullable === true)
1054
+ )
1055
+ present.add(binding.prop);
1056
+ // A field inside a value another component renders (a view's toolbar
1057
+ // config) places its children in that component (KF-THTR71).
1058
+ const parent =
1059
+ (field && fieldParent(ctx, node, component, definitions, zoneKey)) ||
1060
+ node.type;
1061
+ // A shallow run checks the node alone, noting where a child appended to
1062
+ // `trace.zone` would be checked.
1063
+ if (trace?.shallow === node) {
1064
+ if (zoneKey === trace.zone)
1065
+ trace.child = [
1066
+ `${zoneAt}[${children.length - 1}]`,
1067
+ scope,
1068
+ rowScoped,
1069
+ parent,
1070
+ binding.text,
1071
+ ctx.interactiveHost,
1072
+ ];
1073
+ } else
1074
+ children.forEach((child, index) =>
1075
+ checkChild(
1076
+ ctx,
1077
+ child,
1078
+ `${zoneAt}[${index}]`,
1079
+ scope,
1080
+ rowScoped,
1081
+ parent,
1082
+ binding.text,
1083
+ ),
1084
+ );
1085
+ shapes.set(zoneKey, combine(children.map((child) => childShape(child))));
1086
+ }
1087
+ ctx.interactiveHost = host;
1088
+ if (component.variants) {
1089
+ if (
1090
+ !component.variants.some((variant) =>
1091
+ variantMatches(variant, present, literals),
1092
+ )
1093
+ ) {
1094
+ ctx.report(
1095
+ 'KUI-V004',
1096
+ at,
1097
+ `${node.type} props match none of its variants`,
1098
+ );
1099
+ }
1100
+ } else {
1101
+ for (const prop of component.props) {
1102
+ if (prop.required && !prop.variantOnly && !present.has(prop.name)) {
1103
+ ctx.report('KUI-V005', at, `${node.type} requires "${prop.name}"`);
1104
+ }
1105
+ }
1106
+ }
1107
+ checkComposition(ctx, node, at, parentKey, shapes, literals, zones);
1108
+ }
1109
+
1110
+ function checkChild(ctx, child, at, scope, rowScoped, parentKey, text = false) {
1111
+ if (!isObject(child)) {
1112
+ ctx.report('KUI-V001', at, 'a zone child is an object');
1113
+ return;
1114
+ }
1115
+ if ('$each' in child) {
1116
+ for (const key of only(child, ['$each', 'as', 'key', 'template']))
1117
+ ctx.report('KUI-V001', `${at}.${key}`, 'unknown `$each` field');
1118
+ // KF-CFA1S1: an inner `$each` in this document renders as a plain map, but
1119
+ // a document composed into another's row cannot know it is in one: its
1120
+ // module renders a keyed each(), which kerf refuses inside a row render.
1121
+ if (ctx.rowHost && !rowScoped) {
1122
+ ctx.report(
1123
+ 'KUI-V016',
1124
+ at,
1125
+ 'a document composed into an `$each` row cannot repeat; move the `$each` into the composing document',
1126
+ );
1127
+ }
1128
+ const source = dynamicType(ctx, child.$each, scope, `${at}.$each`);
1129
+ const list = source ? resolveType(source, {}) : undefined;
1130
+ if (source === null)
1131
+ ctx.report(
1132
+ 'KUI-V008',
1133
+ `${at}.$each`,
1134
+ '`$each` iterates a `$param` or `$bind`, not a literal',
1135
+ );
1136
+ else if (list && list.kind !== 'array')
1137
+ ctx.report(
1138
+ 'KUI-V008',
1139
+ `${at}.$each`,
1140
+ `\`$each\` needs an array, not ${describe(list)}`,
1141
+ );
1142
+ // kerf's each() keys rows by item identity, so items are objects.
1143
+ else if (
1144
+ list &&
1145
+ !['object', 'unknown', 'record'].includes(
1146
+ resolveType(list.items, {}).kind,
1147
+ )
1148
+ ) {
1149
+ ctx.report(
1150
+ 'KUI-V008',
1151
+ `${at}.$each`,
1152
+ '`$each` items are objects (each() keys rows by item identity)',
1153
+ );
1154
+ }
1155
+ if (
1156
+ typeof child.as !== 'string' ||
1157
+ !CAMEL.test(child.as) ||
1158
+ RESERVED_NAMES.has(child.as) ||
1159
+ ctx.params.has(child.as) ||
1160
+ scope.has(child.as)
1161
+ ) {
1162
+ ctx.report(
1163
+ 'KUI-V008',
1164
+ `${at}.as`,
1165
+ '`as` names the item with a camelCase identifier that is not reserved, a param, or an outer item',
1166
+ );
1167
+ return;
1168
+ }
1169
+ const inner = new Map(scope).set(
1170
+ child.as,
1171
+ list?.kind === 'array' ? list.items : { kind: 'unknown' },
1172
+ );
1173
+ const keyType =
1174
+ typeof child.key === 'string' && child.key.split('.')[0] === child.as
1175
+ ? bindingType(ctx, child.key, inner, `${at}.key`)
1176
+ : undefined;
1177
+ const keyKind = keyType && resolveType(keyType, {}).kind;
1178
+ if (!keyType || !['string', 'number', 'unknown'].includes(keyKind)) {
1179
+ ctx.report(
1180
+ 'KUI-V008',
1181
+ `${at}.key`,
1182
+ '`key` is a path on the item that resolves to a string or number',
1183
+ );
1184
+ }
1185
+ if (!isObject(child.template) || !('type' in child.template)) {
1186
+ ctx.report(
1187
+ 'KUI-V008',
1188
+ `${at}.template`,
1189
+ 'the template is exactly one node',
1190
+ );
1191
+ return;
1192
+ }
1193
+ const template = ctx.catalog.components.get(child.template.type);
1194
+ if (template && channelOf(template.component) === 'none') {
1195
+ ctx.report(
1196
+ 'KUI-V008',
1197
+ `${at}.template`,
1198
+ `${child.template.type} has no data-* channel to carry the row key`,
1199
+ );
1200
+ }
1201
+ checkNode(
1202
+ ctx,
1203
+ child.template,
1204
+ `${at}.template`,
1205
+ inner,
1206
+ true,
1207
+ parentKey,
1208
+ text,
1209
+ );
1210
+ return;
1211
+ }
1212
+ if ('$if' in child) {
1213
+ for (const key of only(child, ['$if', 'then', 'else']))
1214
+ ctx.report('KUI-V001', `${at}.${key}`, 'unknown `$if` field');
1215
+ checkPropValue(
1216
+ ctx,
1217
+ { name: 'condition', type: { kind: 'boolean' } },
1218
+ child.$if,
1219
+ {},
1220
+ scope,
1221
+ `${at}.$if`,
1222
+ rowScoped,
1223
+ );
1224
+ checkChild(
1225
+ ctx,
1226
+ child.then,
1227
+ `${at}.then`,
1228
+ scope,
1229
+ rowScoped,
1230
+ parentKey,
1231
+ text,
1232
+ );
1233
+ if ('else' in child)
1234
+ checkChild(
1235
+ ctx,
1236
+ child.else,
1237
+ `${at}.else`,
1238
+ scope,
1239
+ rowScoped,
1240
+ parentKey,
1241
+ text,
1242
+ );
1243
+ return;
1244
+ }
1245
+ if ('$slot' in child) {
1246
+ for (const key of only(child, ['$slot', 'input']))
1247
+ ctx.report('KUI-V001', `${at}.${key}`, 'unknown `$slot` field');
1248
+ if (typeof child.$slot !== 'string' || !CAMEL.test(child.$slot)) {
1249
+ ctx.report(
1250
+ 'KUI-V001',
1251
+ `${at}.$slot`,
1252
+ 'a slot name is a camelCase identifier',
1253
+ );
1254
+ return;
1255
+ }
1256
+ const declared = ctx.slots.get(child.$slot);
1257
+ const props = declared?.input?.props ?? [];
1258
+ if (child.input !== undefined && !declared?.input) {
1259
+ ctx.report(
1260
+ 'KUI-V001',
1261
+ `${at}.input`,
1262
+ `slot "${child.$slot}" declares no input`,
1263
+ );
1264
+ return;
1265
+ }
1266
+ const given = isObject(child.input) ? child.input : {};
1267
+ for (const prop of props) {
1268
+ if (!(prop.name in given)) {
1269
+ if (prop.required)
1270
+ ctx.report(
1271
+ 'KUI-V005',
1272
+ `${at}.input`,
1273
+ `slot "${child.$slot}" requires input "${prop.name}"`,
1274
+ );
1275
+ continue;
1276
+ }
1277
+ checkPropValue(
1278
+ ctx,
1279
+ prop,
1280
+ given[prop.name],
1281
+ {},
1282
+ scope,
1283
+ `${at}.input.${prop.name}`,
1284
+ rowScoped,
1285
+ );
1286
+ }
1287
+ for (const name of Object.keys(given)) {
1288
+ if (!props.some((prop) => prop.name === name))
1289
+ ctx.report(
1290
+ 'KUI-V003',
1291
+ `${at}.input.${name}`,
1292
+ `slot "${child.$slot}" has no input "${name}"`,
1293
+ );
1294
+ }
1295
+ return;
1296
+ }
1297
+ checkNode(ctx, child, at, scope, rowScoped, parentKey, text);
1298
+ }
1299
+
1300
+ function checkView(ctx, node, at, scope, rowScoped) {
1301
+ if (typeof node.src !== 'string' || node.src === '') {
1302
+ ctx.report(
1303
+ 'KUI-V012',
1304
+ `${at}.src`,
1305
+ 'a #view node names its document in `src`',
1306
+ );
1307
+ return;
1308
+ }
1309
+ if (!ctx.resolveView) return;
1310
+ if (ctx.viewStack.includes(node.src)) {
1311
+ ctx.report('KUI-V012', `${at}.src`, `#view "${node.src}" is cyclic`);
1312
+ return;
1313
+ }
1314
+ const child = ctx.resolveView(node.src);
1315
+ if (!isObject(child)) {
1316
+ ctx.report('KUI-V012', `${at}.src`, `#view "${node.src}" was not found`);
1317
+ return;
1318
+ }
1319
+ if (isObject(child.slots) && Object.keys(child.slots).length > 0) {
1320
+ ctx.report(
1321
+ 'KUI-V012',
1322
+ `${at}.src`,
1323
+ `#view "${node.src}" declares slots, which a composing document cannot fill`,
1324
+ );
1325
+ }
1326
+ const params = isObject(child.params) ? child.params : {};
1327
+ const given = isObject(node.props) ? node.props : {};
1328
+ for (const [name, value] of Object.entries(given)) {
1329
+ if (!isObject(params[name])) {
1330
+ ctx.report(
1331
+ 'KUI-V012',
1332
+ `${at}.props.${name}`,
1333
+ `#view "${node.src}" has no param "${name}"`,
1334
+ );
1335
+ continue;
1336
+ }
1337
+ checkPropValue(
1338
+ ctx,
1339
+ { name, type: params[name].type },
1340
+ value,
1341
+ {},
1342
+ scope,
1343
+ `${at}.props.${name}`,
1344
+ rowScoped,
1345
+ );
1346
+ }
1347
+ for (const [name, param] of Object.entries(params)) {
1348
+ if (isObject(param) && !('default' in param) && !(name in given)) {
1349
+ ctx.report(
1350
+ 'KUI-V012',
1351
+ at,
1352
+ `#view "${node.src}" requires param "${name}"`,
1353
+ );
1354
+ }
1355
+ }
1356
+ const nested = validateView(child, ctx.catalog, {
1357
+ resolveView: ctx.resolveView,
1358
+ icons: ctx.icons,
1359
+ viewStack: [...ctx.viewStack, node.src],
1360
+ // A composed document inside a control renders inside it too.
1361
+ interactiveHost: ctx.interactiveHost,
1362
+ // ... and one inside a row renders inside that row.
1363
+ rowHost: ctx.rowHost || rowScoped,
1364
+ });
1365
+ for (const diagnostic of nested.diagnostics) {
1366
+ ctx.report(
1367
+ diagnostic.code,
1368
+ `${at}{${node.src}}${diagnostic.path.slice(1)}`,
1369
+ diagnostic.message,
1370
+ );
1371
+ }
1372
+ for (const [name, actionScope] of nested.actions)
1373
+ ctx.noteAction(name, actionScope, at);
1374
+ }
1375
+
1376
+ // Zone shapes, as the ESLint rule computes them over JSX: how many direct
1377
+ // children a zone can hold at least and at most, and which ones.
1378
+ const shape = (min, max, items) => ({ min, max, items });
1379
+ function combine(shapes) {
1380
+ return shapes.reduce(
1381
+ (total, item) =>
1382
+ shape(total.min + item.min, total.max + item.max, [
1383
+ ...total.items,
1384
+ ...item.items,
1385
+ ]),
1386
+ shape(0, 0, []),
1387
+ );
1388
+ }
1389
+ function childShape(child) {
1390
+ if (!isObject(child)) return shape(0, 0, []);
1391
+ if ('$each' in child) {
1392
+ const template = isObject(child.template)
1393
+ ? childShape(child.template)
1394
+ : shape(0, 0, []);
1395
+ return shape(0, Number.POSITIVE_INFINITY, template.items);
1396
+ }
1397
+ if ('$if' in child) {
1398
+ const then = childShape(child.then);
1399
+ const otherwise =
1400
+ 'else' in child ? childShape(child.else) : shape(0, 0, []);
1401
+ return shape(
1402
+ Math.min(then.min, otherwise.min),
1403
+ Math.max(then.max, otherwise.max),
1404
+ [...then.items, ...otherwise.items],
1405
+ );
1406
+ }
1407
+ if ('$slot' in child || child.type === '#view') return shape(1, 1, []);
1408
+ if (child.type === '#text') return shape(1, 1, [{ label: 'text' }]);
1409
+ return shape(1, 1, [{ node: child }]);
1410
+ }
1411
+
1412
+ // Interactive content (HTML's button, a, input, label, and so on) cannot hold
1413
+ // more of it: the parser splits the host and the row contract breaks. An
1414
+ // entry's `content.interactive` rules say whether a node renders a control as
1415
+ // its root or inside it; `content.exports` does the same per JSX export.
1416
+ function interactiveOf(catalog, node) {
1417
+ const [base, exportName] = node.type.split('#');
1418
+ const content = catalog.entries.get(base)?.content;
1419
+ const rules = exportName
1420
+ ? content?.exports?.[exportName]?.interactive
1421
+ : content?.interactive;
1422
+ const props = isObject(node.props) ? node.props : {};
1423
+ const applies = (rule) =>
1424
+ !rule.whenProps ||
1425
+ rule.whenProps.some((name) => props[name] != null && props[name] !== false);
1426
+ const matched = (rules ?? []).filter(applies).map((rule) => rule.kind);
1427
+ return matched.includes('root') ? 'root' : matched[0];
1428
+ }
1429
+
1430
+ const conditionLabel = ({ prop, equals }) =>
1431
+ `\`${prop}=${JSON.stringify(equals)}\``;
1432
+
1433
+ function bringsInset(entry, node) {
1434
+ const geometry = entry?.layout?.geometry;
1435
+ if (
1436
+ !geometry ||
1437
+ !['margin', 'border', 'padding'].every((side) => geometry[side] === 'self')
1438
+ )
1439
+ return false;
1440
+ const props = isObject(node.props) ? node.props : {};
1441
+ return !(entry.insetFreeWhen ?? []).some((condition) => {
1442
+ const value = props[condition.prop];
1443
+ const known = !isObject(value);
1444
+ return !known || value === condition.equals;
1445
+ });
1446
+ }
1447
+
1448
+ function checkComposition(
1449
+ ctx,
1450
+ node,
1451
+ at,
1452
+ parentKey,
1453
+ shapes,
1454
+ literals,
1455
+ bindings,
1456
+ ) {
1457
+ const [base, exportName] = node.type.split('#');
1458
+ const entry = ctx.catalog.entries.get(base);
1459
+ if (!entry) return;
1460
+ const exportContract = exportName
1461
+ ? entry.jsxExports?.[exportName]
1462
+ : undefined;
1463
+ const rootsOf = (key) => ctx.catalog.entries.get(key)?.rendersAs ?? [key];
1464
+ const parents = exportName ? exportContract?.parents : entry.parents;
1465
+ if (parents?.mode === 'listed' && parentKey) {
1466
+ const parentRoots = rootsOf(keyOf(parentKey));
1467
+ if (!parentRoots.every((root) => parents.entries.includes(root))) {
1468
+ ctx.report(
1469
+ 'KUI-L201',
1470
+ at,
1471
+ `\`${node.type}\` requires one of these cataloged parents: ${parents.entries.join(', ')}`,
1472
+ );
1473
+ }
1474
+ }
1475
+ if (exportName) return;
1476
+ const insetCondition = (entry.insetFreeChildren ?? []).find(
1477
+ (condition) =>
1478
+ literals.has(condition.prop) &&
1479
+ literals.get(condition.prop) === condition.equals,
1480
+ );
1481
+ for (const zone of entry.zones ?? []) {
1482
+ if (!zone.jsx?.prop) continue;
1483
+ const found = shapes.get(zone.id) ?? shape(0, 0, []);
1484
+ const allowed = new Set(
1485
+ zone.accepts
1486
+ .map((accepted) =>
1487
+ accepted.includes(':') ? accepted : `${entry.package}:${accepted}`,
1488
+ )
1489
+ .filter((accepted) => ctx.catalog.entries.has(accepted)),
1490
+ );
1491
+ if (allowed.size) {
1492
+ for (const item of found.items) {
1493
+ const key = item.node
1494
+ ? item.node.type.includes('#')
1495
+ ? item.node.type.replace('#', ':')
1496
+ : item.node.type
1497
+ : undefined;
1498
+ const roots = key ? rootsOf(key) : [];
1499
+ if (!key || !roots.every((root) => allowed.has(root))) {
1500
+ ctx.report(
1501
+ 'KUI-L202',
1502
+ `${at}.zones.${zone.id}`,
1503
+ `\`${node.type}\` zone \`${zone.id}\` does not accept ${key ?? item.label}; catalog accepts: ${[...allowed].join(', ')}`,
1504
+ );
1505
+ }
1506
+ }
1507
+ }
1508
+ const { min, max } = zone.cardinality;
1509
+ if (found.max < min || (max !== 'unbounded' && found.min > max)) {
1510
+ ctx.report(
1511
+ 'KUI-L203',
1512
+ `${at}.zones.${zone.id}`,
1513
+ `\`${node.type}\` zone \`${zone.id}\` requires ${min}..${max} direct children; found ${found.max < min ? found.max : found.min}`,
1514
+ );
1515
+ }
1516
+ }
1517
+ // The inset rule reads the children region, whether the catalog binds it
1518
+ // as a zone or the component exposes it as a content prop.
1519
+ const childrenKey = [...bindings].find(
1520
+ ([, binding]) => binding.prop === 'children',
1521
+ )?.[0];
1522
+ const children = childrenKey ? shapes.get(childrenKey) : undefined;
1523
+ if (!insetCondition || !children) return;
1524
+ for (const item of children.items) {
1525
+ const childEntry = item.node && ctx.catalog.entries.get(item.node.type);
1526
+ if (!childEntry || !bringsInset(childEntry, item.node)) continue;
1527
+ const fix = childEntry.insetFreeWhen?.length
1528
+ ? `set ${childEntry.insetFreeWhen.map(conditionLabel).join(' or ')}`
1529
+ : 'use an inset-free child';
1530
+ ctx.report(
1531
+ 'KUI-L204',
1532
+ `${at}.zones.${childrenKey}`,
1533
+ `\`${item.node.type}\` brings its own content-item inset into \`${node.type}\` with ${conditionLabel(insetCondition)}, which expects inset-free content; ${fix}`,
1534
+ );
1535
+ }
1536
+ }
1537
+
1538
+ /**
1539
+ * Kerf UI's whole-screen layouts: each fills its parent's height and has no
1540
+ * height of its own, so below the root it collapses to its bar unless a
1541
+ * SizedRegion or another of these layouts gives it a height (KF-KQ72TW).
1542
+ */
1543
+ const SCREEN_LAYOUTS = new Set([
1544
+ '@kerfjs/ui:nav-stack',
1545
+ '@kerfjs/ui:split-view',
1546
+ '@kerfjs/ui:tab-navigator',
1547
+ '@kerfjs/ui:workbench',
1548
+ ]);
1549
+ const SIZED_REGION = '@kerfjs/ui:sized-region';
1550
+
1551
+ const PANE = '@kerfjs/ui:pane';
1552
+
1553
+ /**
1554
+ * Whether `node`'s `zone` gives a child a definite height. A SizedRegion or
1555
+ * another whole-screen layout always does. A Pane with a literal `fill: true`
1556
+ * gives its `content` zone one when the Pane itself sits in a sized place (the
1557
+ * root, inside a SizedRegion or layout), since its rows then have a height
1558
+ * (KF-AMEZB3: a filled root Pane sizes a nested layout).
1559
+ */
1560
+ function zoneSizes(node, zone, sized) {
1561
+ if (node.type === SIZED_REGION || SCREEN_LAYOUTS.has(node.type)) return true;
1562
+ return (
1563
+ sized &&
1564
+ node.type === PANE &&
1565
+ zone === 'content' &&
1566
+ isObject(node.props) &&
1567
+ node.props.fill === true
1568
+ );
1569
+ }
1570
+
1571
+ /**
1572
+ * `KUI-H001` hints (non-blocking): a whole-screen layout below the root whose
1573
+ * place has no definite height: its parent is not a SizedRegion, another
1574
+ * whole-screen layout, or a filled Pane's content in a sized place. `sized`
1575
+ * is whether `node` itself sits in a place with a definite height.
1576
+ */
1577
+ function hintUnsizedLayouts(node, at, sized, hints, isRoot = false) {
1578
+ if (!isObject(node) || typeof node.type !== 'string') return;
1579
+ if (!isRoot && !sized && SCREEN_LAYOUTS.has(node.type))
1580
+ hints.push({
1581
+ code: 'KUI-H001',
1582
+ path: at,
1583
+ message: `${node.type} has no height of its own here and collapses to its bar; wrap it in ${SIZED_REGION}`,
1584
+ });
1585
+ const child = (item, path, childSized) => {
1586
+ if (!isObject(item)) return;
1587
+ if ('$each' in item) child(item.template, `${path}.template`, childSized);
1588
+ else if ('$if' in item) {
1589
+ child(item.then, `${path}.then`, childSized);
1590
+ if ('else' in item) child(item.else, `${path}.else`, childSized);
1591
+ } else hintUnsizedLayouts(item, path, childSized, hints);
1592
+ };
1593
+ for (const [zone, children] of Object.entries(
1594
+ isObject(node.zones) ? node.zones : {},
1595
+ )) {
1596
+ const childSized = zoneSizes(node, zone, sized);
1597
+ if (Array.isArray(children))
1598
+ children.forEach((item, index) =>
1599
+ child(item, `${at}.zones.${zone}[${index}]`, childSized),
1600
+ );
1601
+ }
1602
+ }
1603
+
1604
+ /**
1605
+ * Validates a view document. Returns `{ valid, diagnostics, hints, actions }`,
1606
+ * where each diagnostic is `{ code, path, message }` (a `KUI-V###` document id
1607
+ * or a `KUI-L201`–`L204` composition id) and `actions` maps each action name
1608
+ * to its `row` or `view` scope. `hints` are non-blocking `KUI-H###` advice
1609
+ * about a valid document (a nested layout with no height); they never make it
1610
+ * invalid. `options.resolveView(src)` loads a composed document; without it,
1611
+ * `#view` nodes are checked for shape only.
1612
+ */
1613
+ export function validateView(document, catalog, options = {}) {
1614
+ return runView(document, catalog, options);
1615
+ }
1616
+
1617
+ /**
1618
+ * A validation context: the options, a diagnostics sink, and the id, name,
1619
+ * and action tables. A `trace` marks a scoped run (validate-move.mjs): it
1620
+ * records each action use, and a `quiet` one leaves conflicts to its caller.
1621
+ */
1622
+ function createContext(catalog, options, trace) {
1623
+ const diagnostics = [];
1624
+ const ids = new Map();
1625
+ const names = new Map();
1626
+ const actions = new Map();
1627
+ const ctx = {
1628
+ catalog,
1629
+ diagnostics,
1630
+ actions,
1631
+ trace,
1632
+ resolveView: options.resolveView,
1633
+ icons: options.icons ? new Set(options.icons) : undefined,
1634
+ viewStack: options.viewStack ?? [],
1635
+ params: new Map(),
1636
+ slots: new Map(),
1637
+ checkedSlots: new WeakSet(),
1638
+ nestedDynamics: new WeakMap(),
1639
+ packages: undefined,
1640
+ interactiveHost: options.interactiveHost,
1641
+ rowHost: options.rowHost === true,
1642
+ report(code, path, message) {
1643
+ diagnostics.push({ code, path, message });
1644
+ },
1645
+ noteId(id, at) {
1646
+ if (typeof id !== 'string' || !ULID.test(id)) {
1647
+ ctx.report('KUI-V006', `${at}.id`, 'a node id is a 26-character ULID');
1648
+ } else if (ids.has(id)) {
1649
+ ctx.report(
1650
+ 'KUI-V006',
1651
+ `${at}.id`,
1652
+ `duplicate node id ${id} (first at ${ids.get(id)})`,
1653
+ );
1654
+ } else ids.set(id, at);
1655
+ },
1656
+ noteName(name, at) {
1657
+ if (typeof name !== 'string' || !CAMEL.test(name)) {
1658
+ ctx.report(
1659
+ 'KUI-V006',
1660
+ `${at}.name`,
1661
+ 'a node name is a camelCase identifier',
1662
+ );
1663
+ } else if (names.has(name)) {
1664
+ ctx.report(
1665
+ 'KUI-V006',
1666
+ `${at}.name`,
1667
+ `duplicate node name "${name}" (first at ${names.get(name)})`,
1668
+ );
1669
+ } else names.set(name, at);
1670
+ },
1671
+ noteAction(name, scope, at) {
1672
+ if (trace) {
1673
+ trace.notes.push([name, scope]);
1674
+ if (trace.quiet) return;
1675
+ }
1676
+ const seen = actions.get(name);
1677
+ if (seen && seen !== scope) {
1678
+ ctx.report(
1679
+ 'KUI-V009',
1680
+ at,
1681
+ `action "${name}" is used with both row and view scope`,
1682
+ );
1683
+ } else actions.set(name, scope);
1684
+ },
1685
+ };
1686
+ return ctx;
1687
+ }
1688
+
1689
+ /**
1690
+ * Checks a document's own fields, params, and slots into `ctx`, which then
1691
+ * knows them. False when the document is not an object.
1692
+ */
1693
+ function checkHeader(ctx, document) {
1694
+ if (!isObject(document)) {
1695
+ ctx.report('KUI-V001', '$', 'a view document is a JSON object');
1696
+ return false;
1697
+ }
1698
+ for (const key of only(document, [
1699
+ '$schema',
1700
+ 'schema',
1701
+ 'name',
1702
+ 'catalogs',
1703
+ 'params',
1704
+ 'slots',
1705
+ 'root',
1706
+ ])) {
1707
+ ctx.report('KUI-V001', `$.${key}`, 'unknown top-level field');
1708
+ }
1709
+ if (document.schema !== VIEW_DOCUMENT_SCHEMA_ID) {
1710
+ ctx.report(
1711
+ 'KUI-V001',
1712
+ '$.schema',
1713
+ `schema must be "${VIEW_DOCUMENT_SCHEMA_ID}"`,
1714
+ );
1715
+ }
1716
+ if (typeof document.name !== 'string' || !PASCAL.test(document.name)) {
1717
+ ctx.report('KUI-V001', '$.name', 'name is a PascalCase identifier');
1718
+ }
1719
+ if (
1720
+ !Array.isArray(document.catalogs) ||
1721
+ document.catalogs.some((item) => typeof item !== 'string')
1722
+ ) {
1723
+ ctx.report(
1724
+ 'KUI-V001',
1725
+ '$.catalogs',
1726
+ 'catalogs is a list of package names or catalog paths',
1727
+ );
1728
+ } else {
1729
+ // Only package names can be checked here; a path's package is the caller's
1730
+ // to resolve, so a document naming any path skips the package check.
1731
+ const pathLike = document.catalogs.some(
1732
+ (item) => item.startsWith('.') || item.startsWith('/'),
1733
+ );
1734
+ if (!pathLike) ctx.packages = new Set(document.catalogs);
1735
+ }
1736
+ for (const [name, param] of Object.entries(
1737
+ isObject(document.params) ? document.params : {},
1738
+ )) {
1739
+ const at = `$.params.${name}`;
1740
+ if (!CAMEL.test(name) || !isObject(param)) {
1741
+ ctx.report(
1742
+ 'KUI-V001',
1743
+ at,
1744
+ 'a param is a camelCase name mapped to `{ type, default? }`',
1745
+ );
1746
+ continue;
1747
+ }
1748
+ for (const key of only(param, ['type', 'default', 'description']))
1749
+ ctx.report('KUI-V001', `${at}.${key}`, 'unknown param field');
1750
+ validateDeclaredType(ctx, param.type, `${at}.type`);
1751
+ // A prop-typed param's default is a literal of that prop (KF-V9V2B6: a
1752
+ // Select's choices promoted with their current list).
1753
+ const owner =
1754
+ param.type?.kind === 'prop'
1755
+ ? ctx.catalog.components.get(param.type.component)
1756
+ : undefined;
1757
+ const ownerProp = owner?.component.props.find(
1758
+ (prop) => prop.name === param.type.prop,
1759
+ );
1760
+ if (
1761
+ 'default' in param &&
1762
+ PARAM_KINDS.has(param.type?.kind) &&
1763
+ !(ownerProp
1764
+ ? isLiteralOf(param.default, ownerProp.type, owner.definitions)
1765
+ : isLiteralOf(param.default, param.type))
1766
+ ) {
1767
+ ctx.report(
1768
+ 'KUI-V004',
1769
+ `${at}.default`,
1770
+ `the default is not a valid ${describe(param.type)}`,
1771
+ );
1772
+ }
1773
+ ctx.params.set(name, param);
1774
+ }
1775
+ if (document.params !== undefined && !isObject(document.params))
1776
+ ctx.report('KUI-V001', '$.params', 'params is an object');
1777
+ for (const [name, slot] of Object.entries(
1778
+ isObject(document.slots) ? document.slots : {},
1779
+ )) {
1780
+ const at = `$.slots.${name}`;
1781
+ if (!CAMEL.test(name) || !isObject(slot)) {
1782
+ ctx.report(
1783
+ 'KUI-V001',
1784
+ at,
1785
+ 'a slot is a camelCase name mapped to `{ input? }`',
1786
+ );
1787
+ continue;
1788
+ }
1789
+ for (const key of only(slot, ['input', 'description']))
1790
+ ctx.report('KUI-V001', `${at}.${key}`, 'unknown slot field');
1791
+ if (slot.input !== undefined) {
1792
+ if (slot.input?.kind !== 'object')
1793
+ ctx.report('KUI-V001', `${at}.input`, 'a slot input is an object type');
1794
+ else validateDeclaredType(ctx, slot.input, `${at}.input`);
1795
+ }
1796
+ ctx.slots.set(name, slot);
1797
+ }
1798
+ return true;
1799
+ }
1800
+
1801
+ /**
1802
+ * `validateView` with an optional `trace` (validate-move.mjs): its
1803
+ * `entries` map, when given, records where each node is checked. Internal.
1804
+ */
1805
+ export function runView(document, catalog, options, trace) {
1806
+ const ctx = createContext(catalog, options, trace);
1807
+ const { diagnostics, actions } = ctx;
1808
+ if (!checkHeader(ctx, document))
1809
+ return { valid: false, diagnostics, hints: [], actions };
1810
+ // KF-PK3GVY: an editor's empty draft has no root yet; it is a document,
1811
+ // but nothing can generate or render it until a component becomes one.
1812
+ if (document.root === undefined) {
1813
+ ctx.report(
1814
+ 'KUI-V017',
1815
+ '$.root',
1816
+ 'the document has no root; add a component to start it',
1817
+ );
1818
+ } else if (!isObject(document.root) || !('type' in document.root)) {
1819
+ ctx.report('KUI-V001', '$.root', 'root is exactly one node');
1820
+ } else {
1821
+ checkNode(ctx, document.root, '$.root', new Map(), false, undefined);
1822
+ }
1823
+ const hints = [];
1824
+ hintUnsizedLayouts(document.root, '$.root', true, hints, true);
1825
+ return { valid: diagnostics.length === 0, diagnostics, hints, actions };
1826
+ }
1827
+
1828
+ /**
1829
+ * Checks pieces of `document` alone (KF-SFAA5R: scoped move validation), as
1830
+ * `validateView(document, catalog)` checks them in the place `entry`
1831
+ * describes (an `entries` record of a traced run). Returns a function that
1832
+ * checks `item`, a node (or, with `asChild`, any zone child) and its
1833
+ * subtree, or, with `shallow`, the node alone, noting where a child appended
1834
+ * to `zone` would be checked. Action conflicts and duplicate ids and names
1835
+ * are left to the caller: each run has its own tables. Internal.
1836
+ */
1837
+ export function createScopedCheck(document, catalog) {
1838
+ const header = createContext(catalog, {});
1839
+ checkHeader(header, document);
1840
+ return (item, entry, { asChild = false, shallow = false, zone } = {}) => {
1841
+ const trace = {
1842
+ quiet: true,
1843
+ notes: [],
1844
+ shallow: shallow ? item : undefined,
1845
+ zone,
1846
+ child: undefined,
1847
+ hostAfter: undefined,
1848
+ };
1849
+ const ctx = createContext(catalog, {}, trace);
1850
+ ctx.params = header.params;
1851
+ ctx.slots = header.slots;
1852
+ ctx.packages = header.packages;
1853
+ ctx.interactiveHost = entry[5];
1854
+ (asChild ? checkChild : checkNode)(ctx, item, ...entry.slice(0, 5));
1855
+ return { ...trace, diagnostics: ctx.diagnostics };
1856
+ };
1857
+ }
1858
+
1859
+ /**
1860
+ * What a parent's checks read of node `node` as its child: its type and
1861
+ * whether it brings its own content-item inset (`KUI-L204`). Internal.
1862
+ */
1863
+ export const childFacts = (catalog, node) =>
1864
+ `${node.type} ${bringsInset(catalog.entries.get(node.type), node)}`;