import { useField, type FieldName } from "@conform-to/react/future"; import { Field, type FieldProps } from "../field/Field"; import { RadioWithLegend } from "./Radio"; import clsx from "clsx"; import type { ReactNode } from "react"; export type RadioWithLegendOption = { label: string; value: T; children: ReactNode; }; interface Props extends Omit { name: FieldName; options: readonly RadioWithLegendOption[]; labelClassName?: string; } export function RadiosWithLegendField({ name, options, className, labelClassName, id: forcedId, ...rest }: Props) { const field = useField(name); const id = forcedId ?? field.id; return (
{options.map((option) => ( {option.children} ))}
); }