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

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 (518) hide show
  1. package/README.md +6 -0
  2. package/ai/application-ui-diagnostic-ids-v1.json +1 -0
  3. package/ai/component-catalog.json +168 -7
  4. package/ai/component-catalog.schema.json +14 -1
  5. package/ai/component-composition.json +97 -6
  6. package/ai/component-props.json +447 -40
  7. package/ai/components/README.md +1 -0
  8. package/ai/components/combobox.md +1 -1
  9. package/ai/components/gauge.md +83 -0
  10. package/ai/components/segmented-control.md +1 -0
  11. package/ai/components/surface-scaffold.md +19 -5
  12. package/ai/components/tab-bar.md +2 -0
  13. package/ai/components/toolbar.md +1 -0
  14. package/ai/public-api-signatures-v1.md +345 -295
  15. package/ai/skill.md +36 -27
  16. package/ai/view-document.schema.json +55 -2
  17. package/ai/webawesome-jsx-signatures-v1.md +1 -1
  18. package/analyzer/cli.mjs +60 -24
  19. package/analyzer/index.mjs +331 -58
  20. package/catalog-projection-cli.mjs +86 -50
  21. package/dist/anchored-surface.js +2 -1
  22. package/dist/browser/editor.js +11 -8
  23. package/dist/browser/gauge.js +3 -0
  24. package/dist/browser/segmented-control.js +1 -0
  25. package/dist/catalog-resources.d.ts +1 -1
  26. package/dist/catalog.d.ts +1 -1
  27. package/dist/catalog.js +7 -7
  28. package/dist/{chunk-VX3YF2UD.js → chunk-3K5V3ZSD.js} +3 -3
  29. package/dist/{chunk-VX3YF2UD.js.map → chunk-3K5V3ZSD.js.map} +1 -1
  30. package/dist/chunk-3SCGTP5O.js +682 -0
  31. package/dist/chunk-3SCGTP5O.js.map +1 -0
  32. package/dist/{chunk-3JOEJT2Z.js → chunk-3ZKUXWAV.js} +4 -4
  33. package/dist/chunk-3ZKUXWAV.js.map +1 -0
  34. package/dist/{chunk-ADMWT7FX.js → chunk-3ZWYGGEC.js} +136 -8
  35. package/dist/chunk-3ZWYGGEC.js.map +1 -0
  36. package/dist/{chunk-KLR3DCHH.js → chunk-4L5ZIKDZ.js} +1 -1
  37. package/dist/chunk-4L5ZIKDZ.js.map +1 -0
  38. package/dist/{chunk-2E7S5C4D.js → chunk-4UWLHKNU.js} +5 -5
  39. package/dist/chunk-4UWLHKNU.js.map +1 -0
  40. package/dist/{chunk-EXGDKG7B.js → chunk-5A2DN3LR.js} +5 -5
  41. package/dist/chunk-5A2DN3LR.js.map +1 -0
  42. package/dist/{chunk-DJ65XFVN.js → chunk-63TJH2RF.js} +4 -4
  43. package/dist/chunk-63TJH2RF.js.map +1 -0
  44. package/dist/{chunk-Q2CLQ3IJ.js → chunk-6PHG2DMG.js} +1 -1
  45. package/dist/chunk-6PHG2DMG.js.map +1 -0
  46. package/dist/{chunk-SPI6VMIY.js → chunk-6T7AX365.js} +4 -4
  47. package/dist/chunk-6T7AX365.js.map +1 -0
  48. package/dist/{chunk-GVII4JSD.js → chunk-6V6UHPJD.js} +4 -4
  49. package/dist/chunk-6V6UHPJD.js.map +1 -0
  50. package/dist/{chunk-2LM3PYHA.js → chunk-C2TY5DJC.js} +11 -8
  51. package/dist/chunk-C2TY5DJC.js.map +1 -0
  52. package/dist/{chunk-3WYREXW4.js → chunk-COMEWURO.js} +8 -6
  53. package/dist/chunk-COMEWURO.js.map +1 -0
  54. package/dist/{chunk-VPDSPD76.js → chunk-DB64I3DB.js} +4 -3
  55. package/dist/chunk-DB64I3DB.js.map +1 -0
  56. package/dist/{chunk-SBCXWGNP.js → chunk-DBCDYBZP.js} +2 -2
  57. package/dist/{chunk-SBCXWGNP.js.map → chunk-DBCDYBZP.js.map} +1 -1
  58. package/dist/{chunk-CNM6ZWP2.js → chunk-DJWBXEF4.js} +4 -2
  59. package/dist/chunk-DJWBXEF4.js.map +1 -0
  60. package/dist/{chunk-7AUZG5EW.js → chunk-E2MTHHLS.js} +3 -3
  61. package/dist/{chunk-7AUZG5EW.js.map → chunk-E2MTHHLS.js.map} +1 -1
  62. package/dist/{chunk-JG4ONAOI.js → chunk-EI55KWHP.js} +2 -2
  63. package/dist/chunk-EI55KWHP.js.map +1 -0
  64. package/dist/{chunk-MVKHSAKE.js → chunk-GE2BQXB3.js} +41 -4
  65. package/dist/chunk-GE2BQXB3.js.map +1 -0
  66. package/dist/{chunk-KELWWCMX.js → chunk-I2K4OQKB.js} +4 -4
  67. package/dist/chunk-I2K4OQKB.js.map +1 -0
  68. package/dist/chunk-IFDTSVE6.js +9 -0
  69. package/dist/chunk-IFDTSVE6.js.map +1 -0
  70. package/dist/{chunk-TPLVC5BE.js → chunk-IR32NI2O.js} +336 -247
  71. package/dist/chunk-IR32NI2O.js.map +1 -0
  72. package/dist/{chunk-ZKKO4MHC.js → chunk-JYKP7TBZ.js} +4 -2
  73. package/dist/chunk-JYKP7TBZ.js.map +1 -0
  74. package/dist/{chunk-F3PZGFEA.js → chunk-K3C35KGR.js} +4 -4
  75. package/dist/chunk-K3C35KGR.js.map +1 -0
  76. package/dist/{chunk-4RECPEHI.js → chunk-KBS3GP6S.js} +4 -3
  77. package/dist/chunk-KBS3GP6S.js.map +1 -0
  78. package/dist/{chunk-YHRJNKD5.js → chunk-KS7EXW4P.js} +6 -4
  79. package/dist/chunk-KS7EXW4P.js.map +1 -0
  80. package/dist/{chunk-V6N3YLTM.js → chunk-LTOTL5AS.js} +3 -3
  81. package/dist/chunk-LTOTL5AS.js.map +1 -0
  82. package/dist/chunk-M64TAGZY.js +590 -0
  83. package/dist/chunk-M64TAGZY.js.map +1 -0
  84. package/dist/{chunk-JZZVWTUB.js → chunk-MMOQR426.js} +2 -2
  85. package/dist/chunk-MMOQR426.js.map +1 -0
  86. package/dist/{chunk-SJBMKA4X.js → chunk-OHT2AXER.js} +11 -10
  87. package/dist/chunk-OHT2AXER.js.map +1 -0
  88. package/dist/{chunk-4Z4QSTRF.js → chunk-OZKBIPXU.js} +38 -5
  89. package/dist/chunk-OZKBIPXU.js.map +1 -0
  90. package/dist/{chunk-Q2SLOMN6.js → chunk-RHMY45DK.js} +4 -4
  91. package/dist/chunk-RHMY45DK.js.map +1 -0
  92. package/dist/{chunk-BZXA5SSA.js → chunk-S7QB5KMM.js} +2 -2
  93. package/dist/{chunk-BZXA5SSA.js.map → chunk-S7QB5KMM.js.map} +1 -1
  94. package/dist/{chunk-HDXUHLTQ.js → chunk-SHECA2N4.js} +8 -2
  95. package/dist/chunk-SHECA2N4.js.map +1 -0
  96. package/dist/{chunk-R6FIXYAE.js → chunk-SJEPM5ZU.js} +2 -2
  97. package/dist/{chunk-R6FIXYAE.js.map → chunk-SJEPM5ZU.js.map} +1 -1
  98. package/dist/{chunk-FJMABKKV.js → chunk-UQ4FRQ6M.js} +35 -17
  99. package/dist/chunk-UQ4FRQ6M.js.map +1 -0
  100. package/dist/{chunk-S4ZGTDSG.js → chunk-UU37OR3D.js} +2 -2
  101. package/dist/chunk-UU37OR3D.js.map +1 -0
  102. package/dist/{chunk-SWXWLSUD.js → chunk-WEQNPYVA.js} +1 -1
  103. package/dist/{chunk-SWXWLSUD.js.map → chunk-WEQNPYVA.js.map} +1 -1
  104. package/dist/{chunk-5SFHBYEY.js → chunk-WUVHP3UC.js} +97 -24
  105. package/dist/chunk-WUVHP3UC.js.map +1 -0
  106. package/dist/{chunk-3S3WXAZ5.js → chunk-X43QQWVC.js} +3 -2
  107. package/dist/chunk-X43QQWVC.js.map +1 -0
  108. package/dist/{chunk-Z3T24FX3.js → chunk-YE6KCAIN.js} +3 -2
  109. package/dist/chunk-YE6KCAIN.js.map +1 -0
  110. package/dist/{chunk-BCO673YW.js → chunk-Z3BT2SZE.js} +3 -3
  111. package/dist/chunk-Z3BT2SZE.js.map +1 -0
  112. package/dist/{chunk-NYNNNEAU.js → chunk-ZC4KSRAF.js} +7 -7
  113. package/dist/chunk-ZC4KSRAF.js.map +1 -0
  114. package/dist/collapsible-panel.d.ts +2 -2
  115. package/dist/collapsible-panel.js +2 -2
  116. package/dist/collapsible-panel.js.map +1 -1
  117. package/dist/column-explorer.d.ts +2 -2
  118. package/dist/column-explorer.js +2 -2
  119. package/dist/column-explorer.js.map +1 -1
  120. package/dist/dialog-surface-controller-BeKZ3e8Z.d.ts +251 -0
  121. package/dist/editor-frame.d.ts +1 -1
  122. package/dist/editor-frame.js +1 -1
  123. package/dist/editor.d.ts +38 -20
  124. package/dist/editor.js +10869 -6993
  125. package/dist/editor.js.map +1 -1
  126. package/dist/file-picker.js +1 -1
  127. package/dist/gauge.d.ts +73 -0
  128. package/dist/gauge.js +157 -0
  129. package/dist/gauge.js.map +1 -0
  130. package/dist/help-tags-register.js +2 -1
  131. package/dist/help-tags-register.js.map +1 -1
  132. package/dist/index.d.ts +2 -1
  133. package/dist/index.js +29 -28
  134. package/dist/list-action-row.d.ts +1 -1
  135. package/dist/list-action-row.js +1 -1
  136. package/dist/list-detail-dialog.d.ts +7 -7
  137. package/dist/list-detail-dialog.js +6 -5
  138. package/dist/list-detail-dialog.js.map +1 -1
  139. package/dist/list-header.d.ts +1 -1
  140. package/dist/list-header.js +1 -1
  141. package/dist/list-item.d.ts +1 -1
  142. package/dist/list-item.js +1 -1
  143. package/dist/message-composer.js +1 -1
  144. package/dist/nav-stack.d.ts +6 -6
  145. package/dist/nav-stack.js +1 -1
  146. package/dist/popup-menu-register.js +1 -7
  147. package/dist/popup-menu-register.js.map +1 -1
  148. package/dist/popup-menu.d.ts +2 -2
  149. package/dist/popup-menu.js +1 -1
  150. package/dist/resizable-region.js +1 -1
  151. package/dist/segmented-control.d.ts +22 -1
  152. package/dist/segmented-control.js +3 -1
  153. package/dist/select-register.js +17 -23
  154. package/dist/select-register.js.map +1 -1
  155. package/dist/split-view.d.ts +6 -6
  156. package/dist/split-view.js +1 -1
  157. package/dist/styles/badge.css +39 -0
  158. package/dist/styles/collapsible-panel.css +34 -25
  159. package/dist/styles/components/actions/popup-menu/popup-menu.css +4 -4
  160. package/dist/styles/components/actions/toolbar/toolbar.css +34 -1
  161. package/dist/styles/components/actions/toolbar-control-group/toolbar-control-group.css +1 -1
  162. package/dist/styles/components/feedback/badge/badge.css +39 -0
  163. package/dist/styles/components/feedback/gauge/gauge.css +132 -0
  164. package/dist/styles/components/forms/segmented-control/segmented-control.css +17 -1
  165. package/dist/styles/components/layout/collapsible-panel/collapsible-panel.css +34 -25
  166. package/dist/styles/components/layout/split-view/split-view.css +19 -33
  167. package/dist/styles/components/navigation/nav-stack/nav-stack.css +15 -19
  168. package/dist/styles/components/navigation/tab-navigator/tab-navigator.css +30 -29
  169. package/dist/styles/components/surfaces/editor-frame/editor-frame.css +2 -2
  170. package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +259 -4
  171. package/dist/styles/editor/editor.css +55 -0
  172. package/dist/styles/editor-frame.css +2 -2
  173. package/dist/styles/gauge.css +132 -0
  174. package/dist/styles/nav-stack.css +15 -19
  175. package/dist/styles/popup-menu.css +4 -4
  176. package/dist/styles/segmented-control.css +17 -1
  177. package/dist/styles/split-view.css +19 -33
  178. package/dist/styles/styles.css +1 -0
  179. package/dist/styles/surface-scaffold.css +259 -4
  180. package/dist/styles/tab-navigator.css +30 -29
  181. package/dist/styles/toolbar-control-group.css +1 -1
  182. package/dist/styles/toolbar.css +34 -1
  183. package/dist/styles/webawesome.css +4 -5
  184. package/dist/surface-scaffold-register.js +2 -1
  185. package/dist/surface-scaffold-register.js.map +1 -1
  186. package/dist/surface-scaffold.d.ts +153 -246
  187. package/dist/surface-scaffold.js +3 -2
  188. package/dist/toolbar-control-group.d.ts +2 -2
  189. package/dist/toolbar-control-group.js +1 -1
  190. package/dist/toolbar.d.ts +6 -1
  191. package/dist/toolbar.js +1 -1
  192. package/dist/tree-list.d.ts +2 -2
  193. package/dist/tree-list.js +1 -1
  194. package/dist/wire-catalog.d.ts +1 -1
  195. package/dist/wire-catalog.js +3 -2
  196. package/dist/wire-catalog.js.map +1 -1
  197. package/dist/wire-checkboxes.js +2 -1
  198. package/dist/wire-choice-chips.js +2 -1
  199. package/dist/wire-color-fields.js +2 -1
  200. package/dist/wire-color-pickers.js +2 -1
  201. package/dist/wire-comboboxes.d.ts +2 -0
  202. package/dist/wire-comboboxes.js +2 -1
  203. package/dist/wire-content-items.js +2 -1
  204. package/dist/wire-corner-status.js +2 -1
  205. package/dist/wire-nav-stack.js +2 -1
  206. package/dist/wire-overlay-sheets.js +2 -1
  207. package/dist/wire-paged-views.js +2 -2
  208. package/dist/wire-paged-views.js.map +1 -1
  209. package/dist/wire-resizable-regions.js +2 -1
  210. package/dist/wire-scroll-dividers.js +1 -1
  211. package/dist/wire-search-fields.js +2 -1
  212. package/dist/wire-sidebar.js +2 -1
  213. package/dist/wire-tab-bars.d.ts +41 -2
  214. package/dist/wire-tab-bars.js +1 -1
  215. package/dist/wire-tab-navigator.js +2 -1
  216. package/dist/wire-tag-fields.js +2 -1
  217. package/dist/wire-workbench.js +2 -1
  218. package/dist/workbench-dialog.d.ts +7 -7
  219. package/dist/workbench-dialog.js +5 -4
  220. package/dist/workbench-dialog.js.map +1 -1
  221. package/dist/workbench.d.ts +1 -1
  222. package/dist/workbench.js +1 -1
  223. package/docs/accessibility.md +3 -6
  224. package/docs/component-contract.md +47 -7
  225. package/docs/component-selection.md +90 -79
  226. package/docs/design/sketch/Kerf-UI.sketch +0 -0
  227. package/docs/design/sketch/README.md +1 -1
  228. package/docs/design/sketch/content/README.md +8 -8
  229. package/docs/design/sketch/coverage.md +7 -5
  230. package/docs/design/sketch/unified/README.md +1 -1
  231. package/docs/design/sketch/unified/pages/content.png +0 -0
  232. package/docs/design/templates/button/full-width-dark.svg +1 -1
  233. package/docs/design/templates/button/full-width.svg +1 -1
  234. package/docs/design/templates/button/icons-dark.svg +1 -1
  235. package/docs/design/templates/button/icons.svg +1 -1
  236. package/docs/design/templates/button/pill-dark.svg +1 -1
  237. package/docs/design/templates/button/pill.svg +1 -1
  238. package/docs/design/templates/button/toggles-dark.svg +1 -1
  239. package/docs/design/templates/button/toggles.svg +1 -1
  240. package/docs/design/templates/button-dark.svg +1 -1
  241. package/docs/design/templates/button.svg +1 -1
  242. package/docs/design/templates/checkbox/compact-dark.svg +1 -1
  243. package/docs/design/templates/checkbox/compact.svg +1 -1
  244. package/docs/design/templates/checkbox/mixed-dark.svg +1 -1
  245. package/docs/design/templates/checkbox/mixed.svg +1 -1
  246. package/docs/design/templates/checkbox/states-dark.svg +1 -1
  247. package/docs/design/templates/checkbox/states.svg +1 -1
  248. package/docs/design/templates/checkbox-dark.svg +1 -1
  249. package/docs/design/templates/checkbox-group/vertical-dark.svg +1 -1
  250. package/docs/design/templates/checkbox-group/vertical.svg +1 -1
  251. package/docs/design/templates/checkbox-group-dark.svg +1 -1
  252. package/docs/design/templates/checkbox-group.svg +1 -1
  253. package/docs/design/templates/checkbox.svg +1 -1
  254. package/docs/design/templates/chip/tags-dark.svg +1 -1
  255. package/docs/design/templates/chip/tags.svg +1 -1
  256. package/docs/design/templates/chip-dark.svg +1 -1
  257. package/docs/design/templates/chip.svg +1 -1
  258. package/docs/design/templates/choice-chips/compact-icons-dark.svg +1 -1
  259. package/docs/design/templates/choice-chips/compact-icons.svg +1 -1
  260. package/docs/design/templates/choice-chips-dark.svg +1 -1
  261. package/docs/design/templates/choice-chips.svg +1 -1
  262. package/docs/design/templates/color-field/compact-dark.svg +1 -1
  263. package/docs/design/templates/color-field/compact.svg +1 -1
  264. package/docs/design/templates/color-field/error-dark.svg +1 -1
  265. package/docs/design/templates/color-field/error.svg +1 -1
  266. package/docs/design/templates/color-field/hint-dark.svg +1 -1
  267. package/docs/design/templates/color-field/hint.svg +1 -1
  268. package/docs/design/templates/color-field-dark.svg +1 -1
  269. package/docs/design/templates/color-field.svg +1 -1
  270. package/docs/design/templates/color-picker/gray-dark.svg +1 -1
  271. package/docs/design/templates/color-picker/gray.svg +1 -1
  272. package/docs/design/templates/color-picker/hsb-dark.svg +1 -1
  273. package/docs/design/templates/color-picker/hsb.svg +1 -1
  274. package/docs/design/templates/color-picker/rgb-dark.svg +1 -1
  275. package/docs/design/templates/color-picker/rgb.svg +1 -1
  276. package/docs/design/templates/color-picker-dark.svg +1 -1
  277. package/docs/design/templates/color-picker.svg +1 -1
  278. package/docs/design/templates/disclosure/embedded-dark.svg +1 -1
  279. package/docs/design/templates/disclosure/embedded.svg +1 -1
  280. package/docs/design/templates/disclosure/framed-sunken-dark.svg +1 -1
  281. package/docs/design/templates/disclosure/framed-sunken.svg +1 -1
  282. package/docs/design/templates/disclosure/plain-dark.svg +1 -1
  283. package/docs/design/templates/disclosure/plain.svg +1 -1
  284. package/docs/design/templates/disclosure-dark.svg +1 -1
  285. package/docs/design/templates/disclosure.svg +1 -1
  286. package/docs/design/templates/empty-state/filtered-dark.svg +1 -1
  287. package/docs/design/templates/empty-state/filtered.svg +1 -1
  288. package/docs/design/templates/empty-state/with-action-dark.svg +1 -1
  289. package/docs/design/templates/empty-state/with-action.svg +1 -1
  290. package/docs/design/templates/empty-state-dark.svg +1 -1
  291. package/docs/design/templates/empty-state.svg +1 -1
  292. package/docs/design/templates/gauge/bare-dark.svg +1 -0
  293. package/docs/design/templates/gauge/bare.svg +1 -0
  294. package/docs/design/templates/gauge/full-dark.svg +1 -0
  295. package/docs/design/templates/gauge/full.svg +1 -0
  296. package/docs/design/templates/gauge-dark.svg +1 -0
  297. package/docs/design/templates/gauge.svg +1 -0
  298. package/docs/design/templates/list/compact-dark.svg +1 -1
  299. package/docs/design/templates/list/compact.svg +1 -1
  300. package/docs/design/templates/list/stack-dark.svg +1 -1
  301. package/docs/design/templates/list/stack.svg +1 -1
  302. package/docs/design/templates/list-action-row/default-dark.svg +1 -1
  303. package/docs/design/templates/list-action-row/default.svg +1 -1
  304. package/docs/design/templates/list-action-row/icon-tile-dark.svg +1 -1
  305. package/docs/design/templates/list-action-row/icon-tile.svg +1 -1
  306. package/docs/design/templates/list-action-row/selected-dark.svg +1 -1
  307. package/docs/design/templates/list-action-row/selected.svg +1 -1
  308. package/docs/design/templates/list-action-row/trailing-menu-dark.svg +1 -1
  309. package/docs/design/templates/list-action-row/trailing-menu.svg +1 -1
  310. package/docs/design/templates/list-action-row-dark.svg +1 -1
  311. package/docs/design/templates/list-action-row.svg +1 -1
  312. package/docs/design/templates/list-dark.svg +1 -1
  313. package/docs/design/templates/list-header/action-dark.svg +1 -1
  314. package/docs/design/templates/list-header/action.svg +1 -1
  315. package/docs/design/templates/list-header/inline-action-dark.svg +1 -1
  316. package/docs/design/templates/list-header/inline-action.svg +1 -1
  317. package/docs/design/templates/list-header/toggle-collapsed-dark.svg +1 -1
  318. package/docs/design/templates/list-header/toggle-collapsed.svg +1 -1
  319. package/docs/design/templates/list-header/toggle-expanded-dark.svg +1 -1
  320. package/docs/design/templates/list-header/toggle-expanded.svg +1 -1
  321. package/docs/design/templates/list-header-dark.svg +1 -1
  322. package/docs/design/templates/list-header.svg +1 -1
  323. package/docs/design/templates/list-item/default-dark.svg +1 -1
  324. package/docs/design/templates/list-item/default.svg +1 -1
  325. package/docs/design/templates/list-item/icon-tile-dark.svg +1 -1
  326. package/docs/design/templates/list-item/icon-tile.svg +1 -1
  327. package/docs/design/templates/list-item/multiline-dark.svg +1 -1
  328. package/docs/design/templates/list-item/multiline.svg +1 -1
  329. package/docs/design/templates/list-item/selected-dark.svg +1 -1
  330. package/docs/design/templates/list-item/selected.svg +1 -1
  331. package/docs/design/templates/list-item/trailing-dark.svg +1 -1
  332. package/docs/design/templates/list-item/trailing.svg +1 -1
  333. package/docs/design/templates/list-item-dark.svg +1 -1
  334. package/docs/design/templates/list-item.svg +1 -1
  335. package/docs/design/templates/list.svg +1 -1
  336. package/docs/design/templates/progress-ring/sizes-dark.svg +1 -1
  337. package/docs/design/templates/progress-ring/sizes.svg +1 -1
  338. package/docs/design/templates/progress-ring/tones-dark.svg +1 -1
  339. package/docs/design/templates/progress-ring/tones.svg +1 -1
  340. package/docs/design/templates/progress-ring-dark.svg +1 -1
  341. package/docs/design/templates/progress-ring.svg +1 -1
  342. package/docs/design/templates/search-field/empty-dark.svg +1 -1
  343. package/docs/design/templates/search-field/empty.svg +1 -1
  344. package/docs/design/templates/search-field/tokens-dark.svg +1 -1
  345. package/docs/design/templates/search-field/tokens.svg +1 -1
  346. package/docs/design/templates/search-field-dark.svg +1 -1
  347. package/docs/design/templates/search-field.svg +1 -1
  348. package/docs/design/templates/segmented-control/equal-dark.svg +1 -1
  349. package/docs/design/templates/segmented-control/equal.svg +1 -1
  350. package/docs/design/templates/segmented-control/pill-small-dark.svg +1 -1
  351. package/docs/design/templates/segmented-control/pill-small.svg +1 -1
  352. package/docs/design/templates/segmented-control-dark.svg +1 -1
  353. package/docs/design/templates/segmented-control.svg +1 -1
  354. package/docs/design/templates/select/compact-dark.svg +1 -1
  355. package/docs/design/templates/select/compact.svg +1 -1
  356. package/docs/design/templates/select/form-dark.svg +1 -1
  357. package/docs/design/templates/select/form.svg +1 -1
  358. package/docs/design/templates/select/icons-dark.svg +1 -1
  359. package/docs/design/templates/select/icons.svg +1 -1
  360. package/docs/design/templates/select-dark.svg +1 -1
  361. package/docs/design/templates/select.svg +1 -1
  362. package/docs/design/templates/split-button/full-width-dark.svg +1 -1
  363. package/docs/design/templates/split-button/full-width.svg +1 -1
  364. package/docs/design/templates/split-button/pill-dark.svg +1 -1
  365. package/docs/design/templates/split-button/pill.svg +1 -1
  366. package/docs/design/templates/split-button/states-dark.svg +1 -1
  367. package/docs/design/templates/split-button/states.svg +1 -1
  368. package/docs/design/templates/split-button/tones-dark.svg +1 -1
  369. package/docs/design/templates/split-button/tones.svg +1 -1
  370. package/docs/design/templates/split-button-dark.svg +1 -1
  371. package/docs/design/templates/split-button.svg +1 -1
  372. package/docs/design/templates/state-banner/danger-dark.svg +1 -1
  373. package/docs/design/templates/state-banner/danger.svg +1 -1
  374. package/docs/design/templates/state-banner/info-badge-dark.svg +1 -1
  375. package/docs/design/templates/state-banner/info-badge.svg +1 -1
  376. package/docs/design/templates/state-banner/info-dark.svg +1 -1
  377. package/docs/design/templates/state-banner/info.svg +1 -1
  378. package/docs/design/templates/state-banner/strip-dark.svg +1 -1
  379. package/docs/design/templates/state-banner/strip.svg +1 -1
  380. package/docs/design/templates/state-banner/success-dark.svg +1 -1
  381. package/docs/design/templates/state-banner/success.svg +1 -1
  382. package/docs/design/templates/state-banner/warning-dark.svg +1 -1
  383. package/docs/design/templates/state-banner/warning.svg +1 -1
  384. package/docs/design/templates/state-banner-dark.svg +1 -1
  385. package/docs/design/templates/state-banner.svg +1 -1
  386. package/docs/design/templates/tab-bar/workspace-tabs-dark.svg +1 -1
  387. package/docs/design/templates/tab-bar/workspace-tabs.svg +1 -1
  388. package/docs/design/templates/tab-bar-dark.svg +1 -1
  389. package/docs/design/templates/tab-bar.svg +1 -1
  390. package/docs/design/templates/tag-field/error-dark.svg +1 -1
  391. package/docs/design/templates/tag-field/error.svg +1 -1
  392. package/docs/design/templates/tag-field/tags-dark.svg +1 -1
  393. package/docs/design/templates/tag-field/tags.svg +1 -1
  394. package/docs/design/templates/tag-field-dark.svg +1 -1
  395. package/docs/design/templates/tag-field.svg +1 -1
  396. package/docs/design/templates/text-field/labeled-dark.svg +1 -1
  397. package/docs/design/templates/text-field/labeled.svg +1 -1
  398. package/docs/design/templates/text-field/search-dark.svg +1 -1
  399. package/docs/design/templates/text-field/search.svg +1 -1
  400. package/docs/design/templates/text-field-dark.svg +1 -1
  401. package/docs/design/templates/text-field.svg +1 -1
  402. package/docs/design/templates/toolbar/title-and-actions-dark.svg +1 -1
  403. package/docs/design/templates/toolbar/title-and-actions.svg +1 -1
  404. package/docs/design/templates/toolbar/width-visibility-320-dark.svg +1 -1
  405. package/docs/design/templates/toolbar/width-visibility-320.svg +1 -1
  406. package/docs/design/templates/toolbar/width-visibility-600-dark.svg +1 -1
  407. package/docs/design/templates/toolbar/width-visibility-600.svg +1 -1
  408. package/docs/design/templates/toolbar-control-group/borderless-single-dark.svg +1 -1
  409. package/docs/design/templates/toolbar-control-group/borderless-single.svg +1 -1
  410. package/docs/design/templates/toolbar-control-group/glass-dark.svg +1 -1
  411. package/docs/design/templates/toolbar-control-group/glass.svg +1 -1
  412. package/docs/design/templates/toolbar-control-group/icon-buttons-dark.svg +1 -1
  413. package/docs/design/templates/toolbar-control-group/icon-buttons.svg +1 -1
  414. package/docs/design/templates/toolbar-control-group/icon-tile-brand-dark.svg +1 -1
  415. package/docs/design/templates/toolbar-control-group/icon-tile-brand.svg +1 -1
  416. package/docs/design/templates/toolbar-control-group/icon-tile-danger-dark.svg +1 -1
  417. package/docs/design/templates/toolbar-control-group/icon-tile-danger.svg +1 -1
  418. package/docs/design/templates/toolbar-control-group/icon-tile-neutral-dark.svg +1 -1
  419. package/docs/design/templates/toolbar-control-group/icon-tile-neutral.svg +1 -1
  420. package/docs/design/templates/toolbar-control-group/icon-tile-success-dark.svg +1 -1
  421. package/docs/design/templates/toolbar-control-group/icon-tile-success.svg +1 -1
  422. package/docs/design/templates/toolbar-control-group/icon-tile-warning-dark.svg +1 -1
  423. package/docs/design/templates/toolbar-control-group/icon-tile-warning.svg +1 -1
  424. package/docs/design/templates/toolbar-control-group/push-buttons-dark.svg +1 -1
  425. package/docs/design/templates/toolbar-control-group/push-buttons.svg +1 -1
  426. package/docs/design/templates/toolbar-control-group/with-text-dark.svg +1 -1
  427. package/docs/design/templates/toolbar-control-group/with-text.svg +1 -1
  428. package/docs/design/templates/toolbar-control-group-dark.svg +1 -1
  429. package/docs/design/templates/toolbar-control-group.svg +1 -1
  430. package/docs/design/templates/toolbar-dark.svg +1 -1
  431. package/docs/design/templates/toolbar.svg +1 -1
  432. package/docs/design/templates/tree-list/files-dark.svg +1 -1
  433. package/docs/design/templates/tree-list/files.svg +1 -1
  434. package/docs/design/templates/tree-list/outline-dark.svg +1 -1
  435. package/docs/design/templates/tree-list/outline.svg +1 -1
  436. package/docs/design/templates/tree-list-dark.svg +1 -1
  437. package/docs/design/templates/tree-list.svg +1 -1
  438. package/docs/design/templates/value-table/details-dark.svg +1 -1
  439. package/docs/design/templates/value-table/details.svg +1 -1
  440. package/docs/design/templates/value-table-dark.svg +1 -1
  441. package/docs/design/templates/value-table.svg +1 -1
  442. package/docs/design/templates.md +5 -4
  443. package/docs/editor-frame.md +1 -1
  444. package/docs/editor-host.md +15 -2
  445. package/docs/gauge.md +55 -0
  446. package/docs/overlay-tooltip.md +1 -1
  447. package/docs/progress.md +3 -2
  448. package/docs/recipes.md +1 -1
  449. package/docs/surface-scaffold.md +63 -2
  450. package/docs/ui-analyzer.md +42 -0
  451. package/docs/ui-doctor.md +45 -1
  452. package/docs/ui-evaluator.md +35 -0
  453. package/docs/ux-demo.md +1 -1
  454. package/docs/view.md +295 -0
  455. package/docs/webawesome-theme.md +16 -0
  456. package/doctor/cli.mjs +36 -31
  457. package/doctor/index.mjs +349 -162
  458. package/evaluator/cli.mjs +36 -30
  459. package/llms.txt +27 -5
  460. package/package.json +10 -2
  461. package/props/cli.mjs +47 -21
  462. package/scripts/lib/cli-args.mjs +98 -0
  463. package/ux-demo/recipes/compact-toolbar.tsx +1 -1
  464. package/ux-demo/recipes/loading-inspector.tsx +1 -1
  465. package/view/catalog.mjs +229 -0
  466. package/view/child-kind.mjs +22 -0
  467. package/view/cli.mjs +142 -119
  468. package/view/contract.mjs +84 -11
  469. package/view/css-grammar.mjs +93 -0
  470. package/view/generate.d.mts +16 -0
  471. package/view/generate.mjs +122 -43
  472. package/view/index.d.mts +80 -14
  473. package/view/index.mjs +5 -9
  474. package/view/interpret.mjs +104 -36
  475. package/view/types.mjs +161 -0
  476. package/view/validate-move.mjs +66 -30
  477. package/view/validate.mjs +420 -654
  478. package/vite-editor.d.mts +16 -1
  479. package/vite-editor.mjs +74 -4
  480. package/dist/chunk-2E7S5C4D.js.map +0 -1
  481. package/dist/chunk-2LM3PYHA.js.map +0 -1
  482. package/dist/chunk-3JOEJT2Z.js.map +0 -1
  483. package/dist/chunk-3S3WXAZ5.js.map +0 -1
  484. package/dist/chunk-3WYREXW4.js.map +0 -1
  485. package/dist/chunk-4RECPEHI.js.map +0 -1
  486. package/dist/chunk-4Z4QSTRF.js.map +0 -1
  487. package/dist/chunk-5SFHBYEY.js.map +0 -1
  488. package/dist/chunk-ADMWT7FX.js.map +0 -1
  489. package/dist/chunk-BCO673YW.js.map +0 -1
  490. package/dist/chunk-CNM6ZWP2.js.map +0 -1
  491. package/dist/chunk-DJ65XFVN.js.map +0 -1
  492. package/dist/chunk-EXGDKG7B.js.map +0 -1
  493. package/dist/chunk-F3PZGFEA.js.map +0 -1
  494. package/dist/chunk-FJMABKKV.js.map +0 -1
  495. package/dist/chunk-GVII4JSD.js.map +0 -1
  496. package/dist/chunk-HDXUHLTQ.js.map +0 -1
  497. package/dist/chunk-JG4ONAOI.js.map +0 -1
  498. package/dist/chunk-JZZVWTUB.js.map +0 -1
  499. package/dist/chunk-KELWWCMX.js.map +0 -1
  500. package/dist/chunk-KLR3DCHH.js.map +0 -1
  501. package/dist/chunk-LD6A6PYB.js +0 -268
  502. package/dist/chunk-LD6A6PYB.js.map +0 -1
  503. package/dist/chunk-MVKHSAKE.js.map +0 -1
  504. package/dist/chunk-NYNNNEAU.js.map +0 -1
  505. package/dist/chunk-Q2CLQ3IJ.js.map +0 -1
  506. package/dist/chunk-Q2SLOMN6.js.map +0 -1
  507. package/dist/chunk-S4ZGTDSG.js.map +0 -1
  508. package/dist/chunk-SJBMKA4X.js.map +0 -1
  509. package/dist/chunk-SPI6VMIY.js.map +0 -1
  510. package/dist/chunk-TPLVC5BE.js.map +0 -1
  511. package/dist/chunk-V6N3YLTM.js.map +0 -1
  512. package/dist/chunk-VNT4MXR5.js +0 -548
  513. package/dist/chunk-VNT4MXR5.js.map +0 -1
  514. package/dist/chunk-VPDSPD76.js.map +0 -1
  515. package/dist/chunk-YHRJNKD5.js.map +0 -1
  516. package/dist/chunk-Z3T24FX3.js.map +0 -1
  517. package/dist/chunk-ZKKO4MHC.js.map +0 -1
  518. package/dist/{nav-stack-DwxpXxqJ.d.ts → nav-stack-vQ3ieerq.d.ts} +3 -3
