import React, { ReactNode, useContext } from "react"; import classNames from "classnames"; import { useId } from "@reach/auto-id"; import { Box } from "../Box"; import { Stack, StackProps } from "../Stack"; import { Input, InputProps } from "../Input"; import { Label } from "../Label"; import { Text } from "../Text"; import { bem } from "../../utilities/bem"; import isUndefined from "../../utilities/isUndefined"; import { ORIENTATION } from "../../types"; import { FormGroupContext } from "../FormGroup/FormGroupContext"; const cn = "Radio"; interface RadioProps extends InputProps { label: ReactNode; isLabelHidden?: boolean; } const RadioGroup = (props: StackProps) => { const { orientation = ORIENTATION.VERTICAL, ...rest } = props; return ; }; export const Radio = (props: RadioProps) => { const { label, id: idProp, checked, disabled, className, defaultValue, isLabelHidden = false, theme: themeProp, ...rest } = props; const fallbackId = `radio:${useId()}`; const id = isUndefined(idProp) ? fallbackId : idProp; const { theme: themeContext } = useContext(FormGroupContext); const theme = themeProp || themeContext; const checkboxWrapClassname = classNames( bem(`${cn}Wrap`), disabled && bem(`${cn}Wrap`, { m: "isDisabled" }), isLabelHidden && bem(`${cn}Wrap`, { m: "isLabelHidden" }), className, ); return ( ); }; Radio.Group = RadioGroup;