"use client"; import { composeRefs } from "@radix-ui/react-compose-refs"; import { mergeProps } from "@seed-design/dom-utils"; import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive"; import type * as React from "react"; import { forwardRef } from "react"; import { useRadioGroup, type RadioItemProps, type UseRadioGroupProps } from "./useRadioGroup"; import { RadioGroupProvider, useRadioGroupContext } from "./useRadioGroupContext"; import { RadioGroupItemProvider, useRadioGroupItemContext } from "./useRadioGroupItemContext"; export interface RadioGroupRootProps extends UseRadioGroupProps, PrimitiveProps, Omit, "defaultValue"> {} export const RadioGroupRoot = forwardRef((props, ref) => { const { value, defaultValue, onValueChange, form, name, disabled, invalid, ...otherProps } = props; const api = useRadioGroup({ value, defaultValue, onValueChange, form, name, disabled, invalid, }); const mergedProps = mergeProps(api.rootProps, otherProps); return ( ); }); RadioGroupRoot.displayName = "RadioGroupRoot"; export interface RadioGroupLabelProps extends PrimitiveProps, React.HTMLAttributes {} export const RadioGroupLabel = forwardRef((props, ref) => { const { refs, labelProps } = useRadioGroupContext(); const mergedProps = mergeProps(labelProps, props); return ; }); RadioGroupLabel.displayName = "RadioGroupLabel"; export interface RadioGroupItemProps extends RadioItemProps, PrimitiveProps, Omit, "value"> {} export const RadioGroupItem = forwardRef((props, ref) => { const { value, disabled, ...otherProps } = props; const { getItemProps } = useRadioGroupContext(); const itemProps = getItemProps({ value, disabled }); const mergedProps = mergeProps(itemProps.rootProps, otherProps); return ( ); }); RadioGroupItem.displayName = "RadioGroupItem"; export interface RadioGroupItemControlProps extends PrimitiveProps, React.HTMLAttributes {} export const RadioGroupItemControl = forwardRef( (props, ref) => { const { controlProps } = useRadioGroupItemContext(); const mergedProps = mergeProps(controlProps, props); return ; }, ); RadioGroupItemControl.displayName = "RadioGroupItemControl"; export interface RadioGroupItemHiddenInputProps extends PrimitiveProps, React.InputHTMLAttributes {} export const RadioGroupItemHiddenInput = forwardRef< HTMLInputElement, RadioGroupItemHiddenInputProps >((props, ref) => { const { hiddenInputProps } = useRadioGroupItemContext(); const mergedProps = mergeProps(hiddenInputProps, props); return ; }); RadioGroupItemHiddenInput.displayName = "RadioGroupItemHiddenInput"; export interface RadioGroupDescriptionProps extends PrimitiveProps, React.HTMLAttributes {} export const RadioGroupDescription = forwardRef( (props, ref) => { const { refs, descriptionProps } = useRadioGroupContext(); const mergedProps = mergeProps(descriptionProps, props); return ; }, ); RadioGroupDescription.displayName = "RadioGroupDescription"; export interface RadioGroupErrorMessageProps extends PrimitiveProps, React.HTMLAttributes {} export const RadioGroupErrorMessage = forwardRef( (props, ref) => { const { refs, errorMessageProps } = useRadioGroupContext(); const mergedProps = mergeProps(errorMessageProps, props); return ; }, ); RadioGroupErrorMessage.displayName = "RadioGroupErrorMessage";