import { forwardRef, useState } from 'react' import { Button } from '../../Button/index' import { ButtonType, ButtonSize } from '../../Button/types' import ChatInput from '../ChatInput' import { chatInputAccessibilityReport } from './ChatInputAccessibilityReport' import { generateAccessibilityReport, downloadReport, getMimeType, getFileExtension, type ReportFormat, } from '../../shared/accessibility/reportGenerator' import { Download as DownloadIcon } from 'lucide-react' import type { AttachedFile, TopQuery } from '../types' export type ChatInputAccessibilityProps = { className?: string } const ChatInputAccessibility = forwardRef< HTMLDivElement, ChatInputAccessibilityProps >(({ className }, ref) => { const [selectedFormat, setSelectedFormat] = useState('markdown') const [includeTestResults, setIncludeTestResults] = useState(true) const [includeRecommendations, setIncludeRecommendations] = useState(true) const [reportHtmlContent, setReportHtmlContent] = useState( null ) const [showFullReport, setShowFullReport] = useState(false) const [message, setMessage] = useState('') const [attachedFiles, setAttachedFiles] = useState([]) const [topQueries] = useState([ { id: '1', text: 'What is the status of my order?' }, { id: '2', text: 'How do I return an item?' }, { id: '3', text: 'Where is my package?' }, { id: '4', text: 'How do I cancel my subscription?' }, ]) const handleDownload = () => { try { const content = generateAccessibilityReport( chatInputAccessibilityReport, { format: selectedFormat, includeTestResults, includeRecommendations, } ) const filename = `chatinput-accessibility-report-${chatInputAccessibilityReport.reportDate}.${getFileExtension(selectedFormat)}` const mimeType = getMimeType(selectedFormat) downloadReport(content, filename, mimeType) } catch (error) { console.error('Error generating report:', error) alert('Failed to generate report. Please try again.') } } const handleViewReport = () => { try { const htmlContent = generateAccessibilityReport( chatInputAccessibilityReport, { format: 'html', includeTestResults, includeRecommendations, } ) setReportHtmlContent(htmlContent) setShowFullReport(true) } catch (error) { console.error('Error generating report:', error) alert('Failed to generate report. Please try again.') } } const handleAttachFiles = (files: File[]) => { const newFiles: AttachedFile[] = files.map((file, index) => ({ id: `file-${Date.now()}-${index}`, name: file.name, type: file.type.startsWith('image/') ? 'image' : file.type === 'application/pdf' ? 'pdf' : file.type === 'text/csv' || file.name.endsWith('.csv') ? 'csv' : file.type.startsWith('text/') ? 'text' : 'other', size: file.size, })) setAttachedFiles([...attachedFiles, ...newFiles]) } const handleFileRemove = (fileId: string) => { setAttachedFiles(attachedFiles.filter((f) => f.id !== fileId)) } const handleTopQuerySelect = (query: TopQuery) => { setMessage(query.text) } const report = chatInputAccessibilityReport const compliantCount = report.criteria.filter( (c) => c.status === 'compliant' ).length const nonCompliantCount = report.criteria.filter( (c) => c.status === 'non-compliant' ).length const unsureCount = report.criteria.filter( (c) => c.status === 'unsure' ).length const totalApplicable = report.criteria.filter( (c) => c.status !== 'not-applicable' ).length const complianceRate = totalApplicable > 0 ? Math.round((compliantCount / totalApplicable) * 100) : 0 return (

ChatInput Component Accessibility

WCAG {report.wcagVersion} • {report.conformanceLevel} • {report.reportDate}
Evaluates: WCAG 2.0, 2.1, 2.2

Download Report

{/* Summary Cards */}
{compliantCount}
Compliant ✅
Verified & tested
{nonCompliantCount}
Non-Compliant ❌
Issues found
{unsureCount}
Unsure ⚠️
Needs verification
{complianceRate}%
Compliance Rate
Based on verified items
{/* Full Report Viewer */} {showFullReport && reportHtmlContent && (

Full Accessibility Report

Interactive HTML report (same as downloaded version)