import type { Meta, StoryObj } from 'storybook-solidjs-vite'; import './register'; // side effect: registers the custom elements import { argTypesFor, specDescription } from '../stories/docs/element-controls'; // The web components are custom DOM elements, so declare the tags for JSX. declare module 'solid-js' { // eslint-disable-next-line @typescript-eslint/no-namespace namespace JSX { interface IntrinsicElements { 'kc-thinking-bar': JSX.HTMLAttributes & { text?: string; stoppable?: boolean | string; 'stop-label'?: string; 'on:kc-stop'?: (e: CustomEvent) => void; }; } } } const HTML_SNIPPET = ` `; const meta = { title: 'Components/ThinkingBar', tags: ['autodocs'], argTypes: argTypesFor('kc-thinking-bar'), parameters: { layout: 'fullscreen', docs: { description: specDescription('kc-thinking-bar', [ '`` is the framework-agnostic **web component** for an animated "thinking" indicator with an optional stop affordance — a pure leaf element isolated in **Shadow DOM**. (`` does not surface this; compose it yourself.)', '**When to use:** showing that the assistant is reasoning, optionally letting the user interrupt with "Answer now". In SolidJS, use the `ThinkingBar` primitive.', "**How to use:** register once with `import '@kitn.ai/chat/elements'`, set the `text`/`stop-label` attributes, add the `stoppable` flag to show the stop button, and listen for the `kc-stop` **CustomEvent**.", 'See the **Code** tab for HTML usage.', ]), }, }, } satisfies Meta; export default meta; type Story = StoryObj; /** A plain thinking indicator. */ export const Default: Story = { render: () => (
), parameters: { docs: { source: { code: HTML_SNIPPET, language: 'html' } } }, }; /** Stoppable — shows an "Answer now" affordance that fires a `stop` event. */ export const Stoppable: Story = { render: () => (
console.log('stop')} />
), };