@kitn.ai/ui 0.15.0 → 0.16.0

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 (366) hide show
  1. package/README.md +9 -0
  2. package/bin/mcp.js +22 -0
  3. package/dist/bash-InADTalH.js +6 -1
  4. package/dist/components/artifact.d.ts +58 -0
  5. package/dist/components/attachments.d.ts +67 -0
  6. package/dist/components/card-fallback.d.ts +10 -0
  7. package/dist/components/card-renderer.d.ts +13 -0
  8. package/dist/components/card.d.ts +28 -0
  9. package/dist/components/chain-of-thought.d.ts +29 -0
  10. package/dist/components/chat-container.d.ts +19 -0
  11. package/dist/components/chat-scope-picker.d.ts +9 -0
  12. package/dist/components/chat-thread.d.ts +93 -0
  13. package/dist/components/checkpoint.d.ts +20 -0
  14. package/dist/components/choice-card.d.ts +77 -0
  15. package/dist/components/code-block.d.ts +16 -0
  16. package/dist/components/confirm-card.d.ts +57 -0
  17. package/dist/components/context.d.ts +65 -0
  18. package/dist/components/conversation-item.d.ts +8 -0
  19. package/dist/components/conversation-list.d.ts +11 -0
  20. package/dist/components/embed.d.ts +21 -0
  21. package/dist/components/empty.d.ts +43 -0
  22. package/dist/components/feedback-bar.d.ts +45 -0
  23. package/dist/components/file-tree.d.ts +57 -0
  24. package/dist/components/file-upload.d.ts +16 -0
  25. package/dist/components/form-widgets.d.ts +31 -0
  26. package/dist/components/form.d.ts +103 -0
  27. package/dist/components/image.d.ts +12 -0
  28. package/dist/components/link-preview.d.ts +23 -0
  29. package/dist/components/loader.d.ts +60 -0
  30. package/dist/components/markdown.d.ts +8 -0
  31. package/dist/components/message-skills.d.ts +15 -0
  32. package/dist/components/message.d.ts +54 -0
  33. package/dist/components/model-switcher.d.ts +8 -0
  34. package/dist/components/prompt-input.d.ts +38 -0
  35. package/dist/components/prompt-suggestion.d.ts +13 -0
  36. package/dist/components/reasoning.d.ts +20 -0
  37. package/dist/components/response-stream.d.ts +14 -0
  38. package/dist/components/scroll-button.d.ts +7 -0
  39. package/dist/components/slash-command.d.ts +15 -0
  40. package/dist/components/source.d.ts +23 -0
  41. package/dist/components/tasks-card.d.ts +71 -0
  42. package/dist/components/text-shimmer.d.ts +9 -0
  43. package/dist/components/thinking-bar.d.ts +10 -0
  44. package/dist/components/tool.d.ts +16 -0
  45. package/dist/components/use-card-resolution.d.ts +12 -0
  46. package/dist/components/voice-input.d.ts +7 -0
  47. package/dist/core-AYMC6_lb.js +5874 -12
  48. package/dist/css-M7EaDHN_.js +6 -1
  49. package/dist/elements/artifact.d.ts +1 -0
  50. package/dist/elements/attachments.d.ts +1 -0
  51. package/dist/elements/card.d.ts +1 -0
  52. package/dist/elements/cards.d.ts +0 -0
  53. package/dist/elements/chain-of-thought.d.ts +13 -0
  54. package/dist/elements/chat-scope-picker.d.ts +1 -0
  55. package/dist/elements/chat-types.d.ts +41 -0
  56. package/dist/elements/chat-workspace.d.ts +1 -0
  57. package/dist/elements/chat.d.ts +1 -0
  58. package/dist/elements/checkpoint.d.ts +1 -0
  59. package/dist/elements/choice.d.ts +1 -0
  60. package/dist/elements/code-block.d.ts +1 -0
  61. package/dist/elements/confirm-card.d.ts +1 -0
  62. package/dist/elements/context-meter.d.ts +1 -0
  63. package/dist/elements/conversation-list.d.ts +11 -0
  64. package/dist/elements/css.d.ts +1 -0
  65. package/dist/elements/default-input.d.ts +40 -0
  66. package/dist/elements/define.d.ts +42 -0
  67. package/dist/elements/embed.d.ts +1 -0
  68. package/dist/elements/empty.d.ts +1 -0
  69. package/dist/elements/feedback-bar.d.ts +1 -0
  70. package/dist/elements/file-tree.d.ts +1 -0
  71. package/dist/elements/file-upload.d.ts +1 -0
  72. package/dist/elements/form.d.ts +1 -0
  73. package/dist/elements/image.d.ts +1 -0
  74. package/dist/elements/link-preview.d.ts +1 -0
  75. package/dist/elements/loader.d.ts +1 -0
  76. package/dist/elements/markdown.d.ts +1 -0
  77. package/dist/elements/message-skills.d.ts +17 -0
  78. package/dist/elements/message.d.ts +1 -0
  79. package/dist/elements/model-switcher.d.ts +11 -0
  80. package/dist/elements/popover.d.ts +1 -0
  81. package/dist/elements/prompt-input.d.ts +9 -0
  82. package/dist/elements/prompt-suggestions.d.ts +7 -0
  83. package/dist/elements/reasoning.d.ts +1 -0
  84. package/dist/elements/register-impl.d.ts +0 -0
  85. package/dist/elements/register.d.ts +3 -0
  86. package/dist/elements/remote.d.ts +1 -0
  87. package/dist/elements/resizable.d.ts +17 -0
  88. package/dist/elements/response-stream.d.ts +1 -0
  89. package/dist/elements/scroll-button.d.ts +1 -0
  90. package/dist/elements/source.d.ts +18 -0
  91. package/dist/elements/switch.d.ts +1 -0
  92. package/dist/elements/tasks.d.ts +1 -0
  93. package/dist/elements/text-shimmer.d.ts +1 -0
  94. package/dist/elements/thinking-bar.d.ts +1 -0
  95. package/dist/elements/tool.d.ts +1 -0
  96. package/dist/elements/voice-input.d.ts +1 -0
  97. package/dist/elements.d.ts +732 -0
  98. package/dist/engine-javascript-vq0WuIJl.js +2516 -14
  99. package/dist/github-dark-dimmed-DUshB20C.js +4 -1
  100. package/dist/github-light-JYsPkUQd.js +4 -1
  101. package/dist/html-CPZ3oZQ7.js +10 -1
  102. package/dist/index.d.ts +112 -2
  103. package/dist/index.js +13551 -0
  104. package/dist/javascript-C25yR2R2.js +6 -1
  105. package/dist/json-DxJze_jm.js +6 -1
  106. package/dist/kitn-chat.es.js +1 -77
  107. package/dist/llms/llms-full.txt +1 -1
  108. package/dist/llms/llms.txt +1 -1
  109. package/dist/mcp.es.js +2140 -0
  110. package/dist/primitives/card-contract.d.ts +103 -0
  111. package/dist/primitives/card-host.d.ts +12 -0
  112. package/dist/primitives/card-registry.d.ts +17 -0
  113. package/dist/primitives/card-resolution.d.ts +8 -0
  114. package/dist/primitives/card-routing.d.ts +12 -0
  115. package/dist/primitives/card-validate.d.ts +25 -0
  116. package/dist/primitives/chat-config.d.ts +31 -0
  117. package/dist/primitives/controllable.d.ts +13 -0
  118. package/dist/primitives/embed-providers.d.ts +65 -0
  119. package/dist/primitives/highlighter.d.ts +23 -0
  120. package/dist/primitives/link-preview.d.ts +47 -0
  121. package/dist/primitives/pdf-preview.d.ts +50 -0
  122. package/dist/primitives/use-auto-resize.d.ts +8 -0
  123. package/dist/primitives/use-resize-observer.d.ts +1 -0
  124. package/dist/primitives/use-stick-to-bottom.d.ts +5 -0
  125. package/dist/primitives/use-text-stream.d.ts +19 -0
  126. package/dist/primitives/use-voice-recorder.d.ts +9 -0
  127. package/dist/react/index.d.ts +1118 -0
  128. package/dist/react/runtime.d.ts +15 -0
  129. package/dist/react.js +265 -0
  130. package/dist/register-impl-wCsFPoh9.js +77 -0
  131. package/dist/register-ujhr1nBS.js +1 -0
  132. package/dist/remote/host-embed.d.ts +33 -0
  133. package/dist/remote/index.d.ts +2 -0
  134. package/dist/remote/origin.d.ts +5 -0
  135. package/dist/remote/provider-runtime.d.ts +27 -0
  136. package/dist/remote/provider.d.ts +2 -0
  137. package/dist/remote/validate.d.ts +4 -0
  138. package/dist/remote/version.d.ts +4 -0
  139. package/dist/remote/wire.d.ts +53 -0
  140. package/dist/svelte--5p79yCD.js +15 -1
  141. package/dist/tsx-B8rCNbgL.js +6 -1
  142. package/dist/types.d.ts +42 -0
  143. package/dist/typescript-RycA9KXf.js +6 -1
  144. package/dist/ui/action-icons.d.ts +11 -0
  145. package/dist/ui/avatar.d.ts +8 -0
  146. package/dist/ui/badge.d.ts +9 -0
  147. package/dist/ui/button.d.ts +10 -0
  148. package/dist/ui/collapsible.d.ts +27 -0
  149. package/dist/ui/dropdown.d.ts +20 -0
  150. package/dist/ui/hover-card.d.ts +28 -0
  151. package/dist/ui/overlay.d.ts +67 -0
  152. package/dist/ui/popover.d.ts +32 -0
  153. package/dist/ui/resizable.d.ts +76 -0
  154. package/dist/ui/scroll-area.d.ts +5 -0
  155. package/dist/ui/separator.d.ts +5 -0
  156. package/dist/ui/skeleton.d.ts +5 -0
  157. package/dist/ui/switch.d.ts +19 -0
  158. package/dist/ui/textarea.d.ts +6 -0
  159. package/dist/ui/tooltip.d.ts +8 -0
  160. package/dist/utils/cn.d.ts +2 -0
  161. package/dist/vue-BmIZj4XD.js +33 -1
  162. package/frameworks/react/index.tsx +4 -0
  163. package/frameworks/react/runtime.tsx +16 -2
  164. package/llms-full.txt +1 -1
  165. package/llms.txt +1 -1
  166. package/package.json +29 -11
  167. package/src/agent-tooling/archetypes.ts +46 -0
  168. package/src/agent-tooling/integrations/cloudflare.ts +88 -0
  169. package/src/agent-tooling/integrations/langgraph.ts +60 -0
  170. package/src/agent-tooling/integrations/mastra.ts +27 -0
  171. package/src/agent-tooling/integrations/mock.ts +34 -0
  172. package/src/agent-tooling/integrations/ollama.ts +47 -0
  173. package/src/agent-tooling/integrations/openrouter.ts +26 -0
  174. package/src/agent-tooling/integrations/pi.ts +40 -0
  175. package/src/agent-tooling/integrations/pydantic-ai.ts +52 -0
  176. package/src/agent-tooling/integrations/vercel-ai-sdk.ts +44 -0
  177. package/src/agent-tooling/mcp/manifest.ts +128 -0
  178. package/src/agent-tooling/mcp/server.ts +59 -0
  179. package/src/agent-tooling/mcp/stdio.ts +18 -0
  180. package/src/agent-tooling/mcp/tools/debug.ts +305 -0
  181. package/src/agent-tooling/mcp/tools/reference.ts +132 -0
  182. package/src/agent-tooling/mcp/tools/scaffold.ts +1627 -0
  183. package/src/agent-tooling/mcp/tools/theme.ts +340 -0
  184. package/src/agent-tooling/mcp/tools/types.ts +14 -0
  185. package/src/agent-tooling/registry.ts +41 -0
  186. package/src/agent-tooling/types.ts +30 -0
  187. package/src/elements/compiled.css +1 -1
  188. package/src/elements/define.tsx +7 -1
  189. package/src/elements/element-types.d.ts +2 -1
  190. package/src/elements/register-impl.ts +55 -0
  191. package/src/elements/register.ts +17 -51
  192. package/theme.css +4 -2
  193. package/src/components/artifact.stories.tsx +0 -138
  194. package/src/components/attachments.stories.tsx +0 -303
  195. package/src/components/attachments.test.tsx +0 -64
  196. package/src/components/chain-of-thought.stories.tsx +0 -211
  197. package/src/components/chat-container.stories.tsx +0 -187
  198. package/src/components/chat-thread.test.tsx +0 -58
  199. package/src/components/checkpoint.stories.tsx +0 -102
  200. package/src/components/code-block.stories.tsx +0 -150
  201. package/src/components/confirm-card.stories.tsx +0 -74
  202. package/src/components/context.stories.tsx +0 -229
  203. package/src/components/context.test.tsx +0 -133
  204. package/src/components/conversation-item.stories.tsx +0 -125
  205. package/src/components/conversation-list.stories.tsx +0 -133
  206. package/src/components/default-input.test.tsx +0 -111
  207. package/src/components/empty.stories.tsx +0 -434
  208. package/src/components/feedback-bar.stories.tsx +0 -138
  209. package/src/components/feedback-bar.test.tsx +0 -103
  210. package/src/components/file-tree.stories.tsx +0 -73
  211. package/src/components/file-upload.stories.tsx +0 -156
  212. package/src/components/image.stories.tsx +0 -89
  213. package/src/components/loader.stories.tsx +0 -181
  214. package/src/components/markdown.stories.tsx +0 -180
  215. package/src/components/message-action-bar.test.tsx +0 -128
  216. package/src/components/message-narrow.stories.tsx +0 -329
  217. package/src/components/message-skills.stories.tsx +0 -211
  218. package/src/components/message.stories.tsx +0 -281
  219. package/src/components/model-switcher.stories.tsx +0 -123
  220. package/src/components/model-switcher.test.tsx +0 -65
  221. package/src/components/prompt-input.stories.tsx +0 -222
  222. package/src/components/prompt-suggestion.stories.tsx +0 -142
  223. package/src/components/reasoning.stories.tsx +0 -140
  224. package/src/components/resizable.test.tsx +0 -226
  225. package/src/components/scroll-button.stories.tsx +0 -100
  226. package/src/components/slash-command.stories.tsx +0 -163
  227. package/src/components/source-list.test.tsx +0 -152
  228. package/src/components/source.stories.tsx +0 -124
  229. package/src/components/tasks-card.stories.tsx +0 -78
  230. package/src/components/text-shimmer.stories.tsx +0 -87
  231. package/src/components/thinking-bar.stories.tsx +0 -87
  232. package/src/components/tool.stories.tsx +0 -153
  233. package/src/components/voice-input.stories.tsx +0 -83
  234. package/src/elements/artifact.stories.tsx +0 -506
  235. package/src/elements/attachments.stories.tsx +0 -190
  236. package/src/elements/card.stories.tsx +0 -113
  237. package/src/elements/cards.stories.tsx +0 -59
  238. package/src/elements/catalog.stories.tsx +0 -491
  239. package/src/elements/chain-of-thought.declarative.test.tsx +0 -153
  240. package/src/elements/chain-of-thought.stories.tsx +0 -113
  241. package/src/elements/chat-scope-picker.stories.tsx +0 -73
  242. package/src/elements/chat-workspace.stories.tsx +0 -288
  243. package/src/elements/chat.stories.tsx +0 -151
  244. package/src/elements/checkpoint.stories.tsx +0 -72
  245. package/src/elements/choice.stories.tsx +0 -240
  246. package/src/elements/code-block.stories.tsx +0 -83
  247. package/src/elements/composed-shell.stories.tsx +0 -316
  248. package/src/elements/confirm-card.stories.tsx +0 -227
  249. package/src/elements/context-meter.stories.tsx +0 -151
  250. package/src/elements/conversation-list.declarative.test.tsx +0 -137
  251. package/src/elements/conversation-list.stories.tsx +0 -243
  252. package/src/elements/embed.stories.tsx +0 -213
  253. package/src/elements/empty.stories.tsx +0 -111
  254. package/src/elements/feedback-bar.stories.tsx +0 -114
  255. package/src/elements/file-tree.stories.tsx +0 -134
  256. package/src/elements/file-upload.stories.tsx +0 -82
  257. package/src/elements/form.stories.tsx +0 -248
  258. package/src/elements/image.stories.tsx +0 -71
  259. package/src/elements/link-preview.stories.tsx +0 -209
  260. package/src/elements/loader.stories.tsx +0 -88
  261. package/src/elements/markdown.stories.tsx +0 -76
  262. package/src/elements/message-skills.declarative.test.tsx +0 -104
  263. package/src/elements/message-skills.stories.tsx +0 -114
  264. package/src/elements/message.stories.tsx +0 -218
  265. package/src/elements/model-switcher.declarative.test.tsx +0 -130
  266. package/src/elements/model-switcher.stories.tsx +0 -198
  267. package/src/elements/popover.stories.tsx +0 -80
  268. package/src/elements/prompt-input-slash-command.test.tsx +0 -128
  269. package/src/elements/prompt-input-stoppable.test.tsx +0 -88
  270. package/src/elements/prompt-input-toolbar-actions.test.tsx +0 -120
  271. package/src/elements/prompt-input.stories.tsx +0 -331
  272. package/src/elements/prompt-suggestions.declarative.test.tsx +0 -164
  273. package/src/elements/prompt-suggestions.stories.tsx +0 -213
  274. package/src/elements/reasoning.stories.tsx +0 -77
  275. package/src/elements/remote.stories.tsx +0 -314
  276. package/src/elements/resizable.stories.tsx +0 -426
  277. package/src/elements/response-stream.stories.tsx +0 -79
  278. package/src/elements/scroll-button.stories.tsx +0 -202
  279. package/src/elements/scroll-button.test.tsx +0 -148
  280. package/src/elements/source-list.stories.tsx +0 -143
  281. package/src/elements/source.stories.tsx +0 -88
  282. package/src/elements/switch.stories.tsx +0 -56
  283. package/src/elements/tasks.stories.tsx +0 -237
  284. package/src/elements/text-shimmer.stories.tsx +0 -64
  285. package/src/elements/thinking-bar.stories.tsx +0 -72
  286. package/src/elements/tool.stories.tsx +0 -89
  287. package/src/elements/voice-input.stories.tsx +0 -88
  288. package/src/primitives/controllable.test.ts +0 -47
  289. package/src/stories/chat-panel-layout.stories.tsx +0 -145
  290. package/src/stories/chat-scene.tsx +0 -571
  291. package/src/stories/checkpoint-restore.stories.tsx +0 -256
  292. package/src/stories/context-usage.stories.tsx +0 -212
  293. package/src/stories/conversation-with-reasoning.stories.tsx +0 -182
  294. package/src/stories/conversation-with-sources.stories.tsx +0 -471
  295. package/src/stories/docs/Accessibility.mdx +0 -119
  296. package/src/stories/docs/ChildElements.mdx +0 -269
  297. package/src/stories/docs/ForAIAgents.mdx +0 -162
  298. package/src/stories/docs/GettingStarted.mdx +0 -65
  299. package/src/stories/docs/Installation.mdx +0 -83
  300. package/src/stories/docs/Introduction.mdx +0 -50
  301. package/src/stories/docs/SolidJsAdvanced.mdx +0 -17
  302. package/src/stories/docs/Theming.mdx +0 -85
  303. package/src/stories/docs/element-controls.ts +0 -121
  304. package/src/stories/docs/frameworks/Angular.mdx +0 -245
  305. package/src/stories/docs/frameworks/Html.mdx +0 -227
  306. package/src/stories/docs/frameworks/Overview.mdx +0 -47
  307. package/src/stories/docs/frameworks/React.mdx +0 -227
  308. package/src/stories/docs/frameworks/Solid.mdx +0 -173
  309. package/src/stories/docs/frameworks/Svelte.mdx +0 -194
  310. package/src/stories/docs/frameworks/Vue.mdx +0 -238
  311. package/src/stories/docs/generative-ui-overview.mdx +0 -186
  312. package/src/stories/docs/recipes/SpeechToText.mdx +0 -7
  313. package/src/stories/docs/recipes/Streaming.mdx +0 -68
  314. package/src/stories/docs/recipes/TextToSpeech.mdx +0 -35
  315. package/src/stories/docs/theme-editor/canvas.tsx +0 -32
  316. package/src/stories/docs/theme-editor/inspector.tsx +0 -66
  317. package/src/stories/docs/theme-editor/presets.test.ts +0 -32
  318. package/src/stories/docs/theme-editor/presets.ts +0 -64
  319. package/src/stories/docs/theme-editor/theme-css.test.ts +0 -19
  320. package/src/stories/docs/theme-editor/theme-css.ts +0 -15
  321. package/src/stories/docs/theme-editor/theme-editor.tsx +0 -146
  322. package/src/stories/docs/theme-tokens.tsx +0 -174
  323. package/src/stories/examples/ChoosingComponents.mdx +0 -106
  324. package/src/stories/examples/sample-data.ts +0 -79
  325. package/src/stories/examples/usage/checkpoint-restore.ts +0 -156
  326. package/src/stories/examples/usage/context-usage.ts +0 -591
  327. package/src/stories/examples/usage/conversation-with-reasoning.ts +0 -224
  328. package/src/stories/examples/usage/conversation-with-sources.ts +0 -589
  329. package/src/stories/examples/usage/empty-state.ts +0 -144
  330. package/src/stories/examples/usage/full-chat-app.ts +0 -277
  331. package/src/stories/examples/usage/index.ts +0 -63
  332. package/src/stories/examples/usage/message-actions.ts +0 -704
  333. package/src/stories/examples/usage/pattern-centered-conversation.ts +0 -446
  334. package/src/stories/examples/usage/pattern-chat-panel-layout.ts +0 -442
  335. package/src/stories/examples/usage/pattern-docked-widget.ts +0 -479
  336. package/src/stories/examples/usage/prompt-input-variants.ts +0 -1356
  337. package/src/stories/examples/usage/streaming-response.ts +0 -687
  338. package/src/stories/examples/usage/types.ts +0 -33
  339. package/src/stories/full-chat.stories.tsx +0 -18
  340. package/src/stories/message-actions.stories.tsx +0 -230
  341. package/src/stories/pattern-centered-conversation.stories.tsx +0 -93
  342. package/src/stories/pattern-docked-widget.stories.tsx +0 -93
  343. package/src/stories/pattern-empty-state.stories.tsx +0 -76
  344. package/src/stories/prompt-input-variants.stories.tsx +0 -456
  345. package/src/stories/streaming-response.stories.tsx +0 -438
  346. package/src/stories/theme-editor.stories.tsx +0 -16
  347. package/src/stories/token-reference.stories.tsx +0 -18
  348. package/src/stories/typography.stories.tsx +0 -78
  349. package/src/ui/avatar.stories.tsx +0 -103
  350. package/src/ui/badge.stories.tsx +0 -86
  351. package/src/ui/button.stories.tsx +0 -145
  352. package/src/ui/collapsible.stories.tsx +0 -69
  353. package/src/ui/dropdown.stories.tsx +0 -59
  354. package/src/ui/hover-card.stories.tsx +0 -77
  355. package/src/ui/hover-card.test.tsx +0 -30
  356. package/src/ui/overlay.stories.tsx +0 -115
  357. package/src/ui/popover.stories.tsx +0 -81
  358. package/src/ui/popover.test.tsx +0 -99
  359. package/src/ui/resizable.stories.tsx +0 -236
  360. package/src/ui/scroll-area.stories.tsx +0 -50
  361. package/src/ui/separator.stories.tsx +0 -81
  362. package/src/ui/skeleton.stories.tsx +0 -337
  363. package/src/ui/switch.stories.tsx +0 -51
  364. package/src/ui/switch.test.tsx +0 -59
  365. package/src/ui/textarea.stories.tsx +0 -76
  366. package/src/ui/tooltip.stories.tsx +0 -74
