import { ToggleGroupControl, ToggleGroupControlOption } from '../../../../components/ui/toggle-group-control'; type Choice = 'unset' | 'yes' | 'no'; // A switch has no "not set" position, so an untouched one was saved as an authored No. export const booleanInitialChoice = (value: unknown): Choice => value === true ? 'yes' : value === false ? 'no' : 'unset'; export const booleanInitialValue = (choice: string): boolean | null => choice === 'yes' ? true : choice === 'no' ? false : null; interface BooleanInitialControlProps { value: unknown; onChange: (value: boolean | null) => void; disabled?: boolean; } const BooleanInitialControl = ({ value, onChange, disabled }: BooleanInitialControlProps) => ( onChange(booleanInitialValue(choice))} isBlock disabled={disabled} > ); export default BooleanInitialControl;