import React, { InputHTMLAttributes, PropsWithChildren, useEffect, useRef, useState, } from "react"; import classNames from "classnames"; import { Field, FieldProps } from "components/Forms/Field"; type Props = InputHTMLAttributes & FieldProps & { indeterminate?: boolean; label?: string; }; export const Checkbox = ({ indeterminate, className = "", checked, label, text, rightText, state, ...props }: Props) => { const inputRef = useRef(null); const [value, setValue] = useState(!!checked); useEffect(() => { setValue(!!checked); }, [checked]); useEffect(() => { if (inputRef.current) { inputRef.current.indeterminate = !!indeterminate; } }, [indeterminate]); return ( setValue(e.target.checked)} {...props} checked={value} ref={inputRef} /> {label && {label}} ); }; export const CheckboxGroup = ({ children, state, text, rightText, }: PropsWithChildren & FieldProps) => { return ( {children} ); }; const Checkmark = () => ( ); const Indeterminate = () => ( );