package/view/generate.mjs CHANGED
@@ -13,11 +13,13 @@ import {
13
13
  import {
14
14
  channelOf,
15
15
  fieldZoneOf,
16
- parseCssCall,
17
16
  withFieldZones,
18
17
  ZoneFill,
19
18
  zonePropOf,
20
- } from './validate.mjs';
19
+ } from './catalog.mjs';
20
+ import { childKind } from './child-kind.mjs';
21
+ import { parseCssCall } from './css-grammar.mjs';
22
+ import { composedViewPath, eachNodes } from './validate.mjs';
21
23
 
22
24
  export const GENERATOR_VERSION = 1;
23
25
  const HEADER_LINES = 3;
@@ -256,6 +258,16 @@ function createEmitter(document, catalog, imports, importFrom) {
256
258
  return raw(literal(input));
257
259
  };
258
260
 
261
+ // KF-EP2152: the document root's key is the render function's optional
262
+ // `rowKey` argument, given when a composing document renders this one as a
263
+ // row; every other row root's key is an expression over its item.
264
+ const ROOT_KEY = Symbol('root key');
265
+ const keyEntries = (rowKey) => {
266
+ if (rowKey === ROOT_KEY)
267
+ return [["...(rowKey === undefined ? {} : { 'data-key': rowKey })"]];
268
+ return rowKey ? [["'data-key'", raw(`String(${rowKey})`)]] : [];
269
+ };
270
+
259
271
  /** Marker (and row key) attributes merged into a node's data-* channel. */
