@kitn.ai/ui 0.17.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (494) hide show
  1. package/README.md +28 -5
  2. package/dist/components/artifact.d.ts +39 -1
  3. package/dist/components/attachment-types.d.ts +12 -0
  4. package/dist/components/attachments.d.ts +2 -10
  5. package/dist/components/card.d.ts +27 -0
  6. package/dist/components/chain-of-thought.d.ts +78 -2
  7. package/dist/components/chat-scope-picker.d.ts +7 -0
  8. package/dist/components/chat-thread.d.ts +37 -12
  9. package/dist/components/choice-card.d.ts +26 -0
  10. package/dist/components/coachmark.d.ts +49 -0
  11. package/dist/components/composer-dom.d.ts +35 -0
  12. package/dist/components/composer-highlight.d.ts +48 -0
  13. package/dist/components/composer-history.d.ts +34 -0
  14. package/dist/components/composer.d.ts +86 -0
  15. package/dist/components/confirm-card.d.ts +17 -0
  16. package/dist/components/conversation-item.d.ts +9 -0
  17. package/dist/components/conversation-list.d.ts +36 -1
  18. package/dist/components/file-tree.d.ts +15 -0
  19. package/dist/components/form.d.ts +34 -0
  20. package/dist/components/markdown.d.ts +3 -0
  21. package/dist/components/message.d.ts +12 -0
  22. package/dist/components/model-switcher.d.ts +7 -0
  23. package/dist/components/prompt-input.d.ts +13 -4
  24. package/dist/components/prompt-suggestion.d.ts +9 -1
  25. package/dist/components/reasoning.d.ts +14 -1
  26. package/dist/components/response-compare.d.ts +14 -0
  27. package/dist/components/screen.d.ts +46 -0
  28. package/dist/components/tasks-card.d.ts +49 -1
  29. package/dist/components/toast.d.ts +12 -2
  30. package/dist/components/tool-types.d.ts +10 -0
  31. package/dist/components/tool.d.ts +8 -8
  32. package/dist/components/voice-input.d.ts +27 -0
  33. package/dist/components/voice-output.d.ts +33 -0
  34. package/dist/core-C8fzo39E.js +12 -0
  35. package/dist/custom-elements.json +8392 -1860
  36. package/dist/elements/agent-card.d.ts +1 -0
  37. package/dist/elements/agent-card.js +1 -0
  38. package/dist/elements/artifact.js +1 -1
  39. package/dist/elements/attachments.js +1 -1
  40. package/dist/elements/autoloader.js +1 -1
  41. package/dist/elements/avatar.d.ts +1 -0
  42. package/dist/elements/avatar.js +1 -0
  43. package/dist/elements/badge.d.ts +1 -0
  44. package/dist/elements/badge.js +1 -0
  45. package/dist/elements/button.d.ts +1 -0
  46. package/dist/elements/button.js +1 -0
  47. package/dist/elements/card.js +1 -1
  48. package/dist/elements/cards.js +1 -1
  49. package/dist/elements/chain-of-thought.js +1 -1
  50. package/dist/elements/chat-scope-picker.js +1 -1
  51. package/dist/elements/chat-types.d.ts +47 -0
  52. package/dist/elements/chat-workspace.js +1 -1
  53. package/dist/elements/chat.js +1 -1
  54. package/dist/elements/checkpoint.js +1 -1
  55. package/dist/elements/choice.js +1 -1
  56. package/dist/elements/chunks/Icon-C2LTALdM.js +1 -0
  57. package/dist/elements/chunks/action-icons-Dtl8Ox5D.js +1 -0
  58. package/dist/elements/chunks/arrow-left-GbBceGBE.js +1 -0
  59. package/dist/elements/chunks/attachments-DLJcWCDV.js +1 -0
  60. package/dist/elements/chunks/badge-BTNZTODL.js +1 -0
  61. package/dist/elements/chunks/button-DBDZebGr.js +1 -0
  62. package/dist/elements/chunks/card-YfCyI4fH.js +1 -0
  63. package/dist/elements/chunks/chat-thread-Dz2qbzvI.js +1 -0
  64. package/dist/elements/chunks/check-fhmRksq_.js +1 -0
  65. package/dist/elements/chunks/chevron-down-DcRg1aRU.js +1 -0
  66. package/dist/elements/chunks/chevron-right-ChzBcNJ-.js +1 -0
  67. package/dist/elements/chunks/circle-B4fTe9v6.js +1 -0
  68. package/dist/elements/chunks/circle-check-CJV-3Rem.js +1 -0
  69. package/dist/elements/chunks/circle-x-pDtzlghQ.js +1 -0
  70. package/dist/elements/chunks/cn-CU7UAWzk.js +1 -0
  71. package/dist/elements/chunks/code-block-DZ6mz6vs.js +1 -0
  72. package/dist/elements/chunks/collapsible-CWUAShMC.js +1 -0
  73. package/dist/elements/chunks/composer-BZyPU6gD.js +65 -0
  74. package/dist/elements/chunks/context-Cx6eQA_G.js +1 -0
  75. package/dist/elements/chunks/conversation-list-C4xTQSpT.js +1 -0
  76. package/dist/elements/chunks/default-input-BZcwyKcP.js +1 -0
  77. package/dist/elements/chunks/define-CNSKFZCd.js +1 -0
  78. package/dist/elements/chunks/disclosure-BcBs--Jf.js +1 -0
  79. package/dist/elements/chunks/download-BDQwcFav.js +1 -0
  80. package/dist/elements/chunks/dropdown-wgs8xCJZ.js +1 -0
  81. package/dist/elements/chunks/ellipsis-CUiEJ6R1.js +1 -0
  82. package/dist/elements/chunks/external-link-DJUmC7g2.js +1 -0
  83. package/dist/elements/chunks/file-text-DOYfYvrh.js +1 -0
  84. package/dist/elements/chunks/file-tree-DQzNQrbr.js +1 -0
  85. package/dist/elements/chunks/folder-DBDUBANz.js +1 -0
  86. package/dist/elements/chunks/hover-card-BQGdGAQ3.js +1 -0
  87. package/dist/elements/chunks/icon-CAyRqVrg.js +1 -0
  88. package/dist/elements/chunks/{index-CTBEJeo6.js → index-BCRhi84a.js} +1 -1
  89. package/dist/elements/chunks/info-DBQl-m6e.js +1 -0
  90. package/dist/elements/chunks/input-DZD67EvW.js +1 -0
  91. package/dist/elements/chunks/kbd-DbyVrlnU.js +1 -0
  92. package/dist/elements/chunks/link-vko7AttA.js +1 -0
  93. package/dist/elements/chunks/loader-Cg6rO8tQ.js +1 -0
  94. package/dist/elements/chunks/{markdown-CMTGx9r8.js → markdown-n3Xbj3PR.js} +9 -9
  95. package/dist/elements/chunks/message-CgKytiSB.js +1 -0
  96. package/dist/elements/chunks/message-feedback-Ds3-US0e.js +1 -0
  97. package/dist/elements/chunks/message-square-MmRkvc-M.js +1 -0
  98. package/dist/elements/chunks/minimize-2-3kCdE0q3.js +1 -0
  99. package/dist/elements/chunks/model-switcher-BMtXGwLU.js +1 -0
  100. package/dist/elements/chunks/overlay-B1-MBI6h.js +1 -0
  101. package/dist/elements/chunks/paperclip-DDEfmkHc.js +1 -0
  102. package/dist/elements/chunks/progress-bar-Dwbiyv3s.js +1 -0
  103. package/dist/elements/chunks/prompt-suggestion-9lvgFcEa.js +1 -0
  104. package/dist/elements/chunks/reasoning-DzHWsdAJ.js +1 -0
  105. package/dist/elements/chunks/resizable-Bq_eHxUm.js +1 -0
  106. package/dist/elements/chunks/rotate-cw-jpisOdOV.js +1 -0
  107. package/dist/elements/chunks/scroll-area-g5Ze3K6f.js +1 -0
  108. package/dist/elements/chunks/separator-Bmjc5XyX.js +1 -0
  109. package/dist/elements/chunks/settings-Cz1bMJP9.js +1 -0
  110. package/dist/elements/chunks/settings-group-9imY3kRA.js +1 -0
  111. package/dist/elements/chunks/share-BdenF0wQ.js +1 -0
  112. package/dist/elements/chunks/skeleton-Pjc5jiaY.js +1 -0
  113. package/dist/elements/chunks/slots-DkZ-Cmha.js +1 -0
  114. package/dist/elements/chunks/star-DY6z1UUH.js +1 -0
  115. package/dist/elements/chunks/store-th4VyJXM.js +1 -0
  116. package/dist/elements/chunks/text-shimmer-CEi-tlXr.js +1 -0
  117. package/dist/elements/chunks/textarea-CboigarR.js +1 -0
  118. package/dist/elements/chunks/thumbs-up-BR33KLfA.js +1 -0
  119. package/dist/elements/chunks/toast-store-BEMda0fv.js +1 -0
  120. package/dist/elements/chunks/tool-TMued3WO.js +1 -0
  121. package/dist/elements/chunks/tooltip-Cft_Rxiw.js +1 -0
  122. package/dist/elements/chunks/triangle-alert-B07fX3Q8.js +1 -0
  123. package/dist/elements/chunks/use-card-resolution-M36zVciB.js +1 -0
  124. package/dist/elements/chunks/video-MKp3LmNT.js +1 -0
  125. package/dist/elements/chunks/x-Ckwicf6g.js +1 -0
  126. package/dist/elements/coachmark.d.ts +1 -0
  127. package/dist/elements/coachmark.js +1 -0
  128. package/dist/elements/code-block.js +1 -1
  129. package/dist/elements/command.d.ts +1 -0
  130. package/dist/elements/command.js +1 -0
  131. package/dist/elements/compare.js +1 -1
  132. package/dist/elements/composer.d.ts +1 -0
  133. package/dist/elements/composer.js +1 -0
  134. package/dist/elements/confirm-card.js +1 -1
  135. package/dist/elements/context-meter.js +1 -1
  136. package/dist/elements/conversation-list.js +1 -1
  137. package/dist/elements/css.d.ts +1 -0
  138. package/dist/elements/default-input.d.ts +51 -0
  139. package/dist/elements/define.d.ts +53 -0
  140. package/dist/elements/dialog.d.ts +1 -0
  141. package/dist/elements/dialog.js +1 -0
  142. package/dist/elements/disclosure.d.ts +37 -0
  143. package/dist/elements/editable-label.d.ts +1 -0
  144. package/dist/elements/editable-label.js +1 -0
  145. package/dist/elements/embed.js +1 -1
  146. package/dist/elements/empty.js +1 -1
  147. package/dist/elements/feedback-bar.js +1 -1
  148. package/dist/elements/file-tree.js +1 -1
  149. package/dist/elements/file-upload.js +1 -1
  150. package/dist/elements/form.js +1 -1
  151. package/dist/elements/hover-card.d.ts +1 -0
  152. package/dist/elements/hover-card.js +1 -0
  153. package/dist/elements/icon.d.ts +1 -0
  154. package/dist/elements/icon.js +1 -0
  155. package/dist/elements/image.js +1 -1
  156. package/dist/elements/input.d.ts +1 -0
  157. package/dist/elements/input.js +1 -0
  158. package/dist/elements/kbd.d.ts +1 -0
  159. package/dist/elements/kbd.js +1 -0
  160. package/dist/elements/link-preview.js +1 -1
  161. package/dist/elements/loader.js +1 -1
  162. package/dist/elements/markdown.js +1 -1
  163. package/dist/elements/menu.d.ts +1 -0
  164. package/dist/elements/menu.js +1 -0
  165. package/dist/elements/message-skills.js +1 -1
  166. package/dist/elements/message.js +1 -1
  167. package/dist/elements/model-switcher.js +1 -1
  168. package/dist/elements/nav.d.ts +1 -0
  169. package/dist/elements/nav.js +1 -0
  170. package/dist/elements/notice.d.ts +1 -0
  171. package/dist/elements/notice.js +1 -0
  172. package/dist/elements/pane-group.d.ts +1 -0
  173. package/dist/elements/pane-group.js +1 -0
  174. package/dist/elements/pane.d.ts +1 -0
  175. package/dist/elements/pane.js +1 -0
  176. package/dist/elements/popover.js +1 -1
  177. package/dist/elements/progress-bar.d.ts +1 -0
  178. package/dist/elements/progress-bar.js +1 -0
  179. package/dist/elements/prompt-dock.d.ts +1 -0
  180. package/dist/elements/prompt-dock.js +1 -0
  181. package/dist/elements/prompt-input.js +1 -1
  182. package/dist/elements/prompt-suggestions.js +1 -1
  183. package/dist/elements/reasoning.js +1 -1
  184. package/dist/elements/register-impl.d.ts +0 -0
  185. package/dist/elements/register.d.ts +13 -0
  186. package/dist/elements/remote.d.ts +1 -0
  187. package/dist/elements/remote.js +1 -0
  188. package/dist/elements/resizable.js +1 -1
  189. package/dist/elements/response-stream.js +2 -2
  190. package/dist/elements/screen.d.ts +1 -0
  191. package/dist/elements/screen.js +1 -0
  192. package/dist/elements/scroll-area.d.ts +1 -0
  193. package/dist/elements/scroll-area.js +1 -0
  194. package/dist/elements/scroll-button.js +1 -1
  195. package/dist/elements/search.d.ts +1 -0
  196. package/dist/elements/search.js +1 -0
  197. package/dist/elements/segmented.d.ts +1 -0
  198. package/dist/elements/segmented.js +1 -0
  199. package/dist/elements/separator.d.ts +1 -0
  200. package/dist/elements/separator.js +1 -0
  201. package/dist/elements/setting-item.d.ts +1 -0
  202. package/dist/elements/setting-item.js +1 -0
  203. package/dist/elements/settings-group.d.ts +1 -0
  204. package/dist/elements/settings-group.js +1 -0
  205. package/dist/elements/skeleton.d.ts +1 -0
  206. package/dist/elements/skeleton.js +1 -0
  207. package/dist/elements/slots.d.ts +176 -0
  208. package/dist/elements/source.js +1 -1
  209. package/dist/elements/status.d.ts +1 -0
  210. package/dist/elements/status.js +1 -0
  211. package/dist/elements/switch.js +1 -1
  212. package/dist/elements/tabs.d.ts +1 -0
  213. package/dist/elements/tabs.js +1 -0
  214. package/dist/elements/tasks.js +1 -1
  215. package/dist/elements/text-shimmer.js +1 -1
  216. package/dist/elements/thinking-bar.js +1 -1
  217. package/dist/elements/toast.js +1 -1
  218. package/dist/elements/tool.js +1 -1
  219. package/dist/elements/tooltip.d.ts +1 -0
  220. package/dist/elements/tooltip.js +1 -0
  221. package/dist/elements/voice-input.js +1 -1
  222. package/dist/elements/voice-output.d.ts +1 -0
  223. package/dist/elements/voice-output.js +1 -0
  224. package/dist/elements.d.ts +733 -58
  225. package/dist/engine-javascript-C1x7zo1_.js +141 -0
  226. package/dist/index.d.ts +3 -2
  227. package/dist/index.js +8255 -5703
  228. package/dist/kai.es.js +1 -0
  229. package/dist/llms/llms-full.txt +1146 -64
  230. package/dist/llms/llms.txt +4 -4
  231. package/dist/mcp.es.js +62 -7
  232. package/dist/primitives/composer-model.d.ts +22 -0
  233. package/dist/primitives/composer-triggers.d.ts +19 -0
  234. package/dist/primitives/create-kai-chat.d.ts +38 -0
  235. package/dist/primitives/toast-store.d.ts +32 -2
  236. package/dist/primitives/use-speech-recognition.d.ts +26 -0
  237. package/dist/react/index.d.ts +1085 -97
  238. package/dist/react/runtime.d.ts +9 -2
  239. package/dist/react/use-kai-chat.d.ts +41 -0
  240. package/dist/react.js +572 -193
  241. package/dist/register-impl-cKscku5m.js +141 -0
  242. package/dist/schemas/tasks.schema.json +2 -2
  243. package/dist/state/index.d.ts +4 -0
  244. package/dist/state/messages.d.ts +11 -0
  245. package/dist/state/stream.d.ts +22 -0
  246. package/dist/state/suggestions.d.ts +4 -0
  247. package/dist/state.js +117 -0
  248. package/dist/theme.tokens.css +87 -0
  249. package/dist/types.d.ts +4 -0
  250. package/dist/ui/agent-card.d.ts +61 -0
  251. package/dist/ui/button.d.ts +5 -2
  252. package/dist/ui/card.d.ts +61 -0
  253. package/dist/ui/collapsible.d.ts +15 -1
  254. package/dist/ui/command.d.ts +33 -0
  255. package/dist/ui/dialog.d.ts +42 -0
  256. package/dist/ui/dropdown.d.ts +95 -1
  257. package/dist/ui/editable-label.d.ts +26 -0
  258. package/dist/ui/hover-card.d.ts +13 -1
  259. package/dist/ui/icon.d.ts +18 -0
  260. package/dist/ui/input.d.ts +33 -0
  261. package/dist/ui/kbd.d.ts +21 -0
  262. package/dist/ui/nav.d.ts +62 -0
  263. package/dist/ui/notice.d.ts +31 -0
  264. package/dist/ui/overlay.d.ts +12 -0
  265. package/dist/ui/pane-grid.d.ts +58 -0
  266. package/dist/ui/pane-group.d.ts +77 -0
  267. package/dist/ui/pane.d.ts +78 -0
  268. package/dist/ui/popover.d.ts +11 -1
  269. package/dist/ui/progress-bar.d.ts +23 -0
  270. package/dist/ui/prompt-dock.d.ts +96 -0
  271. package/dist/ui/resizable.d.ts +12 -0
  272. package/dist/ui/scroll-area.d.ts +4 -0
  273. package/dist/ui/segmented.d.ts +28 -0
  274. package/dist/ui/settings-group.d.ts +32 -0
  275. package/dist/ui/skeleton.d.ts +12 -0
  276. package/dist/ui/stat.d.ts +16 -0
  277. package/dist/ui/status.d.ts +13 -0
  278. package/dist/ui/switch.d.ts +8 -1
  279. package/dist/ui/tabs.d.ts +35 -0
  280. package/dist/ui/tooltip.d.ts +19 -1
  281. package/frameworks/react/index.tsx +1042 -157
  282. package/frameworks/react/runtime.tsx +30 -1
  283. package/frameworks/react/use-kai-chat.tsx +87 -0
  284. package/llms-full.txt +1146 -64
  285. package/llms.txt +4 -4
  286. package/package.json +31 -10
  287. package/src/agent-tooling/mcp/manifest.ts +14 -0
  288. package/src/agent-tooling/mcp/tools/debug.ts +11 -7
  289. package/src/agent-tooling/mcp/tools/reference.ts +32 -0
  290. package/src/agent-tooling/mcp/tools/scaffold.ts +30 -1
  291. package/src/components/artifact.tsx +98 -13
  292. package/src/components/attachment-types.ts +13 -0
  293. package/src/components/attachments.tsx +4 -14
  294. package/src/components/card.tsx +109 -15
  295. package/src/components/chain-of-thought.tsx +210 -1
  296. package/src/components/chat-scope-picker.tsx +13 -3
  297. package/src/components/chat-thread.tsx +225 -116
  298. package/src/components/choice-card.tsx +103 -11
  299. package/src/components/coachmark.tsx +249 -0
  300. package/src/components/component-meta.json +699 -110
  301. package/src/components/composer-dom.ts +159 -0
  302. package/src/components/composer-highlight.ts +242 -0
  303. package/src/components/composer-history.ts +82 -0
  304. package/src/components/composer.tsx +979 -0
  305. package/src/components/confirm-card.tsx +54 -1
  306. package/src/components/conversation-item.tsx +69 -7
  307. package/src/components/conversation-list.tsx +134 -37
  308. package/src/components/file-tree.tsx +197 -47
  309. package/src/components/form-widgets.tsx +9 -7
  310. package/src/components/form.tsx +140 -17
  311. package/src/components/image.tsx +3 -5
  312. package/src/components/link-preview.tsx +5 -4
  313. package/src/components/markdown.tsx +5 -2
  314. package/src/components/message.tsx +23 -4
  315. package/src/components/model-switcher.tsx +19 -4
  316. package/src/components/prompt-input.tsx +46 -75
  317. package/src/components/prompt-suggestion.tsx +48 -16
  318. package/src/components/reasoning.tsx +29 -6
  319. package/src/components/response-compare.tsx +31 -2
  320. package/src/components/screen.tsx +176 -0
  321. package/src/components/tasks-card.tsx +341 -21
  322. package/src/components/toast.tsx +119 -31
  323. package/src/components/tool-types.ts +10 -0
  324. package/src/components/tool.tsx +22 -16
  325. package/src/components/voice-input.tsx +102 -19
  326. package/src/components/voice-output.tsx +202 -0
  327. package/src/elements/agent-card.tsx +67 -0
  328. package/src/elements/artifact.tsx +53 -4
  329. package/src/elements/attachments.tsx +1 -0
  330. package/src/elements/avatar.tsx +33 -0
  331. package/src/elements/badge.tsx +32 -0
  332. package/src/elements/button.tsx +126 -0
  333. package/src/elements/card-media.jpg +0 -0
  334. package/src/elements/card.tsx +124 -31
  335. package/src/elements/cards.tsx +81 -7
  336. package/src/elements/chain-of-thought.tsx +77 -32
  337. package/src/elements/chat-scope-picker.tsx +35 -8
  338. package/src/elements/chat-types.ts +2 -2
  339. package/src/elements/chat-workspace.tsx +153 -41
  340. package/src/elements/chat.tsx +45 -23
  341. package/src/elements/choice.tsx +71 -19
  342. package/src/elements/coachmark.tsx +90 -0
  343. package/src/elements/command.tsx +209 -0
  344. package/src/elements/compare.tsx +24 -2
  345. package/src/elements/compiled.css +2 -2
  346. package/src/elements/composer.tsx +151 -0
  347. package/src/elements/confirm-card.tsx +36 -11
  348. package/src/elements/conversation-list.tsx +80 -11
  349. package/src/elements/default-input.tsx +75 -53
  350. package/src/elements/define.tsx +87 -7
  351. package/src/elements/dialog.tsx +98 -0
  352. package/src/elements/disclosure.ts +73 -0
  353. package/src/elements/editable-label.tsx +125 -0
  354. package/src/elements/element-manifest.json +129 -1
  355. package/src/elements/element-meta.json +5562 -1336
  356. package/src/elements/element-types.d.ts +732 -57
  357. package/src/elements/file-tree.tsx +12 -2
  358. package/src/elements/file-upload.tsx +1 -1
  359. package/src/elements/form.tsx +54 -11
  360. package/src/elements/hover-card.tsx +80 -0
  361. package/src/elements/icon-names.json +48 -0
  362. package/src/elements/icon.tsx +41 -0
  363. package/src/elements/input.tsx +203 -0
  364. package/src/elements/kbd.tsx +45 -0
  365. package/src/elements/menu.tsx +217 -0
  366. package/src/elements/message.tsx +58 -11
  367. package/src/elements/model-switcher.tsx +27 -1
  368. package/src/elements/nav.tsx +87 -0
  369. package/src/elements/notice.tsx +53 -0
  370. package/src/elements/pane-group.tsx +119 -0
  371. package/src/elements/pane.tsx +129 -0
  372. package/src/elements/popover.tsx +39 -17
  373. package/src/elements/progress-bar.tsx +39 -0
  374. package/src/elements/prompt-dock.tsx +81 -0
  375. package/src/elements/prompt-input.tsx +112 -63
  376. package/src/elements/prompt-suggestions.tsx +25 -9
  377. package/src/elements/reasoning.tsx +30 -9
  378. package/src/elements/register-impl.ts +38 -3
  379. package/src/elements/register.ts +11 -3
  380. package/src/elements/resizable.tsx +48 -11
  381. package/src/elements/screen.tsx +90 -0
  382. package/src/elements/scroll-area.tsx +33 -0
  383. package/src/elements/search.tsx +180 -0
  384. package/src/elements/segmented.tsx +135 -0
  385. package/src/elements/separator.tsx +36 -0
  386. package/src/elements/setting-item.tsx +50 -0
  387. package/src/elements/settings-group.tsx +37 -0
  388. package/src/elements/skeleton.tsx +45 -0
  389. package/src/elements/slots.ts +607 -0
  390. package/src/elements/source.tsx +13 -6
  391. package/src/elements/status.tsx +42 -0
  392. package/src/elements/switch.tsx +89 -14
  393. package/src/elements/tabs.tsx +95 -0
  394. package/src/elements/tasks.tsx +70 -14
  395. package/src/elements/toast.tsx +17 -2
  396. package/src/elements/tool.tsx +43 -9
  397. package/src/elements/tooltip.tsx +85 -0
  398. package/src/elements/video-poster.jpg +0 -0
  399. package/src/elements/voice-input.tsx +66 -16
  400. package/src/elements/voice-output.tsx +69 -0
  401. package/src/index.ts +5 -2
  402. package/src/primitives/card-schemas/tasks.schema.json +2 -2
  403. package/src/primitives/composer-model.ts +49 -0
  404. package/src/primitives/composer-triggers.ts +35 -0
  405. package/src/primitives/create-kai-chat.ts +66 -0
  406. package/src/primitives/toast-store.ts +43 -2
  407. package/src/primitives/use-speech-recognition.ts +135 -0
  408. package/src/state/index.ts +6 -0
  409. package/src/state/messages.ts +36 -0
  410. package/src/state/stream.ts +92 -0
  411. package/src/state/suggestions.ts +9 -0
  412. package/src/types.ts +4 -0
  413. package/src/ui/agent-card.tsx +218 -0
  414. package/src/ui/button.tsx +16 -5
  415. package/src/ui/card.tsx +245 -0
  416. package/src/ui/collapsible.tsx +30 -4
  417. package/src/ui/command.tsx +99 -0
  418. package/src/ui/dialog.tsx +217 -0
  419. package/src/ui/dropdown.tsx +375 -13
  420. package/src/ui/editable-label.tsx +112 -0
  421. package/src/ui/hover-card.tsx +28 -5
  422. package/src/ui/icon.tsx +110 -0
  423. package/src/ui/input.tsx +132 -0
  424. package/src/ui/kbd.tsx +118 -0
  425. package/src/ui/nav.tsx +282 -0
  426. package/src/ui/notice.tsx +84 -0
  427. package/src/ui/overlay.tsx +108 -2
  428. package/src/ui/pane-grid.tsx +117 -0
  429. package/src/ui/pane-group.tsx +291 -0
  430. package/src/ui/pane.tsx +193 -0
  431. package/src/ui/popover.tsx +16 -2
  432. package/src/ui/progress-bar.tsx +83 -0
  433. package/src/ui/prompt-dock.tsx +145 -0
  434. package/src/ui/resizable.tsx +69 -1
  435. package/src/ui/scroll-area.tsx +14 -3
  436. package/src/ui/segmented.tsx +109 -0
  437. package/src/ui/settings-group.tsx +67 -0
  438. package/src/ui/skeleton.tsx +62 -5
  439. package/src/ui/stat.tsx +41 -0
  440. package/src/ui/status.tsx +48 -0
  441. package/src/ui/switch.tsx +49 -23
  442. package/src/ui/tabs.tsx +168 -0
  443. package/src/ui/tooltip.tsx +52 -8
  444. package/theme.css +113 -0
  445. package/dist/components/slash-command.d.ts +0 -15
  446. package/dist/elements/chunks/Icon-D_Zmwmwh.js +0 -1
  447. package/dist/elements/chunks/action-icons-PVfIvcuG.js +0 -1
  448. package/dist/elements/chunks/attachments-Dp6vqtrc.js +0 -1
  449. package/dist/elements/chunks/button-CKyYD9G4.js +0 -1
  450. package/dist/elements/chunks/card-Cjho-PYk.js +0 -1
  451. package/dist/elements/chunks/chat-thread-RT808iPf.js +0 -1
  452. package/dist/elements/chunks/check-CDYaMYrM.js +0 -1
  453. package/dist/elements/chunks/chevron-down-3SBiq8HF.js +0 -1
  454. package/dist/elements/chunks/chevron-right-k2UFlIVK.js +0 -1
  455. package/dist/elements/chunks/cn-Dogu6PbV.js +0 -1
  456. package/dist/elements/chunks/code-block-BYUmfFSd.js +0 -1
  457. package/dist/elements/chunks/collapsible-BiNwdOn6.js +0 -1
  458. package/dist/elements/chunks/context-18g6oi4J.js +0 -1
  459. package/dist/elements/chunks/conversation-list-D9Y0NVdo.js +0 -1
  460. package/dist/elements/chunks/default-input-CSAoYYMd.js +0 -1
  461. package/dist/elements/chunks/download-D8K0Je8r.js +0 -1
  462. package/dist/elements/chunks/dropdown-bUs2iTia.js +0 -1
  463. package/dist/elements/chunks/external-link-6mA0wxab.js +0 -1
  464. package/dist/elements/chunks/file-text-DnaYk3Dm.js +0 -1
  465. package/dist/elements/chunks/file-tree-CgtRLlxK.js +0 -1
  466. package/dist/elements/chunks/hover-card-CIGw62gP.js +0 -1
  467. package/dist/elements/chunks/link-BlGSeoPy.js +0 -1
  468. package/dist/elements/chunks/loader-DvhR4qa0.js +0 -1
  469. package/dist/elements/chunks/message-CDZwXjhL.js +0 -1
  470. package/dist/elements/chunks/message-feedback-CYx81QiA.js +0 -1
  471. package/dist/elements/chunks/model-switcher-O_tUhoOT.js +0 -1
  472. package/dist/elements/chunks/overlay-DydXYMQW.js +0 -1
  473. package/dist/elements/chunks/prompt-suggestion-ldlWV5kd.js +0 -1
  474. package/dist/elements/chunks/reasoning-2PUnHlmr.js +0 -1
  475. package/dist/elements/chunks/resizable-B5WNbSeb.js +0 -1
  476. package/dist/elements/chunks/star-t9tI-P0q.js +0 -1
  477. package/dist/elements/chunks/store-C6rIooZz.js +0 -1
  478. package/dist/elements/chunks/text-shimmer-uh9V_KUh.js +0 -1
  479. package/dist/elements/chunks/textarea-3nm6Ia9U.js +0 -1
  480. package/dist/elements/chunks/thumbs-up-BBtguGld.js +0 -1
  481. package/dist/elements/chunks/toast-store-D8cL3fWl.js +0 -1
  482. package/dist/elements/chunks/tool-GJ3vwp1U.js +0 -1
  483. package/dist/elements/chunks/tooltip-DwKAz4XR.js +0 -1
  484. package/dist/elements/chunks/triangle-alert-Ct1zt2JL.js +0 -1
  485. package/dist/elements/chunks/use-card-resolution-D-_0Alzy.js +0 -1
  486. package/dist/elements/chunks/video-mVYiM99-.js +0 -1
  487. package/dist/elements/chunks/x-CzxL27Ch.js +0 -1
  488. package/dist/kitn-chat.es.js +0 -1
  489. package/dist/register-JyTglR6m.js +0 -1
  490. package/dist/register-impl-C6wlSsts.js +0 -77
  491. package/src/components/slash-command.tsx +0 -232
  492. package/src/elements/framework-usage.json +0 -588
  493. /package/dist/{kitn-chat-provider.d.ts → kai-provider.d.ts} +0 -0
  494. /package/dist/{kitn-chat-provider.es.js → kai-provider.es.js} +0 -0
