@kitn.ai/ui 0.14.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/LICENSE +21 -0
- package/README.md +394 -0
- package/dist/bash-InADTalH.js +1 -0
- package/dist/core-AYMC6_lb.js +12 -0
- package/dist/css-M7EaDHN_.js +1 -0
- package/dist/custom-elements.json +4739 -0
- package/dist/engine-javascript-vq0WuIJl.js +141 -0
- package/dist/github-dark-dimmed-DUshB20C.js +1 -0
- package/dist/github-light-JYsPkUQd.js +1 -0
- package/dist/host-embed.d.ts +33 -0
- package/dist/html-CPZ3oZQ7.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/javascript-C25yR2R2.js +1 -0
- package/dist/json-DxJze_jm.js +1 -0
- package/dist/kitn-chat-provider.d.ts +2 -0
- package/dist/kitn-chat-provider.es.js +240 -0
- package/dist/kitn-chat.es.js +77 -0
- package/dist/llms/llms-full.txt +1018 -0
- package/dist/llms/llms.txt +104 -0
- package/dist/origin.d.ts +5 -0
- package/dist/provider-runtime.d.ts +27 -0
- package/dist/schemas/card-envelope.schema.json +14 -0
- package/dist/schemas/card-event.schema.json +12 -0
- package/dist/schemas/choice.schema.json +70 -0
- package/dist/schemas/confirm.schema.json +65 -0
- package/dist/schemas/embed.schema.json +65 -0
- package/dist/schemas/form.result.schema.json +7 -0
- package/dist/schemas/form.schema.json +33 -0
- package/dist/schemas/link.schema.json +56 -0
- package/dist/schemas/tasks.result.schema.json +16 -0
- package/dist/schemas/tasks.schema.json +78 -0
- package/dist/svelte--5p79yCD.js +1 -0
- package/dist/theme.tokens.css +176 -0
- package/dist/tsx-B8rCNbgL.js +1 -0
- package/dist/typescript-RycA9KXf.js +1 -0
- package/dist/validate.d.ts +4 -0
- package/dist/version.d.ts +4 -0
- package/dist/vue-BmIZj4XD.js +1 -0
- package/dist/wire.d.ts +53 -0
- package/frameworks/react/index.tsx +948 -0
- package/frameworks/react/runtime.tsx +94 -0
- package/llms-full.txt +1018 -0
- package/llms.txt +104 -0
- package/package.json +141 -0
- package/src/components/artifact.stories.tsx +138 -0
- package/src/components/artifact.tsx +743 -0
- package/src/components/attachments.stories.tsx +303 -0
- package/src/components/attachments.test.tsx +64 -0
- package/src/components/attachments.tsx +399 -0
- package/src/components/card-fallback.tsx +28 -0
- package/src/components/card-renderer.tsx +52 -0
- package/src/components/card.tsx +110 -0
- package/src/components/chain-of-thought.stories.tsx +211 -0
- package/src/components/chain-of-thought.tsx +139 -0
- package/src/components/chat-container.stories.tsx +187 -0
- package/src/components/chat-container.tsx +82 -0
- package/src/components/chat-scope-picker.tsx +47 -0
- package/src/components/chat-thread.test.tsx +58 -0
- package/src/components/chat-thread.tsx +249 -0
- package/src/components/checkpoint.stories.tsx +102 -0
- package/src/components/checkpoint.tsx +88 -0
- package/src/components/choice-card.tsx +569 -0
- package/src/components/code-block.stories.tsx +150 -0
- package/src/components/code-block.tsx +105 -0
- package/src/components/component-meta.json +3735 -0
- package/src/components/confirm-card.stories.tsx +74 -0
- package/src/components/confirm-card.tsx +315 -0
- package/src/components/context.stories.tsx +229 -0
- package/src/components/context.test.tsx +133 -0
- package/src/components/context.tsx +363 -0
- package/src/components/conversation-item.stories.tsx +125 -0
- package/src/components/conversation-item.tsx +16 -0
- package/src/components/conversation-list.stories.tsx +133 -0
- package/src/components/conversation-list.tsx +101 -0
- package/src/components/default-input.test.tsx +111 -0
- package/src/components/embed.tsx +196 -0
- package/src/components/empty.stories.tsx +434 -0
- package/src/components/empty.tsx +166 -0
- package/src/components/feedback-bar.stories.tsx +138 -0
- package/src/components/feedback-bar.test.tsx +103 -0
- package/src/components/feedback-bar.tsx +166 -0
- package/src/components/file-tree.stories.tsx +73 -0
- package/src/components/file-tree.tsx +383 -0
- package/src/components/file-upload.stories.tsx +156 -0
- package/src/components/file-upload.tsx +161 -0
- package/src/components/form-widgets.tsx +461 -0
- package/src/components/form.tsx +873 -0
- package/src/components/image.stories.tsx +89 -0
- package/src/components/image.tsx +67 -0
- package/src/components/link-preview.tsx +194 -0
- package/src/components/loader.stories.tsx +181 -0
- package/src/components/loader.tsx +333 -0
- package/src/components/markdown.stories.tsx +180 -0
- package/src/components/markdown.tsx +81 -0
- package/src/components/message-action-bar.test.tsx +128 -0
- package/src/components/message-narrow.stories.tsx +329 -0
- package/src/components/message-skills.stories.tsx +211 -0
- package/src/components/message-skills.tsx +36 -0
- package/src/components/message.stories.tsx +281 -0
- package/src/components/message.tsx +227 -0
- package/src/components/model-switcher.stories.tsx +123 -0
- package/src/components/model-switcher.test.tsx +65 -0
- package/src/components/model-switcher.tsx +87 -0
- package/src/components/prompt-input.stories.tsx +222 -0
- package/src/components/prompt-input.tsx +211 -0
- package/src/components/prompt-suggestion.stories.tsx +142 -0
- package/src/components/prompt-suggestion.tsx +115 -0
- package/src/components/reasoning.stories.tsx +140 -0
- package/src/components/reasoning.tsx +156 -0
- package/src/components/resizable.test.tsx +226 -0
- package/src/components/response-stream.tsx +103 -0
- package/src/components/scroll-button.stories.tsx +100 -0
- package/src/components/scroll-button.tsx +34 -0
- package/src/components/slash-command.stories.tsx +163 -0
- package/src/components/slash-command.tsx +232 -0
- package/src/components/source-list.test.tsx +152 -0
- package/src/components/source.stories.tsx +124 -0
- package/src/components/source.tsx +129 -0
- package/src/components/tasks-card.stories.tsx +78 -0
- package/src/components/tasks-card.tsx +432 -0
- package/src/components/text-shimmer.stories.tsx +87 -0
- package/src/components/text-shimmer.tsx +37 -0
- package/src/components/thinking-bar.stories.tsx +87 -0
- package/src/components/thinking-bar.tsx +50 -0
- package/src/components/tool.stories.tsx +153 -0
- package/src/components/tool.tsx +184 -0
- package/src/components/use-card-resolution.ts +28 -0
- package/src/components/voice-input.stories.tsx +83 -0
- package/src/components/voice-input.tsx +107 -0
- package/src/elements/artifact.stories.tsx +506 -0
- package/src/elements/artifact.tsx +137 -0
- package/src/elements/attachments.stories.tsx +190 -0
- package/src/elements/attachments.tsx +136 -0
- package/src/elements/card.stories.tsx +113 -0
- package/src/elements/card.tsx +40 -0
- package/src/elements/cards.stories.tsx +59 -0
- package/src/elements/cards.tsx +97 -0
- package/src/elements/catalog.stories.tsx +491 -0
- package/src/elements/chain-of-thought.declarative.test.tsx +153 -0
- package/src/elements/chain-of-thought.stories.tsx +113 -0
- package/src/elements/chain-of-thought.tsx +92 -0
- package/src/elements/chat-scope-picker.stories.tsx +73 -0
- package/src/elements/chat-scope-picker.tsx +36 -0
- package/src/elements/chat-types.ts +42 -0
- package/src/elements/chat-workspace.stories.tsx +288 -0
- package/src/elements/chat-workspace.tsx +161 -0
- package/src/elements/chat.stories.tsx +151 -0
- package/src/elements/chat.tsx +80 -0
- package/src/elements/checkpoint.stories.tsx +72 -0
- package/src/elements/checkpoint.tsx +47 -0
- package/src/elements/choice.stories.tsx +240 -0
- package/src/elements/choice.tsx +48 -0
- package/src/elements/code-block.stories.tsx +83 -0
- package/src/elements/code-block.tsx +42 -0
- package/src/elements/compiled.css +2 -0
- package/src/elements/composed-shell.stories.tsx +316 -0
- package/src/elements/confirm-card.stories.tsx +227 -0
- package/src/elements/confirm-card.tsx +51 -0
- package/src/elements/context-meter.stories.tsx +151 -0
- package/src/elements/context-meter.tsx +121 -0
- package/src/elements/conversation-list.declarative.test.tsx +137 -0
- package/src/elements/conversation-list.stories.tsx +243 -0
- package/src/elements/conversation-list.tsx +80 -0
- package/src/elements/css.ts +5 -0
- package/src/elements/default-input.tsx +247 -0
- package/src/elements/define.tsx +171 -0
- package/src/elements/element-meta.json +3314 -0
- package/src/elements/element-types.d.ts +710 -0
- package/src/elements/embed.stories.tsx +213 -0
- package/src/elements/embed.tsx +35 -0
- package/src/elements/empty.stories.tsx +111 -0
- package/src/elements/empty.tsx +29 -0
- package/src/elements/feedback-bar.stories.tsx +114 -0
- package/src/elements/feedback-bar.tsx +61 -0
- package/src/elements/file-tree.stories.tsx +134 -0
- package/src/elements/file-tree.tsx +52 -0
- package/src/elements/file-upload.stories.tsx +82 -0
- package/src/elements/file-upload.tsx +44 -0
- package/src/elements/form.stories.tsx +248 -0
- package/src/elements/form.tsx +43 -0
- package/src/elements/framework-usage.json +563 -0
- package/src/elements/image.stories.tsx +71 -0
- package/src/elements/image.tsx +32 -0
- package/src/elements/link-preview.stories.tsx +209 -0
- package/src/elements/link-preview.tsx +34 -0
- package/src/elements/loader.stories.tsx +88 -0
- package/src/elements/loader.tsx +25 -0
- package/src/elements/markdown.stories.tsx +76 -0
- package/src/elements/markdown.tsx +38 -0
- package/src/elements/message-skills.declarative.test.tsx +104 -0
- package/src/elements/message-skills.stories.tsx +114 -0
- package/src/elements/message-skills.tsx +85 -0
- package/src/elements/message.stories.tsx +218 -0
- package/src/elements/message.tsx +162 -0
- package/src/elements/model-switcher.declarative.test.tsx +130 -0
- package/src/elements/model-switcher.stories.tsx +198 -0
- package/src/elements/model-switcher.tsx +93 -0
- package/src/elements/popover.stories.tsx +80 -0
- package/src/elements/popover.tsx +59 -0
- package/src/elements/prompt-input-slash-command.test.tsx +128 -0
- package/src/elements/prompt-input-stoppable.test.tsx +88 -0
- package/src/elements/prompt-input-toolbar-actions.test.tsx +120 -0
- package/src/elements/prompt-input.stories.tsx +331 -0
- package/src/elements/prompt-input.tsx +185 -0
- package/src/elements/prompt-suggestions.declarative.test.tsx +164 -0
- package/src/elements/prompt-suggestions.stories.tsx +213 -0
- package/src/elements/prompt-suggestions.tsx +94 -0
- package/src/elements/reasoning.stories.tsx +77 -0
- package/src/elements/reasoning.tsx +50 -0
- package/src/elements/register.ts +56 -0
- package/src/elements/remote.stories.tsx +314 -0
- package/src/elements/remote.tsx +221 -0
- package/src/elements/resizable.d.ts +27 -0
- package/src/elements/resizable.stories.tsx +426 -0
- package/src/elements/resizable.tsx +553 -0
- package/src/elements/response-stream.stories.tsx +79 -0
- package/src/elements/response-stream.tsx +40 -0
- package/src/elements/scroll-button.stories.tsx +202 -0
- package/src/elements/scroll-button.test.tsx +148 -0
- package/src/elements/scroll-button.tsx +126 -0
- package/src/elements/source-list.stories.tsx +143 -0
- package/src/elements/source.stories.tsx +88 -0
- package/src/elements/source.tsx +120 -0
- package/src/elements/styles.css +199 -0
- package/src/elements/switch.stories.tsx +56 -0
- package/src/elements/switch.tsx +43 -0
- package/src/elements/tasks.stories.tsx +237 -0
- package/src/elements/tasks.tsx +46 -0
- package/src/elements/text-shimmer.stories.tsx +64 -0
- package/src/elements/text-shimmer.tsx +28 -0
- package/src/elements/thinking-bar.stories.tsx +72 -0
- package/src/elements/thinking-bar.tsx +34 -0
- package/src/elements/tool.stories.tsx +89 -0
- package/src/elements/tool.tsx +23 -0
- package/src/elements/voice-input.stories.tsx +88 -0
- package/src/elements/voice-input.tsx +41 -0
- package/src/index.ts +253 -0
- package/src/primitives/card-contract.ts +71 -0
- package/src/primitives/card-host.tsx +35 -0
- package/src/primitives/card-registry.tsx +67 -0
- package/src/primitives/card-resolution.ts +36 -0
- package/src/primitives/card-routing.ts +79 -0
- package/src/primitives/card-schemas/card-envelope.schema.json +14 -0
- package/src/primitives/card-schemas/card-event.schema.json +12 -0
- package/src/primitives/card-schemas/choice.schema.json +70 -0
- package/src/primitives/card-schemas/confirm.schema.json +65 -0
- package/src/primitives/card-schemas/embed.schema.json +65 -0
- package/src/primitives/card-schemas/form.result.schema.json +7 -0
- package/src/primitives/card-schemas/form.schema.json +33 -0
- package/src/primitives/card-schemas/link.schema.json +56 -0
- package/src/primitives/card-schemas/tasks.result.schema.json +16 -0
- package/src/primitives/card-schemas/tasks.schema.json +78 -0
- package/src/primitives/card-validate.ts +95 -0
- package/src/primitives/chat-config.tsx +76 -0
- package/src/primitives/controllable.test.ts +47 -0
- package/src/primitives/controllable.ts +21 -0
- package/src/primitives/embed-providers.ts +254 -0
- package/src/primitives/highlighter.ts +157 -0
- package/src/primitives/link-preview.ts +87 -0
- package/src/primitives/pdf-preview.ts +121 -0
- package/src/primitives/use-auto-resize.ts +31 -0
- package/src/primitives/use-resize-observer.ts +12 -0
- package/src/primitives/use-stick-to-bottom.ts +43 -0
- package/src/primitives/use-text-stream.ts +112 -0
- package/src/primitives/use-voice-recorder.ts +50 -0
- package/src/remote/host-embed.ts +345 -0
- package/src/remote/index.ts +2 -0
- package/src/remote/origin.ts +30 -0
- package/src/remote/provider-runtime.ts +259 -0
- package/src/remote/provider.ts +2 -0
- package/src/remote/validate.ts +22 -0
- package/src/remote/version.ts +12 -0
- package/src/remote/wire.ts +48 -0
- package/src/stories/chat-panel-layout.stories.tsx +145 -0
- package/src/stories/chat-scene.tsx +571 -0
- package/src/stories/checkpoint-restore.stories.tsx +256 -0
- package/src/stories/context-usage.stories.tsx +212 -0
- package/src/stories/conversation-with-reasoning.stories.tsx +182 -0
- package/src/stories/conversation-with-sources.stories.tsx +471 -0
- package/src/stories/docs/Accessibility.mdx +119 -0
- package/src/stories/docs/ChildElements.mdx +269 -0
- package/src/stories/docs/ForAIAgents.mdx +162 -0
- package/src/stories/docs/GettingStarted.mdx +65 -0
- package/src/stories/docs/Installation.mdx +83 -0
- package/src/stories/docs/Introduction.mdx +50 -0
- package/src/stories/docs/SolidJsAdvanced.mdx +17 -0
- package/src/stories/docs/Theming.mdx +85 -0
- package/src/stories/docs/element-controls.ts +121 -0
- package/src/stories/docs/frameworks/Angular.mdx +245 -0
- package/src/stories/docs/frameworks/Html.mdx +227 -0
- package/src/stories/docs/frameworks/Overview.mdx +47 -0
- package/src/stories/docs/frameworks/React.mdx +227 -0
- package/src/stories/docs/frameworks/Solid.mdx +173 -0
- package/src/stories/docs/frameworks/Svelte.mdx +194 -0
- package/src/stories/docs/frameworks/Vue.mdx +238 -0
- package/src/stories/docs/generative-ui-overview.mdx +186 -0
- package/src/stories/docs/recipes/SpeechToText.mdx +7 -0
- package/src/stories/docs/recipes/Streaming.mdx +68 -0
- package/src/stories/docs/recipes/TextToSpeech.mdx +35 -0
- package/src/stories/docs/theme-editor/canvas.tsx +32 -0
- package/src/stories/docs/theme-editor/inspector.tsx +66 -0
- package/src/stories/docs/theme-editor/presets.test.ts +32 -0
- package/src/stories/docs/theme-editor/presets.ts +64 -0
- package/src/stories/docs/theme-editor/theme-css.test.ts +19 -0
- package/src/stories/docs/theme-editor/theme-css.ts +15 -0
- package/src/stories/docs/theme-editor/theme-editor.tsx +146 -0
- package/src/stories/docs/theme-tokens.tsx +174 -0
- package/src/stories/examples/ChoosingComponents.mdx +106 -0
- package/src/stories/examples/sample-data.ts +79 -0
- package/src/stories/examples/usage/checkpoint-restore.ts +156 -0
- package/src/stories/examples/usage/context-usage.ts +591 -0
- package/src/stories/examples/usage/conversation-with-reasoning.ts +224 -0
- package/src/stories/examples/usage/conversation-with-sources.ts +589 -0
- package/src/stories/examples/usage/empty-state.ts +144 -0
- package/src/stories/examples/usage/full-chat-app.ts +277 -0
- package/src/stories/examples/usage/index.ts +63 -0
- package/src/stories/examples/usage/message-actions.ts +704 -0
- package/src/stories/examples/usage/pattern-centered-conversation.ts +446 -0
- package/src/stories/examples/usage/pattern-chat-panel-layout.ts +442 -0
- package/src/stories/examples/usage/pattern-docked-widget.ts +479 -0
- package/src/stories/examples/usage/prompt-input-variants.ts +1356 -0
- package/src/stories/examples/usage/streaming-response.ts +687 -0
- package/src/stories/examples/usage/types.ts +33 -0
- package/src/stories/full-chat.stories.tsx +18 -0
- package/src/stories/message-actions.stories.tsx +230 -0
- package/src/stories/pattern-centered-conversation.stories.tsx +93 -0
- package/src/stories/pattern-docked-widget.stories.tsx +93 -0
- package/src/stories/pattern-empty-state.stories.tsx +76 -0
- package/src/stories/prompt-input-variants.stories.tsx +456 -0
- package/src/stories/streaming-response.stories.tsx +438 -0
- package/src/stories/theme-editor.stories.tsx +16 -0
- package/src/stories/token-reference.stories.tsx +18 -0
- package/src/stories/typography.stories.tsx +78 -0
- package/src/types.ts +47 -0
- package/src/ui/action-icons.ts +52 -0
- package/src/ui/avatar.stories.tsx +103 -0
- package/src/ui/avatar.tsx +23 -0
- package/src/ui/badge.stories.tsx +86 -0
- package/src/ui/badge.tsx +21 -0
- package/src/ui/button.stories.tsx +145 -0
- package/src/ui/button.tsx +38 -0
- package/src/ui/collapsible.stories.tsx +69 -0
- package/src/ui/collapsible.tsx +125 -0
- package/src/ui/dropdown.stories.tsx +59 -0
- package/src/ui/dropdown.tsx +196 -0
- package/src/ui/hover-card.stories.tsx +77 -0
- package/src/ui/hover-card.test.tsx +30 -0
- package/src/ui/hover-card.tsx +172 -0
- package/src/ui/overlay.stories.tsx +115 -0
- package/src/ui/overlay.tsx +158 -0
- package/src/ui/popover.stories.tsx +81 -0
- package/src/ui/popover.test.tsx +99 -0
- package/src/ui/popover.tsx +92 -0
- package/src/ui/resizable.stories.tsx +236 -0
- package/src/ui/resizable.tsx +576 -0
- package/src/ui/scroll-area.stories.tsx +50 -0
- package/src/ui/scroll-area.tsx +15 -0
- package/src/ui/separator.stories.tsx +81 -0
- package/src/ui/separator.tsx +10 -0
- package/src/ui/skeleton.stories.tsx +337 -0
- package/src/ui/skeleton.tsx +16 -0
- package/src/ui/switch.stories.tsx +51 -0
- package/src/ui/switch.test.tsx +59 -0
- package/src/ui/switch.tsx +62 -0
- package/src/ui/textarea.stories.tsx +76 -0
- package/src/ui/textarea.tsx +21 -0
- package/src/ui/tooltip.stories.tsx +74 -0
- package/src/ui/tooltip.tsx +68 -0
- package/src/utils/cn.ts +24 -0
- package/theme.css +187 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Docs/Composition & Child Elements" />
|
|
4
|
+
|
|
5
|
+
# Composition & Child Elements
|
|
6
|
+
|
|
7
|
+
Seven collection elements in the kit accept two input paths — **data** (a JS property array) and **composition** (declarative child markup). Both produce identical rendered output and can be mixed on the same element.
|
|
8
|
+
|
|
9
|
+
## Two ways to populate a collection
|
|
10
|
+
|
|
11
|
+
### Data — the JS property array
|
|
12
|
+
|
|
13
|
+
Set the element's array property from JavaScript. The parent re-renders reactively whenever the reference changes.
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<kai-suggestions id="s"></kai-suggestions>
|
|
17
|
+
|
|
18
|
+
<script type="module">
|
|
19
|
+
import '@kitn.ai/ui/elements';
|
|
20
|
+
|
|
21
|
+
document.getElementById('s').suggestions = [
|
|
22
|
+
{ label: 'Summarise this', value: 'summarise' },
|
|
23
|
+
{ label: 'Translate to French', value: 'translate' },
|
|
24
|
+
];
|
|
25
|
+
</script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Composition — declarative child elements
|
|
29
|
+
|
|
30
|
+
Place `<kai-*>` child elements directly in markup. They live in the light DOM but are invisible — the parent's Shadow DOM has no `<slot>` for them, so it reads them via `querySelectorAll` and a `MutationObserver` instead. No JavaScript required.
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<kai-suggestions>
|
|
34
|
+
<kai-suggestion value="summarise">Summarise this</kai-suggestion>
|
|
35
|
+
<kai-suggestion value="translate">Translate to French</kai-suggestion>
|
|
36
|
+
</kai-suggestions>
|
|
37
|
+
|
|
38
|
+
<script type="module">
|
|
39
|
+
import '@kitn.ai/ui/elements';
|
|
40
|
+
</script>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Merge order
|
|
44
|
+
|
|
45
|
+
When both are provided, **property items render first** and child elements are appended after. There is no conflict — they simply concatenate.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Choosing the right path
|
|
50
|
+
|
|
51
|
+
| Situation | Reach for |
|
|
52
|
+
|-----------|-----------|
|
|
53
|
+
| Data arrives from a fetch, a stream, or application state | **Data (property)** |
|
|
54
|
+
| Content is model-driven, user-specific, or changes at runtime | **Data (property)** |
|
|
55
|
+
| You're working in React, Vue, Svelte, or Angular with a component model | **Data (property)** |
|
|
56
|
+
| Content is static and known at build time | **Composition (children)** |
|
|
57
|
+
| You're authoring a CMS template, server-rendered HTML, or a no-build page | **Composition (children)** |
|
|
58
|
+
| You want zero JavaScript for the initial population | **Composition (children)** |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Child element reference
|
|
63
|
+
|
|
64
|
+
Each row below is verified against the element's source in `src/elements/`.
|
|
65
|
+
|
|
66
|
+
### `<kai-action>`
|
|
67
|
+
|
|
68
|
+
**Parents:** `<kai-message>` (action bar → `kai-message-action`) and `<kai-prompt-input>` (custom toolbar buttons → `kai-toolbar-action`)
|
|
69
|
+
|
|
70
|
+
| Attribute | Maps to | Notes |
|
|
71
|
+
|-----------|---------|-------|
|
|
72
|
+
| `id` | `CustomAction.id` | Falls back to the `action` attribute when `id` is absent |
|
|
73
|
+
| `action` | `CustomAction.id` | Secondary fallback when `id` is also absent |
|
|
74
|
+
| `icon` | `CustomAction.icon` | Optional icon name |
|
|
75
|
+
| `tooltip` | `CustomAction.tooltip` | Optional tooltip string |
|
|
76
|
+
| *(text content)* | `CustomAction.label` | Falls back to the `label` attribute, then `id` |
|
|
77
|
+
|
|
78
|
+
**Event fired by parent:** `kai-message-action` → `{ messageId: string, action: string }`
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<kai-message>
|
|
82
|
+
<kai-action id="copy" icon="copy" tooltip="Copy to clipboard">Copy</kai-action>
|
|
83
|
+
<kai-action id="retry" icon="refresh">Retry</kai-action>
|
|
84
|
+
</kai-message>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### `<kai-suggestion>`
|
|
90
|
+
|
|
91
|
+
**Parent:** `<kai-suggestions>`
|
|
92
|
+
|
|
93
|
+
| Attribute | Maps to | Notes |
|
|
94
|
+
|-----------|---------|-------|
|
|
95
|
+
| `value` | `Item.value` | Falls back to text content when absent |
|
|
96
|
+
| *(text content)* | `Item.label` | The chip label |
|
|
97
|
+
|
|
98
|
+
**Event fired by parent:** `kai-select` → `{ value: string }`
|
|
99
|
+
|
|
100
|
+
```html
|
|
101
|
+
<kai-suggestions>
|
|
102
|
+
<kai-suggestion value="summarise">Summarise this</kai-suggestion>
|
|
103
|
+
<kai-suggestion value="translate">Translate to French</kai-suggestion>
|
|
104
|
+
</kai-suggestions>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### `<kai-source>`
|
|
110
|
+
|
|
111
|
+
**Parent:** `<kai-sources>`
|
|
112
|
+
|
|
113
|
+
| Attribute | Maps to | Notes |
|
|
114
|
+
|-----------|---------|-------|
|
|
115
|
+
| `href` | `SourceItem.href` | Required — the citation URL |
|
|
116
|
+
| `label` | `SourceItem.label` | Trigger label (defaults to the domain) |
|
|
117
|
+
| `headline` | `SourceItem.title` | Hover-card headline. Named `headline` (not `title`) because `title` is a reserved HTML global attribute |
|
|
118
|
+
| `description` | `SourceItem.description` | Hover-card body text |
|
|
119
|
+
| `show-favicon` | `SourceItem.showFavicon` | Boolean — bare attribute or `show-favicon="true"` |
|
|
120
|
+
| *(text content)* | *(not read by `kai-sources`)* | Text content on a child `<kai-source>` is not mapped by the parent; use `label`/`headline`/`description` attributes instead |
|
|
121
|
+
|
|
122
|
+
**No interaction event** — sources open their `href` as links.
|
|
123
|
+
|
|
124
|
+
```html
|
|
125
|
+
<kai-sources>
|
|
126
|
+
<kai-source
|
|
127
|
+
href="https://example.com/page"
|
|
128
|
+
label="Example"
|
|
129
|
+
headline="Example Domain"
|
|
130
|
+
description="An illustrative domain used in documentation."
|
|
131
|
+
show-favicon
|
|
132
|
+
></kai-source>
|
|
133
|
+
</kai-sources>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
> **Note:** `<kai-source>` also works as a **standalone** element — its own `href`, `label`, `headline`, `description`, and `show-favicon` props drive a single citation chip with a hover-card. The child-element role above is its use *inside* `<kai-sources>`.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
### `<kai-conversation>`
|
|
141
|
+
|
|
142
|
+
**Parent:** `<kai-conversations>`
|
|
143
|
+
|
|
144
|
+
| Attribute | Maps to | Notes |
|
|
145
|
+
|-----------|---------|-------|
|
|
146
|
+
| `id` | `ConversationSummary.id` | Required — stable conversation identifier |
|
|
147
|
+
| `group-id` | `ConversationSummary.groupId` | Optional group bucket (e.g. "today", "yesterday") |
|
|
148
|
+
| *(text content)* | `ConversationSummary.title` | The conversation title shown in the list |
|
|
149
|
+
|
|
150
|
+
Required fields not expressible as HTML attributes (`scope`, `messageCount`, `lastMessageAt`, `updatedAt`) receive safe defaults so the list item is fully functional with just `id` and text.
|
|
151
|
+
|
|
152
|
+
**Events fired by parent:** `kai-conversation-select` → `{ id: string }`, `kai-new-chat` → `{}`, `kai-toggle-sidebar` → `{}`
|
|
153
|
+
|
|
154
|
+
```html
|
|
155
|
+
<kai-conversations>
|
|
156
|
+
<kai-conversation id="conv-1" group-id="today">Morning standup recap</kai-conversation>
|
|
157
|
+
<kai-conversation id="conv-2" group-id="yesterday">API design review</kai-conversation>
|
|
158
|
+
</kai-conversations>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### `<kai-step>`
|
|
164
|
+
|
|
165
|
+
**Parent:** `<kai-chain-of-thought>`
|
|
166
|
+
|
|
167
|
+
| Attribute | Maps to | Notes |
|
|
168
|
+
|-----------|---------|-------|
|
|
169
|
+
| `label` | `Step.label` | The always-visible step heading (required) |
|
|
170
|
+
| *(text content)* | `Step.content` | Optional expandable detail; empty string is treated as `undefined` (no expand affordance) |
|
|
171
|
+
|
|
172
|
+
**No interaction event** — steps expand/collapse internally.
|
|
173
|
+
|
|
174
|
+
```html
|
|
175
|
+
<kai-chain-of-thought>
|
|
176
|
+
<kai-step label="Understand the request">The user wants a concise summary.</kai-step>
|
|
177
|
+
<kai-step label="Draft a response">Condense the key points into three sentences.</kai-step>
|
|
178
|
+
<kai-step label="Review"></kai-step>
|
|
179
|
+
</kai-chain-of-thought>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
### `<kai-model>`
|
|
185
|
+
|
|
186
|
+
**Parent:** `<kai-model-switcher>`
|
|
187
|
+
|
|
188
|
+
| Attribute | Maps to | Notes |
|
|
189
|
+
|-----------|---------|-------|
|
|
190
|
+
| `id` | `ModelOption.id` | Required — the model identifier passed in `kai-model-change` |
|
|
191
|
+
| `provider` | `ModelOption.provider` | Optional provider name shown in the switcher UI |
|
|
192
|
+
| *(text content)* | `ModelOption.name` | Human-readable model name |
|
|
193
|
+
|
|
194
|
+
**Event fired by parent:** `kai-model-change` → `{ modelId: string }`
|
|
195
|
+
|
|
196
|
+
The switcher only renders when more than one model is provided.
|
|
197
|
+
|
|
198
|
+
```html
|
|
199
|
+
<kai-model-switcher>
|
|
200
|
+
<kai-model id="gpt-4o" provider="OpenAI">GPT-4o</kai-model>
|
|
201
|
+
<kai-model id="gpt-4o-mini" provider="OpenAI">GPT-4o mini</kai-model>
|
|
202
|
+
<kai-model id="claude-3-7-sonnet" provider="Anthropic">Claude 3.7 Sonnet</kai-model>
|
|
203
|
+
</kai-model-switcher>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
### `<kai-skill>`
|
|
209
|
+
|
|
210
|
+
**Parent:** `<kai-skills>`
|
|
211
|
+
|
|
212
|
+
| Attribute | Maps to | Notes |
|
|
213
|
+
|-----------|---------|-------|
|
|
214
|
+
| `id` | `Skill.id` | Falls back to text content when absent |
|
|
215
|
+
| *(text content)* | `Skill.name` | The badge label |
|
|
216
|
+
|
|
217
|
+
**No interaction event** — skills badges are display-only.
|
|
218
|
+
|
|
219
|
+
```html
|
|
220
|
+
<kai-skills>
|
|
221
|
+
<kai-skill id="web-search">Web Search</kai-skill>
|
|
222
|
+
<kai-skill id="code">Code</kai-skill>
|
|
223
|
+
</kai-skills>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Side-by-side comparison
|
|
229
|
+
|
|
230
|
+
The same set of suggestions rendered both ways — identical output, different authoring model.
|
|
231
|
+
|
|
232
|
+
**Data path:**
|
|
233
|
+
|
|
234
|
+
```html
|
|
235
|
+
<kai-suggestions id="s1"></kai-suggestions>
|
|
236
|
+
|
|
237
|
+
<script type="module">
|
|
238
|
+
import '@kitn.ai/ui/elements';
|
|
239
|
+
document.getElementById('s1').suggestions = [
|
|
240
|
+
{ label: 'Explain quantum computing', value: 'explain-quantum' },
|
|
241
|
+
{ label: 'Write a haiku', value: 'haiku' },
|
|
242
|
+
{ label: 'Summarise in bullet points', value: 'summarise' },
|
|
243
|
+
];
|
|
244
|
+
</script>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Composition path:**
|
|
248
|
+
|
|
249
|
+
```html
|
|
250
|
+
<kai-suggestions>
|
|
251
|
+
<kai-suggestion value="explain-quantum">Explain quantum computing</kai-suggestion>
|
|
252
|
+
<kai-suggestion value="haiku">Write a haiku</kai-suggestion>
|
|
253
|
+
<kai-suggestion value="summarise">Summarise in bullet points</kai-suggestion>
|
|
254
|
+
</kai-suggestions>
|
|
255
|
+
|
|
256
|
+
<script type="module">
|
|
257
|
+
import '@kitn.ai/ui/elements';
|
|
258
|
+
</script>
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Both fire `kai-select` with the same `value` string. The only difference is where the data lives — in application state or in the HTML.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Customisation
|
|
266
|
+
|
|
267
|
+
Child elements are **attribute- and text-driven data carriers**. Their visual appearance is entirely controlled by the parent element's props and the kit's design tokens (`--kai-*`, `--color-*`). There is no CSS to pierce through Shadow DOM boundaries and no per-child styling surface — reach for the parent's documented attributes and tokens instead.
|
|
268
|
+
|
|
269
|
+
See **[Theming](?path=/docs/theming-overview--docs)** for the full token reference.
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Docs/Using with AI" />
|
|
4
|
+
|
|
5
|
+
# Using with AI
|
|
6
|
+
|
|
7
|
+
`@kitn.ai/ui` ships machine-readable orientation files that follow the
|
|
8
|
+
[llmstxt.org](https://llmstxt.org) convention, so coding agents (Claude Code,
|
|
9
|
+
Copilot, Cursor, Codex, …) can wire up the components correctly without guessing.
|
|
10
|
+
|
|
11
|
+
The philosophy is **human-led, AI-assisted**: humans own the architecture,
|
|
12
|
+
the design decisions, and the final review. The files below exist so that AI
|
|
13
|
+
tools do the wiring work correctly the first time instead of hallucinating
|
|
14
|
+
prop names or attribute APIs.
|
|
15
|
+
|
|
16
|
+
**View them now:** <a href="/llms.txt" target="_blank" rel="noreferrer">llms.txt</a> ·
|
|
17
|
+
<a href="/llms-full.txt" target="_blank" rel="noreferrer">llms-full.txt</a>
|
|
18
|
+
(open in a new tab)
|
|
19
|
+
|
|
20
|
+
## The files
|
|
21
|
+
|
|
22
|
+
Both files are **auto-generated** from `dist/custom-elements.json` by
|
|
23
|
+
`scripts/gen-llms.mjs` during `npm run build`, so they never drift from the
|
|
24
|
+
shipped API. Do not edit them by hand.
|
|
25
|
+
|
|
26
|
+
| File | Size | Audience | Contents |
|
|
27
|
+
|---|---|---|---|
|
|
28
|
+
| `llms.txt` | ~4 KB | Agents + humans | Dense orientation: install command, the property-vs-attribute rule, two-layer architecture, framework wiring (React / Vue / plain HTML), theming tokens. Fast to read — the right file to paste into a prompt. |
|
|
29
|
+
| `llms-full.txt` | ~60 KB | Agents | Everything in `llms.txt` plus a generated props/events table for every element, a streaming recipe, and a step-by-step "build a chat app" runbook. |
|
|
30
|
+
|
|
31
|
+
### Where to find them after `npm install`
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
node_modules/@kitn.ai/ui/llms.txt
|
|
35
|
+
node_modules/@kitn.ai/ui/llms-full.txt
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Both paths are listed in the package's `files` field and are therefore always
|
|
39
|
+
present after install. They are also copied to `dist/llms/` inside the package
|
|
40
|
+
(at `node_modules/@kitn.ai/ui/dist/llms/llms.txt`), and published at:
|
|
41
|
+
|
|
42
|
+
- https://kitn.dev/llms.txt
|
|
43
|
+
- https://kitn.dev/llms-full.txt
|
|
44
|
+
|
|
45
|
+
## How to point an agent at them
|
|
46
|
+
|
|
47
|
+
| Tool | What to do |
|
|
48
|
+
|---|---|
|
|
49
|
+
| **Claude Code** | Add `@node_modules/@kitn.ai/ui/llms.txt` to `CLAUDE.md`, or run `read node_modules/@kitn.ai/ui/llms-full.txt` inside the session |
|
|
50
|
+
| **GitHub Copilot** | Add the path to `.github/copilot-instructions.md`; workspace indexing picks it up automatically |
|
|
51
|
+
| **Cursor** | Reference the file in `.cursorrules` |
|
|
52
|
+
| **Codex / ChatGPT** | Paste the URL `https://kitn.dev/llms.txt` into the prompt, or fetch it with a browsing tool |
|
|
53
|
+
| **Any agent** | `npm install @kitn.ai/ui` → file is at `node_modules/@kitn.ai/ui/llms.txt` |
|
|
54
|
+
|
|
55
|
+
For one-off sessions, pasting the content of `llms.txt` directly into the
|
|
56
|
+
system prompt is enough. For a project where the agent will revisit these
|
|
57
|
+
components repeatedly, point it at the installed file path so it always reads
|
|
58
|
+
the version that matches the installed package.
|
|
59
|
+
|
|
60
|
+
## What agents most need to know
|
|
61
|
+
|
|
62
|
+
These are the facts that AI tools most commonly get wrong when working with
|
|
63
|
+
`kai-*` elements. They appear in both machine-readable files, but they are
|
|
64
|
+
worth knowing up front.
|
|
65
|
+
|
|
66
|
+
### 1 — Array and object data goes on JS properties, not HTML attributes
|
|
67
|
+
|
|
68
|
+
An HTML attribute is always a string. Passing `messages`, `models`, `context`,
|
|
69
|
+
`suggestions`, or `slashCommands` as an attribute silently fails.
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
const chat = document.querySelector('kai-chat');
|
|
73
|
+
chat.messages = [{ id: '1', role: 'assistant', content: 'Hi!' }]; // ✅ property
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<kai-chat messages="[...]"></kai-chat> <!-- ❌ never works -->
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Only scalar props (string / number / boolean) work as attributes — for example
|
|
81
|
+
`placeholder`, `loading`, and `theme`.
|
|
82
|
+
|
|
83
|
+
### 2 — Events are kebab-case `kai-*` CustomEvents, and they do not bubble
|
|
84
|
+
|
|
85
|
+
Listen directly on the element, not on a parent:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
chat.addEventListener('kai-submit', (e) => console.log(e.detail.value));
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Common events: `kai-submit`, `kai-feedback`, `kai-model-change`, `kai-new-chat`, `kai-select`.
|
|
92
|
+
|
|
93
|
+
### 3 — Streaming requires a new array + new object on every chunk
|
|
94
|
+
|
|
95
|
+
Mutating an existing message object in place does **not** trigger a re-render.
|
|
96
|
+
Replace, don't mutate:
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
// ✅ re-renders on every chunk
|
|
100
|
+
chat.messages = chat.messages.map(
|
|
101
|
+
(m) => (m.id === aid ? { ...m, content: answer } : m)
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// ❌ does NOT re-render
|
|
105
|
+
chat.messages[i].content = next;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The same rule applies to every array/object property: always assign a new
|
|
109
|
+
reference.
|
|
110
|
+
|
|
111
|
+
## Build a chat app (the runbook agents follow)
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
import '@kitn.ai/ui/elements';
|
|
115
|
+
const chat = document.querySelector('kai-chat');
|
|
116
|
+
chat.messages = [];
|
|
117
|
+
|
|
118
|
+
chat.addEventListener('kai-submit', async (e) => {
|
|
119
|
+
const userText = e.detail.value;
|
|
120
|
+
|
|
121
|
+
// Append the user message (new array)
|
|
122
|
+
const history = [...chat.messages, { id: crypto.randomUUID(), role: 'user', content: userText }];
|
|
123
|
+
chat.messages = history;
|
|
124
|
+
chat.loading = true;
|
|
125
|
+
|
|
126
|
+
// Empty assistant placeholder to stream into
|
|
127
|
+
const aid = crypto.randomUUID();
|
|
128
|
+
chat.messages = [...history, { id: aid, role: 'assistant', content: '' }];
|
|
129
|
+
|
|
130
|
+
// Stream — reassign a NEW array with a NEW message object each chunk.
|
|
131
|
+
// Mutating in place will NOT re-render.
|
|
132
|
+
let answer = '';
|
|
133
|
+
for await (const token of streamFromYourAPI(history)) {
|
|
134
|
+
answer += token;
|
|
135
|
+
chat.messages = chat.messages.map((m) => (m.id === aid ? { ...m, content: answer } : m));
|
|
136
|
+
}
|
|
137
|
+
chat.loading = false;
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Agent Skills (progressive loading) — planned
|
|
142
|
+
|
|
143
|
+
Web Awesome and similar design systems are moving toward a **skills directory**:
|
|
144
|
+
a structured set of per-component markdown files that AI tools load
|
|
145
|
+
progressively, fetching only the documentation relevant to the current task.
|
|
146
|
+
|
|
147
|
+
`@kitn.ai/ui` already provides `dist/llms/llms-full.txt` as a single,
|
|
148
|
+
comprehensive reference (60 KB, all 42 elements). A per-element skills
|
|
149
|
+
directory would let agents pull just the `kai-chat` spec when they only need
|
|
150
|
+
that one element, rather than loading the full file.
|
|
151
|
+
|
|
152
|
+
This is tracked as a follow-up improvement. If you want it sooner, the starting
|
|
153
|
+
point is `scripts/gen-llms.mjs` — it already reads `dist/custom-elements.json`
|
|
154
|
+
and has all the data needed to emit `dist/skills/kai-chat.md`,
|
|
155
|
+
`dist/skills/kai-message.md`, etc.
|
|
156
|
+
|
|
157
|
+
## Links
|
|
158
|
+
|
|
159
|
+
- <a href="/llms.txt" target="_blank" rel="noreferrer"><code>llms.txt</code></a> — orientation (~4 KB; also at `https://kitn.dev/llms.txt`)
|
|
160
|
+
- <a href="/llms-full.txt" target="_blank" rel="noreferrer"><code>llms-full.txt</code></a> — full per-element reference (~60 KB; also at `https://kitn.dev/llms-full.txt`)
|
|
161
|
+
- Custom Elements Manifest — `dist/custom-elements.json` (published at `https://unpkg.com/@kitn.ai/ui/dist/custom-elements.json`)
|
|
162
|
+
- Repository — https://github.com/kitn-ai/ui
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Meta, Canvas } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as FullChat from '../full-chat.stories';
|
|
3
|
+
|
|
4
|
+
<Meta title="Docs/Getting Started" />
|
|
5
|
+
|
|
6
|
+
# Getting Started
|
|
7
|
+
|
|
8
|
+
`<kai-chat>` is **transport-agnostic**: give it a `messages` array, it renders the conversation and
|
|
9
|
+
emits a `submit` event when the user sends. You own the request and the streaming; the component
|
|
10
|
+
owns the UI.
|
|
11
|
+
|
|
12
|
+
## Your first chat in ~10 lines
|
|
13
|
+
|
|
14
|
+
Set rich data as JS **properties** and listen for **events**. This is the universal pattern — every
|
|
15
|
+
framework just wraps it in its own binding syntax.
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<kai-chat id="chat" style="display:block; height:100dvh;"></kai-chat>
|
|
19
|
+
|
|
20
|
+
<script type="module">
|
|
21
|
+
import '@kitn.ai/ui/elements';
|
|
22
|
+
|
|
23
|
+
const chat = document.getElementById('chat');
|
|
24
|
+
chat.messages = [
|
|
25
|
+
{ id: '1', role: 'assistant', content: 'Hello! How can I help?' },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
chat.addEventListener('kai-submit', (e) => {
|
|
29
|
+
const text = e.detail.value;
|
|
30
|
+
chat.messages = [
|
|
31
|
+
...chat.messages,
|
|
32
|
+
{ id: crypto.randomUUID(), role: 'user', content: text },
|
|
33
|
+
];
|
|
34
|
+
// …call your model, then append an assistant message
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
> Reactivity tip: assign a **new array** (and a new object for any message you change) when updating
|
|
40
|
+
> `chat.messages` — that's what triggers a re-render.
|
|
41
|
+
|
|
42
|
+
## Now pick your stack
|
|
43
|
+
|
|
44
|
+
That's the raw element. For install, setup, and idiomatic examples in your framework — plus the
|
|
45
|
+
**two ways** to use the kit (the all-in-one `<kai-chat>` and composing the individual elements):
|
|
46
|
+
|
|
47
|
+
[HTML](?path=/docs/docs-frameworks-html--docs) ·
|
|
48
|
+
[React](?path=/docs/docs-frameworks-react--docs) ·
|
|
49
|
+
[Solid](?path=/docs/docs-frameworks-solid--docs) ·
|
|
50
|
+
[Vue](?path=/docs/docs-frameworks-vue--docs) ·
|
|
51
|
+
[Svelte](?path=/docs/docs-frameworks-svelte--docs) ·
|
|
52
|
+
[Angular](?path=/docs/docs-frameworks-angular--docs)
|
|
53
|
+
|
|
54
|
+
## A complete example
|
|
55
|
+
|
|
56
|
+
Everything assembled into a real app — a conversation sidebar, a message thread with markdown,
|
|
57
|
+
reasoning blocks and a tool call, a model switcher, context-usage meter, and a rich prompt input
|
|
58
|
+
with attachments:
|
|
59
|
+
|
|
60
|
+
<Canvas of={FullChat.Default} />
|
|
61
|
+
|
|
62
|
+
Open it full-screen under **Examples → Full Chat App**, then explore each building block on its own
|
|
63
|
+
page under **Components**.
|
|
64
|
+
|
|
65
|
+
Ready to make it yours? See **[Theming](?path=/docs/theming-overview--docs)**.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Docs/Installation" />
|
|
4
|
+
|
|
5
|
+
# Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @kitn.ai/ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The package ships two entry points — pick whichever fits your stack, and you can mix them:
|
|
12
|
+
|
|
13
|
+
- **`@kitn.ai/ui/elements`** — the framework-agnostic **web components** (`<kai-chat>`, …). Works
|
|
14
|
+
in React, Vue, Angular, Svelte, or plain HTML. **This is what most apps use.**
|
|
15
|
+
- **`@kitn.ai/ui`** — the native **SolidJS** components, if you're building in SolidJS.
|
|
16
|
+
|
|
17
|
+
## Web components (React, Vue, Angular, Svelte, HTML)
|
|
18
|
+
|
|
19
|
+
Import the element bundle once as a **side effect** — that registers `<kai-chat>` and every other
|
|
20
|
+
`<kai-*>` element globally:
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import '@kitn.ai/ui/elements';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- The bundle is **ESM-only** and loads via `<script type="module">` or any modern bundler.
|
|
27
|
+
- **SolidJS is bundled in** — the host page needs nothing else.
|
|
28
|
+
- The kit's CSS is injected into each element's Shadow DOM automatically; importing `theme.css` is
|
|
29
|
+
optional, only to override design tokens.
|
|
30
|
+
|
|
31
|
+
Then head to your framework's page for setup + examples:
|
|
32
|
+
[HTML](?path=/docs/docs-frameworks-html--docs) ·
|
|
33
|
+
[React](?path=/docs/docs-frameworks-react--docs) ·
|
|
34
|
+
[Vue](?path=/docs/docs-frameworks-vue--docs) ·
|
|
35
|
+
[Svelte](?path=/docs/docs-frameworks-svelte--docs) ·
|
|
36
|
+
[Angular](?path=/docs/docs-frameworks-angular--docs).
|
|
37
|
+
|
|
38
|
+
### Via CDN (no build step, no npm)
|
|
39
|
+
|
|
40
|
+
The element bundle is a self-contained ES module, so you can load it straight from a CDN — no
|
|
41
|
+
install, no bundler. It's published on both <a href="https://www.jsdelivr.com/package/npm/@kitn.ai/ui" target="_blank" rel="noreferrer">jsDelivr</a> and <a href="https://unpkg.com/browse/@kitn.ai/ui/" target="_blank" rel="noreferrer">unpkg</a>:
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<script type="module">
|
|
45
|
+
import 'https://cdn.jsdelivr.net/npm/@kitn.ai/ui/dist/kitn-chat.es.js';
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<kai-chat></kai-chat>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- The URL above tracks the **latest** release (no version) — great for demos and quick starts.
|
|
52
|
+
- **For production, pin an exact version** — e.g. `.../npm/@kitn.ai/ui@0.4.0/dist/kitn-chat.es.js`.
|
|
53
|
+
Pinned URLs are immutable and cached aggressively, and — since this package is **pre-1.0** —
|
|
54
|
+
pinning shields you from breaking changes in a future minor. A range (`@0` / `@0.4`) won't: pre-1.0
|
|
55
|
+
it can still resolve to a breaking minor.
|
|
56
|
+
- SolidJS and the kit's CSS are bundled in, and the lazy syntax-highlighting chunks load from the
|
|
57
|
+
**same CDN** automatically. To override design tokens, also pull in `theme.css`:
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@kitn.ai/ui/theme.css">
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## SolidJS projects
|
|
64
|
+
|
|
65
|
+
The kit is authored in SolidJS, so SolidJS apps can import the components natively for full
|
|
66
|
+
compositional control. `solid-js` is a peer dependency:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm install solid-js
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { ChatContainer, Message, MessageContent, PromptInput } from '@kitn.ai/ui';
|
|
74
|
+
import '@kitn.ai/ui/theme.css';
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The `@kitn.ai/ui` entry ships as source, so your bundler tree-shakes it to exactly what you
|
|
78
|
+
import. See the [Solid](?path=/docs/docs-frameworks-solid--docs) page and the **Solid (Advanced)**
|
|
79
|
+
section for the full component + primitive reference.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
Ready? Head to **[Getting Started](?path=/docs/docs-getting-started--docs)** to render your first chat.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Meta, Canvas } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as ChatPanel from '../chat-panel-layout.stories';
|
|
3
|
+
|
|
4
|
+
<Meta title="Docs/Introduction" />
|
|
5
|
+
|
|
6
|
+
# @kitn.ai/ui
|
|
7
|
+
|
|
8
|
+
**Framework-agnostic, Shadow-DOM web components for building AI chat interfaces.**
|
|
9
|
+
|
|
10
|
+
Message threads, prompt inputs, streaming responses, markdown + code rendering, reasoning & tool-call panels, attachments, and a conversation sidebar — composable building blocks you can drop into any app.
|
|
11
|
+
|
|
12
|
+
<Canvas of={ChatPanel.ChatGPTStyle} />
|
|
13
|
+
|
|
14
|
+
## Why @kitn.ai/ui
|
|
15
|
+
|
|
16
|
+
- **Works in any framework** — drop in the framework-agnostic **web components** (`<kai-chat>`) and they just work in React, Vue, Angular, Svelte, or plain HTML. Authored in SolidJS, so SolidJS apps can also import the components natively for full compositional control.
|
|
17
|
+
- **Zero style conflicts** — the web components render in **Shadow DOM**, so the host page's CSS can't leak in and the kit's Tailwind can't leak out.
|
|
18
|
+
- **Lightweight** — a markdown-only `<kai-chat>` is **~110 KB gzip**, a single file. Syntax highlighting loads **on demand, per language, with no WASM** — and never loads at all if you don't render code.
|
|
19
|
+
- **~50 composable components** across three layers: headless primitives → accessible UI primitives (built in-house, WCAG 2.1 AA — no third-party UI dependency) → AI feature components.
|
|
20
|
+
- **Themeable** — restyle everything by overriding a handful of `--color-*` design tokens.
|
|
21
|
+
|
|
22
|
+
## Browsing the sidebar — which group do I copy from?
|
|
23
|
+
|
|
24
|
+
The kit ships at two layers, and the sidebar reflects that. **Use the right one for your stack:**
|
|
25
|
+
|
|
26
|
+
- **Components** — the framework-agnostic `<kai-*>` custom elements. **This is what to copy into a React, Vue, Angular, Svelte, or plain-HTML app.** Data goes on JS properties, interactions come back as events.
|
|
27
|
+
- **Solid (Advanced)** — under it, **Elements** (the native SolidJS feature components) and **Primitives** (Button, Dropdown, HoverCard, …) that the web components are *built from*. Their snippets are SolidJS JSX, so **only copy these into a SolidJS app**.
|
|
28
|
+
|
|
29
|
+
In other words: the `<kai-chat>` web component is a thin facade over the SolidJS `ChatContainer`/`Message`/… components — same UI, different consumption model. When in doubt, reach for **Components**.
|
|
30
|
+
|
|
31
|
+
## Components, Patterns & Recipes
|
|
32
|
+
|
|
33
|
+
Three sidebar groups answer different questions:
|
|
34
|
+
|
|
35
|
+
- **Components** — one reusable building block with one job and a documented prop/event API (`kai-message`, `kai-prompt-input`). Answers _"what is this control and how do I configure it?"_
|
|
36
|
+
- **Patterns** — a prescriptive, framework-agnostic solution to a recurring chat-UX problem. Answers _"how do I solve this scenario?"_ A Pattern **stands alone if you delete every code block** — the guidance is the value, not the snippet.
|
|
37
|
+
- **Recipes / Examples** — concrete, copy-paste assemblies tied to specific components, frameworks, or services. **Worthless without their code** — that's what makes them Recipes, not Patterns.
|
|
38
|
+
|
|
39
|
+
> **The delete-the-code test:** remove every code block. If the page is gutted, it's a Recipe. If the guidance stands alone, it's a Pattern.
|
|
40
|
+
|
|
41
|
+
Browse **Patterns** for recurring chat-UX solutions (streaming, empty state, message actions) and **Examples** for full assembled apps and task-specific snippets. The **[Choosing Components](?path=/docs/docs-choosing-components--docs)** guide explains which tier of building block to reach for first.
|
|
42
|
+
|
|
43
|
+
## Where to next
|
|
44
|
+
|
|
45
|
+
- **[Installation](?path=/docs/docs-installation--docs)** — add it to your project
|
|
46
|
+
- **[Getting Started](?path=/docs/docs-getting-started--docs)** — your first chat in a few lines, plus a full example
|
|
47
|
+
- **[Theming](?path=/docs/theming-overview--docs)** — make it match your brand
|
|
48
|
+
- **[Frameworks & Integrations](?path=/docs/docs-frameworks-overview--docs)** — wire up React, Vue, Svelte, Angular, or plain HTML; stream responses from OpenRouter and add text-to-speech
|
|
49
|
+
|
|
50
|
+
Or browse every component in isolation from the sidebar.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Solid (Advanced)/Overview" />
|
|
4
|
+
|
|
5
|
+
# Solid (Advanced)
|
|
6
|
+
|
|
7
|
+
**Most people want the [Components](?path=/docs/components-chat--docs).** This tier is
|
|
8
|
+
only for building a **custom chat UI in SolidJS** — the kit is authored in SolidJS, and these
|
|
9
|
+
are the same building blocks the web components compose from.
|
|
10
|
+
|
|
11
|
+
- **Elements** — the composed SolidJS pieces (message, tool, reasoning, …). Each maps to a
|
|
12
|
+
`kai-*` element; reach for these only if you're assembling your own layout in Solid.
|
|
13
|
+
- **Primitives** — the low-level base components (button, tooltip, dropdown, …) the components
|
|
14
|
+
are built on. You rarely use these directly.
|
|
15
|
+
|
|
16
|
+
Using a web component instead? Every element's **API** tab has copy-paste examples for
|
|
17
|
+
HTML, React, Svelte, Vue, Angular, and Solid.
|