allaw-ui 2.3.6 → 2.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,6 +7,7 @@ export interface VerificationCodeInputProps {
|
|
|
7
7
|
onError?: (error: string | null) => void;
|
|
8
8
|
onComplete?: (value: string) => void;
|
|
9
9
|
testError?: boolean;
|
|
10
|
+
autoFocus?: boolean;
|
|
10
11
|
}
|
|
11
12
|
declare const VerificationCodeInput: React.FC<VerificationCodeInputProps>;
|
|
12
13
|
export default VerificationCodeInput;
|
|
@@ -11,18 +11,20 @@ import React, { useState, useEffect, useRef } from "react";
|
|
|
11
11
|
import styles from "./VerificationCodeInput.module.css";
|
|
12
12
|
import TinyInfo from "../typography/TinyInfo";
|
|
13
13
|
var VerificationCodeInput = function (_a) {
|
|
14
|
-
var numInputs = _a.numInputs, _b = _a.allowedChars, allowedChars = _b === void 0 ? "numeric" : _b, _c = _a.size, size = _c === void 0 ? "large" : _c, onChange = _a.onChange, onError = _a.onError, onComplete = _a.onComplete, _d = _a.testError, testError = _d === void 0 ? false : _d;
|
|
15
|
-
var
|
|
16
|
-
var
|
|
14
|
+
var numInputs = _a.numInputs, _b = _a.allowedChars, allowedChars = _b === void 0 ? "numeric" : _b, _c = _a.size, size = _c === void 0 ? "large" : _c, onChange = _a.onChange, onError = _a.onError, onComplete = _a.onComplete, _d = _a.testError, testError = _d === void 0 ? false : _d, _e = _a.autoFocus, autoFocus = _e === void 0 ? false : _e;
|
|
15
|
+
var _f = useState(Array(numInputs).fill("")), values = _f[0], setValues = _f[1];
|
|
16
|
+
var _g = useState(""), error = _g[0], setError = _g[1];
|
|
17
17
|
var inputRefs = useRef(Array(numInputs).fill(null));
|
|
18
18
|
useEffect(function () {
|
|
19
19
|
setValues(Array(numInputs).fill(""));
|
|
20
20
|
inputRefs.current = Array(numInputs).fill(null);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
if (autoFocus) {
|
|
22
|
+
setTimeout(function () {
|
|
23
|
+
var _a;
|
|
24
|
+
(_a = inputRefs.current[0]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
25
|
+
}, 0);
|
|
26
|
+
}
|
|
27
|
+
}, [numInputs, autoFocus]);
|
|
26
28
|
useEffect(function () {
|
|
27
29
|
if (testError) {
|
|
28
30
|
setError("Code de vérification invalide");
|