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