import { c, classy, m, RadioProps as BaseProps } from '@onfido/castor';
import { useField } from '@onfido/castor-react';
import React, { useMemo } from 'react';
import { IndicatorContainer, splitContainerProps } from '../../internal';
import { withRef } from '../../utils';
export const Radio = withRef(function Radio(
{
id: initialId,
bordered,
invalid,
children,
className,
style,
...restProps
}: RadioProps,
ref: RadioProps['ref']
) {
const { disabled, touched } = useField();
const id = useMemo(
() => initialId || `castor_radio_${++idCount}`,
[initialId]
);
const [containerProps, inputProps] = splitContainerProps(restProps);
return (
{{
children,
input: (
),
}}
);
});
export type RadioProps = BaseProps &
Omit & {
id?: string; // id is now optional
};
type InputElementProps = JSX.IntrinsicElements['input'];
let idCount = 0;