'use client'; import type * as React from 'react'; import { Loader2, Mic, MicOff } from 'lucide-react'; import type { CSSProperties, ReactNode } from 'react'; import { cn } from '@djangocfg/ui-core/lib'; import type { RecognitionStatus } from '../types'; export interface DictationButtonProps { status: RecognitionStatus; onClick: () => void; isSupported?: boolean; size?: 'sm' | 'md' | 'lg'; className?: string; style?: CSSProperties; ariaLabel?: string; /** Override icon for the idle state. */ idleIcon?: ReactNode; /** Override icon for the listening state. */ listeningIcon?: ReactNode; /** Disable without unmounting. */ disabled?: boolean; } const SIZE_CLS: Record, string> = { sm: 'h-8 w-8 [&_svg]:h-4 [&_svg]:w-4', md: 'h-10 w-10 [&_svg]:h-5 [&_svg]:w-5', lg: 'h-12 w-12 [&_svg]:h-6 [&_svg]:w-6', }; /** * Round microphone button. Cycles icon by status; shows a soft pulse * ring when listening. ARIA-correct so screen readers announce * "recording" vs "start dictation". */ export function DictationButton({ status, onClick, isSupported = true, size = 'md', className, style, ariaLabel, idleIcon, listeningIcon, disabled, }: DictationButtonProps): React.ReactElement { const listening = status === 'listening' || status === 'starting'; const stopping = status === 'stopping'; const off = !isSupported; return ( ); }