1 import { type FC } from 'react';
3 import { Form, type FormikErrors, FormikProvider, useFormik } from 'formik';
5 import { Button } from '@proton/atoms';
6 import { Field } from '@proton/pass/components/Form/Field/Field';
7 import { PasswordField } from '@proton/pass/components/Form/legacy/PasswordField';
8 import { type PasswordCredentials } from '@proton/pass/lib/auth/password';
15 onSubmit: (values: PasswordCredentials) => void;
16 onValidate?: (values: PasswordCredentials) => FormikErrors<PasswordCredentials>;
19 export const PasswordForm: FC<Props> = ({ id, disabled, loading, submitLabel, onSubmit, onValidate }) => {
20 const form = useFormik({
21 initialValues: { password: '' },
22 validateOnMount: true,
29 <FormikProvider value={form}>
31 <div className="flex flex-nowrap items-end w-full" style={{ '--border-radius-xl': '2em' }}>
33 component={PasswordField}
36 rootClassName="flex-1"
37 className="flex-1 rounded-xl overflow-hidden"
38 inputClassName="text-rg rounded-none"
39 disabled={disabled || loading}
41 {...(disabled ? { error: undefined } : {})}
51 disabled={!form.isValid || disabled}