Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import React from "react"; import RadioComponent from "../RadioComponent/index.tsx"; // Adjust the path as needed import { randomString } from "../../../utils/common/randomString.js"; interface RadioGroupProps { label?: string; options: { label: string; name?: string; disabled?: boolean; value?: string; help?: string; info?: string; isSmall?: boolean; }[]; onChange: (value: string) => void; orientation?: "horizontal" | "vertical"; checked: string; groupName?: string; } const RadioGroup: React.FC<RadioGroupProps> = ({ label, options, onChange, orientation = "horizontal", checked, groupName = randomString(), }) => { const renderOptions = () => { return options.map(({ label, isSmall, value = label, help, info }) => { const checkedValue = checked === value; const shortenedOptionLabel = label.replace(/\s+/g, ""); const optionId = `radio-option-${shortenedOptionLabel}`; return ( <RadioComponent id={`${optionId}-${groupName}`} label={label} key={optionId} isChecked={checkedValue} onChange={() => onChange(value)} isSmall={isSmall ?? false} help={help} info={info} /> ); }); }; return ( <div className="flex flex-col"> {label && <div className="mb-2 text-base font-semibold">{label}</div>} <div className={`flex ${ orientation === "horizontal" ? "flex-row space-x-4" : "flex-col space-y-[2px]" }`}> {renderOptions()} </div> </div> ); }; export default RadioGroup; |