@@ -0,0 +1,92 @@
1
+ // src/state/stream.ts
2
+ import type { ChatMessage } from '../elements/chat-types';
3
+ import type { ToolPart } from '../components/tool-types';
4
+
5
+ /** The one universal contract: a functional-updater setter (React setState shape). */
6
+ export type SetMessages = (updater: (prev: ChatMessage[]) => ChatMessage[]) => void;
7
+
8
+ /** A fluent builder for one in-flight assistant message. Owns no state. */
9
+ export interface AssistantStream {
10
+ readonly id: string;
11
+ appendText(delta: string): AssistantStream;
12
+ setText(content: string): AssistantStream;
13
+ appendReasoning(delta: string, label?: string): AssistantStream;
14
+ setReasoning(text: string, label?: string): AssistantStream;
15
+ upsertTool(tool: ToolPart): AssistantStream;
16
+ updateTool(toolCallId: string, patch: Partial<ToolPart>): AssistantStream;
17
+ patch(patch: Partial<ChatMessage>): AssistantStream;
18
+ done(final?: Partial<ChatMessage>): void;
19
+ abort(reason?: string): void;
20
+ }
21
+
22
+ function newId(): string {
23
+ if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') return crypto.randomUUID();
24
+ return 'kai-' + Math.random().toString(36).slice(2);
25
+ }
26
+
27
+ /** Start an assistant message and drive it through `set`. New refs on every mutation. */
28
+ export function createAssistantStream(set: SetMessages, init: Partial<ChatMessage> = {}): AssistantStream {
29
+ const id = init.id ?? newId();
30
+ const seed: ChatMessage = { id, role: 'assistant', content: '', ...init };
31
+ set((prev) => [...prev, seed]);
32
+
33
+ const mutate = (fn: (m: ChatMessage) => ChatMessage) =>
34
+ set((prev) => prev.map((m) => (m.id === id ? fn(m) : m)));
35
+
36
+ const stream: AssistantStream = {
37
+ id,
38
+ appendText(delta) { mutate((m) => ({ ...m, content: m.content + delta })); return stream; },
39
+ setText(content) { mutate((m) => ({ ...m, content })); return stream; },
40
+ appendReasoning(delta, label) {
41
+ mutate((m) => ({ ...m, reasoning: { text: (m.reasoning?.text ?? '') + delta, label: label ?? m.reasoning?.label } }));
42
+ return stream;
43
+ },
44
+ setReasoning(text, label) {
45
+ mutate((m) => ({ ...m, reasoning: { text, label: label ?? m.reasoning?.label } }));
46
+ return stream;
47
+ },
48
+ upsertTool(tool) {
49
+ mutate((m) => {
50
+ const tools = m.tools ? m.tools.slice() : [];
51
+ const i = tool.toolCallId != null
52
+ ? tools.findIndex((t) => t.toolCallId === tool.toolCallId)
53
+ : tools.findIndex((t) => t.type === tool.type);
54
+ if (i === -1) tools.push(tool); else tools[i] = tool;
55
+ return { ...m, tools };
56
+ });
57
+ return stream;
58
+ },
59
+ updateTool(toolCallId, patch) {
60
+ mutate((m) => ({ ...m, tools: (m.tools ?? []).map((t) => (t.toolCallId === toolCallId ? { ...t, ...patch } : t)) }));
61
+ return stream;
62
+ },
63
+ patch(patch) { mutate((m) => ({ ...m, ...patch })); return stream; },
64
+ done(final) { if (final) mutate((m) => ({ ...m, ...final })); },
65
+ abort(reason) {
66
+ if (reason) {
67
+ mutate((m) => ({ ...m, tools: (m.tools ?? []).map((t) => ({ ...t, state: 'output-error' as const, errorText: reason })) }));
68
+ } else {
69
+ set((prev) => prev.filter((m) => m.id !== id));
70
+ }
71
+ },
72
+ };
73
+ return stream;
74
+ }
75
+
76
+ /** Wrap a stream so `onSettle` fires on done/abort (used to toggle a `loading` flag).
77
+ * Preserves the fluent chain by returning the wrapper from every mutator. */
78
+ export function onStreamSettled(inner: AssistantStream, onSettle: () => void): AssistantStream {
79
+ const wrapper: AssistantStream = {
80
+ id: inner.id,
81
+ appendText(d) { inner.appendText(d); return wrapper; },
82
+ setText(c) { inner.setText(c); return wrapper; },
83
+ appendReasoning(d, l) { inner.appendReasoning(d, l); return wrapper; },
84
+ setReasoning(t, l) { inner.setReasoning(t, l); return wrapper; },
85
+ upsertTool(t) { inner.upsertTool(t); return wrapper; },
86
+ updateTool(tcId, p) { inner.updateTool(tcId, p); return wrapper; },
87
+ patch(p) { inner.patch(p); return wrapper; },
88
+ done(final) { inner.done(final); onSettle(); },
89
+ abort(reason) { inner.abort(reason); onSettle(); },
90
+ };
91
+ return wrapper;
92
+ }
@@ -0,0 +1,9 @@
1
+ /** Append a suggestion; no-op when already present. Returns a new array. */
2
+ export function addSuggestion(suggestions: string[], s: string): string[] {
3
+ return suggestions.includes(s) ? suggestions.slice() : [...suggestions, s];
4
+ }
5
+
6
+ /** Remove a suggestion by value. */
7
+ export function removeSuggestion(suggestions: string[], s: string): string[] {
8
+ return suggestions.filter((x) => x !== s);
9
+ }
package/src/types.ts CHANGED
@@ -35,6 +35,10 @@ export interface ConversationSummary {
35
35
  messageCount: number;
36
36
  lastMessageAt: string;
37
37
  updatedAt: string;
38
+ /** Right-aligned trailing text on the row — a count, status, or "days ago".
39
+ * When omitted, a short relative time is auto-derived from `updatedAt`
40
+ * (fallback `lastMessageAt`). */
41
+ trailing?: string;
38
42
  }
