import { useEffect, useState } from 'react'; import clsx from 'clsx'; import { ChevronUp, ChevronRight, Edit } from 'lucide-react'; import { Button } from '@@/buttons'; import { FormError } from '@@/form-components/FormError'; export type Props = { onChange: (value: string) => void; defaultIsOpen?: boolean; value?: string; labelClass?: string; inputClass?: string; isRequired?: boolean; minLength?: number; isExpandable?: boolean; }; export function Note({ onChange, defaultIsOpen, value, labelClass = 'col-sm-12 mb-2', inputClass = 'col-sm-12', isRequired, minLength, isExpandable, }: Props) { const [isNoteOpen, setIsNoteOpen] = useState(defaultIsOpen || isRequired); useEffect(() => { setIsNoteOpen(defaultIsOpen || isRequired); }, [defaultIsOpen, isRequired]); let error = ''; if (isRequired && minLength && (!value || value.length < minLength)) { error = `You have entered ${value ? value.length : 0} of the ${minLength} ${ minLength === 1 ? 'character' : 'characters' } minimum required.`; } return (