@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,86 +0,0 @@
1
- import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
- import { Badge } from './badge';
3
- import { componentDescription } from '../stories/docs/element-controls';
4
-
5
- const meta = {
6
- title: 'Solid (Advanced)/Primitives/Badge',
7
- component: Badge,
8
- tags: ['autodocs'],
9
- parameters: {
10
- layout: 'padded',
11
- docs: {
12
- controls: { exclude: ['use:eventListener'] },
13
- description: componentDescription([
14
- 'A compact pill **badge** for short status text, counts, or citation markers, rendered as an inline `<span>`.',
15
- '**When to use:** to annotate a count (unread, results), tag a status/label, or mark an inline source citation in assistant output.',
16
- '**How to use:** choose a `variant` (`default` label, `count` numeric pill, `citation` clickable source marker) and pass the text or number as children.',
17
- '**Placement:** inline with message text (citations), next to titles or list items (labels), and on toolbar/icon buttons (counts).',
18
- ]),
19
- },
20
- },
21
- argTypes: {
22
- variant: {
23
- control: 'select',
24
- options: ['default', 'count', 'citation'],
25
- description: 'Visual style: neutral label, numeric count pill, or clickable citation marker.',
26
- table: { defaultValue: { summary: 'default' } },
27
- },
28
- children: {
29
- control: 'text',
30
- description: 'Badge content — short text or a number.',
31
- },
32
- },
33
- args: {
34
- variant: 'default',
35
- children: 'Default badge',
36
- },
37
- render: (args) => <Badge {...args} />,
38
- } satisfies Meta<typeof Badge>;
39
-
40
- export default meta;
41
- type Story = StoryObj<typeof meta>;
42
-
43
- const IMPORT = `import { Badge } from '@kitn.ai/ui';`;
44
- const src = (code: string) => ({
45
- parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
46
- });
47
-
48
- /** Interactive playground — switch the variant and edit the content. */
49
- export const Playground: Story = {
50
- ...src(`<Badge variant="default">Default badge</Badge>`),
51
- };
52
-
53
- export const Default: Story = {
54
- args: { variant: 'default', children: 'Default badge' },
55
- ...src(`<Badge variant="default">Default badge</Badge>`),
56
- };
57
-
58
- export const Count: Story = {
59
- args: { variant: 'count', children: '12' },
60
- ...src(`<Badge variant="count">12</Badge>`),
61
- };
62
-
63
- export const Citation: Story = {
64
- args: { variant: 'citation', children: '1' },
65
- ...src(`<Badge variant="citation">1</Badge>`),
66
- };
67
-
68
- /** All variants side by side (showcase — not driven by controls). */
69
- export const AllVariants: Story = {
70
- render: () => (
71
- <div class="flex items-center gap-3">
72
- <Badge variant="default">Default</Badge>
73
- <Badge variant="count">5</Badge>
74
- <Badge variant="citation">1</Badge>
75
- <Badge variant="citation">2</Badge>
76
- <Badge variant="citation">3</Badge>
77
- </div>
78
- ),
79
- ...src(`<div class="flex items-center gap-3">
80
- <Badge variant="default">Default</Badge>
81
- <Badge variant="count">5</Badge>
82
- <Badge variant="citation">1</Badge>
83
- <Badge variant="citation">2</Badge>
84
- <Badge variant="citation">3</Badge>
85
- </div>`),
86
- };
@@ -1,145 +0,0 @@
1
- import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
- import { fn } from 'storybook/test';
3
- import { Button } from './button';
4
- import { componentDescription } from '../stories/docs/element-controls';
5
-
6
- /**
7
- * Convention exemplar — every component story should follow this shape:
8
- * `component`, a description, `argTypes` (controls), `args` (defaults incl.
9
- * `fn()` for events), a `Playground` story rendered from args, plus showcase
10
- * stories for notable variations.
11
- */
12
- const meta = {
13
- title: 'Solid (Advanced)/Primitives/Button',
14
- component: Button,
15
- tags: ['autodocs'],
16
- parameters: {
17
- layout: 'padded',
18
- docs: {
19
- description: componentDescription([
20
- 'A clickable button with style **variants** and **sizes**, built on a native `<button>` (all standard button attributes pass through).',
21
- '**When to use:** any user-triggered action — submitting input, toolbar/icon actions, confirming or dismissing. Use `default` for the primary action, `ghost`/`outline` for secondary or low-emphasis actions.',
22
- '**How to use:** set `variant` and `size`, pass label or an icon as children, and wire `onClick`. For icon-only buttons use `size="icon"` / `"icon-sm"` and include an `aria-label`.',
23
- '**Placement:** prompt action bars, message action rows, dialogs, toolbars, and empty-state CTAs.',
24
- ]),
25
- },
26
- },
27
- argTypes: {
28
- variant: {
29
- control: 'select',
30
- options: ['default', 'ghost', 'outline'],
31
- description: 'Visual emphasis of the button.',
32
- table: { defaultValue: { summary: 'default' } },
33
- },
34
- size: {
35
- control: 'select',
36
- options: ['sm', 'md', 'lg', 'icon', 'icon-sm'],
37
- description: 'Height/padding preset. `icon` / `icon-sm` are square for icon-only buttons.',
38
- table: { defaultValue: { summary: 'md' } },
39
- },
40
- disabled: {
41
- control: 'boolean',
42
- description: 'Disables interaction and dims the button.',
43
- },
44
- children: {
45
- control: 'text',
46
- description: 'Button content — text or an icon element.',
47
- },
48
- onClick: {
49
- action: 'click',
50
- description: 'Fired when the button is clicked.',
51
- table: { category: 'Events' },
52
- },
53
- },
54
- args: {
55
- variant: 'default',
56
- size: 'md',
57
- disabled: false,
58
- children: 'Click me',
59
- onClick: fn(),
60
- },
61
- render: (args) => <Button {...args} />,
62
- } satisfies Meta<typeof Button>;
63
-
64
- export default meta;
65
- type Story = StoryObj<typeof meta>;
66
-
67
- /**
68
- * Attach a clean, copy-paste-ready SolidJS snippet to a story. SolidJS stories
69
- * can't auto-serialize an args-spread render (it shows `{}`), so we provide real
70
- * usage code (with the import line, so it's truly paste-ready) that the docs
71
- * "Show code" / "Copy code" buttons surface. `language: 'tsx'` labels it as SolidJS.
72
- *
73
- * Note: `Button` is a SolidJS *component* (a scoped import), not a global custom
74
- * element, so the unprefixed name can't conflict with anything — alias on import
75
- * if a host already has a `Button`. Only the web components (`<kai-chat>`, …)
76
- * are prefixed, because those claim global custom-element tag names.
77
- */
78
- const IMPORT = `import { Button } from '@kitn.ai/ui';`;
79
- const src = (code: string) => ({
80
- parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
81
- });
82
-
83
- /** Interactive playground — tweak the controls to explore every combination. */
84
- export const Playground: Story = {
85
- ...src(`<Button variant="default" size="md" onClick={() => {}}>Click me</Button>`),
86
- };
87
-
88
- export const Ghost: Story = {
89
- args: { variant: 'ghost', children: 'Ghost' },
90
- ...src(`<Button variant="ghost">Ghost</Button>`),
91
- };
92
-
93
- export const Outline: Story = {
94
- args: { variant: 'outline', children: 'Outline' },
95
- ...src(`<Button variant="outline">Outline</Button>`),
96
- };
97
-
98
- export const Small: Story = {
99
- args: { size: 'sm', children: 'Small' },
100
- ...src(`<Button size="sm">Small</Button>`),
101
- };
102
-
103
- export const Large: Story = {
104
- args: { size: 'lg', children: 'Large' },
105
- ...src(`<Button size="lg">Large</Button>`),
106
- };
107
-
108
- export const Disabled: Story = {
109
- args: { disabled: true, children: 'Disabled' },
110
- ...src(`<Button disabled>Disabled</Button>`),
111
- };
112
-
113
- const PlusIcon = () => (
114
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
115
- <line x1="12" y1="5" x2="12" y2="19" />
116
- <line x1="5" y1="12" x2="19" y2="12" />
117
- </svg>
118
- );
119
-
120
- export const Icon: Story = {
121
- args: { size: 'icon', children: <PlusIcon />, 'aria-label': 'Add' } as never,
122
- ...src(`<Button size="icon" aria-label="Add">\n <PlusIcon />\n</Button>`),
123
- };
124
-
125
- /** All variants and sizes side by side (showcase — not driven by controls). */
126
- export const AllVariants: Story = {
127
- render: () => (
128
- <div class="flex flex-wrap items-center gap-3">
129
- <Button variant="default">Default</Button>
130
- <Button variant="ghost">Ghost</Button>
131
- <Button variant="outline">Outline</Button>
132
- <Button variant="default" size="sm">Small</Button>
133
- <Button variant="default" size="lg">Large</Button>
134
- <Button variant="default" size="icon" aria-label="Add"><PlusIcon /></Button>
135
- </div>
136
- ),
137
- ...src(`<div class="flex flex-wrap items-center gap-3">
138
- <Button variant="default">Default</Button>
139
- <Button variant="ghost">Ghost</Button>
140
- <Button variant="outline">Outline</Button>
141
- <Button size="sm">Small</Button>
142
- <Button size="lg">Large</Button>
143
- <Button size="icon" aria-label="Add"><PlusIcon /></Button>
144
- </div>`),
145
- };
@@ -1,69 +0,0 @@
1
- import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
- import { Collapsible, CollapsibleTrigger, CollapsibleContent } from './collapsible';
3
- import { componentDescription } from '../stories/docs/element-controls';
4
-
5
- const meta = {
6
- title: 'Solid (Advanced)/Primitives/Collapsible',
7
- component: Collapsible,
8
- tags: ['autodocs'],
9
- parameters: {
10
- layout: 'padded',
11
- docs: {
12
- description: componentDescription([
13
- 'A two-state disclosure that expands and collapses a region of content, animating height via a CSS `grid-template-rows` `0fr` → `1fr` transition (no JS measurement, no layout thrash). The trigger carries `aria-expanded`/`aria-controls` and the collapsed content is `inert`, so it is removed from tab order and the accessibility tree. Works controlled (`open` + `onOpenChange`) or uncontrolled (`defaultOpen`).',
14
- '**When to use:** to hide secondary detail behind a toggle — a reasoning/"chain of thought" panel, a tool-call payload, an expandable conversation group, an FAQ row.',
15
- '**How to use:** wrap `CollapsibleTrigger` and `CollapsibleContent` in a `Collapsible`. The trigger renders a `<button>` by default; pass `as` to render a custom element.',
16
- ]),
17
- },
18
- },
19
- render: () => <CollapsibleDemo defaultOpen />,
20
- } satisfies Meta<typeof Collapsible>;
21
-
22
- export default meta;
23
- type Story = StoryObj<typeof meta>;
24
-
25
- const IMPORT = `import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '@kitn.ai/ui';`;
26
- const src = (code: string) => ({
27
- parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
28
- });
29
-
30
- function CollapsibleDemo(props: { defaultOpen?: boolean }) {
31
- return (
32
- <Collapsible defaultOpen={props.defaultOpen} class="w-80 rounded-lg border border-border">
33
- <CollapsibleTrigger class="group flex w-full items-center justify-between px-3 py-2 text-sm font-medium text-foreground">
34
- <span>Reasoning</span>
35
- <svg
36
- class="size-4 text-muted-foreground transition-transform duration-200 group-data-[expanded]:rotate-180"
37
- viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
38
- >
39
- <polyline points="6 9 12 15 18 9" />
40
- </svg>
41
- </CollapsibleTrigger>
42
- <CollapsibleContent>
43
- <p class="px-3 pb-3 text-sm text-muted-foreground">
44
- First I parsed the request, then checked the available tools, and finally
45
- composed the answer. This panel is removed from the tab order while collapsed.
46
- </p>
47
- </CollapsibleContent>
48
- </Collapsible>
49
- );
50
- }
51
-
52
- /** Toggle the trigger to expand/collapse. The chevron rotates via the `data-expanded` attribute. */
53
- export const Playground: Story = {
54
- ...src(`<Collapsible defaultOpen>
55
- <CollapsibleTrigger>Reasoning</CollapsibleTrigger>
56
- <CollapsibleContent>
57
- <p>First I parsed the request, then checked the available tools…</p>
58
- </CollapsibleContent>
59
- </Collapsible>`),
60
- };
61
-
62
- /** Starts collapsed. */
63
- export const InitiallyClosed: Story = {
64
- render: () => <CollapsibleDemo />,
65
- ...src(`<Collapsible>
66
- <CollapsibleTrigger>Reasoning</CollapsibleTrigger>
67
- <CollapsibleContent>…</CollapsibleContent>
68
- </Collapsible>`),
69
- };
@@ -1,59 +0,0 @@
1
- import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
- import { createSignal } from 'solid-js';
3
- import { Dropdown, DropdownTrigger, DropdownContent, DropdownItem } from './dropdown';
4
- import { buttonVariants } from './button';
5
- import { componentDescription } from '../stories/docs/element-controls';
6
-
7
- const meta = {
8
- title: 'Solid (Advanced)/Primitives/Dropdown',
9
- component: Dropdown,
10
- tags: ['autodocs'],
11
- parameters: {
12
- layout: 'padded',
13
- docs: {
14
- description: componentDescription([
15
- 'An accessible menu that opens from a trigger, built on the kit\'s DIY overlay core (no third-party dependency). Implements the WAI-ARIA menu-button pattern: `aria-haspopup`/`aria-expanded` wiring, roving focus with Arrow/Home/End, type-ahead, Escape/outside-click dismissal, and focus return to the trigger. Portals into the active shadow root and resolves focus through `getRootNode()` so roving focus works inside web components.',
16
- '**When to use:** for a list of *actions* or single-choice options triggered by a button — overflow "⋯" menus, model pickers, scope selectors. For hover-only context use `HoverCard`; for a label use `Tooltip`.',
17
- '**How to use:** compose `Dropdown` › `DropdownTrigger` (the button) + `DropdownContent` › one `DropdownItem` per action. Give each item an `onSelect` handler — selecting also closes the menu.',
18
- ]),
19
- },
20
- },
21
- render: () => <DropdownDemo />,
22
- } satisfies Meta<typeof Dropdown>;
23
-
24
- export default meta;
25
- type Story = StoryObj<typeof meta>;
26
-
27
- const IMPORT = `import { Dropdown, DropdownTrigger, DropdownContent, DropdownItem } from '@kitn.ai/ui';`;
28
- const src = (code: string) => ({
29
- parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
30
- });
31
-
32
- function DropdownDemo() {
33
- const [last, setLast] = createSignal<string>();
34
- return (
35
- <div class="space-y-3">
36
- <Dropdown>
37
- <DropdownTrigger class={buttonVariants({ variant: 'outline' })}>Actions ▾</DropdownTrigger>
38
- <DropdownContent>
39
- <DropdownItem onSelect={() => setLast('Rename')}>Rename</DropdownItem>
40
- <DropdownItem onSelect={() => setLast('Duplicate')}>Duplicate</DropdownItem>
41
- <DropdownItem onSelect={() => setLast('Archive')}>Archive</DropdownItem>
42
- </DropdownContent>
43
- </Dropdown>
44
- <p class="text-xs text-muted-foreground">Last selected: {last() ?? '—'}</p>
45
- </div>
46
- );
47
- }
48
-
49
- /** Click the trigger (or focus it and press ↓ / Enter) to open the menu; Arrow keys move, Escape closes. */
50
- export const Playground: Story = {
51
- ...src(`<Dropdown>
52
- <DropdownTrigger class={buttonVariants({ variant: 'outline' })}>Actions ▾</DropdownTrigger>
53
- <DropdownContent>
54
- <DropdownItem onSelect={() => rename()}>Rename</DropdownItem>
55
- <DropdownItem onSelect={() => duplicate()}>Duplicate</DropdownItem>
56
- <DropdownItem onSelect={() => archive()}>Archive</DropdownItem>
57
- </DropdownContent>
58
- </Dropdown>`),
59
- };
@@ -1,77 +0,0 @@
1
- import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
- import { HoverCard } from './hover-card';
3
- import { Button } from './button';
4
- import { componentDescription } from '../stories/docs/element-controls';
5
-
6
- const meta = {
7
- title: 'Solid (Advanced)/Primitives/HoverCard',
8
- component: HoverCard,
9
- tags: ['autodocs'],
10
- parameters: {
11
- layout: 'padded',
12
- docs: {
13
- description: componentDescription([
14
- 'A floating card that opens when its trigger is hovered or focused, built on the kit\'s DIY overlay core (positioning + dismiss + presence — no third-party dependency). Portals into the active shadow root so it never clips, and a transparent "safe bridge" keeps it open while the pointer travels from trigger to card.',
15
- '**When to use:** to reveal supplementary, non-essential context on hover — a user/profile preview, a link or citation preview, an attachment summary. For an actionable menu use `Dropdown`; for a one-line label use `Tooltip`.',
16
- '**How to use:** pass the trigger element as `trigger` and the card body as `children`. Tune `openDelay` / `closeDelay` (ms) to taste.',
17
- ]),
18
- },
19
- },
20
- argTypes: {
21
- trigger: { control: false, description: 'The element that opens the card on hover/focus.' },
22
- children: { control: false, description: 'The card contents.' },
23
- openDelay: { control: 'number', description: 'Delay (ms) before the card opens. Default 0.' },
24
- closeDelay: { control: 'number', description: 'Delay (ms) before the card closes after the pointer leaves. Default 300.' },
25
- class: { control: 'text', description: 'Extra classes applied to the card body.' },
26
- },
27
- args: {
28
- trigger: <Button variant="outline">@ada</Button>,
29
- children: (
30
- <div class="flex gap-3">
31
- <div class="flex size-10 shrink-0 items-center justify-center rounded-full bg-primary text-sm font-medium text-primary-foreground">AL</div>
32
- <div class="space-y-1">
33
- <p class="text-sm font-medium text-foreground">Ada Lovelace</p>
34
- <p class="text-xs text-muted-foreground">Wrote the first algorithm intended for a machine. Joined in 1843.</p>
35
- </div>
36
- </div>
37
- ),
38
- },
39
- render: (args) => <HoverCard {...args} />,
40
- } satisfies Meta<typeof HoverCard>;
41
-
42
- export default meta;
43
- type Story = StoryObj<typeof meta>;
44
-
45
- const IMPORT = `import { HoverCard } from '@kitn.ai/ui';`;
46
- const src = (code: string) => ({
47
- parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
48
- });
49
-
50
- /** Hover (or focus) the trigger to reveal a profile preview card. */
51
- export const Playground: Story = {
52
- ...src(`<HoverCard trigger={<Button variant="outline">@ada</Button>}>
53
- <ProfilePreview name="Ada Lovelace" />
54
- </HoverCard>`),
55
- };
56
-
57
- /** A link-preview card, the way it might appear inline in an assistant message. */
58
- export const LinkPreview: Story = {
59
- render: () => (
60
- <p class="max-w-md text-sm text-foreground">
61
- See the{' '}
62
- <HoverCard
63
- trigger={<a href="#" class="font-medium text-primary underline underline-offset-2">MDN reference</a>}
64
- >
65
- <div class="space-y-1">
66
- <p class="text-sm font-medium text-foreground">Custom elements — MDN</p>
67
- <p class="text-xs text-muted-foreground">developer.mozilla.org</p>
68
- <p class="text-xs text-muted-foreground">Define your own HTML elements with the CustomElementRegistry.</p>
69
- </div>
70
- </HoverCard>{' '}
71
- for the full custom-elements API.
72
- </p>
73
- ),
74
- ...src(`<HoverCard trigger={<a href="...">MDN reference</a>}>
75
- <LinkPreview title="Custom elements — MDN" host="developer.mozilla.org" />
76
- </HoverCard>`),
77
- };
@@ -1,30 +0,0 @@
1
- /**
2
- * Unit tests for HoverCardTrigger.
3
- *
4
- * The trigger renders as `<As as="span">` — a bare inline span. When the span
5
- * is dropped into a flex row (e.g. an attachment chip), an inline box doesn't
6
- * carry the children's block layout and the row collapses. The fix lets the
7
- * trigger carry layout classes itself, so callers can make it the flex row
8
- * instead of wrapping the content in an extra div.
9
- */
10
- import { describe, it, expect, afterEach } from 'vitest';
11
- import '@testing-library/jest-dom/vitest';
12
- import { render, cleanup } from '@solidjs/testing-library';
13
- import { HoverCardRoot, HoverCardTrigger } from './hover-card';
14
-
15
- afterEach(cleanup);
16
-
17
- describe('HoverCardTrigger', () => {
18
- it('applies a forwarded class to the trigger element', () => {
19
- const { container } = render(() => (
20
- <HoverCardRoot>
21
- <HoverCardTrigger class="flex items-center gap-1.5">content</HoverCardTrigger>
22
- </HoverCardRoot>
23
- ));
24
-
25
- const trigger = container.querySelector('span');
26
- expect(trigger).toBeTruthy();
27
- expect(trigger!.className).toContain('flex');
28
- expect(trigger!.className).toContain('items-center');
29
- });
30
- });
@@ -1,115 +0,0 @@
1
- import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
- import { createSignal, Show } from 'solid-js';
3
- import { Portal } from 'solid-js/web';
4
- import { createPresence, usePosition, useDismiss } from './overlay';
5
- import { buttonVariants } from './button';
6
-
7
- /**
8
- * `overlay.tsx` is not a component — it's the small DIY toolkit that every
9
- * floating surface in the kit (Tooltip, HoverCard, Dropdown) is built from,
10
- * replacing the former third-party UI dependency. Three primitives:
11
- *
12
- * - `usePosition(ref, floating, opts)` — anchors `floating` to `ref` via
13
- * @floating-ui/dom with flip/shift, tracking it on scroll/resize.
14
- * - `createPresence(open)` — keeps a node mounted through its CSS exit
15
- * animation, then unmounts on `animationend`.
16
- * - `useDismiss({ enabled, onDismiss, refs })` — Escape + outside-pointerdown
17
- * dismissal (no scroll lock).
18
- *
19
- * Plus an `As` polymorphic helper for trigger elements.
20
- */
21
- const meta: Meta = {
22
- title: 'Solid (Advanced)/Primitives/Overlay Core',
23
- tags: ['autodocs'],
24
- parameters: {
25
- layout: 'padded',
26
- docs: {
27
- description: {
28
- component: [
29
- "The shared, dependency-free foundation behind every floating surface in the kit — `Tooltip`, `HoverCard`, and `Dropdown` are all assembled from these primitives. It's a toolkit of hooks, not a renderable component.",
30
- '**`usePosition(ref, floating, opts)`** anchors a floating node to a trigger via `@floating-ui/dom` (flip/shift, fixed strategy, tracks on scroll/resize). **`createPresence(open)`** keeps the node mounted through its CSS exit animation. **`useDismiss({ enabled, onDismiss, refs })`** handles Escape + outside-click. An **`As`** helper renders a polymorphic trigger.',
31
- '**When to use:** only when you need a floating surface the prebuilt components don\'t cover. Reach for `Tooltip` / `HoverCard` / `Dropdown` first — they already wire these together with the correct ARIA and focus behavior.',
32
- 'The demo below composes all three into a minimal popover; everything portals into the active shadow root via `ChatConfig`.',
33
- ].join('\n\n'),
34
- },
35
- },
36
- },
37
- };
38
-
39
- export default meta;
40
- type Story = StoryObj<typeof meta>;
41
-
42
- function PopoverDemo() {
43
- const [open, setOpen] = createSignal(false);
44
- const [trigger, setTrigger] = createSignal<HTMLElement>();
45
- const [content, setContent] = createSignal<HTMLElement>();
46
- const presence = createPresence(open);
47
- const position = usePosition(trigger, content, { placement: 'bottom-start', gutter: 6 });
48
- useDismiss({ enabled: open, onDismiss: () => setOpen(false), refs: () => [trigger(), content()] });
49
-
50
- return (
51
- <>
52
- <button
53
- ref={setTrigger}
54
- type="button"
55
- class={buttonVariants({ variant: 'outline' })}
56
- onClick={() => setOpen(!open())}
57
- >
58
- {open() ? 'Close' : 'Open'} popover
59
- </button>
60
- <Show when={presence.present()}>
61
- <Portal>
62
- <div
63
- ref={(el) => { setContent(el); presence.setRef(el); }}
64
- data-expanded={presence.state() === 'open' ? '' : undefined}
65
- data-closed={presence.state() === 'closed' ? '' : undefined}
66
- style={{ position: 'fixed', left: `${position.pos().x}px`, top: `${position.pos().y}px` }}
67
- class="z-50 w-64 rounded-lg bg-card p-3 text-sm text-foreground shadow-lg animate-in fade-in-0 zoom-in-95 data-[closed]:animate-out data-[closed]:fade-out-0 data-[closed]:zoom-out-95"
68
- >
69
- Positioned by <code class="text-xs">usePosition</code>, kept mounted through its
70
- exit animation by <code class="text-xs">createPresence</code>, and closed on
71
- Escape / outside-click by <code class="text-xs">useDismiss</code>.
72
- </div>
73
- </Portal>
74
- </Show>
75
- </>
76
- );
77
- }
78
-
79
- /** A minimal popover hand-built from the three overlay primitives. Click to toggle; click outside or press Escape to dismiss. */
80
- export const MinimalPopover: Story = {
81
- render: () => <PopoverDemo />,
82
- parameters: {
83
- docs: {
84
- source: {
85
- code: `import { createPresence, usePosition, useDismiss } from '@kitn.ai/ui';
86
-
87
- function PopoverDemo() {
88
- const [open, setOpen] = createSignal(false);
89
- const [trigger, setTrigger] = createSignal<HTMLElement>();
90
- const [content, setContent] = createSignal<HTMLElement>();
91
- const presence = createPresence(open);
92
- const position = usePosition(trigger, content, { placement: 'bottom-start', gutter: 6 });
93
- useDismiss({ enabled: open, onDismiss: () => setOpen(false), refs: () => [trigger(), content()] });
94
-
95
- return (
96
- <>
97
- <button ref={setTrigger} onClick={() => setOpen(!open())}>Toggle</button>
98
- <Show when={presence.present()}>
99
- <Portal>
100
- <div
101
- ref={(el) => { setContent(el); presence.setRef(el); }}
102
- style={{ position: 'fixed', left: \`\${position.pos().x}px\`, top: \`\${position.pos().y}px\` }}
103
- >
104
- …content…
105
- </div>
106
- </Portal>
107
- </Show>
108
- </>
109
- );
110
- }`,
111
- language: 'tsx',
112
- },
113
- },
114
- },
115
- };
@@ -1,81 +0,0 @@
1
- import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
- import { fn } from 'storybook/test';
3
- import { createSignal, Show, For } from 'solid-js';
4
- import { Popover, type PopoverProps } from './popover';
5
- import { Switch } from './switch';
6
- import { Button } from './button';
7
- import { componentDescription } from '../stories/docs/element-controls';
8
-
9
- const meta = {
10
- title: 'Solid (Advanced)/Primitives/Popover',
11
- component: Popover,
12
- tags: ['autodocs'],
13
- parameters: {
14
- layout: 'padded',
15
- docs: {
16
- description: componentDescription([
17
- 'A **popover**: a trigger that toggles a floating panel of arbitrary content. Unlike `Dropdown` (a `role="menu"` with roving focus), the panel is a `role="dialog"` region, so it holds anything — model rows, toggles, nested groups.',
18
- '**When to use:** a "button + card" affordance — a header model menu, a settings popover, an account dropdown with mixed controls. For a simple list of commands, use `Dropdown` instead.',
19
- '**How to use:** pass the control as `trigger` and the panel as `children`. Clicking the trigger toggles; Escape or an outside click closes (clicks inside do not). Uncontrolled by default; pass `open` + `onOpenChange` to control it.',
20
- '**Placement:** chat headers, toolbars, and anywhere a compact control should reveal a richer card.',
21
- ]),
22
- },
23
- },
24
- argTypes: {
25
- placement: {
26
- control: 'select',
27
- options: ['bottom-start', 'bottom', 'bottom-end', 'top-start', 'top', 'top-end', 'left', 'right'],
28
- description: 'Floating placement relative to the trigger.',
29
- table: { defaultValue: { summary: 'bottom-start' } },
30
- },
31
- gutter: { control: 'number', description: 'Gap in px between trigger and panel.', table: { defaultValue: { summary: '6' } } },
32
- open: { control: 'boolean', description: 'Controlled open state. Omit for click-to-toggle.' },
33
- },
34
- args: { placement: 'bottom-start', onOpenChange: fn() },
35
- } satisfies Meta<typeof Popover>;
36
-
37
- export default meta;
38
- type Story = StoryObj<typeof meta>;
39
-
40
- const LEGACY = ['GPT-4o', 'GPT-4.1', 'GPT-4o mini'];
41
- const row = 'flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-foreground hover:bg-muted';
42
-
43
- /** A model menu rebuilt from the primitive — flagship row, an expandable group,
44
- * and a Switch — the kind of card a plain menu can't hold. */
45
- export const ModelMenu: Story = {
46
- render: (args: Partial<PopoverProps>) => {
47
- const [legacyOpen, setLegacyOpen] = createSignal(false);
48
- return (
49
- <Popover {...args} trigger={<Button variant="ghost" size="sm">GPT-5.5 ▾</Button>}>
50
- <div style={{ width: '15rem' }}>
51
- <button type="button" class={row}>
52
- <span style={{ 'font-weight': 600 }}>GPT-5.5</span>
53
- <span class="text-caption text-muted-foreground">Flagship</span>
54
- </button>
55
- <button type="button" class={row} aria-expanded={legacyOpen()} onClick={() => setLegacyOpen(!legacyOpen())}>
56
- Legacy models {legacyOpen() ? '▴' : '▾'}
57
- </button>
58
- <Show when={legacyOpen()}>
59
- <For each={LEGACY}>{(m) => <button type="button" class={row} style={{ 'padding-left': '1.75rem' }}>{m}</button>}</For>
60
- </Show>
61
- <div style={{ height: '1px', margin: '4px 0', background: 'var(--color-border)' }} />
62
- <div class={row} style={{ 'justify-content': 'space-between' }}>
63
- <span>Temporary chat</span>
64
- <Switch label="Temporary chat" />
65
- </div>
66
- </div>
67
- </Popover>
68
- );
69
- },
70
- };
71
-
72
- /** Minimal — a trigger and a small card. */
73
- export const Basic: Story = {
74
- render: (args: Partial<PopoverProps>) => (
75
- <Popover {...args} trigger={<Button size="sm">Open</Button>}>
76
- <div style={{ width: '12rem', padding: '0.5rem' }} class="text-sm text-foreground">
77
- Any content goes here — this is a <code>role="dialog"</code> panel.
78
- </div>
79
- </Popover>
80
- ),
81
- };