@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.
- package/dist/kitn-chat.es.js +1 -1
- package/package.json +6 -1
- package/src/components/component-meta.json +10 -10
- package/src/elements/compiled.css +1 -1
- package/src/remote/host-embed.ts +1 -1
- package/src/components/artifact.stories.tsx +0 -138
- package/src/components/attachments.stories.tsx +0 -303
- package/src/components/attachments.test.tsx +0 -64
- package/src/components/chain-of-thought.stories.tsx +0 -211
- package/src/components/chat-container.stories.tsx +0 -187
- package/src/components/chat-thread.test.tsx +0 -58
- package/src/components/checkpoint.stories.tsx +0 -102
- package/src/components/code-block.stories.tsx +0 -150
- package/src/components/confirm-card.stories.tsx +0 -74
- package/src/components/context.stories.tsx +0 -229
- package/src/components/context.test.tsx +0 -133
- package/src/components/conversation-item.stories.tsx +0 -125
- package/src/components/conversation-list.stories.tsx +0 -133
- package/src/components/default-input.test.tsx +0 -111
- package/src/components/empty.stories.tsx +0 -434
- package/src/components/feedback-bar.stories.tsx +0 -138
- package/src/components/feedback-bar.test.tsx +0 -103
- package/src/components/file-tree.stories.tsx +0 -73
- package/src/components/file-upload.stories.tsx +0 -156
- package/src/components/image.stories.tsx +0 -89
- package/src/components/loader.stories.tsx +0 -181
- package/src/components/markdown.stories.tsx +0 -180
- package/src/components/message-action-bar.test.tsx +0 -128
- package/src/components/message-narrow.stories.tsx +0 -329
- package/src/components/message-skills.stories.tsx +0 -211
- package/src/components/message.stories.tsx +0 -281
- package/src/components/model-switcher.stories.tsx +0 -123
- package/src/components/model-switcher.test.tsx +0 -65
- package/src/components/prompt-input.stories.tsx +0 -222
- package/src/components/prompt-suggestion.stories.tsx +0 -142
- package/src/components/reasoning.stories.tsx +0 -140
- package/src/components/resizable.test.tsx +0 -226
- package/src/components/scroll-button.stories.tsx +0 -100
- package/src/components/slash-command.stories.tsx +0 -163
- package/src/components/source-list.test.tsx +0 -152
- package/src/components/source.stories.tsx +0 -124
- package/src/components/tasks-card.stories.tsx +0 -78
- package/src/components/text-shimmer.stories.tsx +0 -87
- package/src/components/thinking-bar.stories.tsx +0 -87
- package/src/components/tool.stories.tsx +0 -153
- package/src/components/voice-input.stories.tsx +0 -83
- package/src/elements/artifact.stories.tsx +0 -506
- package/src/elements/attachments.stories.tsx +0 -190
- package/src/elements/card.stories.tsx +0 -113
- package/src/elements/cards.stories.tsx +0 -59
- package/src/elements/catalog.stories.tsx +0 -491
- package/src/elements/chain-of-thought.declarative.test.tsx +0 -153
- package/src/elements/chain-of-thought.stories.tsx +0 -113
- package/src/elements/chat-scope-picker.stories.tsx +0 -73
- package/src/elements/chat-workspace.stories.tsx +0 -288
- package/src/elements/chat.stories.tsx +0 -151
- package/src/elements/checkpoint.stories.tsx +0 -72
- package/src/elements/choice.stories.tsx +0 -240
- package/src/elements/code-block.stories.tsx +0 -83
- package/src/elements/composed-shell.stories.tsx +0 -316
- package/src/elements/confirm-card.stories.tsx +0 -227
- package/src/elements/context-meter.stories.tsx +0 -151
- package/src/elements/conversation-list.declarative.test.tsx +0 -137
- package/src/elements/conversation-list.stories.tsx +0 -243
- package/src/elements/embed.stories.tsx +0 -213
- package/src/elements/empty.stories.tsx +0 -111
- package/src/elements/feedback-bar.stories.tsx +0 -114
- package/src/elements/file-tree.stories.tsx +0 -134
- package/src/elements/file-upload.stories.tsx +0 -82
- package/src/elements/form.stories.tsx +0 -248
- package/src/elements/image.stories.tsx +0 -71
- package/src/elements/link-preview.stories.tsx +0 -209
- package/src/elements/loader.stories.tsx +0 -88
- package/src/elements/markdown.stories.tsx +0 -76
- package/src/elements/message-skills.declarative.test.tsx +0 -104
- package/src/elements/message-skills.stories.tsx +0 -114
- package/src/elements/message.stories.tsx +0 -218
- package/src/elements/model-switcher.declarative.test.tsx +0 -130
- package/src/elements/model-switcher.stories.tsx +0 -198
- package/src/elements/popover.stories.tsx +0 -80
- package/src/elements/prompt-input-slash-command.test.tsx +0 -128
- package/src/elements/prompt-input-stoppable.test.tsx +0 -88
- package/src/elements/prompt-input-toolbar-actions.test.tsx +0 -120
- package/src/elements/prompt-input.stories.tsx +0 -331
- package/src/elements/prompt-suggestions.declarative.test.tsx +0 -164
- package/src/elements/prompt-suggestions.stories.tsx +0 -213
- package/src/elements/reasoning.stories.tsx +0 -77
- package/src/elements/remote.stories.tsx +0 -314
- package/src/elements/resizable.stories.tsx +0 -426
- package/src/elements/response-stream.stories.tsx +0 -79
- package/src/elements/scroll-button.stories.tsx +0 -202
- package/src/elements/scroll-button.test.tsx +0 -148
- package/src/elements/source-list.stories.tsx +0 -143
- package/src/elements/source.stories.tsx +0 -88
- package/src/elements/switch.stories.tsx +0 -56
- package/src/elements/tasks.stories.tsx +0 -237
- package/src/elements/text-shimmer.stories.tsx +0 -64
- package/src/elements/thinking-bar.stories.tsx +0 -72
- package/src/elements/tool.stories.tsx +0 -89
- package/src/elements/voice-input.stories.tsx +0 -88
- package/src/primitives/controllable.test.ts +0 -47
- package/src/stories/chat-panel-layout.stories.tsx +0 -145
- package/src/stories/chat-scene.tsx +0 -571
- package/src/stories/checkpoint-restore.stories.tsx +0 -256
- package/src/stories/context-usage.stories.tsx +0 -212
- package/src/stories/conversation-with-reasoning.stories.tsx +0 -182
- package/src/stories/conversation-with-sources.stories.tsx +0 -471
- package/src/stories/docs/Accessibility.mdx +0 -119
- package/src/stories/docs/ChildElements.mdx +0 -269
- package/src/stories/docs/ForAIAgents.mdx +0 -162
- package/src/stories/docs/GettingStarted.mdx +0 -65
- package/src/stories/docs/Installation.mdx +0 -83
- package/src/stories/docs/Introduction.mdx +0 -50
- package/src/stories/docs/SolidJsAdvanced.mdx +0 -17
- package/src/stories/docs/Theming.mdx +0 -85
- package/src/stories/docs/element-controls.ts +0 -121
- package/src/stories/docs/frameworks/Angular.mdx +0 -245
- package/src/stories/docs/frameworks/Html.mdx +0 -227
- package/src/stories/docs/frameworks/Overview.mdx +0 -47
- package/src/stories/docs/frameworks/React.mdx +0 -227
- package/src/stories/docs/frameworks/Solid.mdx +0 -173
- package/src/stories/docs/frameworks/Svelte.mdx +0 -194
- package/src/stories/docs/frameworks/Vue.mdx +0 -238
- package/src/stories/docs/generative-ui-overview.mdx +0 -186
- package/src/stories/docs/recipes/SpeechToText.mdx +0 -7
- package/src/stories/docs/recipes/Streaming.mdx +0 -68
- package/src/stories/docs/recipes/TextToSpeech.mdx +0 -35
- package/src/stories/docs/theme-editor/canvas.tsx +0 -32
- package/src/stories/docs/theme-editor/inspector.tsx +0 -66
- package/src/stories/docs/theme-editor/presets.test.ts +0 -32
- package/src/stories/docs/theme-editor/presets.ts +0 -64
- package/src/stories/docs/theme-editor/theme-css.test.ts +0 -19
- package/src/stories/docs/theme-editor/theme-css.ts +0 -15
- package/src/stories/docs/theme-editor/theme-editor.tsx +0 -146
- package/src/stories/docs/theme-tokens.tsx +0 -174
- package/src/stories/examples/ChoosingComponents.mdx +0 -106
- package/src/stories/examples/sample-data.ts +0 -79
- package/src/stories/examples/usage/checkpoint-restore.ts +0 -156
- package/src/stories/examples/usage/context-usage.ts +0 -591
- package/src/stories/examples/usage/conversation-with-reasoning.ts +0 -224
- package/src/stories/examples/usage/conversation-with-sources.ts +0 -589
- package/src/stories/examples/usage/empty-state.ts +0 -144
- package/src/stories/examples/usage/full-chat-app.ts +0 -277
- package/src/stories/examples/usage/index.ts +0 -63
- package/src/stories/examples/usage/message-actions.ts +0 -704
- package/src/stories/examples/usage/pattern-centered-conversation.ts +0 -446
- package/src/stories/examples/usage/pattern-chat-panel-layout.ts +0 -442
- package/src/stories/examples/usage/pattern-docked-widget.ts +0 -479
- package/src/stories/examples/usage/prompt-input-variants.ts +0 -1356
- package/src/stories/examples/usage/streaming-response.ts +0 -687
- package/src/stories/examples/usage/types.ts +0 -33
- package/src/stories/full-chat.stories.tsx +0 -18
- package/src/stories/message-actions.stories.tsx +0 -230
- package/src/stories/pattern-centered-conversation.stories.tsx +0 -93
- package/src/stories/pattern-docked-widget.stories.tsx +0 -93
- package/src/stories/pattern-empty-state.stories.tsx +0 -76
- package/src/stories/prompt-input-variants.stories.tsx +0 -456
- package/src/stories/streaming-response.stories.tsx +0 -438
- package/src/stories/theme-editor.stories.tsx +0 -16
- package/src/stories/token-reference.stories.tsx +0 -18
- package/src/stories/typography.stories.tsx +0 -78
- package/src/ui/avatar.stories.tsx +0 -103
- package/src/ui/badge.stories.tsx +0 -86
- package/src/ui/button.stories.tsx +0 -145
- package/src/ui/collapsible.stories.tsx +0 -69
- package/src/ui/dropdown.stories.tsx +0 -59
- package/src/ui/hover-card.stories.tsx +0 -77
- package/src/ui/hover-card.test.tsx +0 -30
- package/src/ui/overlay.stories.tsx +0 -115
- package/src/ui/popover.stories.tsx +0 -81
- package/src/ui/popover.test.tsx +0 -99
- package/src/ui/resizable.stories.tsx +0 -236
- package/src/ui/scroll-area.stories.tsx +0 -50
- package/src/ui/separator.stories.tsx +0 -81
- package/src/ui/skeleton.stories.tsx +0 -337
- package/src/ui/switch.stories.tsx +0 -51
- package/src/ui/switch.test.tsx +0 -59
- package/src/ui/textarea.stories.tsx +0 -76
- package/src/ui/tooltip.stories.tsx +0 -74
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
|
-
import type { JSX } from 'solid-js';
|
|
3
|
-
import './card';
|
|
4
|
-
import { argTypesFor, specDescription } from '../stories/docs/element-controls';
|
|
5
|
-
|
|
6
|
-
declare module 'solid-js' {
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
8
|
-
namespace JSX {
|
|
9
|
-
interface IntrinsicElements {
|
|
10
|
-
'kai-card': JSX.HTMLAttributes<HTMLElement> & {
|
|
11
|
-
heading?: string;
|
|
12
|
-
description?: string;
|
|
13
|
-
'error-message'?: string;
|
|
14
|
-
dense?: boolean | string;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** A bordered box the card sits inside (gives it a sensible width). */
|
|
21
|
-
function Frame(props: { children: JSX.Element }) {
|
|
22
|
-
return <div style={{ 'max-width': '420px' }}>{props.children}</div>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const CONTENT_SNIPPET = `<!-- kai-card is the chrome/container. Slot in plain content — not interactive controls.
|
|
26
|
-
For data-driven interactive cards use the typed cards instead (see below). -->
|
|
27
|
-
<kai-card heading="Workspace summary" description="Generated just now.">
|
|
28
|
-
<p>Your repository has 3 open pull requests and 12 passing checks.</p>
|
|
29
|
-
</kai-card>
|
|
30
|
-
|
|
31
|
-
<script type="module">
|
|
32
|
-
import '@kitn.ai/ui/elements'; // registers the custom elements
|
|
33
|
-
</script>`;
|
|
34
|
-
|
|
35
|
-
const MEDIA_SNIPPET = `<kai-card heading="Quarterly report" description="Generated just now.">
|
|
36
|
-
<img slot="media" src="/preview.png" alt="Report preview" />
|
|
37
|
-
<p>Your Q2 numbers are ready to review.</p>
|
|
38
|
-
</kai-card>`;
|
|
39
|
-
|
|
40
|
-
const ERROR_SNIPPET = `<!-- The one consistent inline error every card uses. -->
|
|
41
|
-
<kai-card heading="Share your feedback" error-message="This card couldn't be displayed."></kai-card>`;
|
|
42
|
-
|
|
43
|
-
const meta = {
|
|
44
|
-
title: 'Generative UI/Cards/kai-card',
|
|
45
|
-
tags: ['autodocs'],
|
|
46
|
-
argTypes: argTypesFor('kai-card'),
|
|
47
|
-
parameters: {
|
|
48
|
-
layout: 'padded',
|
|
49
|
-
docs: {
|
|
50
|
-
description: specDescription('kai-card', [
|
|
51
|
-
'`<kai-card>` is the shared, presentational **card chrome** every native generative-UI card composes from: an optional **media** region (`slot="media"`), a **heading** + **description**, a **body** (default slot), an **actions** footer (`slot="actions"`), and one consistent inline **error** state (`error-message`).',
|
|
52
|
-
'**Chrome only — it emits no events and reads no context.** Raw light-DOM content slotted into `kai-card` (such as plain `<button>` elements) is unstyled because light DOM cannot reach shadow CSS. The cards that compose it own the Card-contract interaction.',
|
|
53
|
-
'**For interactive, data-driven cards use the typed cards:** `<kai-confirm>` (approval actions — see that story for the canonical data-in → event-out example), `<kai-form>` (input/submit), `<kai-choice>` (single-select), `<kai-tasks>` (progress), `<kai-link-preview>` (rich link), `<kai-embed>` (media). Use `kai-card` only as a **plain themed surface** for presentational content.',
|
|
54
|
-
"**How to use as a surface:** register once with `import '@kitn.ai/ui/elements'`, set `heading`/`description` attributes, drop body markup in the default slot, and optionally a media region in `slot=\"media\"`. Set `error-message` to render the standard inline error (it replaces the body/actions).",
|
|
55
|
-
'See the **Code** tab for HTML usage.',
|
|
56
|
-
]),
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
} satisfies Meta;
|
|
60
|
-
|
|
61
|
-
export default meta;
|
|
62
|
-
type Story = StoryObj;
|
|
63
|
-
|
|
64
|
-
/** `kai-card` as a plain themed surface: heading + description + slotted text content. This is the correct use of `kai-card` — presentational chrome around passive content. For interactive cards (actions, forms, choices) use the typed cards such as `kai-confirm`. */
|
|
65
|
-
export const ContentSurface: Story = {
|
|
66
|
-
name: 'Content surface',
|
|
67
|
-
render: () => (
|
|
68
|
-
<Frame>
|
|
69
|
-
<kai-card heading="Workspace summary" description="Generated just now.">
|
|
70
|
-
<p style={{ margin: 0 }}>Your repository has 3 open pull requests and 12 passing checks.</p>
|
|
71
|
-
</kai-card>
|
|
72
|
-
</Frame>
|
|
73
|
-
),
|
|
74
|
-
parameters: { docs: { source: { code: CONTENT_SNIPPET, language: 'html' } } },
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/** An image media region above the heading. */
|
|
78
|
-
export const WithMedia: Story = {
|
|
79
|
-
render: () => (
|
|
80
|
-
<Frame>
|
|
81
|
-
<kai-card heading="Quarterly report" description="Generated just now.">
|
|
82
|
-
<div
|
|
83
|
-
slot="media"
|
|
84
|
-
style={{
|
|
85
|
-
height: '120px',
|
|
86
|
-
display: 'grid',
|
|
87
|
-
'place-items': 'center',
|
|
88
|
-
background: 'var(--color-muted, #f4f4f5)',
|
|
89
|
-
color: 'var(--color-muted-foreground, #71717a)',
|
|
90
|
-
'font-size': '13px',
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
93
|
-
media slot
|
|
94
|
-
</div>
|
|
95
|
-
<p style={{ margin: 0 }}>Your Q2 numbers are ready to review.</p>
|
|
96
|
-
</kai-card>
|
|
97
|
-
</Frame>
|
|
98
|
-
),
|
|
99
|
-
parameters: { docs: { source: { code: MEDIA_SNIPPET, language: 'html' } } },
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/** The standard inline error state (replaces the body/actions). */
|
|
103
|
-
export const ErrorState: Story = {
|
|
104
|
-
render: () => (
|
|
105
|
-
<Frame>
|
|
106
|
-
<kai-card
|
|
107
|
-
heading="Share your feedback"
|
|
108
|
-
error-message="This card couldn't be displayed."
|
|
109
|
-
/>
|
|
110
|
-
</Frame>
|
|
111
|
-
),
|
|
112
|
-
parameters: { docs: { source: { code: ERROR_SNIPPET, language: 'html' } } },
|
|
113
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// src/elements/cards.stories.tsx
|
|
2
|
-
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
3
|
-
import { createSignal, onMount } from 'solid-js';
|
|
4
|
-
import './register'; // registers all kai-* incl. kai-cards
|
|
5
|
-
import type { CardEnvelope, CardEvent } from '../primitives/card-contract';
|
|
6
|
-
|
|
7
|
-
declare module 'solid-js' {
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
9
|
-
namespace JSX {
|
|
10
|
-
interface IntrinsicElements { 'kai-cards': JSX.HTMLAttributes<HTMLElement>; }
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const CARDS: CardEnvelope[] = [
|
|
15
|
-
{ type: 'confirm', id: 'deploy', title: 'Deploy to production?',
|
|
16
|
-
data: { body: 'Apply 3 migrations and deploy?', tone: 'warning',
|
|
17
|
-
actions: [{ id: 'go', label: 'Deploy', style: 'primary', default: true }, { id: 'no', label: 'Cancel' }] } },
|
|
18
|
-
{ type: 'tasks', id: 'plan', title: 'Pick the steps',
|
|
19
|
-
data: { tasks: [{ id: 'a', label: 'Run tests', checked: true }, { id: 'b', label: 'Tag release' }], confirmLabel: 'Run selected' } },
|
|
20
|
-
{ type: 'choice', id: 'plan-pick', title: 'Choose a plan',
|
|
21
|
-
data: { prompt: 'Which plan fits your team?', options: [
|
|
22
|
-
{ id: 'free', label: 'Free', meta: '$0' },
|
|
23
|
-
{ id: 'pro', label: 'Pro', meta: '$12/seat', recommended: true, payload: { plan: 'pro' } },
|
|
24
|
-
] } },
|
|
25
|
-
{ type: 'link', id: 'doc', data: { url: 'https://kitn.dev', title: 'kitn.dev', description: 'Generative UI cards', domain: 'kitn.dev' } },
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
/** A host renders a stream of envelopes via <kai-cards> and handles events via `.policy`. */
|
|
29
|
-
function Demo() {
|
|
30
|
-
let el: HTMLElement | undefined;
|
|
31
|
-
const [log, setLog] = createSignal<string[]>([]);
|
|
32
|
-
onMount(() => {
|
|
33
|
-
if (!el) return;
|
|
34
|
-
(el as unknown as { cards: CardEnvelope[] }).cards = CARDS;
|
|
35
|
-
(el as unknown as { policy: unknown }).policy = {
|
|
36
|
-
onAction: (id: string, action: string) => setLog((l) => [`action: ${id} → ${action}`, ...l]),
|
|
37
|
-
onSubmit: (id: string, data: unknown) => setLog((l) => [`submit: ${id} → ${JSON.stringify(data)}`, ...l]),
|
|
38
|
-
onOpen: (url: string) => setLog((l) => [`open: ${url}`, ...l]),
|
|
39
|
-
onError: (id: string, msg: string) => setLog((l) => [`error: ${id} → ${msg}`, ...l]),
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
return (
|
|
43
|
-
<div style={{ display: 'grid', 'grid-template-columns': '1fr 18rem', gap: '1rem', padding: '1rem' }}>
|
|
44
|
-
<kai-cards ref={(e) => (el = e as HTMLElement)} />
|
|
45
|
-
<pre style={{ 'font-size': '12px', background: '#f4f4f5', padding: '8px', 'border-radius': '6px', 'min-height': '6rem' }}>
|
|
46
|
-
{log().join('\n') || 'events appear here…'}
|
|
47
|
-
</pre>
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const meta = {
|
|
53
|
-
title: 'Generative UI/SDK/kai-cards',
|
|
54
|
-
parameters: { layout: 'fullscreen' },
|
|
55
|
-
} satisfies Meta;
|
|
56
|
-
export default meta;
|
|
57
|
-
type Story = StoryObj;
|
|
58
|
-
|
|
59
|
-
export const CardStream: Story = { render: () => <Demo /> };
|
|
@@ -1,491 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
|
-
import { onMount, type JSX } from 'solid-js';
|
|
3
|
-
import './register'; // side effect: registers the custom elements
|
|
4
|
-
import {
|
|
5
|
-
attachments,
|
|
6
|
-
conversations,
|
|
7
|
-
context,
|
|
8
|
-
cotSteps,
|
|
9
|
-
models,
|
|
10
|
-
assistantMessage,
|
|
11
|
-
userMessage,
|
|
12
|
-
slashCommands,
|
|
13
|
-
sources,
|
|
14
|
-
} from '../stories/examples/sample-data';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Examples / Catalog — the `examples/composable/index.html` showcase, ported into
|
|
18
|
-
* Storybook as source-visible web-component stories. Every kai-* element rendered
|
|
19
|
-
* with minimal sample data, grouped by category, so a developer can answer
|
|
20
|
-
* "what exists?" without leaving Storybook — and read the exact markup via the
|
|
21
|
-
* "Show code" panel on each story.
|
|
22
|
-
*
|
|
23
|
-
* Convention (matches the per-element stories): the kai-* tags are custom DOM
|
|
24
|
-
* elements declared as JSX intrinsics elsewhere with only the standard
|
|
25
|
-
* attributes; element-specific attributes and object/array PROPERTIES are set
|
|
26
|
-
* imperatively through a `ref` (see `wire`/`attrs`/`props`), so this file stays
|
|
27
|
-
* type-safe without re-declaring the tags.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
type AnyEl = HTMLElement & Record<string, unknown>;
|
|
31
|
-
|
|
32
|
-
/** Set JS properties (objects/arrays) on an element. */
|
|
33
|
-
const props = (el: HTMLElement, p: Record<string, unknown>) => {
|
|
34
|
-
for (const k in p) (el as AnyEl)[k] = p[k];
|
|
35
|
-
};
|
|
36
|
-
/** Set string/boolean attributes on an element. */
|
|
37
|
-
const attrs = (el: HTMLElement, a: Record<string, string | boolean>) => {
|
|
38
|
-
for (const k in a) {
|
|
39
|
-
const v = a[k];
|
|
40
|
-
if (v === false) el.removeAttribute(k);
|
|
41
|
-
else el.setAttribute(k, v === true ? '' : v);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// The kai-* tags are declared as JSX intrinsics by the per-element story files
|
|
46
|
-
// (global `declare module 'solid-js'` augmentations). We only ever pass `style`
|
|
47
|
-
// and `ref` here, so no local re-declaration is needed.
|
|
48
|
-
|
|
49
|
-
// ── helpers ────────────────────────────────────────────────────────────────
|
|
50
|
-
|
|
51
|
-
/** A bordered tile that frames one component with a caption. */
|
|
52
|
-
function Spec(props: { tag: string; note?: string; children: JSX.Element; tall?: boolean }) {
|
|
53
|
-
return (
|
|
54
|
-
<div
|
|
55
|
-
style={{
|
|
56
|
-
border: '1px solid var(--color-border, #e4e4e7)',
|
|
57
|
-
'border-radius': '12px',
|
|
58
|
-
overflow: 'hidden',
|
|
59
|
-
background: 'var(--color-background, #fff)',
|
|
60
|
-
display: 'flex',
|
|
61
|
-
'flex-direction': 'column',
|
|
62
|
-
}}
|
|
63
|
-
>
|
|
64
|
-
<div
|
|
65
|
-
style={{
|
|
66
|
-
padding: '8px 12px',
|
|
67
|
-
'border-bottom': '1px solid var(--color-border, #e4e4e7)',
|
|
68
|
-
'font-size': '12px',
|
|
69
|
-
display: 'flex',
|
|
70
|
-
gap: '8px',
|
|
71
|
-
'align-items': 'baseline',
|
|
72
|
-
'flex-wrap': 'wrap',
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
75
|
-
<code style={{ 'font-weight': '600', color: 'var(--color-foreground, #18181b)' }}>{props.tag}</code>
|
|
76
|
-
{props.note ? (
|
|
77
|
-
<span style={{ color: 'var(--color-muted-foreground, #71717a)' }}>{props.note}</span>
|
|
78
|
-
) : null}
|
|
79
|
-
</div>
|
|
80
|
-
<div style={{ padding: '14px', 'min-height': props.tall ? '320px' : 'auto' }}>{props.children}</div>
|
|
81
|
-
</div>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Responsive grid of Spec tiles. */
|
|
86
|
-
function Grid(props: { children: JSX.Element }) {
|
|
87
|
-
return (
|
|
88
|
-
<div
|
|
89
|
-
style={{
|
|
90
|
-
display: 'grid',
|
|
91
|
-
'grid-template-columns': 'repeat(auto-fill, minmax(320px, 1fr))',
|
|
92
|
-
gap: '16px',
|
|
93
|
-
'max-width': '1100px',
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
96
|
-
{props.children}
|
|
97
|
-
</div>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const meta = {
|
|
102
|
-
title: 'Examples/Catalog',
|
|
103
|
-
parameters: {
|
|
104
|
-
layout: 'padded',
|
|
105
|
-
docs: {
|
|
106
|
-
description: {
|
|
107
|
-
component: [
|
|
108
|
-
'# Component catalog',
|
|
109
|
-
'Every `kai-*` web component rendered with minimal sample data, grouped by category — the in-Storybook port of `examples/composable/index.html`. Use it to answer **"what exists?"**, then open each story\'s **Show code** panel to read the exact composition markup.',
|
|
110
|
-
'Data goes **in via properties** (set with `el.someProp = …` — see each snippet), interactions come **out via events** (`el.addEventListener("kai-submit", …)`). Register everything once with `import "@kitn.ai/ui/elements"`.',
|
|
111
|
-
'Next: see **Examples / Composed chat shell** to watch these leaves assemble into a real chat, and **Examples / Choosing components** for the mental model of which tier to reach for.',
|
|
112
|
-
].join('\n\n'),
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
} satisfies Meta;
|
|
117
|
-
|
|
118
|
-
export default meta;
|
|
119
|
-
type Story = StoryObj;
|
|
120
|
-
|
|
121
|
-
// ── 01 · Batteries-included ──────────────────────────────────────────────────
|
|
122
|
-
|
|
123
|
-
const DROPIN_SNIPPET = `<!-- The drop-in layer: whole surfaces in a single tag -->
|
|
124
|
-
<kai-conversations style="display:block;height:320px"></kai-conversations>
|
|
125
|
-
<kai-prompt-input placeholder="Ask anything… (try typing /)"></kai-prompt-input>
|
|
126
|
-
|
|
127
|
-
<script type="module">
|
|
128
|
-
import '@kitn.ai/ui/elements';
|
|
129
|
-
|
|
130
|
-
const list = document.querySelector('kai-conversations');
|
|
131
|
-
list.conversations = [
|
|
132
|
-
{ id: 'c1', title: 'Web component architecture', scope: { type: 'document' },
|
|
133
|
-
messageCount: 12, lastMessageAt: '…', updatedAt: '…' },
|
|
134
|
-
];
|
|
135
|
-
list.activeId = 'c1';
|
|
136
|
-
list.addEventListener('kai-conversation-select', (e) => (list.activeId = e.detail.id));
|
|
137
|
-
|
|
138
|
-
const input = document.querySelector('kai-prompt-input');
|
|
139
|
-
input.slashCommands = [
|
|
140
|
-
{ id: 'summarize', label: '/summarize', description: 'Summarize', category: 'Actions' },
|
|
141
|
-
];
|
|
142
|
-
input.addEventListener('kai-submit', (e) => console.log('submit', e.detail.value));
|
|
143
|
-
</script>`;
|
|
144
|
-
|
|
145
|
-
export const BatteriesIncluded: Story = {
|
|
146
|
-
name: '01 · Batteries-included',
|
|
147
|
-
render: () => {
|
|
148
|
-
let list!: HTMLElement;
|
|
149
|
-
let input!: HTMLElement;
|
|
150
|
-
onMount(() => {
|
|
151
|
-
props(list, { conversations, activeId: 'c1' });
|
|
152
|
-
list.addEventListener('kai-conversation-select', (e) => ((list as AnyEl).activeId = (e as CustomEvent).detail.id));
|
|
153
|
-
props(input, { slashCommands });
|
|
154
|
-
attrs(input, { placeholder: 'Ask anything… (try typing /)' });
|
|
155
|
-
});
|
|
156
|
-
return (
|
|
157
|
-
<Grid>
|
|
158
|
-
<Spec tag="kai-conversations" note="sidebar list with grouping & selection" tall>
|
|
159
|
-
<div style={{ height: '300px', border: '1px solid var(--color-border,#e4e4e7)', 'border-radius': '8px', overflow: 'hidden' }}>
|
|
160
|
-
<kai-conversations ref={(e) => (list = e)} style={{ display: 'block', height: '100%' }} />
|
|
161
|
-
</div>
|
|
162
|
-
</Spec>
|
|
163
|
-
<Spec tag="kai-prompt-input" note='slash commands — type "/"'>
|
|
164
|
-
<kai-prompt-input ref={(e) => (input = e)} />
|
|
165
|
-
</Spec>
|
|
166
|
-
</Grid>
|
|
167
|
-
);
|
|
168
|
-
},
|
|
169
|
-
parameters: { docs: { source: { code: DROPIN_SNIPPET, language: 'html' } } },
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// ── 02 · Messages ────────────────────────────────────────────────────────────
|
|
173
|
-
|
|
174
|
-
const MESSAGES_SNIPPET = `<!-- Compose your own message list from the parts a turn is made of -->
|
|
175
|
-
<kai-message id="assistant"></kai-message>
|
|
176
|
-
<kai-message id="user"></kai-message>
|
|
177
|
-
<kai-markdown id="md"></kai-markdown>
|
|
178
|
-
<kai-reasoning id="reason" label="Reasoning" streaming></kai-reasoning>
|
|
179
|
-
<kai-chain-of-thought id="cot"></kai-chain-of-thought>
|
|
180
|
-
<kai-code-block id="code" language="ts"></kai-code-block>
|
|
181
|
-
<kai-tool id="tool" open></kai-tool>
|
|
182
|
-
|
|
183
|
-
<script type="module">
|
|
184
|
-
import '@kitn.ai/ui/elements';
|
|
185
|
-
|
|
186
|
-
document.getElementById('assistant').message = {
|
|
187
|
-
id: 'm-a', role: 'assistant',
|
|
188
|
-
content: "Here's the plan…\\n\`\`\`js\\nconst kit = useKitn();\\n\`\`\`",
|
|
189
|
-
reasoning: { text: 'The user wants X…', label: 'Reasoning' },
|
|
190
|
-
tools: [{ type: 'search', state: 'output-available', input: { query: 'kitn' }, output: { hits: 3 } }],
|
|
191
|
-
actions: ['copy', 'like', 'dislike', 'regenerate'],
|
|
192
|
-
};
|
|
193
|
-
document.getElementById('user').message = { id: 'm-u', role: 'user', content: 'How do I compose these?' };
|
|
194
|
-
document.getElementById('md').content = '### Markdown\\nRenders **bold**, \`code\`, lists.';
|
|
195
|
-
document.getElementById('reason').text = 'First I parse, then plan, then verify.';
|
|
196
|
-
document.getElementById('code').code = 'export const add = (a, b) => a + b;';
|
|
197
|
-
document.getElementById('cot').steps = [{ label: 'Understand' }, { label: 'Design' }, { label: 'Build' }];
|
|
198
|
-
document.getElementById('tool').tool = {
|
|
199
|
-
type: 'database_query', state: 'output-available',
|
|
200
|
-
input: { table: 'users', limit: 10 }, output: { rows: 10, ms: 42 },
|
|
201
|
-
};
|
|
202
|
-
</script>`;
|
|
203
|
-
|
|
204
|
-
export const Messages: Story = {
|
|
205
|
-
name: '02 · Messages',
|
|
206
|
-
render: () => {
|
|
207
|
-
let msgA!: HTMLElement, msgU!: HTMLElement, md!: HTMLElement, reason!: HTMLElement;
|
|
208
|
-
let cot!: HTMLElement, code!: HTMLElement, tool!: HTMLElement;
|
|
209
|
-
onMount(() => {
|
|
210
|
-
props(msgA, { message: assistantMessage });
|
|
211
|
-
props(msgU, { message: userMessage });
|
|
212
|
-
props(md, { content: '### Markdown\nRenders **bold**, _italic_, `code`, and lists:\n- one\n- two\n\n> and blockquotes.' });
|
|
213
|
-
props(reason, { text: 'First I parse the request, then I plan the steps, then I execute and verify.' });
|
|
214
|
-
attrs(reason, { label: 'Reasoning', streaming: true });
|
|
215
|
-
props(cot, { steps: cotSteps });
|
|
216
|
-
props(code, { code: 'export function add(a: number, b: number): number {\n return a + b;\n}' });
|
|
217
|
-
attrs(code, { language: 'ts' });
|
|
218
|
-
props(tool, { tool: { type: 'database_query', state: 'output-available', input: { table: 'users', limit: 10 }, output: { rows: 10, ms: 42 } } });
|
|
219
|
-
attrs(tool, { open: true });
|
|
220
|
-
});
|
|
221
|
-
return (
|
|
222
|
-
<Grid>
|
|
223
|
-
<Spec tag="kai-message" note='role="assistant" — reasoning + tool + attachment + actions'>
|
|
224
|
-
<kai-message ref={(e) => (msgA = e)} />
|
|
225
|
-
</Spec>
|
|
226
|
-
<Spec tag="kai-message" note='role="user"'>
|
|
227
|
-
<kai-message ref={(e) => (msgU = e)} />
|
|
228
|
-
</Spec>
|
|
229
|
-
<Spec tag="kai-markdown" note="token-themed markdown + fenced code">
|
|
230
|
-
<kai-markdown ref={(e) => (md = e)} />
|
|
231
|
-
</Spec>
|
|
232
|
-
<Spec tag="kai-reasoning" note="collapsible thinking; auto-opens while streaming">
|
|
233
|
-
<kai-reasoning ref={(e) => (reason = e)} />
|
|
234
|
-
</Spec>
|
|
235
|
-
<Spec tag="kai-chain-of-thought" note="step-by-step reasoning with connectors">
|
|
236
|
-
<kai-chain-of-thought ref={(e) => (cot = e)} />
|
|
237
|
-
</Spec>
|
|
238
|
-
<Spec tag="kai-code-block" note='language="ts" — highlighted, copyable'>
|
|
239
|
-
<kai-code-block ref={(e) => (code = e)} />
|
|
240
|
-
</Spec>
|
|
241
|
-
<Spec tag="kai-tool" note="open — input, output, state badge">
|
|
242
|
-
<kai-tool ref={(e) => (tool = e)} />
|
|
243
|
-
</Spec>
|
|
244
|
-
</Grid>
|
|
245
|
-
);
|
|
246
|
-
},
|
|
247
|
-
parameters: { docs: { source: { code: MESSAGES_SNIPPET, language: 'html' } } },
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
// ── 03 · Attachments & media ─────────────────────────────────────────────────
|
|
251
|
-
|
|
252
|
-
const MEDIA_SNIPPET = `<!-- One element, presentation chosen by attribute -->
|
|
253
|
-
<kai-attachments id="inline" variant="inline" hover-card></kai-attachments>
|
|
254
|
-
<kai-attachments id="grid" variant="grid" removable></kai-attachments>
|
|
255
|
-
<kai-image id="img" alt="demo" style="width:96px"></kai-image>
|
|
256
|
-
<kai-source href="https://kitn.dev" headline="kitn — the kit"
|
|
257
|
-
description="Composable chat UI." show-favicon></kai-source>
|
|
258
|
-
<kai-sources id="srcs"></kai-sources>
|
|
259
|
-
|
|
260
|
-
<script type="module">
|
|
261
|
-
import '@kitn.ai/ui/elements';
|
|
262
|
-
const items = [
|
|
263
|
-
{ id: '1', type: 'file', filename: 'architecture.png', mediaType: 'image/png', url: '…' },
|
|
264
|
-
{ id: '2', type: 'file', filename: 'spec.pdf', mediaType: 'application/pdf' },
|
|
265
|
-
];
|
|
266
|
-
document.getElementById('inline').items = items;
|
|
267
|
-
const grid = document.getElementById('grid');
|
|
268
|
-
grid.items = items;
|
|
269
|
-
grid.addEventListener('kai-remove', (e) => (grid.items = grid.items.filter((x) => x.id !== e.detail.id)));
|
|
270
|
-
document.getElementById('img').base64 = '…'; // pair with media-type
|
|
271
|
-
document.getElementById('srcs').sources = [
|
|
272
|
-
{ href: 'https://kitn.dev', title: 'kitn', description: '…', showFavicon: true },
|
|
273
|
-
];
|
|
274
|
-
</script>`;
|
|
275
|
-
|
|
276
|
-
export const AttachmentsAndMedia: Story = {
|
|
277
|
-
name: '03 · Attachments & media',
|
|
278
|
-
render: () => {
|
|
279
|
-
let inline!: HTMLElement, grid!: HTMLElement, img!: HTMLElement, src!: HTMLElement, srcs!: HTMLElement;
|
|
280
|
-
onMount(() => {
|
|
281
|
-
props(inline, { items: attachments });
|
|
282
|
-
attrs(inline, { variant: 'inline', 'hover-card': true });
|
|
283
|
-
props(grid, { items: attachments });
|
|
284
|
-
attrs(grid, { variant: 'grid', removable: true });
|
|
285
|
-
grid.addEventListener('kai-remove', (e) => {
|
|
286
|
-
const id = (e as CustomEvent).detail.id;
|
|
287
|
-
(grid as AnyEl).items = (attachments as { id: string }[]).filter((x) => x.id !== id);
|
|
288
|
-
});
|
|
289
|
-
props(img, {
|
|
290
|
-
base64: btoa(unescape(encodeURIComponent(
|
|
291
|
-
'<svg xmlns="http://www.w3.org/2000/svg" width="96" height="96"><rect width="96" height="96" rx="16" fill="#7c3aed"/><text x="48" y="62" font-size="44" text-anchor="middle" fill="white">★</text></svg>'))),
|
|
292
|
-
});
|
|
293
|
-
attrs(img, { alt: 'demo', 'media-type': 'image/svg+xml' });
|
|
294
|
-
attrs(src, { href: 'https://kitn.dev', headline: 'kitn — the kit', description: 'Composable SolidJS + web-component chat UI.', 'show-favicon': true });
|
|
295
|
-
props(srcs, { sources });
|
|
296
|
-
});
|
|
297
|
-
return (
|
|
298
|
-
<Grid>
|
|
299
|
-
<Spec tag="kai-attachments" note='variant="inline" hover-card'>
|
|
300
|
-
<kai-attachments ref={(e) => (inline = e)} />
|
|
301
|
-
</Spec>
|
|
302
|
-
<Spec tag="kai-attachments" note='variant="grid" removable'>
|
|
303
|
-
<kai-attachments ref={(e) => (grid = e)} />
|
|
304
|
-
</Spec>
|
|
305
|
-
<Spec tag="kai-image" note="base64 / byte-array image with skeleton">
|
|
306
|
-
<kai-image ref={(e) => (img = e)} style={{ width: '96px' }} />
|
|
307
|
-
</Spec>
|
|
308
|
-
<Spec tag="kai-source" note="show-favicon — citation with hover preview">
|
|
309
|
-
<kai-source ref={(e) => (src = e)} />
|
|
310
|
-
</Spec>
|
|
311
|
-
<Spec tag="kai-sources" note="wrapped row of citations">
|
|
312
|
-
<kai-sources ref={(e) => (srcs = e)} />
|
|
313
|
-
</Spec>
|
|
314
|
-
</Grid>
|
|
315
|
-
);
|
|
316
|
-
},
|
|
317
|
-
parameters: { docs: { source: { code: MEDIA_SNIPPET, language: 'html' } } },
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
// ── 04 · Composer ────────────────────────────────────────────────────────────
|
|
321
|
-
|
|
322
|
-
const COMPOSER_SNIPPET = `<!-- Input affordances you can place anywhere -->
|
|
323
|
-
<kai-suggestions id="suggs"></kai-suggestions>
|
|
324
|
-
<kai-file-upload></kai-file-upload>
|
|
325
|
-
<kai-voice-input id="voice"></kai-voice-input>
|
|
326
|
-
<kai-thinking-bar text="Thinking…" stoppable></kai-thinking-bar>
|
|
327
|
-
|
|
328
|
-
<script type="module">
|
|
329
|
-
import '@kitn.ai/ui/elements';
|
|
330
|
-
const suggs = document.getElementById('suggs');
|
|
331
|
-
suggs.suggestions = ['Explain the architecture', 'Show me a code example'];
|
|
332
|
-
suggs.addEventListener('kai-select', (e) => console.log('select', e.detail.value));
|
|
333
|
-
|
|
334
|
-
const voice = document.getElementById('voice');
|
|
335
|
-
voice.transcribe = async () => 'transcribed text'; // your STT here
|
|
336
|
-
voice.addEventListener('kai-transcription', (e) => console.log(e.detail.text));
|
|
337
|
-
</script>`;
|
|
338
|
-
|
|
339
|
-
export const Composer: Story = {
|
|
340
|
-
name: '04 · Composer',
|
|
341
|
-
render: () => {
|
|
342
|
-
let suggs!: HTMLElement, voice!: HTMLElement, think!: HTMLElement;
|
|
343
|
-
onMount(() => {
|
|
344
|
-
props(suggs, { suggestions: ['Explain the architecture', 'Show me a code example', "What's deferred?"] });
|
|
345
|
-
props(voice, { transcribe: async () => { await new Promise((r) => setTimeout(r, 400)); return 'transcribed text'; } });
|
|
346
|
-
attrs(think, { text: 'Thinking…', stoppable: true });
|
|
347
|
-
});
|
|
348
|
-
return (
|
|
349
|
-
<Grid>
|
|
350
|
-
<Spec tag="kai-suggestions" note="suggestion chips; click fires select">
|
|
351
|
-
<kai-suggestions ref={(e) => (suggs = e)} />
|
|
352
|
-
</Spec>
|
|
353
|
-
<Spec tag="kai-file-upload" note="click / drag-drop dropzone">
|
|
354
|
-
<kai-file-upload />
|
|
355
|
-
</Spec>
|
|
356
|
-
<Spec tag="kai-voice-input · kai-thinking-bar" note="mic capture + shimmering thinking bar">
|
|
357
|
-
<div style={{ display: 'flex', gap: '8px', 'align-items': 'center' }}>
|
|
358
|
-
<kai-voice-input ref={(e) => (voice = e)} />
|
|
359
|
-
<kai-thinking-bar ref={(e) => (think = e)} style={{ flex: '1' }} />
|
|
360
|
-
</div>
|
|
361
|
-
</Spec>
|
|
362
|
-
</Grid>
|
|
363
|
-
);
|
|
364
|
-
},
|
|
365
|
-
parameters: { docs: { source: { code: COMPOSER_SNIPPET, language: 'html' } } },
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
// ── 05 · Header & meta ───────────────────────────────────────────────────────
|
|
369
|
-
|
|
370
|
-
const META_SNIPPET = `<!-- The small pieces around a conversation -->
|
|
371
|
-
<kai-model-switcher id="models"></kai-model-switcher>
|
|
372
|
-
<kai-context id="ctx"></kai-context>
|
|
373
|
-
<kai-scope-picker id="scope"></kai-scope-picker>
|
|
374
|
-
<kai-checkpoint label="Checkpoint" tooltip="Restore"></kai-checkpoint>
|
|
375
|
-
<kai-skills id="skills"></kai-skills>
|
|
376
|
-
<kai-feedback-bar bar-title="Was this helpful?"></kai-feedback-bar>
|
|
377
|
-
|
|
378
|
-
<script type="module">
|
|
379
|
-
import '@kitn.ai/ui/elements';
|
|
380
|
-
const ms = document.getElementById('models');
|
|
381
|
-
ms.models = [{ id: 'opus', name: 'Claude Opus', provider: 'Anthropic' }];
|
|
382
|
-
ms.currentModel = 'opus';
|
|
383
|
-
ms.addEventListener('kai-model-change', (e) => (ms.currentModel = e.detail.modelId));
|
|
384
|
-
|
|
385
|
-
document.getElementById('ctx').context = { usedTokens: 48200, maxTokens: 200000 };
|
|
386
|
-
const scope = document.getElementById('scope');
|
|
387
|
-
scope.availableAuthors = ['Rob', 'Alex'];
|
|
388
|
-
scope.availableTags = ['design', 'api'];
|
|
389
|
-
document.getElementById('skills').skills = [{ id: 's1', name: 'web-search' }];
|
|
390
|
-
</script>`;
|
|
391
|
-
|
|
392
|
-
export const HeaderAndMeta: Story = {
|
|
393
|
-
name: '05 · Header & meta',
|
|
394
|
-
render: () => {
|
|
395
|
-
let ms!: HTMLElement, ctx!: HTMLElement, scope!: HTMLElement, cp!: HTMLElement, skills!: HTMLElement, fb!: HTMLElement;
|
|
396
|
-
onMount(() => {
|
|
397
|
-
props(ms, { models, currentModel: 'opus' });
|
|
398
|
-
ms.addEventListener('kai-model-change', (e) => ((ms as AnyEl).currentModel = (e as CustomEvent).detail.modelId));
|
|
399
|
-
props(ctx, { context });
|
|
400
|
-
props(scope, { availableAuthors: ['Rob', 'Alex'], availableTags: ['design', 'api'] });
|
|
401
|
-
attrs(cp, { label: 'Checkpoint', tooltip: 'Restore' });
|
|
402
|
-
props(skills, { skills: [{ id: 's1', name: 'web-search' }, { id: 's2', name: 'code' }] });
|
|
403
|
-
attrs(fb, { 'bar-title': 'Was this helpful?' });
|
|
404
|
-
});
|
|
405
|
-
return (
|
|
406
|
-
<Grid>
|
|
407
|
-
<Spec tag="kai-model-switcher" note="model dropdown; emits modelchange">
|
|
408
|
-
<kai-model-switcher ref={(e) => (ms = e)} />
|
|
409
|
-
</Spec>
|
|
410
|
-
<Spec tag="kai-context" note="token-usage meter with breakdown">
|
|
411
|
-
<kai-context ref={(e) => (ctx = e)} />
|
|
412
|
-
</Spec>
|
|
413
|
-
<Spec tag="kai-scope-picker" note="scope a chat by author or tag">
|
|
414
|
-
<kai-scope-picker ref={(e) => (scope = e)} />
|
|
415
|
-
</Spec>
|
|
416
|
-
<Spec tag="kai-checkpoint · kai-skills" note="bookmark button + active-skill badges">
|
|
417
|
-
<div style={{ display: 'flex', gap: '8px', 'align-items': 'center' }}>
|
|
418
|
-
<kai-checkpoint ref={(e) => (cp = e)} />
|
|
419
|
-
<kai-skills ref={(e) => (skills = e)} />
|
|
420
|
-
</div>
|
|
421
|
-
</Spec>
|
|
422
|
-
<Spec tag="kai-feedback-bar" note="inline thumbs up/down banner">
|
|
423
|
-
<kai-feedback-bar ref={(e) => (fb = e)} />
|
|
424
|
-
</Spec>
|
|
425
|
-
</Grid>
|
|
426
|
-
);
|
|
427
|
-
},
|
|
428
|
-
parameters: { docs: { source: { code: META_SNIPPET, language: 'html' } } },
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
// ── 06 · Status & motion ─────────────────────────────────────────────────────
|
|
432
|
-
|
|
433
|
-
const STATUS_SNIPPET = `<!-- Loaders, streaming text, and empty states -->
|
|
434
|
-
<kai-loader variant="circular"></kai-loader>
|
|
435
|
-
<kai-loader variant="dots"></kai-loader>
|
|
436
|
-
<kai-text-shimmer text="Generating response…"></kai-text-shimmer>
|
|
437
|
-
<kai-response-stream id="stream" speed="30"></kai-response-stream>
|
|
438
|
-
<kai-empty empty-title="No conversations yet" description="Start chatting to see them here.">
|
|
439
|
-
<span slot="media">✦</span>
|
|
440
|
-
</kai-empty>
|
|
441
|
-
|
|
442
|
-
<script type="module">
|
|
443
|
-
import '@kitn.ai/ui/elements';
|
|
444
|
-
const stream = document.getElementById('stream');
|
|
445
|
-
stream.text = 'This text reveals with a typewriter animation, character by character.';
|
|
446
|
-
stream.addEventListener('kai-complete', () => console.log('done'));
|
|
447
|
-
</script>`;
|
|
448
|
-
|
|
449
|
-
export const StatusAndMotion: Story = {
|
|
450
|
-
name: '06 · Status & motion',
|
|
451
|
-
render: () => {
|
|
452
|
-
let l1!: HTMLElement, l2!: HTMLElement, l3!: HTMLElement, l4!: HTMLElement, l5!: HTMLElement;
|
|
453
|
-
let shimmer!: HTMLElement, stream!: HTMLElement, empty!: HTMLElement;
|
|
454
|
-
onMount(() => {
|
|
455
|
-
attrs(l1, { variant: 'circular' });
|
|
456
|
-
attrs(l2, { variant: 'dots' });
|
|
457
|
-
attrs(l3, { variant: 'wave' });
|
|
458
|
-
attrs(l4, { variant: 'bars' });
|
|
459
|
-
attrs(l5, { variant: 'pulse-dot' });
|
|
460
|
-
attrs(shimmer, { text: 'Generating response…' });
|
|
461
|
-
attrs(stream, { speed: '30' });
|
|
462
|
-
props(stream, { text: "This text reveals with a typewriter animation, streamed character by character — exactly how you'd render a live assistant reply." });
|
|
463
|
-
attrs(empty, { 'empty-title': 'No conversations yet', description: 'Start chatting to see them here.' });
|
|
464
|
-
});
|
|
465
|
-
return (
|
|
466
|
-
<Grid>
|
|
467
|
-
<Spec tag="kai-loader" note="twelve loader styles">
|
|
468
|
-
<div style={{ display: 'flex', gap: '24px', 'align-items': 'center', 'flex-wrap': 'wrap' }}>
|
|
469
|
-
<kai-loader ref={(e) => (l1 = e)} />
|
|
470
|
-
<kai-loader ref={(e) => (l2 = e)} />
|
|
471
|
-
<kai-loader ref={(e) => (l3 = e)} />
|
|
472
|
-
<kai-loader ref={(e) => (l4 = e)} />
|
|
473
|
-
<kai-loader ref={(e) => (l5 = e)} />
|
|
474
|
-
</div>
|
|
475
|
-
</Spec>
|
|
476
|
-
<Spec tag="kai-text-shimmer" note="animated shimmering text">
|
|
477
|
-
<kai-text-shimmer ref={(e) => (shimmer = e)} />
|
|
478
|
-
</Spec>
|
|
479
|
-
<Spec tag="kai-response-stream" note='mode="typewriter" — emits complete'>
|
|
480
|
-
<kai-response-stream ref={(e) => (stream = e)} />
|
|
481
|
-
</Spec>
|
|
482
|
-
<Spec tag="kai-empty" note="empty-state layout — media & default slots">
|
|
483
|
-
<kai-empty ref={(e) => (empty = e)}>
|
|
484
|
-
<span slot="media">✦</span>
|
|
485
|
-
</kai-empty>
|
|
486
|
-
</Spec>
|
|
487
|
-
</Grid>
|
|
488
|
-
);
|
|
489
|
-
},
|
|
490
|
-
parameters: { docs: { source: { code: STATUS_SNIPPET, language: 'html' } } },
|
|
491
|
-
};
|