import { useState, type FormEvent } from 'react'; import { PasswordStrengthBar } from './PasswordStrengthBar.js'; import type { ResetPasswordFormProps } from './types.js'; /** * Reset password form — new password + confirm, with strength indicator. * Styled via CSS custom properties (inherits --bl-* from host app). */ export function ResetPasswordForm({ onSubmit, isLoading = false, error, success, className, }: ResetPasswordFormProps) { const [password, setPassword] = useState(''); const [confirm, setConfirm] = useState(''); const passwordMismatch = confirm.length > 0 && password !== confirm; const canSubmit = password.length >= 8 && !passwordMismatch && !isLoading; function handleSubmit(e: FormEvent) { e.preventDefault(); if (!canSubmit) return; onSubmit(password); } const inputStyle = { padding: '10px 12px', border: '1px solid var(--bl-border, #ccc)', borderRadius: 'var(--bl-radius, 6px)', fontSize: '14px', width: '100%', boxSizing: 'border-box' as const, }; return (
Enter your new password.
{passwordMismatch && (
Passwords do not match
)} {error && (
{error}
)} {success && (
{success}
)}
); }