@kitn.ai/ui 0.14.1 → 0.15.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 (179) hide show
  1. package/dist/kitn-chat.es.js +1 -1
  2. package/package.json +6 -1
  3. package/src/components/component-meta.json +10 -10
  4. package/src/elements/compiled.css +1 -1
  5. package/src/remote/host-embed.ts +1 -1
  6. package/src/components/artifact.stories.tsx +0 -138
  7. package/src/components/attachments.stories.tsx +0 -303
  8. package/src/components/attachments.test.tsx +0 -64
  9. package/src/components/chain-of-thought.stories.tsx +0 -211
  10. package/src/components/chat-container.stories.tsx +0 -187
  11. package/src/components/chat-thread.test.tsx +0 -58
  12. package/src/components/checkpoint.stories.tsx +0 -102
  13. package/src/components/code-block.stories.tsx +0 -150
  14. package/src/components/confirm-card.stories.tsx +0 -74
  15. package/src/components/context.stories.tsx +0 -229
  16. package/src/components/context.test.tsx +0 -133
  17. package/src/components/conversation-item.stories.tsx +0 -125
  18. package/src/components/conversation-list.stories.tsx +0 -133
  19. package/src/components/default-input.test.tsx +0 -111
  20. package/src/components/empty.stories.tsx +0 -434
  21. package/src/components/feedback-bar.stories.tsx +0 -138
  22. package/src/components/feedback-bar.test.tsx +0 -103
  23. package/src/components/file-tree.stories.tsx +0 -73
  24. package/src/components/file-upload.stories.tsx +0 -156
  25. package/src/components/image.stories.tsx +0 -89
  26. package/src/components/loader.stories.tsx +0 -181
  27. package/src/components/markdown.stories.tsx +0 -180
  28. package/src/components/message-action-bar.test.tsx +0 -128
  29. package/src/components/message-narrow.stories.tsx +0 -329
  30. package/src/components/message-skills.stories.tsx +0 -211
  31. package/src/components/message.stories.tsx +0 -281
  32. package/src/components/model-switcher.stories.tsx +0 -123
  33. package/src/components/model-switcher.test.tsx +0 -65
  34. package/src/components/prompt-input.stories.tsx +0 -222
  35. package/src/components/prompt-suggestion.stories.tsx +0 -142
  36. package/src/components/reasoning.stories.tsx +0 -140
  37. package/src/components/resizable.test.tsx +0 -226
  38. package/src/components/scroll-button.stories.tsx +0 -100
  39. package/src/components/slash-command.stories.tsx +0 -163
  40. package/src/components/source-list.test.tsx +0 -152
  41. package/src/components/source.stories.tsx +0 -124
  42. package/src/components/tasks-card.stories.tsx +0 -78
  43. package/src/components/text-shimmer.stories.tsx +0 -87
  44. package/src/components/thinking-bar.stories.tsx +0 -87
  45. package/src/components/tool.stories.tsx +0 -153
  46. package/src/components/voice-input.stories.tsx +0 -83
  47. package/src/elements/artifact.stories.tsx +0 -506
  48. package/src/elements/attachments.stories.tsx +0 -190
  49. package/src/elements/card.stories.tsx +0 -113
  50. package/src/elements/cards.stories.tsx +0 -59
  51. package/src/elements/catalog.stories.tsx +0 -491
  52. package/src/elements/chain-of-thought.declarative.test.tsx +0 -153
  53. package/src/elements/chain-of-thought.stories.tsx +0 -113
  54. package/src/elements/chat-scope-picker.stories.tsx +0 -73
  55. package/src/elements/chat-workspace.stories.tsx +0 -288
  56. package/src/elements/chat.stories.tsx +0 -151
  57. package/src/elements/checkpoint.stories.tsx +0 -72
  58. package/src/elements/choice.stories.tsx +0 -240
  59. package/src/elements/code-block.stories.tsx +0 -83
  60. package/src/elements/composed-shell.stories.tsx +0 -316
  61. package/src/elements/confirm-card.stories.tsx +0 -227
  62. package/src/elements/context-meter.stories.tsx +0 -151
  63. package/src/elements/conversation-list.declarative.test.tsx +0 -137
  64. package/src/elements/conversation-list.stories.tsx +0 -243
  65. package/src/elements/embed.stories.tsx +0 -213
  66. package/src/elements/empty.stories.tsx +0 -111
  67. package/src/elements/feedback-bar.stories.tsx +0 -114
  68. package/src/elements/file-tree.stories.tsx +0 -134
  69. package/src/elements/file-upload.stories.tsx +0 -82
  70. package/src/elements/form.stories.tsx +0 -248
  71. package/src/elements/image.stories.tsx +0 -71
  72. package/src/elements/link-preview.stories.tsx +0 -209
  73. package/src/elements/loader.stories.tsx +0 -88
  74. package/src/elements/markdown.stories.tsx +0 -76
  75. package/src/elements/message-skills.declarative.test.tsx +0 -104
  76. package/src/elements/message-skills.stories.tsx +0 -114
  77. package/src/elements/message.stories.tsx +0 -218
  78. package/src/elements/model-switcher.declarative.test.tsx +0 -130
  79. package/src/elements/model-switcher.stories.tsx +0 -198
  80. package/src/elements/popover.stories.tsx +0 -80
  81. package/src/elements/prompt-input-slash-command.test.tsx +0 -128
  82. package/src/elements/prompt-input-stoppable.test.tsx +0 -88
  83. package/src/elements/prompt-input-toolbar-actions.test.tsx +0 -120
  84. package/src/elements/prompt-input.stories.tsx +0 -331
  85. package/src/elements/prompt-suggestions.declarative.test.tsx +0 -164
  86. package/src/elements/prompt-suggestions.stories.tsx +0 -213
  87. package/src/elements/reasoning.stories.tsx +0 -77
  88. package/src/elements/remote.stories.tsx +0 -314
  89. package/src/elements/resizable.stories.tsx +0 -426
  90. package/src/elements/response-stream.stories.tsx +0 -79
  91. package/src/elements/scroll-button.stories.tsx +0 -202
  92. package/src/elements/scroll-button.test.tsx +0 -148
  93. package/src/elements/source-list.stories.tsx +0 -143
  94. package/src/elements/source.stories.tsx +0 -88
  95. package/src/elements/switch.stories.tsx +0 -56
  96. package/src/elements/tasks.stories.tsx +0 -237
  97. package/src/elements/text-shimmer.stories.tsx +0 -64
  98. package/src/elements/thinking-bar.stories.tsx +0 -72
  99. package/src/elements/tool.stories.tsx +0 -89
  100. package/src/elements/voice-input.stories.tsx +0 -88
  101. package/src/primitives/controllable.test.ts +0 -47
  102. package/src/stories/chat-panel-layout.stories.tsx +0 -145
  103. package/src/stories/chat-scene.tsx +0 -571
  104. package/src/stories/checkpoint-restore.stories.tsx +0 -256
  105. package/src/stories/context-usage.stories.tsx +0 -212
  106. package/src/stories/conversation-with-reasoning.stories.tsx +0 -182
  107. package/src/stories/conversation-with-sources.stories.tsx +0 -471
  108. package/src/stories/docs/Accessibility.mdx +0 -119
  109. package/src/stories/docs/ChildElements.mdx +0 -269
  110. package/src/stories/docs/ForAIAgents.mdx +0 -162
  111. package/src/stories/docs/GettingStarted.mdx +0 -65
  112. package/src/stories/docs/Installation.mdx +0 -83
  113. package/src/stories/docs/Introduction.mdx +0 -50
  114. package/src/stories/docs/SolidJsAdvanced.mdx +0 -17
  115. package/src/stories/docs/Theming.mdx +0 -85
  116. package/src/stories/docs/element-controls.ts +0 -121
  117. package/src/stories/docs/frameworks/Angular.mdx +0 -245
  118. package/src/stories/docs/frameworks/Html.mdx +0 -227
  119. package/src/stories/docs/frameworks/Overview.mdx +0 -47
  120. package/src/stories/docs/frameworks/React.mdx +0 -227
  121. package/src/stories/docs/frameworks/Solid.mdx +0 -173
  122. package/src/stories/docs/frameworks/Svelte.mdx +0 -194
  123. package/src/stories/docs/frameworks/Vue.mdx +0 -238
  124. package/src/stories/docs/generative-ui-overview.mdx +0 -186
  125. package/src/stories/docs/recipes/SpeechToText.mdx +0 -7
  126. package/src/stories/docs/recipes/Streaming.mdx +0 -68
  127. package/src/stories/docs/recipes/TextToSpeech.mdx +0 -35
  128. package/src/stories/docs/theme-editor/canvas.tsx +0 -32
  129. package/src/stories/docs/theme-editor/inspector.tsx +0 -66
  130. package/src/stories/docs/theme-editor/presets.test.ts +0 -32
  131. package/src/stories/docs/theme-editor/presets.ts +0 -64
  132. package/src/stories/docs/theme-editor/theme-css.test.ts +0 -19
  133. package/src/stories/docs/theme-editor/theme-css.ts +0 -15
  134. package/src/stories/docs/theme-editor/theme-editor.tsx +0 -146
  135. package/src/stories/docs/theme-tokens.tsx +0 -174
  136. package/src/stories/examples/ChoosingComponents.mdx +0 -106
  137. package/src/stories/examples/sample-data.ts +0 -79
  138. package/src/stories/examples/usage/checkpoint-restore.ts +0 -156
  139. package/src/stories/examples/usage/context-usage.ts +0 -591
  140. package/src/stories/examples/usage/conversation-with-reasoning.ts +0 -224
  141. package/src/stories/examples/usage/conversation-with-sources.ts +0 -589
  142. package/src/stories/examples/usage/empty-state.ts +0 -144
  143. package/src/stories/examples/usage/full-chat-app.ts +0 -277
  144. package/src/stories/examples/usage/index.ts +0 -63
  145. package/src/stories/examples/usage/message-actions.ts +0 -704
  146. package/src/stories/examples/usage/pattern-centered-conversation.ts +0 -446
  147. package/src/stories/examples/usage/pattern-chat-panel-layout.ts +0 -442
  148. package/src/stories/examples/usage/pattern-docked-widget.ts +0 -479
  149. package/src/stories/examples/usage/prompt-input-variants.ts +0 -1356
  150. package/src/stories/examples/usage/streaming-response.ts +0 -687
  151. package/src/stories/examples/usage/types.ts +0 -33
  152. package/src/stories/full-chat.stories.tsx +0 -18
  153. package/src/stories/message-actions.stories.tsx +0 -230
  154. package/src/stories/pattern-centered-conversation.stories.tsx +0 -93
  155. package/src/stories/pattern-docked-widget.stories.tsx +0 -93
  156. package/src/stories/pattern-empty-state.stories.tsx +0 -76
  157. package/src/stories/prompt-input-variants.stories.tsx +0 -456
  158. package/src/stories/streaming-response.stories.tsx +0 -438
  159. package/src/stories/theme-editor.stories.tsx +0 -16
  160. package/src/stories/token-reference.stories.tsx +0 -18
  161. package/src/stories/typography.stories.tsx +0 -78
  162. package/src/ui/avatar.stories.tsx +0 -103
  163. package/src/ui/badge.stories.tsx +0 -86
  164. package/src/ui/button.stories.tsx +0 -145
  165. package/src/ui/collapsible.stories.tsx +0 -69
  166. package/src/ui/dropdown.stories.tsx +0 -59
  167. package/src/ui/hover-card.stories.tsx +0 -77
  168. package/src/ui/hover-card.test.tsx +0 -30
  169. package/src/ui/overlay.stories.tsx +0 -115
  170. package/src/ui/popover.stories.tsx +0 -81
  171. package/src/ui/popover.test.tsx +0 -99
  172. package/src/ui/resizable.stories.tsx +0 -236
  173. package/src/ui/scroll-area.stories.tsx +0 -50
  174. package/src/ui/separator.stories.tsx +0 -81
  175. package/src/ui/skeleton.stories.tsx +0 -337
  176. package/src/ui/switch.stories.tsx +0 -51
  177. package/src/ui/switch.test.tsx +0 -59
  178. package/src/ui/textarea.stories.tsx +0 -76
  179. 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
- });