import { forwardRef, useState } from 'react' import { Button } from '../../../Button' import { ButtonType, ButtonSize } from '../../../Button/types' import DropdownInput from '../DropdownInput' import { DropdownPosition } from '../types' import { dropdownInputAccessibilityReport } from './DropdownInputAccessibilityReport' import { generateAccessibilityReport, downloadReport, getMimeType, getFileExtension, type ReportFormat, } from '../../../shared/accessibility/reportGenerator' import { Download as DownloadIcon, Globe, MapPin, Phone } from 'lucide-react' import { TextInputSize } from '../../TextInput' // Sample dropdown data const countryData = [ { groupLabel: 'Popular', items: [ { label: 'United States', value: 'US' }, { label: 'United Kingdom', value: 'UK' }, { label: 'Canada', value: 'CA' }, ], }, { groupLabel: 'All Countries', items: [ { label: 'Australia', value: 'AU' }, { label: 'France', value: 'FR' }, { label: 'Germany', value: 'DE' }, { label: 'India', value: 'IN' }, { label: 'Japan', value: 'JP' }, ], }, ] const currencyData = [ { groupLabel: 'Major Currencies', items: [ { label: 'USD', value: 'USD' }, { label: 'EUR', value: 'EUR' }, { label: 'GBP', value: 'GBP' }, ], }, ] const phoneCodeData = [ { groupLabel: 'Country Codes', items: [ { label: '+1', value: '+1' }, { label: '+44', value: '+44' }, { label: '+91', value: '+91' }, ], }, ] export type DropdownInputAccessibilityProps = { className?: string } const DropdownInputAccessibility = forwardRef< HTMLDivElement, DropdownInputAccessibilityProps >(({ 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) // Demo state const [phoneNumber, setPhoneNumber] = useState('') const [countryCode, setCountryCode] = useState('') const [address, setAddress] = useState('') const [country, setCountry] = useState('') const [currency, setCurrency] = useState('') const [disabledValue] = useState('This field is disabled') const [disabledDropdown] = useState('') const phoneError = phoneNumber.length > 0 && phoneNumber.length < 10 ? 'Please enter a valid phone number (at least 10 digits)' : '' const handleDownload = () => { try { const content = generateAccessibilityReport( dropdownInputAccessibilityReport, { format: selectedFormat, includeTestResults, includeRecommendations, } ) const filename = `dropdowninput-accessibility-report-${dropdownInputAccessibilityReport.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( dropdownInputAccessibilityReport, { 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 report = dropdownInputAccessibilityReport 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 (

DropdownInput Component Accessibility

WCAG {report.wcagVersion} • {report.conformanceLevel} • {report.reportDate}
Evaluates: WCAG 2.0, 2.1, 2.2
{/* Download Options */}

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)