({
onLabel,
offLabel,
value,
onToggle,
...props
}: ToggleRadioProps<T>)
| 22 | } |
| 23 | |
| 24 | export function ToggleRadio<T extends string = string>({ |
| 25 | onLabel, |
| 26 | offLabel, |
| 27 | value, |
| 28 | onToggle, |
| 29 | ...props |
| 30 | }: ToggleRadioProps<T>): ReactElement { |
| 31 | const options = [ |
| 32 | { label: offLabel, value: 'off' }, |
| 33 | { label: onLabel, value: 'on' }, |
| 34 | ]; |
| 35 | const selectedValue = value ? 'on' : 'off'; |
| 36 | |
| 37 | const onChange = (newValue: T) => { |
| 38 | onToggle?.(newValue === 'on'); |
| 39 | }; |
| 40 | |
| 41 | return ( |
| 42 | <Radio |
| 43 | {...props} |
| 44 | options={options} |
| 45 | value={selectedValue} |
| 46 | onChange={onChange} |
| 47 | /> |
| 48 | ); |
| 49 | } |
nothing calls this directly
no outgoing calls
no test coverage detected