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