39
43
 
40
44
  export interface ConversationGroup {
@@ -0,0 +1,218 @@
1
+ import { type JSX, Show, splitProps } from 'solid-js';
2
+ import { Bell, MoreHorizontal } from 'lucide-solid';
3
+ import { cn } from '../utils/cn';
4
+
5
+ /** The run state of an agent, mapped to the kit's tool / status hues.
6
+ * - `working` (blue) the agent is actively running.
7
+ * - `idle` (muted) waiting, no current activity.
8
+ * - `done` (green) finished its turn.
9
+ * - `error` (red) failed.
10
+ * - `blocked` (amber) stalled, usually waiting on something. */
11
+ export type AgentStatusTone = 'working' | 'idle' | 'done' | 'error' | 'blocked';
12
+
13
+ export interface AgentStatus {
14
+ /** Which hue the status dot takes. */
15
+ tone: AgentStatusTone;
16
+ /** Optional short label rendered next to the dot (e.g. "Working", "Blocked on you"). */
17
+ label?: string;
18
+ /** Animate the dot with a ping ring (off under prefers-reduced-motion). */
19
+ pulse?: boolean;
20
+ }
21
+
22
+ export interface AgentCardProps {
23
+ /** @deprecated No longer rendered. Kept for back-compat with existing callers. */
24
+ leading?: JSX.Element;
25
+ /** The agent's name. The primary label. */
26
+ name: string;
27
+ /** @deprecated No longer rendered. Kept for back-compat with existing callers. */
28
+ subtitle?: string;
29
+ /** @deprecated No longer rendered. Kept for back-compat with existing callers. */
30
+ lastLine?: string;
31
+ /** Run status: a tone-colored dot, an optional small label, optionally pulsing. */
32
+ status: AgentStatus;
33
+ /** Raise a prominent "needs you" pill plus a glowing amber edge. The
34
+ * attention-routing signal that pulls focus to this agent. */
35
+ needsAttention?: boolean;
36
+ /** Selected / focused state. Highlighted border and surface. */
37
+ active?: boolean;
38
+ /** Promote this agent to focus. Fires on click and on Enter / Space. */
39
+ onActivate?: () => void;
40
+ /** Alias for {@link AgentCardProps.onActivate}. Both fire if both are set. */
41
+ onClick?: () => void;
42
+ /** Show a trailing "..." overflow button and fire this on click. The consumer
43
+ * wires the actual menu; the card only surfaces the affordance. Click is
44
+ * stopped from also activating the card. */
45
+ onMenu?: (e: MouseEvent) => void;
46
+ /** Extra classes merged over the card. */
47
+ class?: string;
48
+ }
49
+
50
+ /** tone -> dot background utility (the kit's tool hues + muted for idle). */
51
+ const TONE_DOT: Record<AgentStatusTone, string> = {
52
+ working: 'bg-tool-blue',
53
+ idle: 'bg-muted-foreground',
54
+ done: 'bg-tool-green',
55
+ error: 'bg-tool-red',
56
+ blocked: 'bg-tool-amber',
57
+ };
58
+
59
+ /** tone -> matching text color for the inline status label. */
60
+ const TONE_TEXT: Record<AgentStatusTone, string> = {
61
+ working: 'text-tool-blue',
62
+ idle: 'text-muted-foreground',
63
+ done: 'text-tool-green',
64
+ error: 'text-tool-red',
65
+ blocked: 'text-tool-amber',
66
+ };
67
+
68
+ /** Default accessible name per tone, used when no `status.label` is given so the
69
+ * state is still announced even when the dot reads as decorative. */
70
+ const TONE_LABEL: Record<AgentStatusTone, string> = {
71
+ working: 'Working',
72
+ idle: 'Idle',
73
+ done: 'Done',
74
+ error: 'Error',
75
+ blocked: 'Blocked',
76
+ };
77
+
78
+ /**
79
+ * AgentCard - the compact representation of one agent in a multi-agent workspace.
80
+ *
81
+ * In a focus + periphery layout the agents you are not focused on collapse to these
82
+ * glanceable cards, arranged as a narrow side RAIL or a wide LIST. The card stays
83
+ * deliberately minimal: the agent name, a tone-colored status dot, a "needs you"
84
+ * affordance when the agent wants your attention, and a trailing "..." overflow
85
+ * button for per-agent actions. Clicking the card promotes the agent back to focus.
86
+ *
87
+ * It is `w-full` and lets the name truncate, so the same component works in both a
88
+ * narrow rail and a wide list without changes - the content adapts to the box.
89
+ *
90
+ * Status maps to the kit's tool hues so it reads in light and dark from tokens alone:
91
+ * working = blue, idle = muted, done = green, error = red, blocked = amber. Setting
92
+ * `needsAttention` raises an amber "Needs you" pill and a glowing amber ring so the
93
+ * card jumps out of the periphery - the attention-routing signal.
94
+ */
95
+ export function AgentCard(props: AgentCardProps) {
96
+ const [local] = splitProps(props, [
97
+ 'name',
98
+ 'status',
99
+ 'needsAttention',
100
+ 'active',
101
+ 'onActivate',
102
+ 'onClick',
103
+ 'onMenu',
104
+ 'class',
105
+ // leading/subtitle/lastLine are accepted but no longer rendered (back-compat).
106
+ 'leading',
107
+ 'subtitle',
108
+ 'lastLine',
109
+ ]);
110
+
111
+ const tone = (): AgentStatusTone => local.status.tone;
112
+ const activate = () => {
113
+ local.onActivate?.();
114
+ local.onClick?.();
115
+ };
116
+
117
+ return (
118
+ // A plain container (no interactive role): the agent name below is the real
119
+ // <button> activator, and the kebab is a separate sibling <button>, so neither
120
+ // interactive control is nested inside the other.
121
+ <div
122
+ data-active={local.active ? '' : undefined}
123
+ data-needs-attention={local.needsAttention ? '' : undefined}
124
+ class={cn(
125
+ 'group relative flex w-full cursor-pointer items-center gap-3 rounded-lg border px-3 py-2.5 text-left',
126
+ 'transition-[background-color,border-color,box-shadow]',
127
+ local.active
128
+ ? 'border-primary bg-accent'
129
+ : 'border-border bg-surface hover:bg-accent',
130
+ // The attention edge: a glowing amber ring + tinted border. Stacks over the
131
+ // active/idle surface so a focused agent can still flag that it needs you.
132
+ local.needsAttention && 'border-tool-amber/50 ring-2 ring-inset ring-tool-amber/60',
133
+ local.class,
134
+ )}
135
+ >
136
+ {/* Status indicator leads, immediately before the name: [● label?] Name. */}
137
+ <span
138
+ class="inline-flex shrink-0 items-center gap-1.5"
139
+ role="status"
140
+ aria-label={local.status.label ?? TONE_LABEL[tone()]}
141
+ >
142
+ <span class="relative inline-flex">
143
+ <Show when={local.status.pulse}>
144
+ <span
145
+ aria-hidden="true"
146
+ class={cn(
147
+ 'absolute inline-flex h-full w-full animate-ping rounded-full opacity-75 motion-reduce:hidden',
148
+ TONE_DOT[tone()],
149
+ )}
150
+ />
151
+ </Show>
152
+ <span
153
+ aria-hidden="true"
154
+ part="status"
155
+ class={cn('relative inline-block size-2 rounded-full', TONE_DOT[tone()])}
156
+ />
157
+ </span>
158
+ <Show when={local.status.label}>
159
+ <span class={cn('text-[11px] font-medium leading-none', TONE_TEXT[tone()])}>
160
+ {local.status.label}
161
+ </span>
162
+ </Show>
163
+ </span>
164
+
165
+ {/* The agent name is the card's primary action: a real <button> whose inset
166
+ ::before overlay stretches the click target over the whole card, so a click
167
+ anywhere promotes the agent. Being a real button it is natively focusable and
168
+ activates on Enter / Space, so no manual key handling is needed. The overlay
169
+ also carries the card's focus ring (rounded to match), keeping the focused
170
+ card visually identical to before. */}
171
+ <button
172
+ type="button"
173
+ onClick={activate}
174
+ aria-current={local.active ? 'true' : undefined}
175
+ class={cn(
176
+ 'min-w-0 flex-1 text-left outline-none',
177
+ "before:absolute before:inset-0 before:rounded-lg before:content-['']",
178
+ 'focus-visible:before:ring-2 focus-visible:before:ring-inset focus-visible:before:ring-ring',
179
+ )}
180
+ >
181
+ <span class="block truncate text-sm font-medium leading-tight text-foreground">
182
+ {local.name}
183
+ </span>
184
+ </button>
185
+
186
+ <span class="flex shrink-0 items-center gap-2">
187
+ <Show when={local.needsAttention}>
188
+ <span class="inline-flex items-center gap-1 rounded-full bg-tool-amber/15 px-2 py-0.5 text-[11px] font-medium text-tool-amber">
189
+ <Bell class="size-3" aria-hidden="true" />
190
+ Needs you
191
+ </span>
192
+ </Show>
193
+
194
+ <Show when={local.onMenu}>
195
+ <button
196
+ type="button"
197
+ part="menu"
198
+ aria-label="More"
199
+ onClick={(e) => {
200
+ // The kebab sits above the name button's stretch overlay (relative z-10),
201
+ // so it opens its menu without activating the card; stop propagation too.
202
+ e.stopPropagation();
203
+ local.onMenu?.(e);
204
+ }}
205
+ class={cn(
206
+ 'relative z-10 inline-flex size-7 shrink-0 items-center justify-center rounded-md',
207
+ 'text-muted-foreground outline-none transition-colors',
208
+ 'hover:bg-surface-sunken hover:text-foreground',
209
+ 'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring',
210
+ )}
211
+ >
212
+ <MoreHorizontal class="size-4" aria-hidden="true" />
213
+ </button>
214
+ </Show>
215
+ </span>
216
+ </div>
217
+ );
218
+ }
package/src/ui/button.tsx CHANGED
@@ -3,12 +3,15 @@ import { cva, type VariantProps } from 'class-variance-authority';
3
3
  import { cn } from '../utils/cn';
4
4
 
5
5
  const buttonVariants = cva(
6
- 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50',
6
+ // No justify-* here the `align` variant owns content justification so it can
7
+ // be overridden (e.g. a full-width, left-aligned block button).
8
+ 'inline-flex items-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50',
7
9
  {
8
10
  variants: {
9
11
  variant: {
10
12
  default: 'bg-primary text-primary-foreground hover:bg-primary/90',
11
13
  ghost: 'hover:bg-muted text-foreground',
14
+ subtle: 'text-muted-foreground hover:bg-accent hover:text-foreground',
12
15
  outline: 'bg-muted/50 text-foreground hover:bg-muted',
13
16
  destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
14
17
  },
@@ -19,17 +22,25 @@ const buttonVariants = cva(
19
22
  icon: 'h-9 w-9',
20
23
  'icon-sm': 'h-7 w-7',
21
24
  },
25
+ align: {
26
+ start: 'justify-start',
27
+ center: 'justify-center',
28
+ end: 'justify-end',
29
+ },
22
30
  },
23
- defaultVariants: { variant: 'default', size: 'md' },
31
+ defaultVariants: { variant: 'default', size: 'md', align: 'center' },
24
32
  }
25
33
  );
26
34
 
27
- export interface ButtonProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {}
35
+ export interface ButtonProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
36
+ /** Stretch to the full width of the container (a block button). */
37
+ full?: boolean;
38
+ }
28
39
 
