/* Copyright 2024 New Vector Ltd. Copyright 2020 The Matrix.org Foundation C.I.C. SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE files in the repository root for full details. */ import React, { type JSX, type ChangeEvent, type ReactNode } from "react"; import classNames from "classnames"; import StyledRadioButton from "./StyledRadioButton"; export interface IDefinition { value: T; className?: string; disabled?: boolean; label: ReactNode; description?: ReactNode; checked?: boolean; // If provided it will override the value comparison done in the group } interface IProps { name: string; className?: string; definitions: IDefinition[]; value?: T; // if not provided no options will be selected outlined?: boolean; disabled?: boolean; onChange(this: void, newValue: T): void; } function StyledRadioGroup({ name, definitions, value, className, outlined, disabled, onChange, }: IProps): JSX.Element { const _onChange = (e: ChangeEvent): void => { onChange(e.target.value as T); }; return ( {definitions.map((d) => { const id = `${name}-${d.value}`; return ( {d.label} {d.description ? {d.description} : null} ); })} ); } export default StyledRadioGroup;