@kitn.ai/ui 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/bin/mcp.js +22 -0
- package/dist/bash-InADTalH.js +6 -1
- package/dist/components/artifact.d.ts +58 -0
- package/dist/components/attachments.d.ts +67 -0
- package/dist/components/card-fallback.d.ts +10 -0
- package/dist/components/card-renderer.d.ts +13 -0
- package/dist/components/card.d.ts +28 -0
- package/dist/components/chain-of-thought.d.ts +29 -0
- package/dist/components/chat-container.d.ts +19 -0
- package/dist/components/chat-scope-picker.d.ts +9 -0
- package/dist/components/chat-thread.d.ts +93 -0
- package/dist/components/checkpoint.d.ts +20 -0
- package/dist/components/choice-card.d.ts +77 -0
- package/dist/components/code-block.d.ts +16 -0
- package/dist/components/confirm-card.d.ts +57 -0
- package/dist/components/context.d.ts +65 -0
- package/dist/components/conversation-item.d.ts +8 -0
- package/dist/components/conversation-list.d.ts +11 -0
- package/dist/components/embed.d.ts +21 -0
- package/dist/components/empty.d.ts +43 -0
- package/dist/components/feedback-bar.d.ts +45 -0
- package/dist/components/file-tree.d.ts +57 -0
- package/dist/components/file-upload.d.ts +16 -0
- package/dist/components/form-widgets.d.ts +31 -0
- package/dist/components/form.d.ts +103 -0
- package/dist/components/image.d.ts +12 -0
- package/dist/components/link-preview.d.ts +23 -0
- package/dist/components/loader.d.ts +60 -0
- package/dist/components/markdown.d.ts +8 -0
- package/dist/components/message-skills.d.ts +15 -0
- package/dist/components/message.d.ts +54 -0
- package/dist/components/model-switcher.d.ts +8 -0
- package/dist/components/prompt-input.d.ts +38 -0
- package/dist/components/prompt-suggestion.d.ts +13 -0
- package/dist/components/reasoning.d.ts +20 -0
- package/dist/components/response-stream.d.ts +14 -0
- package/dist/components/scroll-button.d.ts +7 -0
- package/dist/components/slash-command.d.ts +15 -0
- package/dist/components/source.d.ts +23 -0
- package/dist/components/tasks-card.d.ts +71 -0
- package/dist/components/text-shimmer.d.ts +9 -0
- package/dist/components/thinking-bar.d.ts +10 -0
- package/dist/components/tool.d.ts +16 -0
- package/dist/components/use-card-resolution.d.ts +12 -0
- package/dist/components/voice-input.d.ts +7 -0
- package/dist/core-AYMC6_lb.js +5874 -12
- package/dist/css-M7EaDHN_.js +6 -1
- package/dist/elements/artifact.d.ts +1 -0
- package/dist/elements/attachments.d.ts +1 -0
- package/dist/elements/card.d.ts +1 -0
- package/dist/elements/cards.d.ts +0 -0
- package/dist/elements/chain-of-thought.d.ts +13 -0
- package/dist/elements/chat-scope-picker.d.ts +1 -0
- package/dist/elements/chat-types.d.ts +41 -0
- package/dist/elements/chat-workspace.d.ts +1 -0
- package/dist/elements/chat.d.ts +1 -0
- package/dist/elements/checkpoint.d.ts +1 -0
- package/dist/elements/choice.d.ts +1 -0
- package/dist/elements/code-block.d.ts +1 -0
- package/dist/elements/confirm-card.d.ts +1 -0
- package/dist/elements/context-meter.d.ts +1 -0
- package/dist/elements/conversation-list.d.ts +11 -0
- package/dist/elements/css.d.ts +1 -0
- package/dist/elements/default-input.d.ts +40 -0
- package/dist/elements/define.d.ts +42 -0
- package/dist/elements/embed.d.ts +1 -0
- package/dist/elements/empty.d.ts +1 -0
- package/dist/elements/feedback-bar.d.ts +1 -0
- package/dist/elements/file-tree.d.ts +1 -0
- package/dist/elements/file-upload.d.ts +1 -0
- package/dist/elements/form.d.ts +1 -0
- package/dist/elements/image.d.ts +1 -0
- package/dist/elements/link-preview.d.ts +1 -0
- package/dist/elements/loader.d.ts +1 -0
- package/dist/elements/markdown.d.ts +1 -0
- package/dist/elements/message-skills.d.ts +17 -0
- package/dist/elements/message.d.ts +1 -0
- package/dist/elements/model-switcher.d.ts +11 -0
- package/dist/elements/popover.d.ts +1 -0
- package/dist/elements/prompt-input.d.ts +9 -0
- package/dist/elements/prompt-suggestions.d.ts +7 -0
- package/dist/elements/reasoning.d.ts +1 -0
- package/dist/elements/register-impl.d.ts +0 -0
- package/dist/elements/register.d.ts +3 -0
- package/dist/elements/remote.d.ts +1 -0
- package/dist/elements/resizable.d.ts +17 -0
- package/dist/elements/response-stream.d.ts +1 -0
- package/dist/elements/scroll-button.d.ts +1 -0
- package/dist/elements/source.d.ts +18 -0
- package/dist/elements/switch.d.ts +1 -0
- package/dist/elements/tasks.d.ts +1 -0
- package/dist/elements/text-shimmer.d.ts +1 -0
- package/dist/elements/thinking-bar.d.ts +1 -0
- package/dist/elements/tool.d.ts +1 -0
- package/dist/elements/voice-input.d.ts +1 -0
- package/dist/elements.d.ts +732 -0
- package/dist/engine-javascript-vq0WuIJl.js +2516 -14
- package/dist/github-dark-dimmed-DUshB20C.js +4 -1
- package/dist/github-light-JYsPkUQd.js +4 -1
- package/dist/html-CPZ3oZQ7.js +10 -1
- package/dist/index.d.ts +112 -2
- package/dist/index.js +13551 -0
- package/dist/javascript-C25yR2R2.js +6 -1
- package/dist/json-DxJze_jm.js +6 -1
- package/dist/kitn-chat.es.js +1 -77
- package/dist/llms/llms-full.txt +1 -1
- package/dist/llms/llms.txt +1 -1
- package/dist/mcp.es.js +2140 -0
- package/dist/primitives/card-contract.d.ts +103 -0
- package/dist/primitives/card-host.d.ts +12 -0
- package/dist/primitives/card-registry.d.ts +17 -0
- package/dist/primitives/card-resolution.d.ts +8 -0
- package/dist/primitives/card-routing.d.ts +12 -0
- package/dist/primitives/card-validate.d.ts +25 -0
- package/dist/primitives/chat-config.d.ts +31 -0
- package/dist/primitives/controllable.d.ts +13 -0
- package/dist/primitives/embed-providers.d.ts +65 -0
- package/dist/primitives/highlighter.d.ts +23 -0
- package/dist/primitives/link-preview.d.ts +47 -0
- package/dist/primitives/pdf-preview.d.ts +50 -0
- package/dist/primitives/use-auto-resize.d.ts +8 -0
- package/dist/primitives/use-resize-observer.d.ts +1 -0
- package/dist/primitives/use-stick-to-bottom.d.ts +5 -0
- package/dist/primitives/use-text-stream.d.ts +19 -0
- package/dist/primitives/use-voice-recorder.d.ts +9 -0
- package/dist/react/index.d.ts +1118 -0
- package/dist/react/runtime.d.ts +15 -0
- package/dist/react.js +265 -0
- package/dist/register-impl-wCsFPoh9.js +77 -0
- package/dist/register-ujhr1nBS.js +1 -0
- package/dist/remote/host-embed.d.ts +33 -0
- package/dist/remote/index.d.ts +2 -0
- package/dist/remote/origin.d.ts +5 -0
- package/dist/remote/provider-runtime.d.ts +27 -0
- package/dist/remote/provider.d.ts +2 -0
- package/dist/remote/validate.d.ts +4 -0
- package/dist/remote/version.d.ts +4 -0
- package/dist/remote/wire.d.ts +53 -0
- package/dist/svelte--5p79yCD.js +15 -1
- package/dist/tsx-B8rCNbgL.js +6 -1
- package/dist/types.d.ts +42 -0
- package/dist/typescript-RycA9KXf.js +6 -1
- package/dist/ui/action-icons.d.ts +11 -0
- package/dist/ui/avatar.d.ts +8 -0
- package/dist/ui/badge.d.ts +9 -0
- package/dist/ui/button.d.ts +10 -0
- package/dist/ui/collapsible.d.ts +27 -0
- package/dist/ui/dropdown.d.ts +20 -0
- package/dist/ui/hover-card.d.ts +28 -0
- package/dist/ui/overlay.d.ts +67 -0
- package/dist/ui/popover.d.ts +32 -0
- package/dist/ui/resizable.d.ts +76 -0
- package/dist/ui/scroll-area.d.ts +5 -0
- package/dist/ui/separator.d.ts +5 -0
- package/dist/ui/skeleton.d.ts +5 -0
- package/dist/ui/switch.d.ts +19 -0
- package/dist/ui/textarea.d.ts +6 -0
- package/dist/ui/tooltip.d.ts +8 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/vue-BmIZj4XD.js +33 -1
- package/frameworks/react/index.tsx +4 -0
- package/frameworks/react/runtime.tsx +16 -2
- package/llms-full.txt +1 -1
- package/llms.txt +1 -1
- package/package.json +29 -11
- package/src/agent-tooling/archetypes.ts +46 -0
- package/src/agent-tooling/integrations/cloudflare.ts +88 -0
- package/src/agent-tooling/integrations/langgraph.ts +60 -0
- package/src/agent-tooling/integrations/mastra.ts +27 -0
- package/src/agent-tooling/integrations/mock.ts +34 -0
- package/src/agent-tooling/integrations/ollama.ts +47 -0
- package/src/agent-tooling/integrations/openrouter.ts +26 -0
- package/src/agent-tooling/integrations/pi.ts +40 -0
- package/src/agent-tooling/integrations/pydantic-ai.ts +52 -0
- package/src/agent-tooling/integrations/vercel-ai-sdk.ts +44 -0
- package/src/agent-tooling/mcp/manifest.ts +128 -0
- package/src/agent-tooling/mcp/server.ts +59 -0
- package/src/agent-tooling/mcp/stdio.ts +18 -0
- package/src/agent-tooling/mcp/tools/debug.ts +305 -0
- package/src/agent-tooling/mcp/tools/reference.ts +132 -0
- package/src/agent-tooling/mcp/tools/scaffold.ts +1627 -0
- package/src/agent-tooling/mcp/tools/theme.ts +340 -0
- package/src/agent-tooling/mcp/tools/types.ts +14 -0
- package/src/agent-tooling/registry.ts +41 -0
- package/src/agent-tooling/types.ts +30 -0
- package/src/elements/compiled.css +1 -1
- package/src/elements/define.tsx +7 -1
- package/src/elements/element-types.d.ts +2 -1
- package/src/elements/register-impl.ts +55 -0
- package/src/elements/register.ts +17 -51
- package/theme.css +4 -2
- 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,337 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
|
-
import { Skeleton } from './skeleton';
|
|
3
|
-
import { componentDescription } from '../stories/docs/element-controls';
|
|
4
|
-
|
|
5
|
-
const meta = {
|
|
6
|
-
title: 'Solid (Advanced)/Primitives/Skeleton',
|
|
7
|
-
component: Skeleton,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: 'padded',
|
|
11
|
-
docs: {
|
|
12
|
-
controls: { exclude: ['use:eventListener'] },
|
|
13
|
-
description: componentDescription([
|
|
14
|
-
'A pulsing **placeholder** block used to indicate loading content. It has no shape of its own — size and rounding come from the `class` you pass.',
|
|
15
|
-
'**When to use:** while content (messages, lists, cards, tool output) is loading, to preserve layout and signal progress without a spinner.',
|
|
16
|
-
'**How to use:** compose one or more `Skeleton` elements and set width/height/rounding via utility classes (e.g. `class="h-4 w-3/4"`). Build skeletons that mirror the real layout they replace.',
|
|
17
|
-
'**Placement:** message bubbles, conversation lists, code blocks, tool calls, input areas, and full-page loading states.',
|
|
18
|
-
]),
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
argTypes: {
|
|
22
|
-
class: {
|
|
23
|
-
control: 'text',
|
|
24
|
-
description: 'Utility classes that set the size and rounding of the placeholder.',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
args: {
|
|
28
|
-
class: 'h-4 w-64',
|
|
29
|
-
},
|
|
30
|
-
render: (args) => <Skeleton {...args} />,
|
|
31
|
-
} satisfies Meta<typeof Skeleton>;
|
|
32
|
-
|
|
33
|
-
export default meta;
|
|
34
|
-
type Story = StoryObj<typeof meta>;
|
|
35
|
-
|
|
36
|
-
const IMPORT = `import { Skeleton } from '@kitn.ai/ui';`;
|
|
37
|
-
const src = (code: string) => ({
|
|
38
|
-
parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
/** Interactive playground — edit `class` to resize the placeholder. */
|
|
42
|
-
export const Playground: Story = {
|
|
43
|
-
...src(`<Skeleton class="h-4 w-64" />`),
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const Basic: Story = {
|
|
47
|
-
render: () => (
|
|
48
|
-
<div class="space-y-3 w-80">
|
|
49
|
-
<Skeleton class="h-4 w-full" />
|
|
50
|
-
<Skeleton class="h-4 w-3/4" />
|
|
51
|
-
<Skeleton class="h-4 w-1/2" />
|
|
52
|
-
</div>
|
|
53
|
-
),
|
|
54
|
-
...src(`<div class="space-y-3 w-80">
|
|
55
|
-
<Skeleton class="h-4 w-full" />
|
|
56
|
-
<Skeleton class="h-4 w-3/4" />
|
|
57
|
-
<Skeleton class="h-4 w-1/2" />
|
|
58
|
-
</div>`),
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const MessageBubble: Story = {
|
|
62
|
-
name: 'Message Bubble',
|
|
63
|
-
render: () => (
|
|
64
|
-
<div class="space-y-6 w-full max-w-2xl">
|
|
65
|
-
{/* User message skeleton */}
|
|
66
|
-
<div class="flex justify-end">
|
|
67
|
-
<Skeleton class="h-12 w-64 rounded-3xl" />
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
{/* Assistant message skeleton */}
|
|
71
|
-
<div class="flex gap-3 items-start">
|
|
72
|
-
<Skeleton class="h-8 w-8 rounded-full shrink-0" />
|
|
73
|
-
<div class="flex-1 space-y-2">
|
|
74
|
-
<Skeleton class="h-4 w-full" />
|
|
75
|
-
<Skeleton class="h-4 w-full" />
|
|
76
|
-
<Skeleton class="h-4 w-5/6" />
|
|
77
|
-
<Skeleton class="h-4 w-2/3" />
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
),
|
|
82
|
-
...src(`<div class="space-y-6 w-full max-w-2xl">
|
|
83
|
-
<div class="flex justify-end">
|
|
84
|
-
<Skeleton class="h-12 w-64 rounded-3xl" />
|
|
85
|
-
</div>
|
|
86
|
-
<div class="flex gap-3 items-start">
|
|
87
|
-
<Skeleton class="h-8 w-8 rounded-full shrink-0" />
|
|
88
|
-
<div class="flex-1 space-y-2">
|
|
89
|
-
<Skeleton class="h-4 w-full" />
|
|
90
|
-
<Skeleton class="h-4 w-full" />
|
|
91
|
-
<Skeleton class="h-4 w-5/6" />
|
|
92
|
-
<Skeleton class="h-4 w-2/3" />
|
|
93
|
-
</div>
|
|
94
|
-
</div>
|
|
95
|
-
</div>`),
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const MessageWithCode: Story = {
|
|
99
|
-
name: 'Message with Code Block',
|
|
100
|
-
render: () => (
|
|
101
|
-
<div class="flex gap-3 items-start w-full max-w-2xl">
|
|
102
|
-
<Skeleton class="h-8 w-8 rounded-full shrink-0" />
|
|
103
|
-
<div class="flex-1 space-y-3">
|
|
104
|
-
<div class="space-y-2">
|
|
105
|
-
<Skeleton class="h-4 w-full" />
|
|
106
|
-
<Skeleton class="h-4 w-4/5" />
|
|
107
|
-
</div>
|
|
108
|
-
{/* Code block skeleton */}
|
|
109
|
-
<Skeleton class="h-32 w-full rounded-xl" />
|
|
110
|
-
<div class="space-y-2">
|
|
111
|
-
<Skeleton class="h-4 w-full" />
|
|
112
|
-
<Skeleton class="h-4 w-3/5" />
|
|
113
|
-
</div>
|
|
114
|
-
</div>
|
|
115
|
-
</div>
|
|
116
|
-
),
|
|
117
|
-
...src(`<div class="flex gap-3 items-start w-full max-w-2xl">
|
|
118
|
-
<Skeleton class="h-8 w-8 rounded-full shrink-0" />
|
|
119
|
-
<div class="flex-1 space-y-3">
|
|
120
|
-
<div class="space-y-2">
|
|
121
|
-
<Skeleton class="h-4 w-full" />
|
|
122
|
-
<Skeleton class="h-4 w-4/5" />
|
|
123
|
-
</div>
|
|
124
|
-
<Skeleton class="h-32 w-full rounded-xl" />
|
|
125
|
-
<div class="space-y-2">
|
|
126
|
-
<Skeleton class="h-4 w-full" />
|
|
127
|
-
<Skeleton class="h-4 w-3/5" />
|
|
128
|
-
</div>
|
|
129
|
-
</div>
|
|
130
|
-
</div>`),
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export const ConversationList: Story = {
|
|
134
|
-
name: 'Conversation List',
|
|
135
|
-
render: () => (
|
|
136
|
-
<div class="w-64 space-y-1">
|
|
137
|
-
{/* Section header */}
|
|
138
|
-
<Skeleton class="h-3 w-12 mb-2" />
|
|
139
|
-
{[1, 2, 3].map(() => (
|
|
140
|
-
<div class="flex items-center gap-2 px-2 py-2">
|
|
141
|
-
<Skeleton class="h-4 w-4 rounded shrink-0" />
|
|
142
|
-
<Skeleton class="h-4 flex-1" />
|
|
143
|
-
</div>
|
|
144
|
-
))}
|
|
145
|
-
{/* Section header */}
|
|
146
|
-
<Skeleton class="h-3 w-16 mt-4 mb-2" />
|
|
147
|
-
{[1, 2].map(() => (
|
|
148
|
-
<div class="flex items-center gap-2 px-2 py-2">
|
|
149
|
-
<Skeleton class="h-4 w-4 rounded shrink-0" />
|
|
150
|
-
<Skeleton class="h-4 flex-1" />
|
|
151
|
-
</div>
|
|
152
|
-
))}
|
|
153
|
-
</div>
|
|
154
|
-
),
|
|
155
|
-
...src(`<div class="w-64 space-y-1">
|
|
156
|
-
<Skeleton class="h-3 w-12 mb-2" />
|
|
157
|
-
{[1, 2, 3].map(() => (
|
|
158
|
-
<div class="flex items-center gap-2 px-2 py-2">
|
|
159
|
-
<Skeleton class="h-4 w-4 rounded shrink-0" />
|
|
160
|
-
<Skeleton class="h-4 flex-1" />
|
|
161
|
-
</div>
|
|
162
|
-
))}
|
|
163
|
-
</div>`),
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export const ToolCall: Story = {
|
|
167
|
-
name: 'Tool Call',
|
|
168
|
-
render: () => (
|
|
169
|
-
<div class="w-full max-w-2xl">
|
|
170
|
-
<div class="border border-border rounded-xl overflow-hidden">
|
|
171
|
-
{/* Tool header */}
|
|
172
|
-
<div class="flex items-center gap-2 px-3 py-2.5">
|
|
173
|
-
<Skeleton class="h-4 w-4 rounded-full" />
|
|
174
|
-
<Skeleton class="h-4 w-32" />
|
|
175
|
-
<Skeleton class="h-5 w-20 rounded-full" />
|
|
176
|
-
</div>
|
|
177
|
-
{/* Tool body */}
|
|
178
|
-
<div class="border-t border-border p-3 space-y-3">
|
|
179
|
-
<div>
|
|
180
|
-
<Skeleton class="h-3 w-10 mb-2" />
|
|
181
|
-
<Skeleton class="h-20 w-full rounded" />
|
|
182
|
-
</div>
|
|
183
|
-
<div>
|
|
184
|
-
<Skeleton class="h-3 w-12 mb-2" />
|
|
185
|
-
<Skeleton class="h-16 w-full rounded" />
|
|
186
|
-
</div>
|
|
187
|
-
</div>
|
|
188
|
-
</div>
|
|
189
|
-
</div>
|
|
190
|
-
),
|
|
191
|
-
...src(`<div class="w-full max-w-2xl">
|
|
192
|
-
<div class="border border-border rounded-xl overflow-hidden">
|
|
193
|
-
<div class="flex items-center gap-2 px-3 py-2.5">
|
|
194
|
-
<Skeleton class="h-4 w-4 rounded-full" />
|
|
195
|
-
<Skeleton class="h-4 w-32" />
|
|
196
|
-
<Skeleton class="h-5 w-20 rounded-full" />
|
|
197
|
-
</div>
|
|
198
|
-
<div class="border-t border-border p-3 space-y-3">
|
|
199
|
-
<Skeleton class="h-3 w-10 mb-2" />
|
|
200
|
-
<Skeleton class="h-20 w-full rounded" />
|
|
201
|
-
</div>
|
|
202
|
-
</div>
|
|
203
|
-
</div>`),
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
export const Card: Story = {
|
|
207
|
-
name: 'Content Card',
|
|
208
|
-
render: () => (
|
|
209
|
-
<div class="w-72">
|
|
210
|
-
<Skeleton class="h-40 w-full rounded-xl mb-3" />
|
|
211
|
-
<div class="flex gap-3">
|
|
212
|
-
<Skeleton class="h-8 w-8 rounded-full shrink-0" />
|
|
213
|
-
<div class="flex-1 space-y-2">
|
|
214
|
-
<Skeleton class="h-4 w-full" />
|
|
215
|
-
<Skeleton class="h-3 w-24" />
|
|
216
|
-
<Skeleton class="h-3 w-32" />
|
|
217
|
-
</div>
|
|
218
|
-
</div>
|
|
219
|
-
</div>
|
|
220
|
-
),
|
|
221
|
-
...src(`<div class="w-72">
|
|
222
|
-
<Skeleton class="h-40 w-full rounded-xl mb-3" />
|
|
223
|
-
<div class="flex gap-3">
|
|
224
|
-
<Skeleton class="h-8 w-8 rounded-full shrink-0" />
|
|
225
|
-
<div class="flex-1 space-y-2">
|
|
226
|
-
<Skeleton class="h-4 w-full" />
|
|
227
|
-
<Skeleton class="h-3 w-24" />
|
|
228
|
-
<Skeleton class="h-3 w-32" />
|
|
229
|
-
</div>
|
|
230
|
-
</div>
|
|
231
|
-
</div>`),
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
export const InputArea: Story = {
|
|
235
|
-
name: 'Input Area',
|
|
236
|
-
render: () => (
|
|
237
|
-
<div class="w-full max-w-2xl">
|
|
238
|
-
<div class="border border-border rounded-2xl p-3 space-y-3">
|
|
239
|
-
<Skeleton class="h-10 w-full rounded-lg" />
|
|
240
|
-
<div class="flex items-center justify-between">
|
|
241
|
-
<div class="flex gap-2">
|
|
242
|
-
<Skeleton class="h-8 w-8 rounded-full" />
|
|
243
|
-
<Skeleton class="h-8 w-8 rounded-full" />
|
|
244
|
-
<Skeleton class="h-8 w-8 rounded-full" />
|
|
245
|
-
</div>
|
|
246
|
-
<Skeleton class="h-8 w-8 rounded-full" />
|
|
247
|
-
</div>
|
|
248
|
-
</div>
|
|
249
|
-
</div>
|
|
250
|
-
),
|
|
251
|
-
...src(`<div class="w-full max-w-2xl">
|
|
252
|
-
<div class="border border-border rounded-2xl p-3 space-y-3">
|
|
253
|
-
<Skeleton class="h-10 w-full rounded-lg" />
|
|
254
|
-
<div class="flex items-center justify-between">
|
|
255
|
-
<div class="flex gap-2">
|
|
256
|
-
<Skeleton class="h-8 w-8 rounded-full" />
|
|
257
|
-
<Skeleton class="h-8 w-8 rounded-full" />
|
|
258
|
-
<Skeleton class="h-8 w-8 rounded-full" />
|
|
259
|
-
</div>
|
|
260
|
-
<Skeleton class="h-8 w-8 rounded-full" />
|
|
261
|
-
</div>
|
|
262
|
-
</div>
|
|
263
|
-
</div>`),
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
export const FullChat: Story = {
|
|
267
|
-
name: 'Full Chat Layout',
|
|
268
|
-
render: () => (
|
|
269
|
-
<div class="flex w-full max-w-4xl h-96 border border-border rounded-xl overflow-hidden">
|
|
270
|
-
{/* Sidebar */}
|
|
271
|
-
<div class="w-56 border-r border-border p-3 space-y-3 shrink-0">
|
|
272
|
-
<Skeleton class="h-8 w-full rounded-lg" />
|
|
273
|
-
<div class="space-y-1 mt-4">
|
|
274
|
-
<Skeleton class="h-3 w-12 mb-2" />
|
|
275
|
-
{[1, 2, 3].map(() => (
|
|
276
|
-
<Skeleton class="h-8 w-full rounded-lg" />
|
|
277
|
-
))}
|
|
278
|
-
<Skeleton class="h-3 w-16 mt-3 mb-2" />
|
|
279
|
-
{[1, 2].map(() => (
|
|
280
|
-
<Skeleton class="h-8 w-full rounded-lg" />
|
|
281
|
-
))}
|
|
282
|
-
</div>
|
|
283
|
-
</div>
|
|
284
|
-
|
|
285
|
-
{/* Main */}
|
|
286
|
-
<div class="flex-1 flex flex-col">
|
|
287
|
-
{/* Header */}
|
|
288
|
-
<div class="flex items-center justify-between px-4 py-3 border-b border-border">
|
|
289
|
-
<Skeleton class="h-4 w-48" />
|
|
290
|
-
<div class="flex gap-2">
|
|
291
|
-
<Skeleton class="h-8 w-28 rounded-lg" />
|
|
292
|
-
<Skeleton class="h-8 w-8 rounded-full" />
|
|
293
|
-
</div>
|
|
294
|
-
</div>
|
|
295
|
-
|
|
296
|
-
{/* Messages */}
|
|
297
|
-
<div class="flex-1 p-4 space-y-6 overflow-hidden">
|
|
298
|
-
<div class="flex justify-end">
|
|
299
|
-
<Skeleton class="h-10 w-52 rounded-3xl" />
|
|
300
|
-
</div>
|
|
301
|
-
<div class="flex gap-3 items-start">
|
|
302
|
-
<Skeleton class="h-8 w-8 rounded-full shrink-0" />
|
|
303
|
-
<div class="flex-1 space-y-2">
|
|
304
|
-
<Skeleton class="h-4 w-full" />
|
|
305
|
-
<Skeleton class="h-4 w-5/6" />
|
|
306
|
-
<Skeleton class="h-4 w-2/3" />
|
|
307
|
-
</div>
|
|
308
|
-
</div>
|
|
309
|
-
</div>
|
|
310
|
-
|
|
311
|
-
{/* Input */}
|
|
312
|
-
<div class="p-3">
|
|
313
|
-
<Skeleton class="h-14 w-full rounded-2xl" />
|
|
314
|
-
</div>
|
|
315
|
-
</div>
|
|
316
|
-
</div>
|
|
317
|
-
),
|
|
318
|
-
...src(`<div class="flex w-full max-w-4xl h-96 border rounded-xl overflow-hidden">
|
|
319
|
-
<div class="w-56 border-r p-3 space-y-3 shrink-0">
|
|
320
|
-
<Skeleton class="h-8 w-full rounded-lg" />
|
|
321
|
-
</div>
|
|
322
|
-
<div class="flex-1 flex flex-col">
|
|
323
|
-
<div class="flex-1 p-4 space-y-6">
|
|
324
|
-
<div class="flex gap-3 items-start">
|
|
325
|
-
<Skeleton class="h-8 w-8 rounded-full shrink-0" />
|
|
326
|
-
<div class="flex-1 space-y-2">
|
|
327
|
-
<Skeleton class="h-4 w-full" />
|
|
328
|
-
<Skeleton class="h-4 w-5/6" />
|
|
329
|
-
</div>
|
|
330
|
-
</div>
|
|
331
|
-
</div>
|
|
332
|
-
<div class="p-3">
|
|
333
|
-
<Skeleton class="h-14 w-full rounded-2xl" />
|
|
334
|
-
</div>
|
|
335
|
-
</div>
|
|
336
|
-
</div>`),
|
|
337
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
|
-
import { fn } from 'storybook/test';
|
|
3
|
-
import { Switch, type SwitchProps } from './switch';
|
|
4
|
-
import { componentDescription } from '../stories/docs/element-controls';
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
7
|
-
title: 'Solid (Advanced)/Primitives/Switch',
|
|
8
|
-
component: Switch,
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: 'padded',
|
|
12
|
-
docs: {
|
|
13
|
-
description: componentDescription([
|
|
14
|
-
'A toggle **switch** (`role="switch"`) for an immediate on/off setting, built on a native `<button>`.',
|
|
15
|
-
'**When to use:** a preference that applies the moment it flips — "Temporary chat", notifications, a feature flag. For a labelled choice submitted with a form, prefer a checkbox.',
|
|
16
|
-
'**How to use:** uncontrolled via `defaultChecked`, or controlled via `checked` + `onChange`. Operable with Space/Enter. Pass `label` for the accessible name.',
|
|
17
|
-
'**Placement:** settings rows, preference panels, and popover menus such as a chat header model menu.',
|
|
18
|
-
]),
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
argTypes: {
|
|
22
|
-
checked: { control: 'boolean', description: 'Controlled checked state. Drive it from `onChange`.' },
|
|
23
|
-
defaultChecked: { control: 'boolean', description: 'Initial state when uncontrolled.' },
|
|
24
|
-
disabled: { control: 'boolean', description: 'Disable interaction.' },
|
|
25
|
-
label: { control: 'text', description: 'Accessible label.' },
|
|
26
|
-
},
|
|
27
|
-
args: { label: 'Temporary chat', onChange: fn() },
|
|
28
|
-
} satisfies Meta<typeof Switch>;
|
|
29
|
-
|
|
30
|
-
export default meta;
|
|
31
|
-
type Story = StoryObj<typeof meta>;
|
|
32
|
-
|
|
33
|
-
/** Off by default; click or press Space to toggle. */
|
|
34
|
-
export const Playground: Story = {};
|
|
35
|
-
|
|
36
|
-
/** Starts on via `defaultChecked`. */
|
|
37
|
-
export const On: Story = { args: { defaultChecked: true } };
|
|
38
|
-
|
|
39
|
-
/** Non-interactive. */
|
|
40
|
-
export const Disabled: Story = { args: { disabled: true } };
|
|
41
|
-
|
|
42
|
-
/** The common shape: a labelled settings row with the switch trailing. */
|
|
43
|
-
export const SettingsRow: Story = {
|
|
44
|
-
name: 'In a settings row',
|
|
45
|
-
render: (args: SwitchProps) => (
|
|
46
|
-
<div style={{ display: 'flex', 'align-items': 'center', 'justify-content': 'space-between', gap: '2rem', width: '18rem' }}>
|
|
47
|
-
<span style={{ 'font-size': '14px' }}>Temporary chat</span>
|
|
48
|
-
<Switch {...args} />
|
|
49
|
-
</div>
|
|
50
|
-
),
|
|
51
|
-
};
|
package/src/ui/switch.test.tsx
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
2
|
-
import '@testing-library/jest-dom/vitest';
|
|
3
|
-
import { render, cleanup, fireEvent } from '@solidjs/testing-library';
|
|
4
|
-
import { Switch } from './switch';
|
|
5
|
-
|
|
6
|
-
afterEach(cleanup);
|
|
7
|
-
|
|
8
|
-
describe('Switch', () => {
|
|
9
|
-
it('renders a switch role, off by default', () => {
|
|
10
|
-
const { getByRole } = render(() => <Switch label="Temporary chat" />);
|
|
11
|
-
const sw = getByRole('switch');
|
|
12
|
-
expect(sw).toHaveAttribute('aria-checked', 'false');
|
|
13
|
-
expect(sw).toHaveAttribute('aria-label', 'Temporary chat');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('honours defaultChecked for the initial (uncontrolled) state', () => {
|
|
17
|
-
const { getByRole } = render(() => <Switch defaultChecked />);
|
|
18
|
-
expect(getByRole('switch')).toHaveAttribute('aria-checked', 'true');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('toggles on click and reports the new state', () => {
|
|
22
|
-
const onChange = vi.fn();
|
|
23
|
-
const { getByRole } = render(() => <Switch onChange={onChange} />);
|
|
24
|
-
const sw = getByRole('switch');
|
|
25
|
-
fireEvent.click(sw);
|
|
26
|
-
expect(sw).toHaveAttribute('aria-checked', 'true');
|
|
27
|
-
expect(onChange).toHaveBeenCalledWith(true);
|
|
28
|
-
fireEvent.click(sw);
|
|
29
|
-
expect(sw).toHaveAttribute('aria-checked', 'false');
|
|
30
|
-
expect(onChange).toHaveBeenLastCalledWith(false);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('toggles with the keyboard (Space / Enter)', () => {
|
|
34
|
-
const onChange = vi.fn();
|
|
35
|
-
const { getByRole } = render(() => <Switch onChange={onChange} />);
|
|
36
|
-
fireEvent.keyDown(getByRole('switch'), { key: ' ' });
|
|
37
|
-
expect(onChange).toHaveBeenCalledWith(true);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('is controlled when `checked` is set — defers state to the parent', () => {
|
|
41
|
-
const onChange = vi.fn();
|
|
42
|
-
const { getByRole } = render(() => <Switch checked={false} onChange={onChange} />);
|
|
43
|
-
const sw = getByRole('switch');
|
|
44
|
-
fireEvent.click(sw);
|
|
45
|
-
expect(onChange).toHaveBeenCalledWith(true);
|
|
46
|
-
// controlled: stays off until the parent flips `checked`
|
|
47
|
-
expect(sw).toHaveAttribute('aria-checked', 'false');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('does not toggle when disabled', () => {
|
|
51
|
-
const onChange = vi.fn();
|
|
52
|
-
const { getByRole } = render(() => <Switch disabled onChange={onChange} />);
|
|
53
|
-
const sw = getByRole('switch');
|
|
54
|
-
fireEvent.click(sw);
|
|
55
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
56
|
-
expect(sw).toHaveAttribute('aria-checked', 'false');
|
|
57
|
-
expect(sw).toBeDisabled();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
|
-
import type { JSX } from 'solid-js';
|
|
3
|
-
import { Textarea } from './textarea';
|
|
4
|
-
import { componentDescription } from '../stories/docs/element-controls';
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
7
|
-
title: 'Solid (Advanced)/Primitives/Textarea',
|
|
8
|
-
component: Textarea,
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: 'padded',
|
|
12
|
-
docs: {
|
|
13
|
-
description: componentDescription([
|
|
14
|
-
'A single-line-by-default textarea that auto-grows with its content up to an optional `maxHeight`, after which it scrolls. It is **transparent and borderless by design** — it is meant to drop into a composed input frame that owns the visual boundary and focus ring (the demos below wrap it exactly the way `PromptInput` / `<kai-prompt-input>` does, with `focus-within` on the frame). This is the editable surface behind `PromptInput`.',
|
|
15
|
-
'**When to use:** free-text entry that may span multiple lines — a chat composer, a comment box, an editable note.',
|
|
16
|
-
'**How to use:** drop it inside a framed container and use it like a native `<textarea>` (`value`, `placeholder`, `onInput`, …). Auto-resize is on by default; set `maxHeight` (px) to cap growth, or `autoResize={false}` for a fixed-height field.',
|
|
17
|
-
]),
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
argTypes: {
|
|
21
|
-
placeholder: { control: 'text', description: 'Placeholder text.' },
|
|
22
|
-
maxHeight: { control: 'number', description: 'Max height (px) before the field scrolls instead of growing.' },
|
|
23
|
-
autoResize: { control: 'boolean', description: 'Grow with content. Default true.' },
|
|
24
|
-
class: { control: 'text', description: 'Extra classes.' },
|
|
25
|
-
},
|
|
26
|
-
args: {
|
|
27
|
-
placeholder: 'Ask anything… (Shift+Enter for a newline)',
|
|
28
|
-
maxHeight: 200,
|
|
29
|
-
},
|
|
30
|
-
render: (args) => (
|
|
31
|
-
<Frame>
|
|
32
|
-
<Textarea {...args} class="focus-visible:ring-0" />
|
|
33
|
-
</Frame>
|
|
34
|
-
),
|
|
35
|
-
} satisfies Meta<typeof Textarea>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The composed input frame, mirroring how `PromptInput` wraps the textarea: the
|
|
39
|
-
* FRAME owns the boundary + focus ring (`focus-within`), and the transparent
|
|
40
|
-
* textarea inside has its own ring neutralized so there's no nested box.
|
|
41
|
-
*/
|
|
42
|
-
function Frame(props: { children: JSX.Element }) {
|
|
43
|
-
return (
|
|
44
|
-
<div class="w-96 cursor-text rounded-xl border border-border bg-muted/40 p-3 shadow-xs transition-shadow focus-within:border-ring focus-within:ring-2 focus-within:ring-ring">
|
|
45
|
-
{props.children}
|
|
46
|
-
</div>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default meta;
|
|
51
|
-
type Story = StoryObj<typeof meta>;
|
|
52
|
-
|
|
53
|
-
const IMPORT = `import { Textarea } from '@kitn.ai/ui';`;
|
|
54
|
-
const src = (code: string) => ({
|
|
55
|
-
parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
/** Type several lines — the field grows until `maxHeight`, then scrolls. Focus the field: the ring is on the frame, not a nested box. */
|
|
59
|
-
export const Playground: Story = {
|
|
60
|
-
...src(`{/* The frame owns the focus ring; the textarea's own ring is neutralized. */}
|
|
61
|
-
<div class="cursor-text rounded-xl border bg-muted/40 p-3 focus-within:ring-2 focus-within:ring-ring">
|
|
62
|
-
<Textarea placeholder="Ask anything…" maxHeight={200} class="focus-visible:ring-0" />
|
|
63
|
-
</div>`),
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/** A fixed-height field (auto-resize disabled). */
|
|
67
|
-
export const FixedHeight: Story = {
|
|
68
|
-
render: () => (
|
|
69
|
-
<Frame>
|
|
70
|
-
<Textarea autoResize={false} rows={4} placeholder="Fixed at 4 rows…" class="focus-visible:ring-0" />
|
|
71
|
-
</Frame>
|
|
72
|
-
),
|
|
73
|
-
...src(`<div class="cursor-text rounded-xl border bg-muted/40 p-3 focus-within:ring-2 focus-within:ring-ring">
|
|
74
|
-
<Textarea autoResize={false} rows={4} placeholder="Fixed at 4 rows…" class="focus-visible:ring-0" />
|
|
75
|
-
</div>`),
|
|
76
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
|
-
import { Tooltip } from './tooltip';
|
|
3
|
-
import { Button } from './button';
|
|
4
|
-
import { componentDescription } from '../stories/docs/element-controls';
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
7
|
-
title: 'Solid (Advanced)/Primitives/Tooltip',
|
|
8
|
-
component: Tooltip,
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: 'padded',
|
|
12
|
-
docs: {
|
|
13
|
-
description: componentDescription([
|
|
14
|
-
'A small floating label that appears on hover/focus of its trigger element, built with a DIY overlay-core implementation (no third-party dependency, no arrow).',
|
|
15
|
-
'**When to use:** to clarify the purpose of icon-only buttons or terse controls — short, supplementary hints that are not essential to complete the action.',
|
|
16
|
-
'**How to use:** wrap a single interactive `children` element and set `content` to the hint text. The child becomes the trigger.',
|
|
17
|
-
'**Placement:** toolbars, message action rows, and any compact icon control where a label would not otherwise fit.',
|
|
18
|
-
]),
|
|
19
|
-
controls: { exclude: ['use:eventListener'] },
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
argTypes: {
|
|
23
|
-
content: {
|
|
24
|
-
control: 'text',
|
|
25
|
-
description: 'Text shown inside the tooltip bubble.',
|
|
26
|
-
},
|
|
27
|
-
children: {
|
|
28
|
-
control: false,
|
|
29
|
-
description: 'The trigger element the tooltip is attached to.',
|
|
30
|
-
},
|
|
31
|
-
class: {
|
|
32
|
-
control: 'text',
|
|
33
|
-
description: 'Extra classes applied to the tooltip content bubble.',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
args: {
|
|
37
|
-
content: 'This is a tooltip',
|
|
38
|
-
children: <Button variant="outline">Hover me</Button>,
|
|
39
|
-
},
|
|
40
|
-
render: (args) => <Tooltip {...args} />,
|
|
41
|
-
} satisfies Meta<typeof Tooltip>;
|
|
42
|
-
|
|
43
|
-
export default meta;
|
|
44
|
-
type Story = StoryObj<typeof meta>;
|
|
45
|
-
|
|
46
|
-
const IMPORT = `import { Tooltip } from '@kitn.ai/ui';`;
|
|
47
|
-
const src = (code: string) => ({
|
|
48
|
-
parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
/** Interactive playground — set the tooltip text and hover the trigger. */
|
|
52
|
-
export const Playground: Story = {
|
|
53
|
-
...src(`<Tooltip content="This is a tooltip">
|
|
54
|
-
<Button variant="outline">Hover me</Button>
|
|
55
|
-
</Tooltip>`),
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const OnIconButton: Story = {
|
|
59
|
-
render: () => (
|
|
60
|
-
<Tooltip content="Add new item">
|
|
61
|
-
<Button variant="ghost" size="icon-sm" aria-label="Add new item">
|
|
62
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
63
|
-
<line x1="12" y1="5" x2="12" y2="19" />
|
|
64
|
-
<line x1="5" y1="12" x2="19" y2="12" />
|
|
65
|
-
</svg>
|
|
66
|
-
</Button>
|
|
67
|
-
</Tooltip>
|
|
68
|
-
),
|
|
69
|
-
...src(`<Tooltip content="Add new item">
|
|
70
|
-
<Button variant="ghost" size="icon-sm">
|
|
71
|
-
<PlusIcon />
|
|
72
|
-
</Button>
|
|
73
|
-
</Tooltip>`),
|
|
74
|
-
};
|