@@ -1,434 +0,0 @@
1
- import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
- import { createSignal, For } from 'solid-js';
3
- import {
4
- Empty, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription, EmptyContent,
5
- } from './empty';
6
- import { Button } from '../ui/button';
7
- import { Avatar } from '../ui/avatar';
8
- import { PromptSuggestion } from './prompt-suggestion';
9
- import { PromptInput, PromptInputTextarea, PromptInputActions } from './prompt-input';
10
- import {
11
- FolderPlus, MessageCircleQuestion, Inbox, Search, Sparkles, FileText, ArrowUp, Plus, Upload,
12
- } from 'lucide-solid';
13
- import { componentDescription } from '../stories/docs/element-controls';
14
-
15
- /**
16
- * Story for the compound `Empty` family. `Empty` is the root container; the
17
- * header/media/title/description/content subcomponents compose the layout. The
18
- * only real enum prop is `EmptyMedia`'s `variant`, so the controls focus on the
19
- * common composition, and the variation stories are compositional showcases.
20
- */
21
- const meta = {
22
- title: 'Solid (Advanced)/Elements/Empty',
23
- component: Empty,
24
- tags: ['autodocs'],
25
- parameters: {
26
- layout: 'padded',
27
- docs: {
28
- description: componentDescription([
29
- 'A composable empty-state block (modeled on shadcn/ui `Empty`): a centered media tile, title, description, and a content slot for actions or suggestions. Token-driven styling; no border by default.',
30
- '**When to use:** when a region has nothing to show yet — an empty list/inbox, no search results, a blank chat, or a drop zone — and you want to guide the user toward a next action.',
31
- '**How to use:** compose `Empty > EmptyHeader (EmptyMedia + EmptyTitle + EmptyDescription)` and an optional `EmptyContent` for buttons or prompt suggestions. Set `EmptyMedia` `variant` to `icon` for a muted tile or `default` for a bare slot (avatar/illustration). Add `border border-dashed` via `class` for a card.',
32
- '**Placement:** empty lists/sidebars, search-result panes, blank chat launch states, and file drop zones.',
33
- ]),
34
- controls: { exclude: ['use:eventListener'] },
35
- },
36
- },
37
- argTypes: {
38
- title: {
39
- control: 'text',
40
- description: 'Demo control: the `EmptyTitle` text.',
41
- },
42
- description: {
43
- control: 'text',
44
- description: 'Demo control: the `EmptyDescription` text.',
45
- },
46
- mediaVariant: {
47
- control: 'select',
48
- options: ['default', 'icon'],
49
- description: '`EmptyMedia` variant — `icon` is a muted rounded tile, `default` is a bare slot.',
50
- table: { defaultValue: { summary: 'default' } },
51
- },
52
- actionLabel: {
53
- control: 'text',
54
- description: 'Demo control: label of the primary action button.',
55
- },
56
- },
57
- render: (args: {
58
- title?: string;
59
- description?: string;
60
- mediaVariant?: 'default' | 'icon';
61
- actionLabel?: string;
62
- }) => (
63
- <div class="w-[420px]">
64
- <Empty>
65
- <EmptyHeader>
66
- <EmptyMedia variant={args.mediaVariant ?? 'icon'}><FolderPlus /></EmptyMedia>
67
- <EmptyTitle>{args.title}</EmptyTitle>
68
- <EmptyDescription>{args.description}</EmptyDescription>
69
- </EmptyHeader>
70
- <EmptyContent>
71
- <Button><Plus class="size-4" /> {args.actionLabel}</Button>
72
- </EmptyContent>
73
- </Empty>
74
- </div>
75
- ),
76
- } satisfies Meta<typeof Empty>;
77
-
78
- export default meta;
79
- type Story = StoryObj<typeof meta>;
80
-
81
- const IMPORT = `import {
82
- Empty, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription, EmptyContent,
83
- } from '@kitn.ai/ui';`;
84
- const src = (code: string) => ({
85
- parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
86
- });
87
-
88
- /** Interactive playground — edit the title, description, media variant, and action label. */
89
- export const Playground: Story = {
90
- args: {
91
- title: 'No projects yet',
92
- description: 'Get started by creating your first project.',
93
- mediaVariant: 'icon',
94
- actionLabel: 'Create project',
95
- },
96
- ...src(`<Empty>
97
- <EmptyHeader>
98
- <EmptyMedia variant="icon"><FolderPlus /></EmptyMedia>
99
- <EmptyTitle>No projects yet</EmptyTitle>
100
- <EmptyDescription>Get started by creating your first project.</EmptyDescription>
101
- </EmptyHeader>
102
- <EmptyContent>
103
- <Button><Plus class="size-4" /> Create project</Button>
104
- </EmptyContent>
105
- </Empty>`),
106
- };
107
-
108
- /** A single primary action — the canonical empty state. */
109
- export const Default: Story = {
110
- render: () => (
111
- <div class="w-[420px]">
112
- <Empty>
113
- <EmptyHeader>
114
- <EmptyMedia variant="icon"><FolderPlus /></EmptyMedia>
115
- <EmptyTitle>No projects yet</EmptyTitle>
116
- <EmptyDescription>Get started by creating your first project.</EmptyDescription>
117
- </EmptyHeader>
118
- <EmptyContent>
119
- <Button><Plus class="size-4" /> Create project</Button>
120
- </EmptyContent>
121
- </Empty>
122
- </div>
123
- ),
124
- ...src(`<Empty>
125
- <EmptyHeader>
126
- <EmptyMedia variant="icon"><FolderPlus /></EmptyMedia>
127
- <EmptyTitle>No projects yet</EmptyTitle>
128
- <EmptyDescription>Get started by creating your first project.</EmptyDescription>
129
- </EmptyHeader>
130
- <EmptyContent>
131
- <Button><Plus class="size-4" /> Create project</Button>
132
- </EmptyContent>
133
- </Empty>`),
134
- };
135
-
136
- /** Two actions — a primary plus a secondary (outline). */
137
- export const WithActions: Story = {
138
- name: 'With Multiple Actions',
139
- render: () => (
140
- <div class="w-[420px]">
141
- <Empty>
142
- <EmptyHeader>
143
- <EmptyMedia variant="icon"><Inbox /></EmptyMedia>
144
- <EmptyTitle>Your inbox is empty</EmptyTitle>
145
- <EmptyDescription>Import existing items or start from scratch.</EmptyDescription>
146
- </EmptyHeader>
147
- <EmptyContent>
148
- <div class="flex gap-2">
149
- <Button><Plus class="size-4" /> New item</Button>
150
- <Button variant="outline"><Upload class="size-4" /> Import</Button>
151
- </div>
152
- </EmptyContent>
153
- </Empty>
154
- </div>
155
- ),
156
- ...src(`<Empty>
157
- <EmptyHeader>
158
- <EmptyMedia variant="icon"><Inbox /></EmptyMedia>
159
- <EmptyTitle>Your inbox is empty</EmptyTitle>
160
- <EmptyDescription>Import existing items or start from scratch.</EmptyDescription>
161
- </EmptyHeader>
162
- <EmptyContent>
163
- <div class="flex gap-2">
164
- <Button><Plus class="size-4" /> New item</Button>
165
- <Button variant="outline"><Upload class="size-4" /> Import</Button>
166
- </div>
167
- </EmptyContent>
168
- </Empty>`),
169
- };
170
-
171
- /** The two `EmptyMedia` variants: an icon tile vs. a default (bare) slot
172
- * holding an avatar or larger illustration. */
173
- export const MediaVariants: Story = {
174
- name: 'Media Variants (icon / default)',
175
- render: () => (
176
- <div class="flex gap-8">
177
- <div class="w-[280px]">
178
- <Empty>
179
- <EmptyHeader>
180
- <EmptyMedia variant="icon"><Search /></EmptyMedia>
181
- <EmptyTitle>variant="icon"</EmptyTitle>
182
- <EmptyDescription>Icon sits in a muted rounded tile.</EmptyDescription>
183
- </EmptyHeader>
184
- </Empty>
185
- </div>
186
- <div class="w-[280px]">
187
- <Empty>
188
- <EmptyHeader>
189
- <EmptyMedia variant="default"><Avatar fallback="JA" size="lg" /></EmptyMedia>
190
- <EmptyTitle>variant="default"</EmptyTitle>
191
- <EmptyDescription>Bare slot for an avatar or illustration.</EmptyDescription>
192
- </EmptyHeader>
193
- </Empty>
194
- </div>
195
- </div>
196
- ),
197
- ...src(`<Empty>
198
- <EmptyHeader>
199
- <EmptyMedia variant="icon"><Search /></EmptyMedia>
200
- <EmptyTitle>Icon tile</EmptyTitle>
201
- </EmptyHeader>
202
- </Empty>
203
-
204
- <Empty>
205
- <EmptyHeader>
206
- <EmptyMedia variant="default"><Avatar fallback="JA" size="lg" /></EmptyMedia>
207
- <EmptyTitle>Bare slot</EmptyTitle>
208
- </EmptyHeader>
209
- </Empty>`),
210
- };
211
-
212
- /** Suggestions as pills (PromptSuggestion default) in a centered wrap —
213
- * best for a handful of short prompts. */
214
- export const SuggestionPills: Story = {
215
- name: 'Suggestions — Pills',
216
- render: () => (
217
- <div class="w-[460px]">
218
- <Empty>
219
- <EmptyHeader>
220
- <EmptyMedia variant="icon"><Sparkles /></EmptyMedia>
221
- <EmptyTitle>Start a conversation</EmptyTitle>
222
- <EmptyDescription>Pick a prompt or type your own.</EmptyDescription>
223
- </EmptyHeader>
224
- <EmptyContent>
225
- <div class="flex flex-wrap justify-center gap-2">
226
- <For each={['Summarize this', 'Key takeaways', 'Create an outline', 'Find risks']}>
227
- {(s) => <PromptSuggestion>{s}</PromptSuggestion>}
228
- </For>
229
- </div>
230
- </EmptyContent>
231
- </Empty>
232
- </div>
233
- ),
234
- ...src(`<Empty>
235
- <EmptyHeader>
236
- <EmptyMedia variant="icon"><Sparkles /></EmptyMedia>
237
- <EmptyTitle>Start a conversation</EmptyTitle>
238
- <EmptyDescription>Pick a prompt or type your own.</EmptyDescription>
239
- </EmptyHeader>
240
- <EmptyContent>
241
- <div class="flex flex-wrap justify-center gap-2">
242
- <For each={prompts}>{(s) => <PromptSuggestion>{s}</PromptSuggestion>}</For>
243
- </div>
244
- </EmptyContent>
245
- </Empty>`),
246
- };
247
-
248
- /** Suggestions as a full-width list (PromptSuggestion `block`) — best for
249
- * longer, sentence-length prompts. This is the report chat dock's pattern. */
250
- export const SuggestionList: Story = {
251
- name: 'Suggestions — List (block)',
252
- render: () => (
253
- <div class="w-[360px]">
254
- <Empty>
255
- <EmptyHeader>
256
- <EmptyMedia variant="icon"><MessageCircleQuestion /></EmptyMedia>
257
- <EmptyTitle>Hi Jordan</EmptyTitle>
258
- <EmptyDescription>Ask me anything about your report.</EmptyDescription>
259
- </EmptyHeader>
260
- <EmptyContent class="max-w-none">
261
- <For each={[
262
- 'What does being a Catalyst mean for how I work with others?',
263
- 'How do my Dominance and Influence styles play off each other?',
264
- 'Where might my lower Conscientiousness trip me up?',
265
- ]}>
266
- {(s) => <PromptSuggestion block>{s}</PromptSuggestion>}
267
- </For>
268
- </EmptyContent>
269
- </Empty>
270
- </div>
271
- ),
272
- ...src(`<Empty>
273
- <EmptyHeader>
274
- <EmptyMedia variant="icon"><MessageCircleQuestion /></EmptyMedia>
275
- <EmptyTitle>Hi Jordan</EmptyTitle>
276
- <EmptyDescription>Ask me anything about your report.</EmptyDescription>
277
- </EmptyHeader>
278
- <EmptyContent class="max-w-none">
279
- <For each={prompts}>{(s) => <PromptSuggestion block>{s}</PromptSuggestion>}</For>
280
- </EmptyContent>
281
- </Empty>`),
282
- };
283
-
284
- /** Suggestions organized into labeled groups (mirrors the Prompt Input
285
- * Variants → WithSuggestions pattern), inside an empty block. */
286
- export const GroupedSuggestions: Story = {
287
- name: 'Suggestions — Grouped',
288
- render: () => {
289
- const groups = [
290
- { label: 'Get started', items: ['Summarize this document', 'What are the key takeaways?'] },
291
- { label: 'Go deeper', items: ['Compare with similar approaches', 'What are the tradeoffs?'] },
292
- ];
293
- return (
294
- <div class="w-[460px]">
295
- <Empty>
296
- <EmptyHeader>
297
- <EmptyMedia variant="icon"><FileText /></EmptyMedia>
298
- <EmptyTitle>Ask about this document</EmptyTitle>
299
- <EmptyDescription>Choose a starting point.</EmptyDescription>
300
- </EmptyHeader>
301
- <EmptyContent class="max-w-none gap-4">
302
- <For each={groups}>
303
- {(group) => (
304
- <div class="w-full space-y-2 text-center">
305
- <span class="text-xs font-medium text-muted-foreground uppercase tracking-wider">
306
- {group.label}
307
- </span>
308
- <div class="flex flex-wrap justify-center gap-2">
309
- <For each={group.items}>{(item) => <PromptSuggestion>{item}</PromptSuggestion>}</For>
310
- </div>
311
- </div>
312
- )}
313
- </For>
314
- </EmptyContent>
315
- </Empty>
316
- </div>
317
- );
318
- },
319
- ...src(`<Empty>
320
- <EmptyHeader>
321
- <EmptyMedia variant="icon"><FileText /></EmptyMedia>
322
- <EmptyTitle>Ask about this document</EmptyTitle>
323
- <EmptyDescription>Choose a starting point.</EmptyDescription>
324
- </EmptyHeader>
325
- <EmptyContent class="max-w-none gap-4">
326
- <For each={groups}>{(group) => (/* label + wrapped PromptSuggestions */)}</For>
327
- </EmptyContent>
328
- </Empty>`),
329
- };
330
-
331
- /** An empty block whose content is an input — the "blank chat" launch state. */
332
- export const WithInput: Story = {
333
- name: 'With Prompt Input',
334
- render: () => {
335
- const [value, setValue] = createSignal('');
336
- return (
337
- <div class="w-[460px]">
338
- <Empty>
339
- <EmptyHeader>
340
- <EmptyMedia variant="icon"><Sparkles /></EmptyMedia>
341
- <EmptyTitle>How can I help?</EmptyTitle>
342
- <EmptyDescription>Ask anything to get started.</EmptyDescription>
343
- </EmptyHeader>
344
- <EmptyContent>
345
- <PromptInput value={value()} onValueChange={setValue} onSubmit={() => setValue('')} class="w-full">
346
- <PromptInputTextarea placeholder="Ask anything..." class="min-h-[44px] px-3 pt-2.5" />
347
- <PromptInputActions class="justify-end px-2 pb-2">
348
- <Button size="icon-sm" class="rounded-full" aria-label="Send message" disabled={!value().trim()}>
349
- <ArrowUp class="size-4" />
350
- </Button>
351
- </PromptInputActions>
352
- </PromptInput>
353
- </EmptyContent>
354
- </Empty>
355
- </div>
356
- );
357
- },
358
- ...src(`<Empty>
359
- <EmptyHeader>
360
- <EmptyMedia variant="icon"><Sparkles /></EmptyMedia>
361
- <EmptyTitle>How can I help?</EmptyTitle>
362
- <EmptyDescription>Ask anything to get started.</EmptyDescription>
363
- </EmptyHeader>
364
- <EmptyContent>
365
- <PromptInput value={value()} onValueChange={setValue} onSubmit={() => setValue('')}>
366
- <PromptInputTextarea placeholder="Ask anything..." />
367
- <PromptInputActions class="justify-end">
368
- <Button size="icon-sm" disabled={!value().trim()}><ArrowUp class="size-4" /></Button>
369
- </PromptInputActions>
370
- </PromptInput>
371
- </EmptyContent>
372
- </Empty>`),
373
- };
374
-
375
- /** A description can carry a link; styled underline + primary-on-hover. */
376
- export const WithLink: Story = {
377
- name: 'With Link in Description',
378
- render: () => (
379
- <div class="w-[420px]">
380
- <Empty>
381
- <EmptyHeader>
382
- <EmptyMedia variant="icon"><Search /></EmptyMedia>
383
- <EmptyTitle>No results found</EmptyTitle>
384
- <EmptyDescription>
385
- Try a different search, or <a href="#">browse all items</a> instead.
386
- </EmptyDescription>
387
- </EmptyHeader>
388
- <EmptyContent>
389
- <Button variant="outline">Clear filters</Button>
390
- </EmptyContent>
391
- </Empty>
392
- </div>
393
- ),
394
- ...src(`<Empty>
395
- <EmptyHeader>
396
- <EmptyMedia variant="icon"><Search /></EmptyMedia>
397
- <EmptyTitle>No results found</EmptyTitle>
398
- <EmptyDescription>
399
- Try a different search, or <a href="#">browse all items</a> instead.
400
- </EmptyDescription>
401
- </EmptyHeader>
402
- <EmptyContent>
403
- <Button variant="outline">Clear filters</Button>
404
- </EmptyContent>
405
- </Empty>`),
406
- };
407
-
408
- /** A bordered (dashed) card treatment — add `border border-dashed` via class. */
409
- export const Bordered: Story = {
410
- render: () => (
411
- <div class="w-[420px]">
412
- <Empty class="border border-dashed">
413
- <EmptyHeader>
414
- <EmptyMedia variant="icon"><FolderPlus /></EmptyMedia>
415
- <EmptyTitle>Drop files here</EmptyTitle>
416
- <EmptyDescription>Or click to browse from your computer.</EmptyDescription>
417
- </EmptyHeader>
418
- <EmptyContent>
419
- <Button variant="outline"><Upload class="size-4" /> Choose files</Button>
420
- </EmptyContent>
421
- </Empty>
422
- </div>
423
- ),
424
- ...src(`<Empty class="border border-dashed">
425
- <EmptyHeader>
426
- <EmptyMedia variant="icon"><FolderPlus /></EmptyMedia>
427
- <EmptyTitle>Drop files here</EmptyTitle>
428
- <EmptyDescription>Or click to browse from your computer.</EmptyDescription>
429
- </EmptyHeader>
430
- <EmptyContent>
431
- <Button variant="outline"><Upload class="size-4" /> Choose files</Button>
432
- </EmptyContent>
433
- </Empty>`),
434
- };
@@ -1,138 +0,0 @@
1
- import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
- import { fn } from 'storybook/test';
3
- import { FeedbackBar } from './feedback-bar';
4
- import { componentDescription } from '../stories/docs/element-controls';
5
-
6
- const meta = {
7
- title: 'Solid (Advanced)/Elements/FeedbackBar',
8
- component: FeedbackBar,
9
- tags: ['autodocs'],
10
- parameters: {
11
- layout: 'padded',
12
- docs: {
13
- controls: { exclude: ['use:eventListener'] },
14
- description: componentDescription([
15
- 'An inline bar that prompts the user to rate a response. It owns its own flow — it asks, optionally collects a category + comment on a not-helpful vote, then confirms with a thank-you, all in place (the way ChatGPT/Claude do it). It does **not** disappear on a vote; only the close (X) button dismisses it.',
16
- '**When to use:** after an assistant message, to collect quick helpful / not-helpful feedback (optionally with a reason).',
17
- '**How to use:** set a `title`; for the richer flow set `collect-detail` and pass `categories`. The vote fires `onFeedback` immediately; the optional detail fires `onSubmitDetail`; `onClose` dismisses the bar.',
18
- '**Placement:** directly beneath a completed assistant message, or in a message action row.',
19
- ]),
20
- },
21
- },
22
- argTypes: {
23
- title: {
24
- control: 'text',
25
- description: 'Prompt text shown next to the rating buttons.',
26
- },
27
- icon: {
28
- control: false,
29
- description: 'Optional leading icon element shown before the title.',
30
- },
31
- collectDetail: {
32
- control: 'boolean',
33
- description: 'When on, a not-helpful vote opens an optional detail form (category chips + comment) before the thank-you.',
34
- },
35
- categories: {
36
- control: 'object',
37
- description: 'Category chips offered in the detail form.',
38
- },
39
- thanksMessage: {
40
- control: 'text',
41
- description: 'Confirmation copy shown after a vote/submit.',
42
- },
43
- class: {
44
- control: 'text',
45
- description: 'Additional CSS classes for the root element.',
46
- },
47
- onFeedback: {
48
- action: 'feedback',
49
- description: 'Fired with `value: "helpful" | "not-helpful"` immediately when a rating button is clicked (the vote is recorded even if the detail form is skipped).',
50
- table: { category: 'Events' },
51
- },
52
- onSubmitDetail: {
53
- action: 'submitDetail',
54
- description: 'Fired with `{ value, category?, comment? }` when the optional detail form is submitted.',
55
- table: { category: 'Events' },
56
- },
57
- onClose: {
58
- action: 'close',
59
- description: 'Fired when the close (X) button is clicked.',
60
- table: { category: 'Events' },
61
- },
62
- },
63
- args: {
64
- title: 'Was this response helpful?',
65
- onFeedback: fn(),
66
- onSubmitDetail: fn(),
67
- onClose: fn(),
68
- },
69
- render: (args) => <FeedbackBar {...args} />,
70
- } satisfies Meta<typeof FeedbackBar>;
71
-
72
- export default meta;
73
- type Story = StoryObj<typeof meta>;
74
-
75
- const IMPORT = `import { FeedbackBar } from '@kitn.ai/ui';`;
76
- const src = (code: string) => ({
77
- parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
78
- });
79
-
80
- /** Interactive playground — tweak the controls to explore the feedback bar. */
81
- export const Playground: Story = {
82
- ...src(`<FeedbackBar
83
- title="Was this response helpful?"
84
- onFeedback={(value) => console.log('feedback:', value)}
85
- onClose={() => {}}
86
- />`),
87
- };
88
-
89
- export const CustomTitle: Story = {
90
- args: { title: 'Rate this answer' },
91
- ...src(`<FeedbackBar title="Rate this answer" onFeedback={(value) => console.log('feedback:', value)} />`),
92
- };
93
-
94
- const SmileyIcon = () => (
95
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="text-muted-foreground">
96
- <circle cx="12" cy="12" r="10" />
97
- <path d="M8 14s1.5 2 4 2 4-2 4-2" />
98
- <line x1="9" y1="9" x2="9.01" y2="9" />
99
- <line x1="15" y1="9" x2="15.01" y2="9" />
100
- </svg>
101
- );
102
-
103
- export const WithIcon: Story = {
104
- args: { title: 'How did I do?', icon: <SmileyIcon /> },
105
- ...src(`<FeedbackBar
106
- title="How did I do?"
107
- icon={<SmileyIcon />}
108
- onFeedback={(value) => console.log('feedback:', value)}
109
- />`),
110
- };
111
-
112
- /** The full flow: a not-helpful vote opens an optional detail form (category
113
- * chips + comment) before the thank-you. A helpful vote skips straight to thanks.
114
- * Click 👎 to see the detail step. */
115
- export const WithDetail: Story = {
116
- args: {
117
- title: 'Was this response helpful?',
118
- collectDetail: true,
119
- categories: ['Inaccurate', 'Not helpful', 'Unsafe', 'Other'],
120
- },
121
- ...src(`<FeedbackBar
122
- title="Was this response helpful?"
123
- collectDetail
124
- categories={['Inaccurate', 'Not helpful', 'Unsafe', 'Other']}
125
- onFeedback={(value) => console.log('vote:', value)}
126
- onSubmitDetail={(d) => console.log('detail:', d)} // { value, category?, comment? }
127
- />`),
128
- };
129
-
130
- /** A custom confirmation message shown after the vote. */
131
- export const CustomThanks: Story = {
132
- args: { title: 'Rate this answer', thanksMessage: 'Got it — thanks for helping us improve!' },
133
- ...src(`<FeedbackBar
134
- title="Rate this answer"
135
- thanksMessage="Got it — thanks for helping us improve!"
136
- onFeedback={(value) => console.log('feedback:', value)}
137
- />`),
138
- };
@@ -1,103 +0,0 @@
1
- import { describe, it, expect, vi, afterEach } from 'vitest';
2
- import '@testing-library/jest-dom/vitest';
3
- import { render, cleanup, fireEvent } from '@solidjs/testing-library';
4
- import { FeedbackBar } from './feedback-bar';
5
-
6
- afterEach(cleanup);
7
-
8
- describe('FeedbackBar', () => {
9
- it('shows the prompt and rating buttons in the ask phase', () => {
10
- const { getByText, getByLabelText } = render(() => <FeedbackBar title="Helpful?" />);
11
- expect(getByText('Helpful?')).toBeInTheDocument();
12
- expect(getByLabelText('Helpful')).toBeInTheDocument();
13
- expect(getByLabelText('Not helpful')).toBeInTheDocument();
14
- });
15
-
16
- it('fires onFeedback immediately and confirms in place (no detail by default)', () => {
17
- const onFeedback = vi.fn();
18
- const { getByLabelText, getByText, queryByLabelText } = render(() => (
19
- <FeedbackBar title="Helpful?" onFeedback={onFeedback} />
20
- ));
21
- fireEvent.click(getByLabelText('Helpful'));
22
- expect(onFeedback).toHaveBeenCalledWith('helpful');
23
- // Confirms in place — does not disappear; the prompt is replaced by thanks.
24
- expect(getByText('Thanks for your feedback')).toBeInTheDocument();
25
- expect(queryByLabelText('Helpful')).not.toBeInTheDocument();
26
- });
27
-
28
- it('a not-helpful vote goes straight to thanks when collectDetail is off', () => {
29
- const { getByLabelText, getByText, queryByText } = render(() => <FeedbackBar title="Helpful?" />);
30
- fireEvent.click(getByLabelText('Not helpful'));
31
- expect(getByText('Thanks for your feedback')).toBeInTheDocument();
32
- expect(queryByText('What went wrong?')).not.toBeInTheDocument();
33
- });
34
-
35
- it('opens the detail form on a not-helpful vote when collectDetail is set', () => {
36
- const onFeedback = vi.fn();
37
- const { getByLabelText, getByText } = render(() => (
38
- <FeedbackBar title="Helpful?" collectDetail categories={['Inaccurate', 'Unhelpful']} onFeedback={onFeedback} />
39
- ));
40
- fireEvent.click(getByLabelText('Not helpful'));
41
- // Vote still recorded immediately, AND the detail form appears.
42
- expect(onFeedback).toHaveBeenCalledWith('not-helpful');
43
- expect(getByText('What went wrong?')).toBeInTheDocument();
44
- expect(getByText('Inaccurate')).toBeInTheDocument();
45
- });
46
-
47
- it('a helpful vote skips the detail form even when collectDetail is set', () => {
48
- const { getByLabelText, getByText, queryByText } = render(() => (
49
- <FeedbackBar title="Helpful?" collectDetail categories={['Inaccurate']} />
50
- ));
51
- fireEvent.click(getByLabelText('Helpful'));
52
- expect(getByText('Thanks for your feedback')).toBeInTheDocument();
53
- expect(queryByText('What went wrong?')).not.toBeInTheDocument();
54
- });
55
-
56
- it('submits the detail form with the selected category and comment', () => {
57
- const onSubmitDetail = vi.fn();
58
- const { getByLabelText, getByText, getByPlaceholderText } = render(() => (
59
- <FeedbackBar
60
- title="Helpful?"
61
- collectDetail
62
- categories={['Inaccurate', 'Unhelpful']}
63
- onSubmitDetail={onSubmitDetail}
64
- />
65
- ));
66
- fireEvent.click(getByLabelText('Not helpful'));
67
- fireEvent.click(getByText('Inaccurate'));
68
- fireEvent.input(getByPlaceholderText('Tell us more (optional)'), { target: { value: 'wrong answer' } });
69
- fireEvent.click(getByText('Submit'));
70
- expect(onSubmitDetail).toHaveBeenCalledWith({
71
- value: 'not-helpful',
72
- category: 'Inaccurate',
73
- comment: 'wrong answer',
74
- });
75
- expect(getByText('Thanks for your feedback')).toBeInTheDocument();
76
- });
77
-
78
- it('Skip dismisses the detail form to thanks without firing onSubmitDetail', () => {
79
- const onSubmitDetail = vi.fn();
80
- const { getByLabelText, getByText } = render(() => (
81
- <FeedbackBar title="Helpful?" collectDetail categories={['Inaccurate']} onSubmitDetail={onSubmitDetail} />
82
- ));
83
- fireEvent.click(getByLabelText('Not helpful'));
84
- fireEvent.click(getByText('Skip'));
85
- expect(onSubmitDetail).not.toHaveBeenCalled();
86
- expect(getByText('Thanks for your feedback')).toBeInTheDocument();
87
- });
88
-
89
- it('fires onClose when dismissed from the ask phase', () => {
90
- const onClose = vi.fn();
91
- const { getByLabelText } = render(() => <FeedbackBar title="Helpful?" onClose={onClose} />);
92
- fireEvent.click(getByLabelText('Close'));
93
- expect(onClose).toHaveBeenCalled();
94
- });
95
-
96
- it('honors a custom thanksMessage', () => {
97
- const { getByLabelText, getByText } = render(() => (
98
- <FeedbackBar title="Helpful?" thanksMessage="Got it — thank you!" />
99
- ));
100
- fireEvent.click(getByLabelText('Helpful'));
101
- expect(getByText('Got it — thank you!')).toBeInTheDocument();
102
- });
103
- });