import styles from '@components/RadioButton.module.css'; import * as React from 'react'; import * as Utilities from '@common/utilities'; interface RadioButtonProps { style?: React.CSSProperties; name: string; value: string; selected?: boolean; onSelect?: (value: string) => void; children?: React.ReactNode; } const RadioButton: React.FC = ({ style, name, value, selected = false, onSelect, children }) => { const radioId = `${name}-${value}-radio`; const [isFocused, setIsFocused] = React.useState(false); const handleFocus = () => setIsFocused(true); const handleBlur = () => setIsFocused(false); const handleKeyDown = (event: React.KeyboardEvent) => { switch (event.key) { case 'Enter': event.preventDefault(); onSelect?.(value); break; case 'ArrowUp': case 'ArrowLeft': event.preventDefault(); Utilities.findNextFocusable(document.activeElement, 'previous')?.focus(); break; case 'Tab': case 'ArrowDown': case 'ArrowRight': event.preventDefault(); Utilities.findNextFocusable(document.activeElement, 'next')?.focus(); break; default: break; } }; const handleChange = () => { onSelect?.(value); }; return (
  {children}
); }; export default RadioButton;