29
40
  export function Button(props: ButtonProps) {
30
- const [local, rest] = splitProps(props, ['variant', 'size', 'class', 'children']);
41
+ const [local, rest] = splitProps(props, ['variant', 'size', 'align', 'full', 'class', 'children']);
31
42
  return (
32
- <button class={cn(buttonVariants({ variant: local.variant, size: local.size }), local.class)} {...rest}>
43
+ <button class={cn(buttonVariants({ variant: local.variant, size: local.size, align: local.align }), local.full && 'w-full', local.class)} {...rest}>
33
44
  {local.children}
34
45
  </button>
35
46
  );
@@ -0,0 +1,245 @@
1
+ import { type JSX, Show, splitProps, mergeProps, createSignal, createUniqueId } from 'solid-js';
2
+ import { Dynamic } from 'solid-js/web';
3
+ import { cn } from '../utils/cn';
4
+ import { X } from 'lucide-solid';
5
+
6
+ export type CardAppearance = 'outlined' | 'filled' | 'plain' | 'accent';
7
+ /** `vertical` (media on top), `horizontal` (media at the start), or `responsive`
8
+ * (horizontal when the card's container is at least ~28rem wide, else vertical —
9
+ * a CSS container query on the card's own width, NOT the viewport). */
10
+ export type CardOrientation = 'vertical' | 'horizontal' | 'responsive';
11
+
12
+ /** Surface treatment. `outlined` (default) = bordered card; `filled` = a raised
13
+ * opaque surface; `plain` = no border/background (a padded region); `accent` =
14
+ * the bold primary fill (announcements). */
15
+ const APPEARANCE: Record<CardAppearance, string> = {
16
+ outlined: 'border border-border bg-card text-card-foreground kai-elevation-sm',
17
+ filled: 'border border-transparent bg-surface-strong text-card-foreground',
18
+ plain: 'border border-transparent bg-transparent',
19
+ accent: 'border border-transparent bg-primary text-primary-foreground',
20
+ };
21
+
22
+ export interface CardProps extends JSX.HTMLAttributes<HTMLDivElement> {
23
+ /** Surface treatment: `outlined` | `filled` | `plain` | `accent`. */
24
+ appearance?: CardAppearance;
25
+ /** `vertical` (media on top) or `horizontal` (media at the start). */
26
+ orientation?: CardOrientation;
27
+ /** The card width below which a `responsive` card collapses to vertical and the
28
+ * footer action cluster stacks. A CSS length (e.g. `'24rem'`); default `'28rem'`.
29
+ * Container-query breakpoints can't be CSS variables, so this prop is baked into
30
+ * a per-card `@container` rule. */
31
+ collapse?: string;
32
+ /** Tighter spacing for dense lists (shrinks `--kai-card-spacing`). */
33
+ dense?: boolean;
34
+
35
+ /** Full-bleed media region (image/video/illustration) at the top (vertical) or
36
+ * start (horizontal). Clipped to the card's corners. */
37
+ media?: JSX.Element;
38
+ /** Header content (e.g. a title). Rendered above the body, padded. */
39
+ header?: JSX.Element;
40
+ /** An actions cluster pinned to the end of the header row. */
41
+ headerActions?: JSX.Element;
42
+ /** Footer content. Rendered below the body, padded. */
43
+ footer?: JSX.Element;
44
+ /** An actions cluster pinned to the end of the footer row. */
45
+ footerActions?: JSX.Element;
46
+ /** Whether the default slot (body) has content — the facade computes this so an
47
+ * empty body region isn't rendered (an empty `<slot>` is always truthy). */
48
+ hasBody?: boolean;
49
+
50
+ /** Render a dismiss (×) that hides the card and calls `onDismiss`. Off by default. */
51
+ dismissible?: boolean;
52
+ onDismiss?: () => void;
53
+ /** Render the whole card as a link (`<a>`). Wins over `clickable`. */
54
+ href?: string;
55
+ target?: string;
56
+ rel?: string;
57
+ /** Make the whole card a `role="button"` with Enter/Space activation. A
58
+ * clickable/href card must NOT also contain footer action buttons. */
59
+ clickable?: boolean;
60
+ onCardClick?: (event: MouseEvent | KeyboardEvent) => void;
61
+ }
62
+
63
+ /**
64
+ * `Card` — the kit's presentational card surface (the `<kai-card>` primitive),
65
+ * modeled on the WebAwesome card: ONE element whose flexibility comes from a few
66
+ * structural slots (`media`, `header` + actions, `footer` + actions; body is the
67
+ * default slot), `appearance` + `orientation` variants, `::part` styling, and a
68
+ * single `--kai-card-spacing` knob. The title/description are NOT slots — they are
69
+ * body/header content the consumer marks up, because a slot earns its place only
70
+ * where the shadow boundary blocks the consumer (a pinned media/footer region),
71
+ * not for a text node.
72
+ *
73
+ * Distinct from the generative-UI contract chrome in `../components/card.tsx`
74
+ * (which the Card Contract cards compose); this one is purely presentational.
75
+ *
76
+ * a11y: a `clickable`/`href` card MUST NOT also contain action buttons — that
77
+ * nests interactive controls inside a button/link.
78
+ */
79
+ export function Card(props: CardProps): JSX.Element {
80
+ const merged = mergeProps(
81
+ { appearance: 'outlined' as CardAppearance, orientation: 'vertical' as CardOrientation, collapse: '28rem', dense: false },
82
+ props,
83
+ );
84
+ const [local, rest] = splitProps(merged, [
85
+ 'appearance',
86
+ 'orientation',
87
+ 'collapse',
88
+ 'dense',
89
+ 'media',
90
+ 'header',
91
+ 'headerActions',
92
+ 'footer',
93
+ 'footerActions',
94
+ 'hasBody',
95
+ 'dismissible',
96
+ 'onDismiss',
97
+ 'href',
98
+ 'target',
99
+ 'rel',
100
+ 'clickable',
101
+ 'onCardClick',
102
+ 'class',
103
+ 'children',
104
+ ]);
105
+
106
+ const [open, setOpen] = createSignal(true);
107
+ const dismiss = (event: MouseEvent) => {
108
+ event.stopPropagation();
109
+ setOpen(false);
110
+ local.onDismiss?.();
111
+ };
112
+
113
+ const isLink = () => Boolean(local.href);
114
+ const isButton = () => !isLink() && Boolean(local.clickable);
115
+ const isInteractive = () => isLink() || isButton();
116
+
117
+ // The responsive layout is driven by a per-instance @container rule (a query on
118
+ // the card's OWN width, not the viewport) rather than fixed Tailwind classes, so
119
+ // the breakpoint is the configurable `collapse` prop. Base + query rules share a
120
+ // selector; the query (later) wins above the breakpoint. The card collapses to
121
+ // vertical (responsive orientation) and stacks its footer actions below `collapse`.
122
+ const COLLAPSE_RE = /^[\d.]+(px|rem|em|ch|vw|vh|%)$/;
123
+ const collapseAt = () => (COLLAPSE_RE.test(local.collapse) ? local.collapse : '28rem');
124
+ // Scope the injected <style> to THIS instance. The SolidJS Card renders in light
125
+ // DOM (the primitive story + autodocs page), where unscoped selectors are global
126
+ // and collide across instances (a horizontal card's `.kc-layout{flex-direction:row}`
127
+ // overrides a vertical one's, etc.). Prefixing every rule with a per-card class
128
+ // isolates each instance. Harmless inside the kai-card shadow root, where the
129
+ // boundary already scopes styles.
130
+ const scope = `kc-i-${createUniqueId()}`;
131
+ const styleText = () => {
132
+ const bp = collapseAt();
133
+ const horizontal = local.orientation === 'horizontal';
134
+ const responsive = local.orientation === 'responsive';
135
+ const s = `.${scope}`;
136
+ const base =
137
+ `${s} .kc-layout{display:flex;flex-direction:${horizontal ? 'row' : 'column'}}` +
138
+ `${s} .kc-media{overflow:hidden;${horizontal ? 'flex-shrink:0;align-self:stretch' : 'width:100%'}}` +
139
+ `${s} [part="footer"]{display:flex;flex-direction:column;gap:0.75rem}` +
140
+ `${s} .kc-actions{display:flex;flex-direction:column-reverse;align-items:stretch;gap:0.5rem}`;
141
+ const query =
142
+ `${s} [part="footer"]{flex-direction:row;align-items:center}` +
143
+ `${s} .kc-actions{flex-direction:row;align-items:center;margin-left:auto}` +
144
+ (responsive ? `${s} .kc-layout{flex-direction:row}${s} .kc-media{width:auto;flex-shrink:0;align-self:stretch}` : '');
145
+ return `${base}@container (min-width:${bp}){${query}}`;
146
+ };
147
+
148
+ const activate = (event: MouseEvent | KeyboardEvent) => local.onCardClick?.(event);
149
+ const onKeyDown = (event: KeyboardEvent) => {
150
+ if (!isButton()) return;
151
+ if (event.key === 'Enter' || event.key === ' ' || event.key === 'Spacebar') {
152
+ event.preventDefault();
153
+ activate(event);
154
+ }
155
+ };
156
+ const rel = () => local.rel ?? (local.target === '_blank' ? 'noopener noreferrer' : undefined);
157
+
158
+ const hasHeaderRow = () => Boolean(local.header) || Boolean(local.headerActions);
159
+ const hasFooterRow = () => Boolean(local.footer) || Boolean(local.footerActions);
160
+ const hasSections = () => hasHeaderRow() || local.hasBody || hasFooterRow();
161
+
162
+ // The padded header/body/footer column. Media sits outside it so it stays
163
+ // full-bleed (clipped to the card's corners by the root's overflow-hidden).
164
+ const sections = (
165
+ <div class="flex min-w-0 flex-1 flex-col" style={{ padding: 'var(--kai-card-spacing)', gap: 'var(--kai-card-spacing)' }}>
166
+ <Show when={hasHeaderRow()}>
167
+ <div part="header" class="flex items-start justify-between gap-3">
168
+ <Show when={local.header}>
169
+ <div class="min-w-0 flex-1">{local.header}</div>
170
+ </Show>
171
+ <Show when={local.headerActions}>
172
+ <div class="-mt-1 shrink-0">{local.headerActions}</div>
173
+ </Show>
174
+ </div>
175
+ </Show>
176
+ <Show when={local.hasBody}>
177
+ <div part="body" class="min-w-0 text-sm">{local.children}</div>
178
+ </Show>
179
+ <Show when={hasFooterRow()}>
180
+ {/* Footer + action cluster collapse to a stack below `collapse` (the injected
181
+ @container rule). The cluster is flex-col-REVERSE when stacked, so the
182
+ primary action (authored last → the row's right) rises to the TOP, and
183
+ items-stretch makes the buttons fill the width. No consumer work either way. */}
184
+ <div part="footer">
185
+ <Show when={local.footer}>
186
+ <div class="min-w-0 flex-1">{local.footer}</div>
187
+ </Show>
188
+ <Show when={local.footerActions}>
189
+ <div class="kc-actions">{local.footerActions}</div>
190
+ </Show>
191
+ </div>
192
+ </Show>
193
+ </div>
194
+ );
195
+
196
+ return (
197
+ <Show when={open()}>
198
+ <Dynamic
199
+ component={isLink() ? 'a' : 'div'}
200
+ part="card"
201
+ href={isLink() ? local.href : undefined}
202
+ target={isLink() ? local.target : undefined}
203
+ rel={isLink() ? rel() : undefined}
204
+ role={isButton() ? 'button' : undefined}
205
+ tabindex={isButton() ? 0 : undefined}
206
+ onClick={isInteractive() ? activate : undefined}
207
+ onKeyDown={isButton() ? onKeyDown : undefined}
208
+ style={{ '--kai-card-spacing': local.dense ? '0.875rem' : '1.25rem' }}
209
+ class={cn(
210
+ // @container: the card is a query container for its sections (responsive
211
+ // orientation + the footer action cluster collapse) keyed to its own width.
212
+ 'relative block overflow-hidden rounded-xl no-underline @container',
213
+ // Per-instance scope so the injected <style> can't bleed across cards.
214
+ scope,
215
+ APPEARANCE[local.appearance],
216
+ isInteractive() &&
217
+ 'cursor-pointer transition-colors hover:border-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
218
+ local.class,
219
+ )}
220
+ {...rest}
221
+ >
222
+ <Show when={local.dismissible}>
223
+ <button
224
+ type="button"
225
+ part="dismiss"
226
+ aria-label="Dismiss"
227
+ onClick={dismiss}
228
+ class="absolute right-2 top-2 z-10 shrink-0 rounded p-1 opacity-60 transition-opacity hover:opacity-100"
229
+ >
230
+ <X class="size-3.5" aria-hidden="true" />
231
+ </button>
232
+ </Show>
233
+
234
+ {/* Per-instance responsive rules; the breakpoint is the `collapse` prop. */}
235
+ <style>{styleText()}</style>
236
+ <div class="kc-layout">
237
+ <Show when={local.media}>
238
+ <div part="media" class="kc-media">{local.media}</div>
239
+ </Show>
240
+ <Show when={hasSections()}>{sections}</Show>
241
+ </div>
242
+ </Dynamic>
243
+ </Show>
244
+ );
245
+ }