harbor run -t wsauret/instance_protonmail__webclients-08bb09914d0d37b0cd6376d4cab5b77728a43e7bharbor download wsauret/instance_protonmail__webclients-08bb09914d0d37b0cd6376d4cab5b77728a43e7bA code repository is available in the /app directory. Your task is to implement the changes necessary to satisfy the following Pull Request (PR) description:
<pr_description>
TOTP verification codes are difficult to enter and review in the current input
Two-factor authentication code entry currently uses a standard text field, which makes multi-digit codes hard to read, verify, and edit while typing. Pasting a full code does not distribute characters across separate positions, and keyboard navigation between digits (including backspace and arrow keys) does not behave intuitively for multi-character verification codes.
The TOTP code input must render the number of single-character fields specified by the length prop, with each field corresponding to one character position in the code.
The input must display existing value characters in their corresponding field positions. Invalid characters for the active type must be shown as empty fields (the underlying input's value is the empty string for those positions). For example, with length=4 and value="a12b" and the default type, the four fields display , `1`, `2`, respectively.
The type prop must control validation: number accepts only numeric digits, and alphabet accepts alphanumeric characters. If type is not provided, it must default to number. For example, with type="alphabet", length=3, and value="1a", the fields display 1, a, ``.
Typed, pasted, or otherwise changed input must ignore characters that are invalid for the selected type.
When a user enters a valid character into a field, that character must update the corresponding position and focus must move to the next field when one exists. Entering an invalid character must not change any value and must not move focus.
If a user enters the same value that is already present in a field, focus must still move to the next field when one exists.
When a user pastes or enters multiple characters into a field, the valid characters must fill consecutive fields starting at that field, up to the configured length (extra characters beyond the last field are dropped), and focus must move to the field after the last inserted character, capped at the final field. For example, pasting 7654321 into the first field of a 4-field input with default type fills the fields with 7, 6, 5, 4 and leaves focus on the last field.
Clearing a field must clear only that position and keep focus on the same field.
When Backspace is pressed in an empty field, or while the cursor is at the start of a field (selection start and end both at position 0), the previous field must be cleared and receive focus. If there is no previous field, no value should be changed.
The value passed to onValue must preserve a one-to-one mapping between string indexes and field positions by encoding empty or cleared positions as space characters (' '). For example, clearing the second field from 123 with length=4 must produce 1 3 , not 13.
If autoFocus is true, focus must be applied to the first field when the component is rendered.
Fields must respond to standard DOM change, input, and paste events (paste text read from clipboardData), not only keyboard events.
Entering the same value that a field already holds arrives only as a native input event on that field (no change event and no keyboard event accompany it), and that event alone must move focus to the next field while leaving all values unchanged.
Render exactly length <input> elements and no additional hidden <input> (for example no hidden full-code field).
The rendered <input> elements must support reading and setting selectionStart/selectionEnd; the Backspace key handler must read selectionStart and selectionEnd from the element that received the keyDown event, and must work on a field that is not currently focused.
Paste must be handled synchronously from the paste event itself, reading the pasted text via clipboardData.getData(...); no follow-up change or input event will arrive.
Focus moves must place document focus on the underlying native <input> element itself.
No new interfaces are introduced. </pr_description>
Constraints: