import type { ButtonGroupOption, } from '@ska/components' import type { RadioProps, } from '.' export const buildOptions = (options: RadioProps['options']): ButtonGroupOption[] => { /** Convert Map to label/value objects. */ if(options instanceof Map) { return [...options].map(([key, value]) => ({ label: key, tooltip: value, value: key, })) } /** Convert plain array of options to label/value objects. */ return Array.isArray(options) && options.length > 0 ? ( Object(options[0]).hasOwnProperty('label') ? options as ButtonGroupOption[] : (options as string[]).map(option => ({label: option, value: option})) ) : [] }