@kitnai/chat 0.5.0 → 0.7.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.
- package/README.md +50 -0
- package/dist/custom-elements.json +125 -73
- package/dist/kitn-chat.es.js +1 -1
- package/dist/llms/llms-full.txt +24 -24
- package/dist/theme.tokens.css +25 -1
- package/frameworks/react/index.tsx +46 -24
- package/llms-full.txt +24 -24
- package/package.json +1 -1
- package/src/elements/chat-workspace.tsx +28 -2
- package/src/elements/chat.tsx +22 -1
- package/src/elements/compiled.css +1 -1
- package/src/elements/conversation-list.tsx +10 -1
- package/src/elements/element-meta.json +2003 -0
- package/src/elements/kitn-attachments.stories.tsx +9 -0
- package/src/elements/kitn-chain-of-thought.stories.tsx +9 -0
- package/src/elements/kitn-chat-scope-picker.stories.tsx +9 -0
- package/src/elements/kitn-chat-workspace.stories.tsx +64 -14
- package/src/elements/kitn-chat.stories.tsx +58 -5
- package/src/elements/kitn-checkpoint.stories.tsx +9 -0
- package/src/elements/kitn-code-block.stories.tsx +9 -0
- package/src/elements/kitn-context-meter.stories.tsx +9 -0
- package/src/elements/kitn-conversation-list.stories.tsx +31 -10
- package/src/elements/kitn-empty.stories.tsx +9 -0
- package/src/elements/kitn-feedback-bar.stories.tsx +9 -0
- package/src/elements/kitn-file-upload.stories.tsx +9 -0
- package/src/elements/kitn-image.stories.tsx +9 -0
- package/src/elements/kitn-loader.stories.tsx +9 -0
- package/src/elements/kitn-markdown.stories.tsx +9 -0
- package/src/elements/kitn-message-skills.stories.tsx +9 -0
- package/src/elements/kitn-message.stories.tsx +9 -0
- package/src/elements/kitn-model-switcher.stories.tsx +9 -0
- package/src/elements/kitn-prompt-input.stories.tsx +35 -5
- package/src/elements/kitn-prompt-suggestions.stories.tsx +9 -0
- package/src/elements/kitn-reasoning.stories.tsx +9 -0
- package/src/elements/kitn-response-stream.stories.tsx +9 -0
- package/src/elements/kitn-source-list.stories.tsx +9 -0
- package/src/elements/kitn-source.stories.tsx +9 -0
- package/src/elements/kitn-text-shimmer.stories.tsx +9 -0
- package/src/elements/kitn-thinking-bar.stories.tsx +9 -0
- package/src/elements/kitn-tool.stories.tsx +9 -0
- package/src/elements/kitn-voice-input.stories.tsx +9 -0
- package/src/elements/prompt-input.tsx +2 -2
- package/src/elements/styles.css +21 -0
- package/src/stories/docs/element-controls.ts +28 -0
- package/src/stories/docs/element-spec.tsx +86 -0
- package/src/ui/scroll-area.tsx +1 -1
- package/theme.css +25 -1
|
@@ -2,6 +2,8 @@ import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
|
2
2
|
import { onMount } from 'solid-js';
|
|
3
3
|
import './register'; // side effect: registers the custom elements
|
|
4
4
|
import type { AttachmentData } from '../components/attachments';
|
|
5
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
6
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
5
7
|
|
|
6
8
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
7
9
|
declare module 'solid-js' {
|
|
@@ -125,6 +127,7 @@ const HOVER_SNIPPET = `<!-- inline/list chips with a hover-card image preview --
|
|
|
125
127
|
const meta = {
|
|
126
128
|
title: 'Web Components/kitn-attachments',
|
|
127
129
|
tags: ['autodocs'],
|
|
130
|
+
argTypes: argTypesFor('kitn-attachments'),
|
|
128
131
|
parameters: {
|
|
129
132
|
layout: 'fullscreen',
|
|
130
133
|
docs: {
|
|
@@ -143,6 +146,12 @@ const meta = {
|
|
|
143
146
|
export default meta;
|
|
144
147
|
type Story = StoryObj;
|
|
145
148
|
|
|
149
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
150
|
+
export const API: Story = {
|
|
151
|
+
render: () => <ElementSpec tag="kitn-attachments" />,
|
|
152
|
+
parameters: { layout: 'padded' },
|
|
153
|
+
};
|
|
154
|
+
|
|
146
155
|
/** Visual tiles (the default `grid` variant) — image attachments render as real
|
|
147
156
|
* `<img>` thumbnails; non-image files fall back to a media-type icon. */
|
|
148
157
|
export const Grid: Story = {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
2
|
import { onMount } from 'solid-js';
|
|
3
3
|
import './register'; // side effect: registers the custom elements
|
|
4
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
5
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
4
6
|
|
|
5
7
|
interface Step {
|
|
6
8
|
label: string;
|
|
@@ -50,6 +52,7 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
|
50
52
|
const meta = {
|
|
51
53
|
title: 'Web Components/kitn-chain-of-thought',
|
|
52
54
|
tags: ['autodocs'],
|
|
55
|
+
argTypes: argTypesFor('kitn-chain-of-thought'),
|
|
53
56
|
parameters: {
|
|
54
57
|
layout: 'fullscreen',
|
|
55
58
|
docs: {
|
|
@@ -68,6 +71,12 @@ const meta = {
|
|
|
68
71
|
export default meta;
|
|
69
72
|
type Story = StoryObj;
|
|
70
73
|
|
|
74
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
75
|
+
export const API: Story = {
|
|
76
|
+
render: () => <ElementSpec tag="kitn-chain-of-thought" />,
|
|
77
|
+
parameters: { layout: 'padded' },
|
|
78
|
+
};
|
|
79
|
+
|
|
71
80
|
/** A three-step reasoning trace; the last step has no detail. */
|
|
72
81
|
export const Default: Story = {
|
|
73
82
|
render: () => <CotElement steps={steps} />,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
2
|
import { onMount } from 'solid-js';
|
|
3
3
|
import './register'; // side effect: registers the custom elements
|
|
4
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
5
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
4
6
|
|
|
5
7
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
6
8
|
declare module 'solid-js' {
|
|
@@ -47,6 +49,7 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
|
47
49
|
const meta = {
|
|
48
50
|
title: 'Web Components/kitn-chat-scope-picker',
|
|
49
51
|
tags: ['autodocs'],
|
|
52
|
+
argTypes: argTypesFor('kitn-chat-scope-picker'),
|
|
50
53
|
parameters: {
|
|
51
54
|
layout: 'fullscreen',
|
|
52
55
|
docs: {
|
|
@@ -65,6 +68,12 @@ const meta = {
|
|
|
65
68
|
export default meta;
|
|
66
69
|
type Story = StoryObj;
|
|
67
70
|
|
|
71
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
72
|
+
export const API: Story = {
|
|
73
|
+
render: () => <ElementSpec tag="kitn-chat-scope-picker" />,
|
|
74
|
+
parameters: { layout: 'padded' },
|
|
75
|
+
};
|
|
76
|
+
|
|
68
77
|
/** Authors and tags available as scope filters. */
|
|
69
78
|
export const Default: Story = {
|
|
70
79
|
render: () => <ScopePickerElement authors={['Rob', 'Alex']} tags={['design', 'api']} />,
|
|
@@ -3,6 +3,8 @@ import { onMount } from 'solid-js';
|
|
|
3
3
|
import './register'; // side effect: registers all kitn custom elements including <kitn-chat-workspace>
|
|
4
4
|
import type { ConversationGroup, ConversationSummary, ModelOption } from '../types';
|
|
5
5
|
import type { ChatMessage } from './chat-types';
|
|
6
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
7
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
6
8
|
|
|
7
9
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
8
10
|
declare module 'solid-js' {
|
|
@@ -55,21 +57,37 @@ const sampleMessages: ChatMessage[] = [
|
|
|
55
57
|
},
|
|
56
58
|
];
|
|
57
59
|
|
|
60
|
+
type WorkspaceEl = HTMLElement & {
|
|
61
|
+
groups?: ConversationGroup[];
|
|
62
|
+
conversations?: ConversationSummary[];
|
|
63
|
+
activeId?: string;
|
|
64
|
+
messages?: ChatMessage[];
|
|
65
|
+
models?: ModelOption[];
|
|
66
|
+
currentModel?: string;
|
|
67
|
+
chatTitle?: string;
|
|
68
|
+
placeholder?: string;
|
|
69
|
+
loading?: boolean;
|
|
70
|
+
suggestionMode?: string;
|
|
71
|
+
proseSize?: string;
|
|
72
|
+
codeTheme?: string;
|
|
73
|
+
codeHighlight?: boolean;
|
|
74
|
+
scrollButton?: boolean;
|
|
75
|
+
search?: boolean;
|
|
76
|
+
voice?: boolean;
|
|
77
|
+
slashCompact?: boolean;
|
|
78
|
+
sidebarWidth?: number;
|
|
79
|
+
sidebarMinWidth?: number;
|
|
80
|
+
sidebarMaxWidth?: number;
|
|
81
|
+
sidebarCollapsed?: boolean;
|
|
82
|
+
value?: string;
|
|
83
|
+
};
|
|
84
|
+
|
|
58
85
|
/** Live demo of the actual `<kitn-chat-workspace>` custom element (Shadow DOM and all). */
|
|
59
|
-
function WorkspaceElement() {
|
|
60
|
-
let el:
|
|
61
|
-
| (HTMLElement & {
|
|
62
|
-
groups?: ConversationGroup[];
|
|
63
|
-
conversations?: ConversationSummary[];
|
|
64
|
-
activeId?: string;
|
|
65
|
-
messages?: ChatMessage[];
|
|
66
|
-
models?: ModelOption[];
|
|
67
|
-
currentModel?: string;
|
|
68
|
-
chatTitle?: string;
|
|
69
|
-
})
|
|
70
|
-
| undefined;
|
|
86
|
+
function WorkspaceElement(props: { args?: Record<string, unknown> }) {
|
|
87
|
+
let el: WorkspaceEl | undefined;
|
|
71
88
|
onMount(() => {
|
|
72
89
|
if (el) {
|
|
90
|
+
// Fixed array/object data
|
|
73
91
|
el.groups = sampleGroups;
|
|
74
92
|
el.conversations = sampleConversations;
|
|
75
93
|
el.activeId = '1';
|
|
@@ -77,6 +95,18 @@ function WorkspaceElement() {
|
|
|
77
95
|
el.models = sampleModels;
|
|
78
96
|
el.currentModel = 'claude-4';
|
|
79
97
|
el.chatTitle = 'Web component architecture';
|
|
98
|
+
// Scalar args from Controls (override defaults above for scalar props)
|
|
99
|
+
const args = props.args;
|
|
100
|
+
if (args) {
|
|
101
|
+
const scalarNames = [
|
|
102
|
+
'placeholder', 'loading', 'suggestionMode', 'proseSize', 'codeTheme',
|
|
103
|
+
'codeHighlight', 'scrollButton', 'search', 'voice', 'slashCompact',
|
|
104
|
+
'sidebarWidth', 'sidebarMinWidth', 'sidebarMaxWidth', 'sidebarCollapsed', 'value',
|
|
105
|
+
];
|
|
106
|
+
for (const name of scalarNames) {
|
|
107
|
+
if (name in args) (el as unknown as Record<string, unknown>)[name] = args[name];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
80
110
|
el.addEventListener('conversationselect', (e) => console.log('select', (e as CustomEvent).detail));
|
|
81
111
|
el.addEventListener('submit', (e) => console.log('submit', (e as unknown as CustomEvent).detail));
|
|
82
112
|
el.addEventListener('sidebartoggle', (e) => console.log('sidebartoggle', (e as CustomEvent).detail));
|
|
@@ -85,7 +115,7 @@ function WorkspaceElement() {
|
|
|
85
115
|
return (
|
|
86
116
|
<div style={{ height: '720px', width: '100%' }}>
|
|
87
117
|
<kitn-chat-workspace
|
|
88
|
-
ref={(e) => (el = e as
|
|
118
|
+
ref={(e) => (el = e as WorkspaceEl)}
|
|
89
119
|
style={{ display: 'block', height: '100%' }}
|
|
90
120
|
/>
|
|
91
121
|
</div>
|
|
@@ -162,6 +192,7 @@ function Workspace() {
|
|
|
162
192
|
const meta = {
|
|
163
193
|
title: 'Web Components/kitn-chat-workspace',
|
|
164
194
|
tags: ['autodocs'],
|
|
195
|
+
argTypes: argTypesFor('kitn-chat-workspace'),
|
|
165
196
|
parameters: {
|
|
166
197
|
layout: 'fullscreen',
|
|
167
198
|
docs: {
|
|
@@ -183,7 +214,20 @@ type Story = StoryObj;
|
|
|
183
214
|
|
|
184
215
|
/** The element used the plain-HTML / any-framework way. */
|
|
185
216
|
export const Default: Story = {
|
|
186
|
-
|
|
217
|
+
args: {
|
|
218
|
+
placeholder: 'Send a message...',
|
|
219
|
+
loading: false,
|
|
220
|
+
suggestionMode: 'submit',
|
|
221
|
+
proseSize: 'sm',
|
|
222
|
+
codeTheme: 'github-dark-dimmed',
|
|
223
|
+
codeHighlight: true,
|
|
224
|
+
scrollButton: true,
|
|
225
|
+
search: false,
|
|
226
|
+
voice: false,
|
|
227
|
+
slashCompact: false,
|
|
228
|
+
sidebarCollapsed: false,
|
|
229
|
+
},
|
|
230
|
+
render: (args: Record<string, unknown>) => <WorkspaceElement args={args} />,
|
|
187
231
|
parameters: { docs: { source: { code: HTML_SNIPPET, language: 'html' } } },
|
|
188
232
|
};
|
|
189
233
|
|
|
@@ -193,3 +237,9 @@ export const InSolidJS: Story = {
|
|
|
193
237
|
render: () => <WorkspaceElement />,
|
|
194
238
|
parameters: { docs: { source: { code: SOLID_SNIPPET, language: 'tsx' } } },
|
|
195
239
|
};
|
|
240
|
+
|
|
241
|
+
/** Full generated API reference — properties, events, tokens, and the SolidJS components this element is composed from. */
|
|
242
|
+
export const API: Story = {
|
|
243
|
+
render: () => <ElementSpec tag="kitn-chat-workspace" />,
|
|
244
|
+
parameters: { layout: 'padded' },
|
|
245
|
+
};
|
|
@@ -2,6 +2,8 @@ import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
|
2
2
|
import { onMount } from 'solid-js';
|
|
3
3
|
import './register'; // side effect: registers <kitn-chat>, <kitn-conversation-list>, <kitn-prompt-input>
|
|
4
4
|
import type { ChatMessage } from './chat-types';
|
|
5
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
6
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
5
7
|
|
|
6
8
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
7
9
|
declare module 'solid-js' {
|
|
@@ -24,13 +26,45 @@ const sampleMessages: ChatMessage[] = [
|
|
|
24
26
|
},
|
|
25
27
|
];
|
|
26
28
|
|
|
29
|
+
type ChatEl = HTMLElement & {
|
|
30
|
+
messages?: ChatMessage[];
|
|
31
|
+
value?: string;
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
loading?: boolean;
|
|
34
|
+
suggestionMode?: string;
|
|
35
|
+
proseSize?: string;
|
|
36
|
+
codeTheme?: string;
|
|
37
|
+
codeHighlight?: boolean;
|
|
38
|
+
chatTitle?: string;
|
|
39
|
+
currentModel?: string;
|
|
40
|
+
scrollButton?: boolean;
|
|
41
|
+
search?: boolean;
|
|
42
|
+
voice?: boolean;
|
|
43
|
+
slashCompact?: boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
27
46
|
/** Live demo of the actual `<kitn-chat>` custom element (Shadow DOM and all). */
|
|
28
|
-
function ChatElement() {
|
|
29
|
-
let el:
|
|
47
|
+
function ChatElement(props: { args?: Record<string, unknown> }) {
|
|
48
|
+
let el: ChatEl | undefined;
|
|
30
49
|
onMount(() => {
|
|
31
|
-
if (el)
|
|
50
|
+
if (el) {
|
|
51
|
+
// Fixed array data
|
|
52
|
+
el.messages = sampleMessages;
|
|
53
|
+
// Scalar args from Controls
|
|
54
|
+
const args = props.args;
|
|
55
|
+
if (args) {
|
|
56
|
+
const scalarNames = [
|
|
57
|
+
'value', 'placeholder', 'loading', 'suggestionMode', 'proseSize',
|
|
58
|
+
'codeTheme', 'codeHighlight', 'chatTitle', 'currentModel',
|
|
59
|
+
'scrollButton', 'search', 'voice', 'slashCompact',
|
|
60
|
+
];
|
|
61
|
+
for (const name of scalarNames) {
|
|
62
|
+
if (name in args) (el as unknown as Record<string, unknown>)[name] = args[name];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
32
66
|
});
|
|
33
|
-
return <kitn-chat ref={(e) => (el = e as
|
|
67
|
+
return <kitn-chat ref={(e) => (el = e as ChatEl)} style={{ display: 'block', height: '560px' }} />;
|
|
34
68
|
}
|
|
35
69
|
|
|
36
70
|
const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
@@ -72,6 +106,7 @@ function Chat() {
|
|
|
72
106
|
const meta = {
|
|
73
107
|
title: 'Web Components/kitn-chat',
|
|
74
108
|
tags: ['autodocs'],
|
|
109
|
+
argTypes: argTypesFor('kitn-chat'),
|
|
75
110
|
parameters: {
|
|
76
111
|
layout: 'fullscreen',
|
|
77
112
|
docs: {
|
|
@@ -93,7 +128,19 @@ type Story = StoryObj;
|
|
|
93
128
|
|
|
94
129
|
/** The element used the plain-HTML / any-framework way. */
|
|
95
130
|
export const Default: Story = {
|
|
96
|
-
|
|
131
|
+
args: {
|
|
132
|
+
placeholder: 'Send a message...',
|
|
133
|
+
loading: false,
|
|
134
|
+
suggestionMode: 'submit',
|
|
135
|
+
proseSize: 'sm',
|
|
136
|
+
codeTheme: 'github-dark-dimmed',
|
|
137
|
+
codeHighlight: true,
|
|
138
|
+
scrollButton: true,
|
|
139
|
+
search: false,
|
|
140
|
+
voice: false,
|
|
141
|
+
slashCompact: false,
|
|
142
|
+
},
|
|
143
|
+
render: (args: Record<string, unknown>) => <ChatElement args={args} />,
|
|
97
144
|
parameters: { docs: { source: { code: HTML_SNIPPET, language: 'html' } } },
|
|
98
145
|
};
|
|
99
146
|
|
|
@@ -103,3 +150,9 @@ export const InSolidJS: Story = {
|
|
|
103
150
|
render: () => <ChatElement />,
|
|
104
151
|
parameters: { docs: { source: { code: SOLID_SNIPPET, language: 'tsx' } } },
|
|
105
152
|
};
|
|
153
|
+
|
|
154
|
+
/** Full generated API reference — properties, events, tokens, and the SolidJS components this element is composed from. */
|
|
155
|
+
export const API: Story = {
|
|
156
|
+
render: () => <ElementSpec tag="kitn-chat" />,
|
|
157
|
+
parameters: { layout: 'padded' },
|
|
158
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
2
|
import { onMount } from 'solid-js';
|
|
3
3
|
import './register'; // side effect: registers the custom elements
|
|
4
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
5
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
4
6
|
|
|
5
7
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
6
8
|
declare module 'solid-js' {
|
|
@@ -40,6 +42,7 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
|
40
42
|
const meta = {
|
|
41
43
|
title: 'Web Components/kitn-checkpoint',
|
|
42
44
|
tags: ['autodocs'],
|
|
45
|
+
argTypes: argTypesFor('kitn-checkpoint'),
|
|
43
46
|
parameters: {
|
|
44
47
|
layout: 'fullscreen',
|
|
45
48
|
docs: {
|
|
@@ -58,6 +61,12 @@ const meta = {
|
|
|
58
61
|
export default meta;
|
|
59
62
|
type Story = StoryObj;
|
|
60
63
|
|
|
64
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
65
|
+
export const API: Story = {
|
|
66
|
+
render: () => <ElementSpec tag="kitn-checkpoint" />,
|
|
67
|
+
parameters: { layout: 'padded' },
|
|
68
|
+
};
|
|
69
|
+
|
|
61
70
|
/** A labeled checkpoint button. (Add a `tooltip` attribute for a hover hint — see the Code tab.) */
|
|
62
71
|
export const Labeled: Story = {
|
|
63
72
|
render: () => <CheckpointElement label="Restore" variant="outline" />,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
2
|
import { onMount } from 'solid-js';
|
|
3
3
|
import './register'; // side effect: registers the custom elements
|
|
4
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
5
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
4
6
|
|
|
5
7
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
6
8
|
declare module 'solid-js' {
|
|
@@ -52,6 +54,7 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
|
52
54
|
const meta = {
|
|
53
55
|
title: 'Web Components/kitn-code-block',
|
|
54
56
|
tags: ['autodocs'],
|
|
57
|
+
argTypes: argTypesFor('kitn-code-block'),
|
|
55
58
|
parameters: {
|
|
56
59
|
layout: 'fullscreen',
|
|
57
60
|
docs: {
|
|
@@ -70,6 +73,12 @@ const meta = {
|
|
|
70
73
|
export default meta;
|
|
71
74
|
type Story = StoryObj;
|
|
72
75
|
|
|
76
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
77
|
+
export const API: Story = {
|
|
78
|
+
render: () => <ElementSpec tag="kitn-code-block" />,
|
|
79
|
+
parameters: { layout: 'padded' },
|
|
80
|
+
};
|
|
81
|
+
|
|
73
82
|
/** A TypeScript snippet (the default `tsx` grammar). */
|
|
74
83
|
export const TypeScript: Story = {
|
|
75
84
|
render: () => <CodeBlockElement code={sampleCode} language="ts" />,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
2
|
import { onMount } from 'solid-js';
|
|
3
3
|
import './register'; // side effect: registers the custom elements
|
|
4
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
5
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
4
6
|
|
|
5
7
|
interface ContextUsage {
|
|
6
8
|
usedTokens: number;
|
|
@@ -60,6 +62,7 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
|
60
62
|
const meta = {
|
|
61
63
|
title: 'Web Components/kitn-context-meter',
|
|
62
64
|
tags: ['autodocs'],
|
|
65
|
+
argTypes: argTypesFor('kitn-context-meter'),
|
|
63
66
|
parameters: {
|
|
64
67
|
layout: 'fullscreen',
|
|
65
68
|
docs: {
|
|
@@ -78,6 +81,12 @@ const meta = {
|
|
|
78
81
|
export default meta;
|
|
79
82
|
type Story = StoryObj;
|
|
80
83
|
|
|
84
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
85
|
+
export const API: Story = {
|
|
86
|
+
render: () => <ElementSpec tag="kitn-context-meter" />,
|
|
87
|
+
parameters: { layout: 'padded' },
|
|
88
|
+
};
|
|
89
|
+
|
|
81
90
|
/** A meter at ~24% usage; hover to reveal the full breakdown. */
|
|
82
91
|
export const Default: Story = {
|
|
83
92
|
render: () => <MeterElement context={usage} />,
|
|
@@ -2,6 +2,8 @@ import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
|
2
2
|
import { onMount } from 'solid-js';
|
|
3
3
|
import './register'; // side effect: registers <kitn-chat>, <kitn-conversation-list>, <kitn-prompt-input>
|
|
4
4
|
import type { ConversationGroup, ConversationSummary } from '../types';
|
|
5
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
6
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
5
7
|
|
|
6
8
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
7
9
|
declare module 'solid-js' {
|
|
@@ -56,25 +58,34 @@ const sampleConversations: ConversationSummary[] = [
|
|
|
56
58
|
},
|
|
57
59
|
];
|
|
58
60
|
|
|
61
|
+
type ConversationListEl = HTMLElement & {
|
|
62
|
+
groups?: ConversationGroup[];
|
|
63
|
+
conversations?: ConversationSummary[];
|
|
64
|
+
activeId?: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
59
67
|
/** Live demo of the actual `<kitn-conversation-list>` custom element (Shadow DOM and all). */
|
|
60
|
-
function ConversationListElement() {
|
|
61
|
-
let el:
|
|
62
|
-
| (HTMLElement & {
|
|
63
|
-
groups?: ConversationGroup[];
|
|
64
|
-
conversations?: ConversationSummary[];
|
|
65
|
-
activeId?: string;
|
|
66
|
-
})
|
|
67
|
-
| undefined;
|
|
68
|
+
function ConversationListElement(props: { args?: Record<string, unknown> }) {
|
|
69
|
+
let el: ConversationListEl | undefined;
|
|
68
70
|
onMount(() => {
|
|
69
71
|
if (el) {
|
|
72
|
+
// Fixed array data
|
|
70
73
|
el.groups = sampleGroups;
|
|
71
74
|
el.conversations = sampleConversations;
|
|
72
75
|
el.activeId = 'c-1';
|
|
76
|
+
// Scalar args from Controls
|
|
77
|
+
const args = props.args;
|
|
78
|
+
if (args) {
|
|
79
|
+
const scalarNames = ['activeId'];
|
|
80
|
+
for (const name of scalarNames) {
|
|
81
|
+
if (name in args) (el as unknown as Record<string, unknown>)[name] = args[name];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
73
84
|
}
|
|
74
85
|
});
|
|
75
86
|
return (
|
|
76
87
|
<kitn-conversation-list
|
|
77
|
-
ref={(e) => (el = e as
|
|
88
|
+
ref={(e) => (el = e as ConversationListEl)}
|
|
78
89
|
style={{ display: 'block', width: '300px', height: '560px' }}
|
|
79
90
|
/>
|
|
80
91
|
);
|
|
@@ -144,6 +155,7 @@ function Sidebar() {
|
|
|
144
155
|
const meta = {
|
|
145
156
|
title: 'Web Components/kitn-conversation-list',
|
|
146
157
|
tags: ['autodocs'],
|
|
158
|
+
argTypes: argTypesFor('kitn-conversation-list'),
|
|
147
159
|
parameters: {
|
|
148
160
|
layout: 'fullscreen',
|
|
149
161
|
docs: {
|
|
@@ -165,7 +177,10 @@ type Story = StoryObj;
|
|
|
165
177
|
|
|
166
178
|
/** The element used the plain-HTML / any-framework way. */
|
|
167
179
|
export const Default: Story = {
|
|
168
|
-
|
|
180
|
+
args: {
|
|
181
|
+
activeId: 'c-1',
|
|
182
|
+
},
|
|
183
|
+
render: (args: Record<string, unknown>) => <ConversationListElement args={args} />,
|
|
169
184
|
parameters: { docs: { source: { code: HTML_SNIPPET, language: 'html' } } },
|
|
170
185
|
};
|
|
171
186
|
|
|
@@ -175,3 +190,9 @@ export const InSolidJS: Story = {
|
|
|
175
190
|
render: () => <ConversationListElement />,
|
|
176
191
|
parameters: { docs: { source: { code: SOLID_SNIPPET, language: 'tsx' } } },
|
|
177
192
|
};
|
|
193
|
+
|
|
194
|
+
/** Full generated API reference — properties, events, tokens, and the SolidJS components this element is composed from. */
|
|
195
|
+
export const API: Story = {
|
|
196
|
+
render: () => <ElementSpec tag="kitn-conversation-list" />,
|
|
197
|
+
parameters: { layout: 'padded' },
|
|
198
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
2
|
import { onMount } from 'solid-js';
|
|
3
3
|
import './register'; // side effect: registers the custom elements
|
|
4
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
5
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
4
6
|
|
|
5
7
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
6
8
|
declare module 'solid-js' {
|
|
@@ -46,6 +48,7 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
|
46
48
|
const meta = {
|
|
47
49
|
title: 'Web Components/kitn-empty',
|
|
48
50
|
tags: ['autodocs'],
|
|
51
|
+
argTypes: argTypesFor('kitn-empty'),
|
|
49
52
|
parameters: {
|
|
50
53
|
layout: 'fullscreen',
|
|
51
54
|
docs: {
|
|
@@ -64,6 +67,12 @@ const meta = {
|
|
|
64
67
|
export default meta;
|
|
65
68
|
type Story = StoryObj;
|
|
66
69
|
|
|
70
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
71
|
+
export const API: Story = {
|
|
72
|
+
render: () => <ElementSpec tag="kitn-empty" />,
|
|
73
|
+
parameters: { layout: 'padded' },
|
|
74
|
+
};
|
|
75
|
+
|
|
67
76
|
/** Render the actual `<kitn-empty>` custom element with slotted children. */
|
|
68
77
|
function EmptyElement() {
|
|
69
78
|
let el: HTMLElement | undefined;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
2
|
import './register'; // side effect: registers the custom elements
|
|
3
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
4
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
3
5
|
|
|
4
6
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
5
7
|
declare module 'solid-js' {
|
|
@@ -31,6 +33,7 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
|
31
33
|
const meta = {
|
|
32
34
|
title: 'Web Components/kitn-feedback-bar',
|
|
33
35
|
tags: ['autodocs'],
|
|
36
|
+
argTypes: argTypesFor('kitn-feedback-bar'),
|
|
34
37
|
parameters: {
|
|
35
38
|
layout: 'fullscreen',
|
|
36
39
|
docs: {
|
|
@@ -49,6 +52,12 @@ const meta = {
|
|
|
49
52
|
export default meta;
|
|
50
53
|
type Story = StoryObj;
|
|
51
54
|
|
|
55
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
56
|
+
export const API: Story = {
|
|
57
|
+
render: () => <ElementSpec tag="kitn-feedback-bar" />,
|
|
58
|
+
parameters: { layout: 'padded' },
|
|
59
|
+
};
|
|
60
|
+
|
|
52
61
|
/** The default feedback prompt. */
|
|
53
62
|
export const Default: Story = {
|
|
54
63
|
render: () => (
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
2
|
import './register'; // side effect: registers the custom elements
|
|
3
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
4
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
3
5
|
|
|
4
6
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
5
7
|
declare module 'solid-js' {
|
|
@@ -31,6 +33,7 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
|
31
33
|
const meta = {
|
|
32
34
|
title: 'Web Components/kitn-file-upload',
|
|
33
35
|
tags: ['autodocs'],
|
|
36
|
+
argTypes: argTypesFor('kitn-file-upload'),
|
|
34
37
|
parameters: {
|
|
35
38
|
layout: 'fullscreen',
|
|
36
39
|
docs: {
|
|
@@ -49,6 +52,12 @@ const meta = {
|
|
|
49
52
|
export default meta;
|
|
50
53
|
type Story = StoryObj;
|
|
51
54
|
|
|
55
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
56
|
+
export const API: Story = {
|
|
57
|
+
render: () => <ElementSpec tag="kitn-file-upload" />,
|
|
58
|
+
parameters: { layout: 'padded' },
|
|
59
|
+
};
|
|
60
|
+
|
|
52
61
|
/** A dropzone accepting any files. */
|
|
53
62
|
export const Default: Story = {
|
|
54
63
|
render: () => (
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
2
|
import { onMount } from 'solid-js';
|
|
3
3
|
import './register'; // side effect: registers the custom elements
|
|
4
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
5
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
4
6
|
|
|
5
7
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
6
8
|
declare module 'solid-js' {
|
|
@@ -45,6 +47,7 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
|
45
47
|
const meta = {
|
|
46
48
|
title: 'Web Components/kitn-image',
|
|
47
49
|
tags: ['autodocs'],
|
|
50
|
+
argTypes: argTypesFor('kitn-image'),
|
|
48
51
|
parameters: {
|
|
49
52
|
layout: 'fullscreen',
|
|
50
53
|
docs: {
|
|
@@ -63,6 +66,12 @@ const meta = {
|
|
|
63
66
|
export default meta;
|
|
64
67
|
type Story = StoryObj;
|
|
65
68
|
|
|
69
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
70
|
+
export const API: Story = {
|
|
71
|
+
render: () => <ElementSpec tag="kitn-image" />,
|
|
72
|
+
parameters: { layout: 'padded' },
|
|
73
|
+
};
|
|
74
|
+
|
|
66
75
|
/** A base64-encoded SVG with a media type and alt text. */
|
|
67
76
|
export const Default: Story = {
|
|
68
77
|
render: () => <ImageElement />,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
2
|
import './register'; // side effect: registers the custom elements
|
|
3
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
4
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
3
5
|
|
|
4
6
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
5
7
|
declare module 'solid-js' {
|
|
@@ -25,6 +27,7 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
|
25
27
|
const meta = {
|
|
26
28
|
title: 'Web Components/kitn-loader',
|
|
27
29
|
tags: ['autodocs'],
|
|
30
|
+
argTypes: argTypesFor('kitn-loader'),
|
|
28
31
|
parameters: {
|
|
29
32
|
layout: 'fullscreen',
|
|
30
33
|
docs: {
|
|
@@ -43,6 +46,12 @@ const meta = {
|
|
|
43
46
|
export default meta;
|
|
44
47
|
type Story = StoryObj;
|
|
45
48
|
|
|
49
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
50
|
+
export const API: Story = {
|
|
51
|
+
render: () => <ElementSpec tag="kitn-loader" />,
|
|
52
|
+
parameters: { layout: 'padded' },
|
|
53
|
+
};
|
|
54
|
+
|
|
46
55
|
const VARIANTS = [
|
|
47
56
|
'circular', 'classic', 'pulse', 'pulse-dot', 'dots', 'typing',
|
|
48
57
|
'wave', 'bars', 'terminal', 'text-blink', 'text-shimmer', 'loading-dots',
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
2
|
import { onMount } from 'solid-js';
|
|
3
3
|
import './register'; // side effect: registers the custom elements
|
|
4
|
+
import { ElementSpec } from '../stories/docs/element-spec';
|
|
5
|
+
import { argTypesFor } from '../stories/docs/element-controls';
|
|
4
6
|
|
|
5
7
|
// The web components are custom DOM elements, so declare the tags for JSX.
|
|
6
8
|
declare module 'solid-js' {
|
|
@@ -50,6 +52,7 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
|
|
|
50
52
|
const meta = {
|
|
51
53
|
title: 'Web Components/kitn-markdown',
|
|
52
54
|
tags: ['autodocs'],
|
|
55
|
+
argTypes: argTypesFor('kitn-markdown'),
|
|
53
56
|
parameters: {
|
|
54
57
|
layout: 'fullscreen',
|
|
55
58
|
docs: {
|
|
@@ -68,6 +71,12 @@ const meta = {
|
|
|
68
71
|
export default meta;
|
|
69
72
|
type Story = StoryObj;
|
|
70
73
|
|
|
74
|
+
/** Full generated API reference — properties, events, tokens, and composed-from. */
|
|
75
|
+
export const API: Story = {
|
|
76
|
+
render: () => <ElementSpec tag="kitn-markdown" />,
|
|
77
|
+
parameters: { layout: 'padded' },
|
|
78
|
+
};
|
|
79
|
+
|
|
71
80
|
/** Headings, emphasis, lists, a blockquote, and a highlighted code fence. */
|
|
72
81
|
export const Default: Story = {
|
|
73
82
|
render: () => <MarkdownElement content={sampleMarkdown} />,
|