'use client'; import { LegacyRef } from 'react'; import { experimental_useFormStatus as useFormStatus } from 'react-dom'; import Spinner from './Spinner'; import { cc } from '@/utility/css'; export default function FieldSetWithStatus({ id, label, note, value, onChange, selectOptions, selectOptionsDefaultLabel, placeholder, loading, required, readOnly, type = 'text', inputRef, }: { id: string label: string note?: string value: string onChange?: (value: string) => void selectOptions?: { value: string, label: string }[] selectOptionsDefaultLabel?: string placeholder?: string loading?: boolean required?: boolean readOnly?: boolean type?: 'text' | 'email' | 'password' | 'checkbox' inputRef?: LegacyRef }) { const { pending } = useFormStatus(); return (
{selectOptions ? : onChange?.(type === 'checkbox' ? e.target.value === 'true' ? 'false' : 'true' : e.target.value)} type={type} autoComplete="off" readOnly={readOnly || pending} className={cc(type === 'text' && 'w-full')} />}
); };