"use client"; import React, { memo, useCallback } from "react"; import RadioButton from "./RadioButton"; const RadioGroup = ({ name, value, onChange, mode = "standard", state = "default", disabled = false, options = [], className = "", ...props }) => { // Generate unique ID for accessibility if not provided const groupId = name || `radio-group-${Math.random().toString(36).substr(2, 9)}`; const handleChange = useCallback( (optionValue) => { if (!disabled && onChange) { onChange({ value: optionValue }); } }, [disabled, onChange] ); return (
{options.map((option, index) => { const isSelected = value === option.value; return ( { if (checked) { handleChange(option.value); } }} /> ); })}
); }; RadioGroup.displayName = "RadioGroup"; export default memo(RadioGroup);