@ecohouse/ui 0.1.62 → 0.1.63
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.
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/VerificationCodeInput/VerificationCodeInput.test.ts +14 -0
- package/src/components/VerificationCodeInput/VerificationCodeInput.utils.ts +6 -1
package/dist/index.cjs
CHANGED
|
@@ -36731,11 +36731,13 @@ function reconcileVerificationCells(cells, code, length) {
|
|
|
36731
36731
|
}
|
|
36732
36732
|
function updateVerificationCells(currentCells, index, input, length) {
|
|
36733
36733
|
const safeLength = Math.max(1, length);
|
|
36734
|
-
const
|
|
36734
|
+
const focusedIndex = Math.min(Math.max(0, index), safeLength - 1);
|
|
36735
36735
|
const cells = Array.from({ length: safeLength }, (_, cellIndex) => {
|
|
36736
36736
|
const cell = currentCells[cellIndex] ?? "";
|
|
36737
36737
|
return /^\d$/.test(cell) ? cell : "";
|
|
36738
36738
|
});
|
|
36739
|
+
const pastedDigits = input.replace(/\D/g, "");
|
|
36740
|
+
const safeIndex = pastedDigits.length > 1 && pastedDigits.length > safeLength - focusedIndex ? 0 : focusedIndex;
|
|
36739
36741
|
const insertedDigits = normalizeVerificationCode(input, safeLength - safeIndex);
|
|
36740
36742
|
if (!insertedDigits) {
|
|
36741
36743
|
cells[safeIndex] = "";
|