import React from "react"; import { Field, Label, Radio, RadioGroup } from "@headlessui/react"; // helpers import { cn } from "@/helpers/common.helper"; type RadioInputProps = { label: string | React.ReactNode | undefined; labelClassName?: string; ariaLabel?: string; options: { label: string; value: string; disabled?: boolean }[]; vertical?: boolean; selected: string; onChange: (value: string) => void; className?: string; }; const RadioInput = ({ label: inputLabel, labelClassName: inputLabelClassName, options, vertical, selected, ariaLabel, onChange, className, }: RadioInputProps) => { const wrapperClass = vertical ? "flex flex-col gap-1" : "flex gap-2"; const setSelected = (value: string) => { onChange(value); }; let aria = ariaLabel ? ariaLabel.toLowerCase().replace(" ", "-") : ""; if (!aria && typeof inputLabel === "string") { aria = inputLabel.toLowerCase().replace(" ", "-"); } else { aria = "radio-input"; } return (
{options.map(({ value, label, disabled }) => ( ))}
); }; export { RadioInput };