import type { Meta, StoryObj } from '@storybook/react-vite'; import { useState } from 'react'; import { RichTextInput, MentionItem, SlashCommandItem } from 'reachat'; import { ChatContext } from 'reachat'; import { chatTheme } from 'reachat'; const UserIcon = () => ( ); const HelpIcon = () => ( ); const ClearIcon = () => ( ); const ImageIcon = () => ( ); const CodeIcon = () => ( ); const sampleMentions: MentionItem[] = [ { id: '1', label: 'John Doe', description: 'Engineering', icon: }, { id: '2', label: 'Jane Smith', description: 'Design', icon: }, { id: '3', label: 'Bob Wilson', description: 'Product', icon: } ]; const sampleCommands: SlashCommandItem[] = [ { id: 'help', label: 'help', description: 'Show available commands', icon: , shortcut: '?' }, { id: 'clear', label: 'clear', description: 'Clear the conversation', icon: }, { id: 'image', label: 'image', description: 'Generate an image', icon: }, { id: 'code', label: 'code', description: 'Generate code snippet', icon: } ]; const Wrapper = ({ children }: { children: React.ReactNode }) => ( {children} ); export default { title: 'Components/RichTextInput', component: RichTextInput, decorators: [ (Story) => ( ) ], parameters: { layout: 'centered' } } as Meta; type Story = StoryObj; export const Basic: Story = { render: () => { const [value, setValue] = useState(''); const [submitted, setSubmitted] = useState(''); return (
{ setSubmitted(text); setValue(''); }} />
onChange: {value || '(empty)'}
onSubmit: {submitted || '(press Enter to submit)'}
); } }; export const WithMentions: Story = { render: () => { const [value, setValue] = useState(''); const [submitted, setSubmitted] = useState(''); return (
{ setSubmitted(text); setValue(''); }} />
onChange: {value || '(empty)'}
onSubmit: {submitted || '(press Enter to submit)'}
); } }; export const WithSlashCommands: Story = { render: () => { const [value, setValue] = useState(''); const [submitted, setSubmitted] = useState(''); return (
{ setSubmitted(text); setValue(''); }} />
onChange: {value || '(empty)'}
onSubmit: {submitted || '(press Enter to submit)'}
); } };