260
272
  const markers = (node, rowKey, base, scope) => {
261
273
  const entries = [];
@@ -266,7 +278,7 @@ function createEmitter(document, catalog, imports, importFrom) {
266
278
  entries.push([`...${flat(value(base, scope))}`]);
267
279
  }
268
280
  entries.push(["'data-kerf-node'", raw(literal(node.id))]);
269
- if (rowKey) entries.push(["'data-key'", raw(`String(${rowKey})`)]);
281
+ entries.push(...keyEntries(rowKey));
270
282
  return obj(entries);
271
283
  };
272
284
 
@@ -278,41 +290,77 @@ function createEmitter(document, catalog, imports, importFrom) {
278
290
  };
279
291
 
280
292
  const childExpr = (child, scope, slot) => {
281
- if ('$each' in child) {
282
- const inner = new Map(scope).set(child.as, true);
283
- const template = nodeExpr(child.template, inner, child.key, slot);
284
- // Scope holds only `$each` items, so a non-empty scope is a row
285
- // template. kerf never reconciles a list inside a row (a keyed each()
286
- // there throws), so an inner repeat is a plain map that re-renders with
287
- // its row (KF-CFA1S1).
288
- if (scope.size > 0) {
289
- return call(
290
- `${flat(value(child.$each, scope))}.map((${child.as}) => `,
291
- template,
293
+ switch (childKind(child)) {
294
+ case 'each':
295
+ return eachExpr(child, scope, slot);
296
+ case 'if': {
297
+ const otherwise =
298
+ 'else' in child ? childExpr(child.else, scope, slot) : raw('null');
299
+ return cond(
300
+ flat(value(child.$if, scope)),
301
+ childExpr(child.then, scope, slot),
302
+ otherwise,
292
303
  );
293
304
  }
294
- imports.value('kerfjs', 'each');
305
+ case 'slot':
306
+ return isObject(child.input)
307
+ ? call(`slots.${child.$slot}(`, value(child.input, scope))
308
+ : raw(`slots.${child.$slot}()`);
309
+ default:
310
+ return nodeExpr(child, scope, undefined, slot);
311
+ }
312
+ };
313
+
314
+ const eachExpr = (child, scope, slot) => {
315
+ const inner = new Map(scope).set(child.as, true);
316
+ const template =
317
+ 'templates' in child
318
+ ? kindExpr(child, inner, child.key, slot)
319
+ : rowExpr(child.template, inner, child.key, slot);
320
+ // Scope holds only `$each` items, so a non-empty scope is a row
321
+ // template. kerf never reconciles a list inside a row (a keyed each()
322
+ // there throws), so an inner repeat is a plain map that re-renders with
323
+ // its row (KF-CFA1S1).
324
+ if (scope.size > 0) {
295
325
  return call(
296
- `each(${flat(value(child.$each, scope))}, (${child.as}) => `,
326
+ `${flat(value(child.$each, scope))}.map((${child.as}) => `,
297
327
  template,
298
- `, { key: ${literal(child.template.id)} })`,
299
328
  );
300
329
  }
301
- if ('$if' in child) {
302
- const otherwise =
303
- 'else' in child ? childExpr(child.else, scope, slot) : raw('null');
304
- return cond(
305
- flat(value(child.$if, scope)),
306
- childExpr(child.then, scope, slot),
307
- otherwise,
330
+ imports.value('kerfjs', 'each');
331
+ return call(
332
+ `each(${flat(value(child.$each, scope))}, (${child.as}) => `,
333
+ template,
334
+ `, { key: ${literal(eachNodes(child)[0].id)} })`,
335
+ );
336
+ };
337
+
338
+ // A row: the template node, or the branch its `$if` chain picks per item
339
+ // (KF-8J8E5V). Every branch is a keyed node, and `else` is required.
340
+ const rowExpr = (template, scope, rowKey, slot) =>
341
+ '$if' in template
342
+ ? cond(
343
+ flat(value(template.$if, scope)),
344
+ rowExpr(template.then, scope, rowKey, slot),
345
+ rowExpr(template.else, scope, rowKey, slot),
346
+ )
347
+ : nodeExpr(template, scope, rowKey, slot);
348
+
349
+ // KF-YX6HMT: the template an item's `kind` picks from `templates`, one
350
+ // comparison per kind in document order, with `default` for the rest.
351
+ const kindExpr = (child, scope, rowKey, slot) => {
352
+ const kind = flat(value(child.kind, scope));
353
+ return Object.entries(child.templates)
354
+ .filter(([name]) => name !== 'default')
355
+ .reduceRight(
356
+ (otherwise, [name, node]) =>
357
+ cond(
358
+ `${kind} === ${literal(name)}`,
359
+ nodeExpr(node, scope, rowKey, slot),
360
+ otherwise,
361
+ ),
362
+ nodeExpr(child.templates.default, scope, rowKey, slot),
308
363
  );
309
- }
310
- if ('$slot' in child) {
311
- return isObject(child.input)
312
- ? call(`slots.${child.$slot}(`, value(child.input, scope))
313
- : raw(`slots.${child.$slot}()`);
314
- }
315
- return nodeExpr(child, scope, undefined, slot);
316
364
  };
317
365
 
318
366
  const nodeExpr = (node, scope, rowKey, slot) => {
@@ -332,6 +380,20 @@ function createEmitter(document, catalog, imports, importFrom) {
332
380
  const child = document.views[node.src];
333
381
  const names = namesOf(child.name);
334
382
  imports.value(viewImport(node.src), names.render);
383
+ // A composed row's root carries the row's key (KF-EP2152); a composed
384
+ // document has no slots, so the second argument is always empty.
385
+ if (rowKey === ROOT_KEY)
386
+ return call(
387
+ `${names.render}(`,
388
+ value(node.props ?? {}, scope),
389
+ ', {}, rowKey)',
390
+ );
391
+ if (rowKey)
392
+ return call(
393
+ `${names.render}(`,
394
+ value(node.props ?? {}, scope),
395
+ `, {}, String(${rowKey}))`,
396
+ );
335
397
  return call(`${names.render}(`, value(node.props ?? {}, scope));
336
398
  }
337
399
  const { component: definition, definitions } = catalog.components.get(
@@ -351,7 +413,7 @@ function createEmitter(document, catalog, imports, importFrom) {
351
413
  }
352
414
  if (definition.source === 'webawesome') {
353
415
  entries.push(["'data-kerf-node'", raw(literal(node.id))]);
354
- if (rowKey) entries.push(["'data-key'", raw(`String(${rowKey})`)]);
416
+ entries.push(...keyEntries(rowKey));
355
417
  if (slot) entries.push(['slot', raw(literal(slot))]);
356
418
  const parts = Object.keys(zones)
357
419
  .sort()
@@ -386,7 +448,7 @@ function createEmitter(document, catalog, imports, importFrom) {
386
448
  } else if (channel === 'native') {
387
449
  // The component passes data-* props straight through to its root.
388
450
  entries.push(["'data-kerf-node'", raw(literal(node.id))]);
389
- if (rowKey) entries.push(["'data-key'", raw(`String(${rowKey})`)]);
451
+ entries.push(...keyEntries(rowKey));
390
452
  }
391
453
  imports.value(
392
454
  moduleSpecifier(definition.import, importFrom),
@@ -395,7 +457,7 @@ function createEmitter(document, catalog, imports, importFrom) {
395
457
  return call(`${definition.export}(`, obj(entries));
396
458
  };
397
459
 
398
- return { root: (node) => nodeExpr(node, new Map(), undefined, undefined) };
460
+ return { root: (node) => nodeExpr(node, new Map(), ROOT_KEY, undefined) };
399
461
  }
400
462
 
401
463
  function typesBlock(name, contract, inputType = (input) => input.type) {
@@ -456,6 +518,11 @@ function typesBlock(name, contract, inputType = (input) => input.type) {
456
518
  .join('\n')}\n}`
457
519
  : `export type ${name}Refs = Readonly<Record<string, never>>;`,
458
520
  );
521
+ // KF-YX6HMT: the kinds a `templates` repeat renders, by its item name.
522
+ for (const [as, kinds] of Object.entries(contract.kinds ?? {}))
523
+ lines.push(
524
+ `/** The \`kind\` values with a row design of their own; any other takes \`default\`. */\nexport type ${name}${as[0].toUpperCase()}${as.slice(1)}Kind = ${kinds.map(literal).join(' | ')};`,
525
+ );
459
526
  return lines.join('\n\n');
460
527
  }
461
528
 
@@ -480,7 +547,7 @@ function functionsBlock(name, contract, rootExpr, ts) {
480
547
  const slotsDefault =
481
548
  Object.keys(contract.slots).length === 0 ? ' = {}' : '';
482
549
  blocks.push(
483
- `export function render${name}(inputs${t(`: ${name}Inputs`)}${inputsDefault}, slots${t(`: ${name}Slots`)}${slotsDefault})${t(': SafeHtml')} {\n${unused(rootExpr, 'inputs', 'slots')} return ${rootExpr};\n}`,
550
+ `export function render${name}(inputs${t(`: ${name}Inputs`)}${inputsDefault}, slots${t(`: ${name}Slots`)}${slotsDefault}, rowKey${t('?: string')})${t(': SafeHtml')} {\n${unused(rootExpr, 'inputs', 'slots', 'rowKey')} return ${rootExpr};\n}`,
484
551
  );
485
552
  }
486
553
  const handlerLines = actions.map(([key, scope]) => {
@@ -530,7 +597,7 @@ function declarationsBlock(name, contract, includeRender) {
530
597
  : '';
531
598
  const slotsDefault = Object.keys(contract.slots).length === 0 ? '?' : '';
532
599
  lines.push(
533
- `export declare function render${name}(inputs${inputsDefault}: ${name}Inputs, slots${slotsDefault}: ${name}Slots): SafeHtml;`,
600
+ `export declare function render${name}(inputs${inputsDefault}: ${name}Inputs, slots${slotsDefault}: ${name}Slots, rowKey?: string): SafeHtml;`,
534
601
  );
535
602
  }
536
603
  lines.push(
@@ -544,7 +611,7 @@ function declarationsBlock(name, contract, includeRender) {
544
611
 
545
612
  /**
546
613
  * Generates a view module. `options.source` names the document file in the
547
- * header; `options.resolveView(src)` loads composed documents (required when
614
+ * header; `options.resolveView(src, path)` loads composed documents (required when
548
615
  * the document has `#view` nodes); `options.target` is `ts` (default) or `js`;
549
616
  * `options.declarationsOnly` omits `render<Name>` for documents an app loads
550
617
  * at runtime through `interpretView`.
@@ -567,14 +634,26 @@ export function generateView(document, catalog, options = {}) {
567
634
  const views = {};
568
635
  const collectViews = (node) => {
569
636
  if (!isObject(node)) return;
570
- if (node.type === '#view') views[node.src] = options.resolveView(node.src);
637
+ if (node.type === '#view')
638
+ views[node.src] = options.resolveView(
639
+ node.src,
640
+ composedViewPath(undefined, node.src),
641
+ );
571
642
  for (const list of Object.values(isObject(node.zones) ? node.zones : {})) {
572
643
  for (const child of list) {
573
- if ('$each' in child) collectViews(child.template);
574
- else if ('$if' in child) {
575
- collectViews(child.then);
576
- collectViews(child.else);
577
- } else collectViews(child);
644
+ switch (childKind(child)) {
645
+ case 'each':
646
+ eachNodes(child).forEach(collectViews);
647
+ break;
648
+ case 'if':
649
+ collectViews(child.then);
650
+ collectViews(child.else);
651
+ break;
652
+ case 'slot':
653
+ break;
654
+ default:
655
+ collectViews(child);
656
+ }
578
657
  }
579
658
  }
580
659
  };
package/view/index.d.mts CHANGED
@@ -48,13 +48,41 @@ export interface ViewNode {
48
48
  readonly src?: string;
49
49
  }
50
50
 
51
+ /**
52
+ * A row design chosen per item: every branch is one keyable node, and `else`
53
+ * is required, so each item yields exactly one row.
54
+ */
55
+ export interface ViewTemplateChain {
56
+ readonly $if: ViewValue;
57
+ readonly then: ViewNode;
58
+ readonly else: ViewTemplate;
59
+ }
60
+
61
+ /** An `$each` template: one node, or an `$if` chain of them. */
62
+ export type ViewTemplate = ViewNode | ViewTemplateChain;
63
+
51
64
  export type ViewChild =
52
65
  | ViewNode
53
66
  | {
54
67
  readonly $each: ViewValue;
55
68
  readonly as: string;
56
69
  readonly key: string;
57
- readonly template: ViewNode;
70
+ /** One node, or a `ViewTemplateChain` that picks one per item. */
71
+ readonly template: ViewTemplate;
72
+ }
73
+ | {
74
+ readonly $each: ViewValue;
75
+ readonly as: string;
76
+ readonly key: string;
77
+ /**
78
+ * One row node per item kind; `kind` picks one, and an item of any
79
+ * other kind takes `default`, which is required.
80
+ */
81
+ readonly templates: Readonly<Record<string, ViewNode>> & {
82
+ readonly default: ViewNode;
83
+ };
84
+ /** A string in the item's scope, such as `{ "$bind": "item.kind" }`. */
85
+ readonly kind: ViewValue;
58
86
  }
59
87
  | {
60
88
  readonly $if: ViewValue;
@@ -66,6 +94,28 @@ export type ViewChild =
66
94
  readonly input?: Readonly<Record<string, ViewValue>>;
67
95
  };
68
96
 
97
+ /** An `$each` list child: one template, or per-kind `templates`. */
98
+ export type ViewEachChild = Extract<ViewChild, { readonly $each: ViewValue }>;
99
+ /** An `$if` branch child. */
100
+ export type ViewIfChild = Extract<ViewChild, { readonly $if: ViewValue }>;
101
+ /** A `$slot` placement child. */
102
+ export type ViewSlotChild = Extract<ViewChild, { readonly $slot: string }>;
103
+
104
+ /** A view child's kind; `view` is a composed `#view` node. */
105
+ export type ViewChildKind = 'each' | 'if' | 'slot' | 'view' | 'node';
106
+
107
+ /** A view child paired with its kind, narrowed by a switch on `kind`. */
108
+ export type ClassifiedViewChild =
109
+ | { readonly kind: 'each'; readonly child: ViewEachChild }
110
+ | { readonly kind: 'if'; readonly child: ViewIfChild }
111
+ | { readonly kind: 'slot'; readonly child: ViewSlotChild }
112
+ | { readonly kind: 'view' | 'node'; readonly child: ViewNode };
113
+
114
+ /** The kind of a view child: the one shared child-kind dispatch. */
115
+ export function childKind(child: ViewChild): ViewChildKind;
116
+ /** The child with its kind; switching on `.kind` narrows `.child`. */
117
+ export function classifyChild(child: ViewChild): ClassifiedViewChild;
118
+
69
119
  export interface ViewDocument {
70
120
  readonly $schema?: string;
71
121
  readonly schema: typeof VIEW_DOCUMENT_SCHEMA_ID;
@@ -81,6 +131,11 @@ export interface ViewDocument {
81
131
  * a `$bind` path that starts at this param.
82
132
  */
83
133
  readonly default?: unknown;
134
+ /**
135
+ * `true` makes the input optional with no default, so an omitted
136
+ * value reads as `undefined`. A param with a default does not take it.
137
+ */
138
+ readonly optional?: true;
84
139
  readonly description?: string;
85
140
  }
86
141
  >
@@ -141,12 +196,24 @@ export interface ViewValidation {
141
196
  readonly actions: ReadonlyMap<string, 'row' | 'view'>;
142
197
  }
143
198
 
199
+ /**
200
+ * Where a `#view`'s `src` points relative to the top document's folder, from
201
+ * the composing document at `from` (undefined for the top document): each
202
+ * `src` resolves from the folder of the document that contains it. The
203
+ * `path` every `resolveView(src, path)` receives.
204
+ */
205
+ export function composedViewPath(from: string | undefined, src: string): string;
206
+
144
207
  export function validateView(
145
208
  document: unknown,
146
209
  catalog: ViewCatalog,
147
210
  options?: {
148
- /** Loads a `#view` node's document; without it, `#view` is shape-checked only. */
149
- resolveView?: (src: string) => unknown;
211
+ /**
212
+ * Loads a `#view` node's document; without it, `#view` is shape-checked
213
+ * only. `path` is where `src` points relative to the top document's
214
+ * folder: each `src` resolves from the document that contains it.
215
+ */
216
+ resolveView?: (src: string, path: string) => unknown;
150
217
  /** Known Lucide icon names; with it, an unknown `$icon` is `KUI-V013`. */
151
218
  icons?: Iterable<string>;
152
219
  },
@@ -255,10 +322,15 @@ export interface ViewContract {
255
322
  }
256
323
  >
257
324
  >;
325
+ /**
326
+ * The kinds each `templates` repeat names, by its item name, sorted.
327
+ * Absent when the document has none.
328
+ */
329
+ readonly kinds?: Readonly<Record<string, readonly string[]>>;
258
330
  }
259
331
 
260
332
  export interface ViewContractChange {
261
- readonly member: 'input' | 'action' | 'slot' | 'ref';
333
+ readonly member: 'input' | 'action' | 'slot' | 'ref' | 'kind';
262
334
  readonly name: string;
263
335
  readonly change: string;
264
336
  readonly breaking: boolean;
@@ -275,7 +347,7 @@ export function typeText(type: ViewType): string;
275
347
  export function contractOf(
276
348
  document: unknown,
277
349
  catalog: ViewCatalog,
278
- options?: { resolveView?: (src: string) => unknown },
350
+ options?: { resolveView?: (src: string, path: string) => unknown },
279
351
  ): ViewContract;
280
352
  /** The layout-independent contract digest. */
281
353
  export function contractDigest(contract: ViewContract): string;
@@ -310,7 +382,7 @@ export function generateView(
310
382
  options?: {
311
383
  /** The document file name recorded in the header. */
312
384
  source?: string;
313
- resolveView?: (src: string) => unknown;
385
+ resolveView?: (src: string, path: string) => unknown;
314
386
  target?: 'ts' | 'js';
315
387
  declarationsOnly?: boolean;
316
388
  /** The generated module's folder; absolute component imports become relative to it. */
@@ -336,9 +408,6 @@ export function viewModulePath(
336
408
  target?: 'ts' | 'js',
337
409
  ): string;
338
410
 
339
- /** Layout printer for generated expressions. */
340
- export function printDoc(doc: unknown, indent?: number): string;
341
-
342
411
  /** A parsed `$css` call: `{ name, args }`, each argument a literal or nested call. */
343
412
  export interface CssCallTree {
344
413
  readonly name: string;
@@ -372,7 +441,7 @@ export function interpretView(
372
441
  /** The generated `<name>Contract` the application compiled against. */
373
442
  readonly contract: string;
374
443
  readonly onMismatch?: (error: KuiContractMismatch) => SafeHtmlLike;
375
- readonly resolveView?: (src: string) => unknown;
444
+ readonly resolveView?: (src: string, path: string) => unknown;
376
445
  /** Lucide icon name → icon data, for every `$icon` the document uses. */
377
446
  readonly icons?: Readonly<Record<string, unknown>>;
378
447
  },
@@ -399,13 +468,10 @@ export function previewView(
399
468
  readonly inputs?: object;
400
469
  readonly slots?: object;
401
470
  readonly icons?: Readonly<Record<string, unknown>>;
402
- readonly resolveView?: (src: string) => unknown;
471
+ readonly resolveView?: (src: string, path: string) => unknown;
403
472
  /** Ids of nodes the caller's validation flagged. */
404
473
  readonly broken?: ReadonlySet<string>;
405
474
  /** Renders in place of a broken node; `reason` is `problem` or the thrown message. */
406
475
  readonly placeholder: (node: ViewNode, reason: string) => SafeHtmlLike;
407
476
  },
408
477
  ): SafeHtmlLike;
409
-
410
- /** A component import as the generated module writes it, relative to `importFrom` when absolute. */
411
- export function moduleSpecifier(specifier: string, importFrom?: string): string;
package/view/index.mjs CHANGED
@@ -1,15 +1,13 @@
1
1
  // @kerfjs/ui/view: the published, browser-safe view-document layer
2
2
  // (docs/26-ui-editor.md). The private editor and the kerf-ui-view CLI are
3
3
  // its clients; neither owns the format.
4
+ export { childKind, classifyChild } from './child-kind.mjs';
5
+ export { channelOf, createViewCatalog, fieldZoneOf } from './catalog.mjs';
6
+ export { parseCssCall, parseCssTree } from './css-grammar.mjs';
7
+ export { isAssignable, isLiteralOf } from './types.mjs';
4
8
  export {
5
- channelOf,
6
- createViewCatalog,
9
+ composedViewPath,
7
10
  dataAttributeProblem,
8
- fieldZoneOf,
9
- isAssignable,
10
- isLiteralOf,
11
- parseCssCall,
12
- parseCssTree,
13
11
  validateView,
14
12
  VIEW_DOCUMENT_SCHEMA_ID,
15
13
  } from './validate.mjs';
@@ -28,8 +26,6 @@ export {
28
26
  GENERATOR_VERSION,
29
27
  generateView,
30
28
  lucideExportName,
31
- moduleSpecifier,
32
- printDoc,
33
29
  readViewHeader,
34
30
  viewModulePath,
35
31
  } from './generate.mjs';
@@ -10,11 +10,13 @@ import { contractDigest, contractOf } from './contract.mjs';
10
10
  import {
11
11
  channelOf,
12
12
  fieldZoneOf,
13
- parseCssTree,
14
13
  withFieldZones,
15
14
  ZoneFill,
16
15
  zonePropOf,
17
- } from './validate.mjs';
16
+ } from './catalog.mjs';
17
+ import { childKind } from './child-kind.mjs';
18
+ import { parseCssTree } from './css-grammar.mjs';
19
+ import { composedViewPath, eachNodes } from './validate.mjs';
18
20
 
19
21
  const isObject = (value) =>
20
22
  value !== null && typeof value === 'object' && !Array.isArray(value);
@@ -59,7 +61,8 @@ function readPath(root, path) {
59
61
  * - `inputs`, `slots`: as the generated `render<Name>` takes them;
60
62
  * - `contract`: the `<name>Contract` digest the app compiled against;
61
63
  * - `onMismatch(error)`: returns fallback `SafeHtml` instead of throwing;
62
- * - `resolveView(src)`: loads composed documents synchronously.
64
+ * - `resolveView(src, path)`: loads composed documents synchronously; `path`
65
+ * is where `src` points relative to the top document's folder.
63
66
  * Throws on an invalid document or a component missing from `components`.
64
67
  */
65
68
  export function interpretView(document, options) {
@@ -95,7 +98,25 @@ export function previewView(document, options) {
95
98
  return renderDocument(document, inputs, slots, options);
96
99
  }
97
100
 
98
- function renderDocument(document, inputs, slots, options) {
101
+ /**
102
+ * `at` is the document's place relative to the top document's folder
103
+ * (undefined for the top one), so a nested `#view`'s `src` resolves from the
104
+ * document that contains it, as the validator resolves it (KF-3X7MFF).
105
+ * `inRow` marks a composed document rendered inside a composing document's
106
+ * `$each` row, through any number of `#view` levels, and `rowKey` is that
107
+ * row's key, which its root carries as `data-key` the way any other row root
108
+ * does (KF-EP2152), so kerf reconciles the row by key and a row action reads
109
+ * it (KF-RDZ7N7).
110
+ */
111
+ function renderDocument(
112
+ document,
113
+ inputs,
114
+ slots,
115
+ options,
116
+ at,
117
+ inRow = false,
118
+ rowKey = undefined,
119
+ ) {
99
120
  const { catalog, components, resolveView } = options;
100
121
  const params = document.params ?? {};
101
122
 
@@ -149,37 +170,75 @@ function renderDocument(document, inputs, slots, options) {
149
170
  };
150
171
 
151
172
  const childValue = (child, scope, slot) => {
152
- if ('$each' in child) {
153
- // The key path starts with `as` (validation requires it); read the rest
154
- // from the item.
155
- const rest = child.key.split('.').slice(1);
156
- const items = value(child.$each, scope);
157
- const row = (item) =>
158
- nodeValue(
159
- child.template,
160
- new Map(scope).set(child.as, item),
161
- readPath(item, rest),
162
- slot,
163
- );
164
- // Scope holds only `$each` items, so a non-empty scope is a row
165
- // template. kerf never reconciles a list inside a row (the row is
166
- // flattened to HTML, and a keyed each() there throws), so an inner
167
- // repeat is a plain map that re-renders with its row, as the generated
168
- // module writes it (KF-CFA1S1).
169
- return scope.size
170
- ? items.map(row)
171
- : each(items, row, { key: child.template.id });
172
- }
173
- if ('$if' in child) {
174
- if (value(child.$if, scope)) return childValue(child.then, scope, slot);
175
- return 'else' in child ? childValue(child.else, scope, slot) : null;
173
+ switch (childKind(child)) {
174
+ case 'each':
175
+ return eachValue(child, scope, slot);
176
+ case 'if':
177
+ if (value(child.$if, scope)) return childValue(child.then, scope, slot);
178
+ return 'else' in child ? childValue(child.else, scope, slot) : null;
179
+ case 'slot':
180
+ return isObject(child.input)
181
+ ? slots[child.$slot](value(child.input, scope))
182
+ : slots[child.$slot]();
183
+ default:
184
+ return nodeValue(child, scope, undefined, slot);
176
185
  }
177
- if ('$slot' in child) {
178
- return isObject(child.input)
179
- ? slots[child.$slot](value(child.input, scope))
180
- : slots[child.$slot]();
186
+ };
187
+
188
+ const eachValue = (child, scope, slot) => {
189
+ // The key path starts with `as` (validation requires it); read the rest
190
+ // from the item.
191
+ const rest = child.key.split('.').slice(1);
192
+ // KF-A01VDM: a composed document's own repeat inside a row is the shape
193
+ // validation rejects (KUI-V016). Name it, rather than letting each()
194
+ // refuse the keyed list inside the row with a generic error.
195
+ if (inRow && !scope.size) {
196
+ throw new Error(
197
+ `KUI-V016 ${at} is composed into a row, so it cannot repeat`,
198
+ );
181
199
  }
182
- return nodeValue(child, scope, undefined, slot);
200
+ const items = value(child.$each, scope);
201
+ const row = (item) => {
202
+ const inner = new Map(scope).set(child.as, item);
203
+ return rowValue(
204
+ rowTemplate(child, inner),
205
+ inner,
206
+ readPath(item, rest),
207
+ slot,
208
+ );
209
+ };
210
+ // Scope holds only `$each` items, so a non-empty scope is a row
211
+ // template. kerf never reconciles a list inside a row (the row is
212
+ // flattened to HTML, and a keyed each() there throws), so an inner
213
+ // repeat is a plain map that re-renders with its row, as the generated
214
+ // module writes it (KF-CFA1S1).
215
+ return scope.size
216
+ ? items.map(row)
217
+ : each(items, row, { key: eachNodes(child)[0]?.id });
218
+ };
219
+
220
+ // KF-YX6HMT: the template an item's `kind` picks from `templates`, else
221
+ // the `default` one. A preview of a map with no `default` falls back to
222
+ // its first template, since a keyed row must be one element.
223
+ const rowTemplate = (child, scope) => {
224
+ if (!('templates' in child)) return child.template;
225
+ const { templates } = child;
226
+ const kind = value(child.kind, scope);
227
+ if (Object.hasOwn(templates, kind)) return templates[kind];
228
+ return templates.default ?? Object.values(templates)[0];
229
+ };
230
+
231
+ // A row: the template node, or the branch its `$if` chain picks for this
232
+ // item (KF-8J8E5V). A preview of an unfinished chain with no `else`
233
+ // renders `then` for every item, since a keyed row must be one element.
234
+ const rowValue = (template, scope, rowKey, slot) => {
235
+ if (!isObject(template) || !('$if' in template))
236
+ return nodeValue(template, scope, rowKey, slot);
237
+ const chosen =
238
+ 'else' in template && !value(template.$if, scope)
239
+ ? template.else
240
+ : template.then;
241
+ return rowValue(chosen, scope, rowKey, slot);
183
242
  };
184
243
 
185
244
  // A preview (previewView) swaps a node it cannot render for the caller's
@@ -205,8 +264,17 @@ function renderDocument(document, inputs, slots, options) {
205
264
  return slot ? jsx('span', { slot, children: text }) : text;
206
265
  }
207
266
  if (node.type === '#view') {
208
- const child = resolveView(node.src);
209
- return renderDocument(child, value(node.props ?? {}, scope), {}, options);
267
+ const path = composedViewPath(at, node.src);
268
+ const child = resolveView(node.src, path);
269
+ return renderDocument(
270
+ child,
271
+ value(node.props ?? {}, scope),
272
+ {},
273
+ options,
274
+ path,
275
+ inRow || scope.size > 0,
276
+ rowKey,
277
+ );
210
278
  }
211
279
  const { component: definition, definitions } = catalog.components.get(
212
280
  node.type,
@@ -267,5 +335,5 @@ function renderDocument(document, inputs, slots, options) {
267
335
  return render(out);
268
336
  };
269
337
 
270
- return nodeValue(document.root, new Map(), undefined, undefined);
338
+ return nodeValue(document.root, new Map(), rowKey, undefined);
271
339
  }