allaw-ui 2.3.8 → 2.4.0
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.
|
@@ -18,13 +18,7 @@ var VerificationCodeInput = function (_a) {
|
|
|
18
18
|
useEffect(function () {
|
|
19
19
|
setValues(Array(numInputs).fill(""));
|
|
20
20
|
inputRefs.current = Array(numInputs).fill(null);
|
|
21
|
-
|
|
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]);
|
|
21
|
+
}, [numInputs]);
|
|
28
22
|
useEffect(function () {
|
|
29
23
|
if (testError) {
|
|
30
24
|
setError("Code de vérification invalide");
|
|
@@ -38,23 +32,24 @@ var VerificationCodeInput = function (_a) {
|
|
|
38
32
|
var validateAllInputs = function () {
|
|
39
33
|
var _a;
|
|
40
34
|
var fullValue = values.join("");
|
|
41
|
-
|
|
35
|
+
console.log("[VerificationCodeInput] Validating inputs:", fullValue);
|
|
42
36
|
if (fullValue.length === numInputs) {
|
|
37
|
+
console.log("[VerificationCodeInput] All inputs filled");
|
|
43
38
|
if (testError) {
|
|
44
|
-
// console.log("Showing error state");
|
|
45
39
|
setError("Code de vérification invalide");
|
|
46
40
|
onError === null || onError === void 0 ? void 0 : onError("Code de vérification invalide");
|
|
47
41
|
return;
|
|
48
42
|
}
|
|
49
|
-
// console.log("Code validation successful:", fullValue);
|
|
50
43
|
setError("");
|
|
51
44
|
onError === null || onError === void 0 ? void 0 : onError(null);
|
|
45
|
+
console.log("[VerificationCodeInput] Calling onComplete with:", fullValue);
|
|
52
46
|
onComplete === null || onComplete === void 0 ? void 0 : onComplete(fullValue);
|
|
53
47
|
(_a = inputRefs.current[numInputs - 1]) === null || _a === void 0 ? void 0 : _a.blur();
|
|
54
48
|
}
|
|
55
49
|
};
|
|
56
50
|
var handleInputChange = function (index, value) {
|
|
57
51
|
var _a, _b, _c, _d;
|
|
52
|
+
console.log("[VerificationCodeInput] Input ".concat(index, " changed to:"), value);
|
|
58
53
|
if (value.length > 1) {
|
|
59
54
|
var pastedChars = value.split("");
|
|
60
55
|
var validChars = pastedChars
|
|
@@ -76,15 +71,18 @@ var VerificationCodeInput = function (_a) {
|
|
|
76
71
|
validateAllInputs();
|
|
77
72
|
(_b = inputRefs.current[numInputs - 1]) === null || _b === void 0 ? void 0 : _b.blur();
|
|
78
73
|
}
|
|
74
|
+
console.log("[VerificationCodeInput] Handling pasted value");
|
|
79
75
|
return;
|
|
80
76
|
}
|
|
81
77
|
}
|
|
82
78
|
if (!validateInput(value, allowedChars)) {
|
|
79
|
+
console.log("[VerificationCodeInput] Invalid input value");
|
|
83
80
|
return;
|
|
84
81
|
}
|
|
85
82
|
var newValues = __spreadArray([], values, true);
|
|
86
83
|
newValues[index] = value;
|
|
87
84
|
setValues(newValues);
|
|
85
|
+
console.log("[VerificationCodeInput] New values:", newValues.join(""));
|
|
88
86
|
if (value === "")
|
|
89
87
|
return;
|
|
90
88
|
setError("");
|
|
@@ -95,7 +93,6 @@ var VerificationCodeInput = function (_a) {
|
|
|
95
93
|
(_c = inputRefs.current[index + 1]) === null || _c === void 0 ? void 0 : _c.focus();
|
|
96
94
|
}
|
|
97
95
|
else if (index === numInputs - 1 && value !== "") {
|
|
98
|
-
// console.log("Last input filled, triggering validation");
|
|
99
96
|
validateAllInputs();
|
|
100
97
|
(_d = inputRefs.current[index]) === null || _d === void 0 ? void 0 : _d.blur();
|
|
101
98
|
}
|
|
@@ -114,7 +111,6 @@ var VerificationCodeInput = function (_a) {
|
|
|
114
111
|
setTimeout(function () {
|
|
115
112
|
var isStillFocused = inputRefs.current.some(function (ref) { return ref === document.activeElement; });
|
|
116
113
|
if (!isStillFocused) {
|
|
117
|
-
// console.log("All inputs lost focus, checking validation");
|
|
118
114
|
validateAllInputs();
|
|
119
115
|
}
|
|
120
116
|
}, 0);
|
|
@@ -123,7 +119,6 @@ var VerificationCodeInput = function (_a) {
|
|
|
123
119
|
var _a, _b;
|
|
124
120
|
e.preventDefault();
|
|
125
121
|
var pastedText = e.clipboardData.getData("text");
|
|
126
|
-
// console.log("Pasted text:", pastedText);
|
|
127
122
|
var validChars = pastedText
|
|
128
123
|
.split("")
|
|
129
124
|
.filter(function (char) { return validateInput(char, allowedChars); })
|
|
@@ -138,7 +133,6 @@ var VerificationCodeInput = function (_a) {
|
|
|
138
133
|
setValues(newValues_2);
|
|
139
134
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValues_2.join(""));
|
|
140
135
|
if (validChars.length >= numInputs) {
|
|
141
|
-
// console.log("All inputs filled by paste, triggering validation");
|
|
142
136
|
validateAllInputs();
|
|
143
137
|
inputRefs.current.forEach(function (input) { return input === null || input === void 0 ? void 0 : input.blur(); });
|
|
144
138
|
(_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.blur();
|
|
@@ -162,7 +156,7 @@ var VerificationCodeInput = function (_a) {
|
|
|
162
156
|
? "[0-9]*"
|
|
163
157
|
: allowedChars === "alphabetic"
|
|
164
158
|
? "[a-zA-Z]*"
|
|
165
|
-
: "[a-zA-Z0-9]*", ref: function (input) { return (inputRefs.current[index] = input); } })); });
|
|
159
|
+
: "[a-zA-Z0-9]*", ref: function (input) { return (inputRefs.current[index] = input); }, autoFocus: index === 0 && autoFocus, tabIndex: index === 0 ? 0 : undefined })); });
|
|
166
160
|
};
|
|
167
161
|
return (React.createElement("div", { className: styles.container },
|
|
168
162
|
React.createElement("div", { className: styles.inputsContainer }, renderInputs()),
|