'use client'; import { useState, type FormEvent } from 'react'; /** A file's password, asked where the file is shown; `purpose` says what it opens the file for. */ export function UnlockForm({ state, name, purpose, onUnlock, }: { state: { readonly incorrect: boolean; readonly trying: boolean }; name: string; purpose: string; onUnlock: (password: string) => void; }) { const [password, setPassword] = useState(''); const submit = (event: FormEvent) => { event.preventDefault(); if (password) onUnlock(password); }; return (
{purpose} setPassword(event.target.value)} autoComplete="off" aria-label={`Password for ${name}`} aria-invalid={state.incorrect} placeholder="Password" className={`h-9 w-[min(200px,100%)] rounded-lg border bg-white px-2.5 font-sans text-sm outline-none ${ state.incorrect ? 'border-[#B42318]' : 'border-ep-border focus:border-ep-blue' }`} /> {state.incorrect && ( That password didn’t work. Try again. )}
); }