import { type HTMLAttributes, type ReactNode } from 'react';
import type { BrandMarkMotion } from '../_shared/brand-mark';
/** The fields of the form, in the order they appear. */
export declare const LOGIN_FORM_FIELDS: readonly ["email", "password"];
export type LoginFormField = (typeof LOGIN_FORM_FIELDS)[number];
/** What `onSubmit` receives once both checks have passed. */
export interface LoginFormValues {
email: string;
password: string;
/** True when the "Remember me" box is ticked. Always false when the
* box is not shown. */
rememberMe: boolean;
}
/** Values to show when the form opens. There is no password here, on
* purpose: a password is never sent back to the browser. */
export type LoginFormInitialValues = Partial>;
/** Messages from the server, already translated: one per field, plus
* `form` for a message about the whole form, such as "the email or
* password is incorrect". */
export type LoginFormErrors = Partial>;
/** The host's own form field names, for a native form post. `email` and
* `password` are needed: a field without a name is not posted.
* `rememberMe` is optional and also turns the "Remember me" box on. */
export type LoginFormFieldNames = Record & {
rememberMe?: string;
};
export interface LoginFormProps extends Omit, 'title' | 'onSubmit'> {
/** Replaces the heading "Sign in to Alfadocs". Pass it translated. */
title?: string;
/** A line under the heading. Pass it translated. */
description?: string;
/**
* The heading's level. Default 1: a sign-in page usually has no other
* heading. Pass 2 on a page that has its own `h1`.
*/
headingLevel?: 1 | 2 | 3;
/**
* Shows the Alfadocs mark above the heading, with the heading and its
* line centred under it. Default true. With `false` the heading sits
* at the start edge, for a host that shows its own logo.
*/
showLogo?: boolean;
/**
* How the mark arrives when the card opens: its pieces come together
* (`assemble`, the default), it turns once (`spin`), it beats
* (`pulse`), or it is still (`none`). It plays once and rests, and
* holds still under reduced motion and in the accessible themes.
*/
logoMotion?: BrandMarkMotion;
/**
* Host content between the heading and the fields, such as a notice
* ("You have been signed out"). It sits outside the form, so nothing in
* it is posted. Keep any heading inside it below the card's own level.
*/
children?: ReactNode;
/**
* For hosts whose server also signs people in by a username. The first
* field is still labelled "Email", but text without an "@" is accepted as
* a username: it only has to be filled in. Text with an "@" must be a
* valid email address, as when this is off. Default false.
*/
allowUsername?: boolean;
/** The email to show when the form opens, such as the one last used,
* and whether "Remember me" starts ticked (default false). Read once.
* There is never an initial password. */
initialValues?: LoginFormInitialValues;
/**
* Messages from the server, already translated. A field's message
* shows on that field until the user changes it; `form` shows above
* the fields.
*
* When messages arrive, the password is emptied and focus moves: to
* the error summary at the top of the form, which lists each field
* with a message, or, when only `form` says something, to the
* password, which is then described by that message. The same happens
* for messages present when the form opens (a page the server rendered
* after a failed post).
*
* Never say which of the two values was wrong: one message for both.
* Set `submitting` while you send, so the form also notices an answer
* that says the same as the last one.
*/
errors?: LoginFormErrors;
/**
* Adds "Forgot password?" under the password. A path on the same site,
* or an address written in full (`https://…`). Anything else shows no
* link. The same rule holds for the two addresses below.
*/
forgotPasswordHref?: string;
/**
* Adds a "Remember me on this computer" box under the password, unticked
* by default. Off unless you set this or name the box in
* `fieldNames.rememberMe`. What "remember" means is the server's: the
* kit only reports the box (`rememberMe` in `onSubmit`, or the posted
* field).
*/
showRememberMe?: boolean;
/** Adds "Register as a doctor" under the button. */
registerDoctorHref?: string;
/** Adds "Register as a patient" under the button. */
registerPatientHref?: string;
/** Replaces the button's "Sign in". Pass it translated. */
submitLabel?: string;
/**
* True while the host sends the values: the button shows a spinner and
* a second submit is ignored. Set it inside `onSubmit`, before anything
* is awaited: until it is true, a second press sends a second sign-in.
*/
submitting?: boolean;
/** For React hosts: called with the values once both checks have
* passed. Not called when `fieldNames` is set. */
onSubmit?: (values: LoginFormValues) => void;
/**
* For a native form post: the host's own field names, both of them,
* e.g. `{ email: 'email', password: 'password' }`. When set, the inputs
* carry these names and the browser posts the form. Add `rememberMe`
* (e.g. `'_remember_me'`) to show the "Remember me" box: ticked, it posts
* `=on`; unticked, it posts nothing.
*/
fieldNames?: LoginFormFieldNames;
/**
* Where a native form post goes. Default: the current address. Only a
* path, or an address on the page's own origin, is accepted: another
* origin is never sent what the user typed, and the post then goes to
* the current address. Does nothing without `fieldNames`.
*/
action?: string;
/**
* Extra hidden inputs posted with a native form, by name: a CSRF token,
* a return address. Not used with `onSubmit`. A name that is also one
* of `fieldNames` is left out: the form's own field wins. The server
* must check a return address itself: anyone can change a hidden input.
*/
hiddenFields?: Readonly>;
/**
* A second card beside the sign-in, the same height: the development
* quick sign-in (`LoginDevCard`). Pass it only when the server says
* this is a development environment: the kit never decides that
* itself. The two sit side by side where there is room and stack on a
* phone.
*/
devCard?: ReactNode;
}
/**
* The sign-in card. Mount it on the login page, inside `SignedOutFrame`
* or the host's own chrome.
*/
export declare const LoginForm: import("react").ForwardRefExoticComponent>;
//# sourceMappingURL=login-form.d.ts.map