@swype-org/react-sdk 0.1.164 → 0.1.165

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.js CHANGED
@@ -2426,7 +2426,14 @@ function OtpInput({ value, onChange, length = 6, disabled }) {
2426
2426
  inputsRef.current[clamped]?.focus();
2427
2427
  }, [length]);
2428
2428
  const handleChange = useCallback((index, char) => {
2429
- const digit = char.replace(/\D/g, "").slice(0, 1);
2429
+ const cleaned = char.replace(/\D/g, "");
2430
+ if (cleaned.length > 1) {
2431
+ const filled = cleaned.slice(0, length);
2432
+ onChange(filled);
2433
+ focusInput(Math.min(filled.length, length - 1));
2434
+ return;
2435
+ }
2436
+ const digit = cleaned.slice(0, 1);
2430
2437
  const next = digits.slice();
2431
2438
  next[index] = digit;
2432
2439
  const joined = next.join("").replace(/\s/g, "");
@@ -2464,7 +2471,7 @@ function OtpInput({ value, onChange, length = 6, disabled }) {
2464
2471
  disabled,
2465
2472
  onChange: (e) => handleChange(i, e.target.value),
2466
2473
  onKeyDown: (e) => handleKeyDown(i, e),
2467
- onPaste: i === 0 ? handlePaste : void 0,
2474
+ onPaste: handlePaste,
2468
2475
  onFocus: (e) => e.target.select(),
2469
2476
  style: inputStyle(tokens, !!digit.trim())
2470
2477
  },