import type { Meta, StoryObj } from 'storybook-solidjs-vite'; import { Source, SourceTrigger, SourceContent, SourceList } from './source'; import { componentDescription } from '../stories/docs/element-controls'; const meta = { title: 'Solid (Advanced)/Elements/Source', component: Source, tags: ['autodocs'], parameters: { layout: 'padded', docs: { description: componentDescription([ 'An inline citation chip with a hover-card preview. Compose `Source` (root, holds the `href`) with `SourceTrigger` (the clickable pill) and `SourceContent` (the hover preview). `SourceList` lays out several side by side.', '**When to use:** to cite a referenced web source inline in an assistant message — show a compact domain/number pill that previews the title and description on hover.', '**How to use:** wrap `SourceTrigger` and `SourceContent` in `Source` with the target `href`. Use `label` for custom text or a citation number, `showFavicon` for the site icon, and pass `title`/`description` to `SourceContent`.', '**Placement:** within message body text as citations, or grouped under a message in a `SourceList`.', ]), controls: { exclude: ['use:eventListener'] }, }, }, argTypes: { href: { control: 'text', description: 'Target URL of the source. The domain is derived from it for the default label.', }, children: { control: false, description: 'Trigger and content composition.' }, }, args: { href: 'https://solidjs.com/docs/basic-reactivity/signals', }, render: (args) => ( ), } satisfies Meta; export default meta; type Story = StoryObj; const IMPORT = `import { Source, SourceTrigger, SourceContent, SourceList } from '@kitn.ai/chat';`; const src = (code: string) => ({ parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } }, }); /** Interactive playground — set the `href` and hover the chip to preview. */ export const Playground: Story = { ...src(` `), }; /** Trigger shows the site favicon and derives its label from the domain. */ export const WithFavicon: Story = { render: () => ( ), ...src(` `), }; /** A numbered citation chip. */ export const NumberedCitation: Story = { render: () => ( ), ...src(` `), }; /** Several sources laid out together with `SourceList` (showcase). */ export const SourceListExample: Story = { name: 'Source list', render: () => ( ), ...src(` `), };