import React from 'react'; export interface ButtonGroupProps { /** * A function that will run after the input has changed, it will return the value of the input for you to use in the parent component. */ callback: any; /** * If true, will show an (optional) tag next to the title. If false or not supplied, nothing will show. */ optional: boolean; /** * Id for the radios */ id: string; /** * An array of items to display on each button => [title, value, active, showRadio] */ options: { title: any; value: string; active: boolean; showRadio: boolean; sr?: string; }[]; /** * If true, will show an * next to the title. If false or not supplied, nothing will show. */ required: boolean; /** * Classes to be added to the wrapping label. */ theme: string; /** * The label text title of the input. */ title: string; ariaExpanded?: boolean; ariaControls?: string; } const ButtonGroup = ({ callback, id = 'bg-radio', optional = false, options, required = false, theme = 'w-full h-auto', title, ariaControls, ariaExpanded = false, }: ButtonGroupProps) => { return (
{title && {title}} {(required === true || optional === true) && ( {required === true && ( {'*'} )} {optional === true && ( {'(optional)'} )} )} {options.map((option, index) => { if (!option.title) return false; return ( ); })}
); }; export default ButtonGroup;